function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/* Functions that handle named groups. */
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function PopSpaces(Str)
{
	StrRet = "";
	for(i=0; i<Str.length; i++)
		if( Str.charAt(i)!=" " )
			StrRet += Str.charAt(i);
	return StrRet;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function ToggleMenu(SubMenu)
{
	if(SubMenu>0)
	{
		SubMenuId=('SubMenu'+SubMenu);
		if (document.all[SubMenuId].style.display=='none')
		{
			document.all[SubMenuId].style.display="inline"
			document.images["LeftArrow"+SubMenu].src="/images/layout/left/icon_flechaorange_f2.gif"
			document.images["LeftArrow"+SubMenu].alt="Ocultar sub-menú";
		}
		else
		{
			document.all[SubMenuId].style.display="none"
			document.images["LeftArrow"+SubMenu].src="/images/layout/left/icon_flechaorange.gif"
			document.images["LeftArrow"+SubMenu].alt="Mostrar sub-menú"
		}
		return false;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0

  WIN = window.open(theURL,winName,features);
//  W.resizeTo(screen.availWidth /1.5, screen.availHeight - 60);
  WIN.moveTo(30, 30);
  WIN.parentWindow = Window;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

// Obtiene el valor de un cookie dado el lugar desde donde comienza a leer
function getCookieVal (offset) 
{  
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1)    
		endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

//  COOKIES  //
// Obtiene el valor de una Cookie dado el nombre
function GetCookie (name) 
{
	var arg = name + "=";  
	var alen = arg.length;
	var cooklen = document.cookie.length;
	var i = 0;
	while (i < cooklen) 
	{    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

// Setea el valor de una Cookie
// Argumentos: 1: Nombre; 2: Valor; 3: Tiempo Límite; 
//			   4: Camino; 5: Dominio; 6: Cookie Segura?
function SetCookie (name, value) 
{
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

// Elimina una Cookie dado el Nombre
// Le asigna al Cookie el valor de tiempo 0 para eliminarlo
function DeleteCookie (name) 
{
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

// PLUGINS //
// Verifica que el navegador del usuario soporta Flash
function MM_checkPlugin(plgIn, theURL, altURL, autoGo) 
{ //v4.0
  var ok=false; document.MM_returnValue = false;
  with (navigator) 
  if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) 
  {
    ok=(plugins && plugins[plgIn]);
  } 
  else if (appVersion.indexOf('3.1')==-1) 
  	   { //not Netscape or Win3.1
	    	if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) 
	    		ok=window.MM_flash;
	    	else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) 
	    			ok=window.MM_dir;
	    		else ok=autoGo;
 	    }
  return ok;
}

// Usado por el MM_checkPlugin
with (navigator) if (appName.indexOf('Microsoft')!=-1 && appVersion.indexOf('Mac')==-1) document.write(''+
'<scr'+'ipt language="VBScript">\nOn error resume next\n'+
'MM_dir = IsObject(CreateObject("SWCtl.SWCtl.1"))\n'+
'MM_flash = NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash"))\n</scr'+'ipt>');

// Checkeo la existencia del Cookie y si no existe la cargo.
var flashvar = GetCookie("PageFlashEnabled");
if (flashvar!=1)
{
	if( MM_checkPlugin('Shockwave Flash','','',false) )
	{
//		document.write("Con Flash");
		SetCookie("PageFlashEnabled","1");
	}
	else
	{
//		document.write("Sin Flash");
		SetCookie("PageFlashEnabled","0");
	}
}	
