//  COOKIES  //
// 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));
}

// 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;  
	if ( argc > 2 )
		var expires = (argc > 2) ? argv[2] : null;  
	else
	{
		var expires = new Date();
		expires.setTime (expires.getTime() + 1000 * 24 * 60 * 60 * 30 * 1000 );
	}	
	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 que este el Plugin de Flash y si no existe la cargo.
if( MM_checkPlugin('Shockwave Flash','','',false) )
{
	SetCookie("PageFlashEnabled","1");
}
else
{
	SetCookie("PageFlashEnabled","0");
}

