// 
// 		@author Copyright (c) 2009 Vipperland.com, all rights reserved
// 		@version SWFWriter 2.0.0402
//		@usage for help, visit 'http://chappel.vipperland.com/#/swfwriter'
// 
// 		Redistribution and use in source and binary forms, with or without 
// 		modification, are permitted provided that the following conditions are met:
// 			- Redistributions of source code must retain the above copyright notice, 
//  		  	  this list of conditions and the author credits.
//
function _addSWFinto(target, ignoreVersion){
	var msiexplorer = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var flashVars = this.strVars != "" ? this.strVars : "";
	var swfObject = msiexplorer ? "<object " : "<object ";
	swfObject += 	"type=\"application/x-shockwave-flash\" ";
	swfObject += 	"id=\"" + this.name + "\" ";
	swfObject += 	"width=\"" + this.width + "\" ";
	swfObject += 	"height=\"" + this.height + "\" ";
	for(var flashVar in this.flashVars){ 
		if(this.flashVars[flashVar]!==null){
			flashVars += (flashVars == "" ? "" : "&") + (flashVar + "=" + this.flashVars[flashVar]);
		}
	}
	swfObject += 	msiexplorer ? ("><param name=\"movie\" value=\"" + this.src + "\">") : " data=\"" + this.src + "\" ";
	for(var param in this.params){ 
		if(this.params[param]!==null){
			swfObject += msiexplorer ? ("<param name=\"" + param + "\" value=\"" + this.params[param] + "\">") : (param + "=\"" + this.params[param] + "\" "); 
		}
	}
	if(flashVars != ""){
		swfObject += msiexplorer ? ("<param name=\"flashvars\" value=\"" + flashVars + "\">") : ("flashvars=\"" + flashVars + "\" "); 
	}
	swfObject += 	msiexplorer ? "</object>" : " />";
	if(this.playerVersion >= this.version || ignoreVersion){
		if(target){ 
			this.container = document.getElementById(target);
			this.container.innerHTML = swfObject; 
		} else{ 
			document.write(swfObject); 
		}
		this.content = document.getElementById(this.name);
		return true;
	}else{
		return false;
	}
}
function _editSWFscale(width, height, noborder){
	this.content.style.width = width ? width : this.width;
	this.content.style.height = height ? height : this.height;
	if(this.container && noborder){
		this.container.style.width = width ? width : this.width;
		this.container.style.height = height ? height : this.height;
	}
}
function _removeSWFfrom(){
	this.container.innerHTML = "";
}
function _checkFlashPlayerVersion (){
	var version = 0;
	var msiexplorer = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	if(msiexplorer){
		var axoIE = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axoIE.GetVariable("$version").split(" ")[1].split(",")[0];
	}else{
		var plugins = navigator.plugins.length;
		if (plugins > 0) {
			for (i = 0; i < plugins; i++) {
				if(navigator.plugins[i].name.indexOf("Shockwave Flash")>-1){
					currentVersion = navigator.plugins[i].description.split(" ")[2].split(".")[0];
					if(currentVersion >= version){
						version = currentVersion;
					}
				}
			}
		}
	}
	return version;
}
function _controlSWFVars(param, value){
	this.flashVars[param] = value ? value : null;
}
function _controlSWFParams(param, value){
	this.params[param] = value ? value : null;
}

var _SWFinstanceCount = 0;
var _flashPlayerVersion = _checkFlashPlayerVersion();
function SWF(src, width, height, version){
	_SWFinstanceCount += 1;
	this.src = src;
	this.width = width ? width : "100%";
	this.height = height ? height : "100%";
	this.version = version ? version : 6;
	this.params = {};
	this.flashVars = {};
	this.strVars = "";
	this.name = "instance" + _SWFinstanceCount;
	this.write = _addSWFinto;
	this.clear = _removeSWFfrom; 
	this.scaleTo = _editSWFscale;
	this.playerVersion = _flashPlayerVersion;
	this.setVar = _controlSWFVars;
	this.setParam = _controlSWFParams;
	this.container = null;
	this.content = null;
}
//work with DeepLinking class
function getHash(){	
	return window.location.hash.substr(1); 
}
function setHash(value){ 
	window.location.hash = value; 
	return true;
}