/**
 * Gustavo Gretter (c) 2007 - Todo los derechos reservados.
 * Queda prohibido su uso, distribución o copia, por cualquier medio, en forma total o 
 * parcial, sin el consentimiento explícito de Gustavo Gretter.
 */
var flashversion = 0;
var flashinstalled = 0;

function flashBlock(swf,w,h,vars) {
  flashDetect();

  if ( flashversion>=7 )  { 
	document.write('<embed src="'+swf+'"');
	if (vars!=undefined)
		document.write(' flashvars="'+vars+'"');
	document.write(' quality="high" scale="noscale" bgcolor="#ffffff" width="'+w+'" height="'+h+'" name="dummy" align="middle" wmode="transparent" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
  }  else  {
    document.writeln('<div style="background-color:#fff; padding:10px; color:#000">');
    document.writeln('<b>Este sitio requiere que tenga Flash Player version 7 o superior instalada.</b>');

    document.writeln('<p>');
    document.writeln('Por favor, siga este enlace para instalar gratuitamente Adobe Flash player.');
    document.writeln('</p>');

    document.writeln('<p>');
    document.writeln('<a target="_blank" href="http://www.adobe.com/go/getflashplayer/"><img src="../pt/images/get_flash_player.gif" align="middle" border="0" height="31" width="88"></a>');
    document.writeln('</p>');
    document.writeln('</div>');
  }
}
function trim(s)
{
    var l=0; var r=s.length -1;
    while(l < s.length && s[l] == ' ')
    {     l++; }
    while(r > l && s[r] == ' ')
    {     r-=1;     }
    return s.substring(l, r+1);
} 

function flashDetect()
{
  var MSDetect = false;

  if (navigator.plugins && navigator.plugins.length){
	x = navigator.plugins["Shockwave Flash"];
	if (x){
		flashinstalled = 2;
		if (x.description){
			y = x.description;
			aux = y.substring(y.indexOf('.')-2,y.indexOf('.'));
			aux = trim(aux);
			flashversion = aux;
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"]){
		flashinstalled = 2;
		flashversion = 2;
	}
  }
  else if (navigator.mimeTypes && navigator.mimeTypes.length){
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
  }
  else
    MSDetect = 'true';

  if ( MSDetect ){
// IE flash detection.
	for(var i=10; i>0; i--){

		flashversion = 0;
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
			flashversion = i;
			return;
		}
		catch(e){
		}
	}
  }
}
 
function mediaDisplay(href,ext,width,height){
	var w = width+"px"; 
	var h = height+"px";
	if (ext=="avi" || ext == "mpeg" || ext=="mov" || ext=="wmv"){
	var type="";
	if (ext=="wmv"){
		 type= "type='application/x-mplayer2' autostart='true' ";
		 w=(width-10)+"px"; 
	}
	
		document.write('<embed src="'+href+'"');	
		document.write(' quality="high" scale="noscale" bgcolor="#ffffff" '+type+' name="dummy" width="'+w+'"  align="middle" wmode="transparent" allowScriptAccess="sameDomain" />');		
	}else if (ext=="swf" || ext=="flv" ){
		flashBlock(href,"100%","100%",null);
	}else{
		if (h=="px"){
			document.write("<img src='"+href+"' border='0' width='"+w+"' />");
		}else{
			document.write("<img src='"+href+"' border='0' width='"+w+"' height='"+h+"' />");
		} 
	}
}

function checkFlash(){
	flashDetect();
	aux = document.getElementById("flashalert");	
	if ( flashversion>=7 )  {
		document.getElementById("flashdiv").style.display="";
	}  else  {
	document.getElementById("flashdiv").style.display="none";
    var text ='';
    text+='<b>Este sitio requiere que tenga Flash Player version 7 o superior instalada.</b>';
    text+='<p>';
    text+='Por favor, siga este enlace para instalar gratuitamente Adobe Flash player.';
    text+='</p>';
    text+='<p>';
    text+='<a target="_blank" href="http://www.adobe.com/go/getflashplayer/"><img src="../pt/images/get_flash_player.gif" align="middle" border="0" height="31" width="88"></a>';
    text+='</p>';
    aux.innerHTML=text;
    aux.style.display="";    
  }
	
}