var flashVersion = 0;
var flashVersion_DONTKNOW = -1;
var needFlash = "<div class=AltFlash>Usted necessita Flash 7 o mayor para utilizar esta herramienta.  <a href=\"/help/help.html?c=reqs\">Lea nuestro sitio web requisitos para maiores informaciones.</a></div>"

function getShockVersion() {
	// this function returns a floating point value which should be the version of the Shockwave control or 0.0
	var agent = navigator.userAgent.toLowerCase();
		
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		thearray = navigator.plugins;
		arraylen = thearray.length;

		for (i=0; i < arraylen; i++) {
  			theplugin = thearray[i];
			thename   = theplugin.name;
			thedesc   = theplugin.description;

			// If the plugin is Shockwave...
			if (thename.indexOf("Shockwave") != -1 && thename.indexOf("Director") != -1) {
				// ...extract the version information
				versionString = thedesc.substring(thedesc.indexOf("version ") + 8);
				if (versionString.indexOf(".") > 0) {
					versionMajor = versionString.substring(0,versionString.indexOf("."));
					versionMinor = versionString.substring(versionString.indexOf(".") + 1);
					if (versionMinor.indexOf(".") > 0)
						versionMinor = versionMinor.substring(0,versionString.indexOf(".")) + versionMinor.substring(versionMinor.indexOf(".") + 1);   
					versionString = parseInt(versionMajor) + "." + versionMinor;
				}
			    return (parseFloat(versionString));
			}
		} 
		return (0.0);
	}
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
    	document.write('<scr' + 'ipt language="VBScript"\> \n');
    	document.write('Function VBGetShockwaveVer(i) \n');
    	document.write('on error resume next \n');
    	document.write('Dim swControl, swVersion \n');
    	document.write('swVersion = "0.0" \n');
    	document.write('set swControl = CreateObject("SWCtl.SWCtl." + CStr(i)) \n');
    	document.write('if (IsObject(swControl)) then \n');
    	document.write('swVersion = CStr(i) + ".0" \n');
    	document.write('swVersion = CStr(swControl.ShockwaveVersion("")) \n');
    	document.write('end if \n');
    	document.write('VBGetShockwaveVer = swVersion \n');
    	document.write('End Function \n');
		document.write('</scr' + 'ipt\> \n');
		
		for (i=8; i>0; i--) {
      		versionString = VBGetShockwaveVer(i);
			if (versionString != "0.0") {
	       		// if we get 1.0 we assume it is actually 6.0
	       		versionNum = (versionString == "1.0" ? 6.0 : parseFloat(versionString))
	        	return (versionNum);
	      	}
    	}	
	}
	
	return (0.0);
}

function getFlashVersion() {
	
	var flashVer = -1;
	
  	with(navigator){
   		var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    	var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    	if (!isIE || !isWin){  
      		
      		if (plugins && plugins.length > 0){
        		var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        		desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        		if (desc == "") {
        			flashVer = -1;
        		}
        		else {
          			var descArr = desc.split(" ");
          			var tempArrMajor = descArr[2].split(".");
          			var verMajor = tempArrMajor[0];
          			var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          			var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          			flashVer =  parseFloat(verMajor + "." + verMinor);
        		}
      		}
    	  	// WebTV has Flash Player 4 or lower -- too low for all our stuff
	      	else if (userAgent.toLowerCase().indexOf("webtv") != -1) {
	      		flashVer = 4.0;
	      	}
    	}
    	else if (isIE) {
    		for(var i=9; i>0; i--){
				try{
					var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
					flashVer = i;
					break;
				}
				catch(e){}
			}
    	}
  	} 
	
	//alert("your version of flash is " + flashVer);
	return flashVer;
	}

var flashVersion = getFlashVersion();

function writeFlashMovie(movieName, movieWidth, movieHeight, movieAlt, movieColor) {
	//alert("your version of flash is " + flashVersion);
	if (flashVersion >= 7) {
		document.write("<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
		//document.write("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"");
		document.write("WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\"><PARAM NAME=\"movie\" VALUE=\"" + movieName + "\"><PARAM ");
		document.write("NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"bgcolor\" VALUE=\"" + movieColor + "\"><EMBED ");
		document.write("src=\"" + movieName + "\" quality=\"high\" bgcolor=\"" + movieColor + "\"  WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>");
	}
	
	else {
		if (movieAlt == "") {
			document.write(needFlash);
		}
		document.write(movieAlt);
	}
	
	//document.write("your flash version: " + flashVersion);
	//flashVersion = 0;
}

function getFlashMovie(movieName, movieWidth, movieHeight, movieAlt, movieColor) {
	var retVal = "";
	if (flashVersion >= 7) {
		retVal += "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
		retVal += " WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\"><PARAM NAME=\"movie\" VALUE=\"" + movieName + "\"><PARAM ";
		retVal += " NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"bgcolor\" VALUE=\"" + movieColor + "\"><EMBED ";
		retVal += " src=\"" + movieName + "\" quality=\"high\" bgcolor=\"" + movieColor + "\"  WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>";
	}
	
	else {
		if (movieAlt == "") {
			retVal += needFlash;
		}
		retVal += movieAlt;
	}
	return retVal;
}

function writeShockMovie(movieName, movieWidth, movieHeight, movieAlt, movieColor) {
	if (getShockVersion() >= 7) {
		document.write("<object classid=\"clsid:166B1BCA-3F9C-11CF-8075-444553540000\"");
		//document.write("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=7,0,0,0\"");
		document.write("WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\">");
		document.write("<param name=\"src\" value=\"" + movieName + "\"><PARAM NAME=\"bgcolor\" VALUE=\"" + movieColor + "\">");
		document.write("<embed src=\"" + movieName + "\" bgcolor=\"" + movieColor + "\" pluginspage=\"http://www.macromedia.com/shockwave/download/\" WIDTH=\"" + movieWidth + "\" HEIGHT=\"" + movieHeight + "\"></embed>");
		document.write("</object>");
	}
	
	else {
		if (movieAlt == "") {
			document.write(needFlash);
		}
		document.write(movieAlt);
	}
}

