/*<![CDATA[<img src="http://i.t-op.com/est50.gif" border=0>]]>*/
function abrirDoc(fondo)
{
   window.open("fichero.aspx?fd=" + fondo,null,"width=950px,height=650px,scrollbars=yes,resizable=yes"); 
}

function AvisoMailing()
{
    if(confirm("Se dispone a enviar un mailing masivo, ¿quiere continuar?"))
    {
        document.getElementById("hidConfirmar").value = "1";
        window.location.href="Mailing.aspx?pag=ContentMailing";
    }
    else
    {
        document.getElementById("hidConfirmar").value = "0";
        window.location.href="Mailing.aspx?pag=ContentMailing";
    }
}

function RenderTiempo()
{
    var tiempo = new Date();
   
    var fecha= new Array();
    fecha[0] = tiempo.getFullYear();
    fecha[1] = tiempo.getMonth() + 1;
    fecha[2] = tiempo.getDate();
    
    var anio = fecha[0];
    var mes = fecha[1].toString();
    var dia = fecha[2].toString();
    
    if (mes.length==1)
    {
        fecha[1]= "0" + fecha[1] ;  
    }
    if (dia.length==1)
    {
        fecha[2]= "0" + fecha[2] ;  
    }
    
    var strfecha = fecha[0].toString() + fecha[1].toString() + fecha[2].toString();
    
    document.write("<img src='http://www.aemet.es/imagenes_d/eltiempo/prediccion/espa/" + strfecha + "1224_p01wesp0.jpg'  align='center' border='0'>");
}

function srcImgSelMenSup(c)
{
    /*Esta función presupone que el src del elemento resaltado, lleva un 2 en el id para diferenciarse*/
    var elemento = eval("document.getElementById('" + c + "')");
   // alert(elemento.src);
    var sr = elemento.src;
    sr = sr.replace(".gif","2.gif");
    elemento.src = sr;
}

function delFoto(url)
{
    window.location.href = url;
}

function verFoto(url)
{
       window.open(url,null,"width=950px,height=650px,menubar=no,scrollbars=yes,resizable=yes"); 
}

function ConvertImage(img)
{
    var imagen=eval("document.getElementById('" + img + "')");
    imagen.width="100px";
    imagen.height="100px";
}

function resaltarTexto(pelement,pcolor,pcursor,pweight)
{
	pelement.style.color=pcolor;
	pelement.style.cursor='hand';
	if (pweight=="")
	{pweight='normal';}
	pelement.style.fontweight=pweight;
	
	return true;
}

function irA(ppag)
{
    document.location.href=ppag;
    return true;
}


function srcImagen(pimg,psrc)
{
    document.getElementById(pimg).src=psrc;
}

function cambia(pimg)
{
    if (document.getElementById(pimg).className=="enlace")
    {
        document.getElementById(pimg).style.color="red";
    }
}

function colorCell(c,color)
{
	c.style.backgroundColor=color;
	c.style.cursor='hand';
}


function ItemMenu(pid,psrcA,psrcB,pclk,pover,pout)
{
	this.Id = pid;
	this.srcA = psrcA;
	this.srcB = psrcB;
	this.clk = pclk;
	this.over = pover;
	this.out = pout;
}


function login()
{
	if ((document.getElementById("txtUser").value!="")&&(document.getElementById("txtPass").value!=""))
	{
		document.getElementById("frmDefault").submit();
	}
	else
	{
		alert("Introduzca los datos de acceso.");
	}
}

function cambiarImg(ele,img)
{
	ele.src="images/" + img;
}

function localPage(pLng)
{
	var pathlocal = window.location.toString();
	var pos = pathlocal.split("/");
	var pag = pos[pos.length -1].toString();
	//irA("../" + pLng + "/" + pag);
	irA(pag + "?lang=" + pLng);
	//alert(pos[pos.length -1].toString());
	session("la")="es_GTGT";
}


function editar()
{
    document.getElementById("hidEd").value="Edicion";
}

//COOKIES

function GetCookie (name) 
{ 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) 
	{
		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;
}

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" : "");
}


function DeleteCookie (name) 
{ 
	var exp = new Date(); 
	exp.setTime (exp.getTime() - 1); 
	var cval = GetCookie (name); 
	document.cookie = name + "=" + cval + "; expires=" + 
	exp.toGMTString();
}

var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function amt()
{
	var count = GetCookie('count')
	if(count == null) 
	{
		SetCookie('count','1')
		return 1
	}
	else 
	{
		var newcount = parseInt(count) + 1;
	DeleteCookie('count')
	SetCookie('count',newcount,exp)
	return count
	}
}

function getCookieVal(offset) 
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function red2()
{
	var cok = GetCookie('idioma');
	if ((cok!="esp")&&(cok!="eng"))
	{
		SetCookie ('idioma', 'esp');
	}

	irA(GetCookie('idioma') + "/Default.aspx");
}


function hora(){
if (!document.layers&&!document.all&&!document.getElementById)
return
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM" 
if (hours>12){
dn="PM"
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here to your desire
myclock="<font class='font_v9grnt' face='Arial' >"+hours+":"+minutes+":"
+seconds+" "+dn+"</font>"
if (document.layers){
document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}
else if (document.all)
liveclock.innerHTML=myclock
else if (document.getElementById)
document.getElementById("liveclock").innerHTML=myclock
setTimeout("hora()",1000)
}



/*MACROMEDIA*/
var mmOpenContainer = null;
var mmOpenMenus = null;
var mmHideMenuTimer = null;

function MM_menuStartTimeout(hideTimeout) {
	mmHideMenuTimer = setTimeout("MM_menuHideMenus()", hideTimeout);	
}

function MM_menuHideMenus() {
	MM_menuResetTimeout();
	if(mmOpenContainer) {
		var c = document.getElementById(mmOpenContainer);
		c.style.visibility = "inherit";
		mmOpenContainer = null;
	}
	if( mmOpenMenus ) {
		for(var i in mmOpenMenus) {
			var m = document.getElementById(mmOpenMenus[i]);
			m.style.visibility = "hidden";			
		}
		mmOpenMenus = null;
	}
}

function MM_menuHideSubmenus(menuName) {
	if( mmOpenMenus ) {
		var h = false;
		var c = 0;
		for(var i in mmOpenMenus) {
			if( h ) {
				var m = document.getElementById(mmOpenMenus[i]);
				m.style.visibility = "hidden";
			} else if( mmOpenMenus[i] == menuName ) {
				h = true;
			} else {
				c++;
			}
		}
		mmOpenMenus.length = c+1;
	}
}

function MM_menuOverMenuItem(menuName, subMenuSuffix) {
	MM_menuResetTimeout();
	MM_menuHideSubmenus(menuName);
	if( subMenuSuffix ) {
		var subMenuName = "" + menuName + "_" + subMenuSuffix;
		MM_menuShowSubMenu(subMenuName);
	}
}

function MM_menuShowSubMenu(subMenuName) {
	MM_menuResetTimeout();
	var e = document.getElementById(subMenuName);
	e.style.visibility = "inherit";
	if( !mmOpenMenus ) {
		mmOpenMenus = new Array;
	}
	mmOpenMenus[mmOpenMenus.length] = "" + subMenuName;
}

function MM_menuResetTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
}

function MM_menuShowMenu(containName, menuName, xOffset, yOffset, triggerName) {
	MM_menuHideMenus();
	MM_menuResetTimeout();
	MM_menuShowMenuContainer(containName, xOffset, yOffset, triggerName);
	MM_menuShowSubMenu(menuName);
}

function MM_menuShowMenuContainer(containName, x, y, triggerName) {	
	var c = document.getElementById(containName);
	var s = c.style;
	s.visibility = "inherit";
	
	mmOpenContainer = "" + containName;
}

/*XML*/
function recurso()
{
	//var xmlDoc = new ActiveXObject("MSXML2.DOMDocument");  
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async=false;
	xmlDoc.load("recursos.xml");
	alert(xmlDoc.SelectNodes("\\recursos\recurso[@p='R_uno']\esp").Item(0));
}

/*OPACIDAD*/
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}
