// v1

function cmnInformation(){
	var eHTML = document.getElementsByTagName( 'html' )[0];
	this.sUser_agent = navigator.userAgent.toLowerCase();
	if( window.opera ){
		this.bOpera = true;
	}
	if( !this.bOpera && this.sUser_agent.indexOf( 'msie' ) != -1 ){
		this.bIE = true;
	}else if( navigator.product == 'Gecko' ){
		this.bGecko = true;
		this.bMozilla = true;
	}
	this.bMAC = ( this.sUser_agent.indexOf( 'mac' ) != -1 );
	this.sLanguage = null;
	this.bHTTP = null;
	this.bHandheld = false;
	return this;
}

var cmn_oInformation = new cmnInformation();

function oFlash(){}

oFlash.prototype.build =
function( vEnabled, vDisabled, vNone, iVersion  ){

	var vVersion = this.get_version( iVersion );
	if( vVersion ){
		if( vEnabled.nodeType )	vEnabled.style.display = "block";
		else document.write( this.build_object(vEnabled) );
		if( vDisabled.nodeType ) vDisabled.style.display = "none";
		if( vNone.nodeType ) vNone.style.display = "none";
		//alert('fghgf');
	}else{
		if( vEnabled.nodeType ) vEnabled.style.display = "none";
		if( vDisabled.nodeType ) vDisabled.style.display = "block";
		else if( vDisabled ) document.write( vDisabled );
		if( parseInt(vVersion) == 0 );
			if( vNone.nodeType ) vNone.style.display = "block";
			else if( vNone ) document.write( vNone );
		return false;
	}
	return true;
}

oFlash.prototype.get_version=
function(iVersion){
	return this.check_flash_version(iVersion);
}

oFlash.prototype.check_flash_version=
function(iVersion){
	if( navigator.plugins && navigator.plugins['Shockwave Flash'] ){
		var sVersion = ( !iVersion ) ? "\\d+" : "[" + iVersion + "-9]\\d*";
		sVersion = parseInt( navigator.plugins['Shockwave Flash'].description.replace( new RegExp( "^[^\\d]+(" + sVersion + ").*$"), "$1" ) );
		return ( isNaN( sVersion ) ) ? ( !iVersion ) ? false : 0 : sVersion;
	}else if( cmn_oInformation.bIE && !cmn_oInformation.bMAC ){
		var oTemp, iMax = 20;
		iVersion = ( !iVersion ) ? 3 : iVersion;
		for( var i = iVersion ; i < iMax ; i++ ){
			try{
				oTemp = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + i );
				iVersion = i;
			}catch(e){
				return ( i > iVersion ) ? iVersion : 0;
			}
		}
		return iVersion;
	}else{
		return ( !iVersion ) ? false : 0;
	}
}

oFlash.prototype.build_object =
function( sOptions ){
	var asOptions = sOptions.split( "," );
	for( var i = 0 ; i < asOptions.length ; i++){
		asPair = asOptions[i].split( "=" );
		asOptions[asPair[0]] = unescape( asPair[1] );
	}
	
        var sHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
        sHTML += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"' + 'width="' + asOptions.width + '" height="' + asOptions.height + '" style="' + asOptions.style + '">'
+ '<param name="movie" value="' + asOptions.source + '">' + '<param name="quality" value="high">';
        if( asOptions.background ){ sHTML += '<param name="bgcolor" value="' + asOptions.background + '">'; }
        if( asOptions.transparent ){ sHTML += '<param name="wmode" value="transparent">' }
        sHTML += '<embed quality="high" type="application/x-shockwave-flash"' + ' pluginspage="http://www.macromedia.com/go/getflashplayer"' + ' src="' + asOptions.source
+ '" width="' + asOptions.width + '" height="' + asOptions.height + '"';
        if( asOptions.background ){ sHTML += ' bgcolor="' + asOptions.background + '"'; }
        if( asOptions.transparent ){ sHTML += ' wmode="transparent"' }
        sHTML += '></embed></object>';
        return sHTML;

}

function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
