﻿var futureBgColor;
var ventana;
var cont=0;

function PNG_loader() {
  for(var i=0; i<document.images.length; i++) { 
    var img = document.images[i]; 
    var imgName = img.src.toUpperCase(); 
    if (imgName.substring(imgName.length-3, imgName.length) == "PNG") { 
      var imgID = (img.id) ? "id='" + img.id + "' " : ""; 
      var imgClass = (img.className) ? "class='" + img.className + "' " : ""; 
      var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "; 
      var imgStyle = "display:inline-block;" + img.style.cssText; 
      if (img.align == "left") imgStyle += "float:left;"; 
      if (img.align == "right") imgStyle += "float:right;"; 
      if (img.parentElement.href) imgStyle += "cursor:hand;"; 
      var strNewHTML = "<span style='float:left;' " + imgID + imgClass + imgTitle 
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"; 
      img.outerHTML = strNewHTML; 
      i--; 
    } 
  } 
} 

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}
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];}
}
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 ____changeHeader() {
    var date;
    var selected;
    date = new Date();
    selected = date.getMinutes() % 5;
    document.getElementById("header_right").style.backgroundImage = 'url(resources/image/fnd_header_' + selected + '.jpg)';
}

function ____changeColor() {
    if (futureBgColor)
    document.getElementById('content2').style.background = futureBgColor;
}

function ____setBGColor(sColor) {
    futureBgColor = sColor;
}

function muestraMapa(){
document.getElementById('situa_flash').style.display="none";
document.getElementById('situa_map').style.display="block";

}

function __mostrar_capa(id, n_max) {
			var i, capa;
			for (i=1;i<n_max;i++) {
				capa = document.getElementById("c" + i);
				if (capa)	capa.style.display = "none";
			}
			capa = document.getElementById("c" + id);
			capa.style.display = "";
}

function __PaintWeather(sUrl, sContentCode, sXmlProcess) {
			var oAjax = new WBE_AjaxClass();
			oAjax.addPostParameter("cmp_code", "RSS_URL_VIEWER");
			oAjax.addPostParameter("_rss_code", sContentCode);
			oAjax.addPostParameter("_xml_url", sUrl);
			oAjax.addPostParameter("_xml_process", sXmlProcess);
			oAjax.throwCall2('VIEW_COMPONENT.wbe');
			document.write(oAjax.responseText);
}

function ___WriteDate() {
  var dDate = new Date();
  var esDaysOfWeek = new Array();
  var esMonths = new Array();
  var sDate;
  esDaysOfWeek[0] = 'Lunes';esDaysOfWeek[1] = 'Martes';esDaysOfWeek[2] = 'Miércoles';esDaysOfWeek[3] = 'Jueves';esDaysOfWeek[4] = 'Viernes';esDaysOfWeek[5] = 'Sábado';esDaysOfWeek[6] = 'Domingo';
  esMonths[0] = 'Enero';esMonths[1] = 'Febrero';esMonths[2] = 'Marzo';esMonths[3] = 'Abril';esMonths[4] = 'Mayo';esMonths[5] = 'Junio';esMonths[6] = 'Julio';esMonths[7] = 'Agosto';esMonths[8] = 'Septiembre';esMonths[9] = 'Octubre';esMonths[10] = 'Noviembre';esMonths[11] = 'Diciembre';
  sDate = esDaysOfWeek[dDate.getDay()-1] + ', ' + dDate.getDate() + ' de ' +  esMonths[dDate.getMonth()] + ' de ' + dDate.getYear();
  document.write(sDate);
}


function ___moverImagen(n_max, bArriba) {
	id = document.forms[0].actual.value;
	id = (bArriba) ? parseInt(id)+1 : parseInt(id)-1;
	if (parseInt(id)>parseInt(n_max)) id=1;
	if (parseInt(id)<1) id=n_max;
	___mostrarImagen(n_max, id);
}

function ___mostrarImagen(n_max, id) {
	var i, capa, id;
	for (i=1;i<=n_max;i++) {
		capa = document.getElementById("capa" + i);
		if (capa) capa.style.display = "none";
	}
	capa = document.getElementById("capa" + id);
	if (capa) capa.style.display = "";			
	document.forms[0].actual.value = id;
}

//funcion pop -up imagenes
function afoto(cual,titulo)
{
		var titulopordefecto = "IMAGEN AMPLIADA";
		if(cont==1){ventana.close();ventana=null};
		if(titulo==null){titulo=titulopordefecto};
		ventana=window.open('','ventana','resizable=yes,scrollbars=no');
		ventana.document.write('<html><head><title>' + titulo + '</title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" onUnload="opener.cont=0"><img src="' + cual + '" onLoad="opener.redimensionar(this.width, this.height)"></body></html>');
		ventana.document.close();
		cont++;
}

function redimensionar(ancho,alto)
{
	ventana.resizeTo(ancho+12,alto+38);
	ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
}

///////  FUNCION PARA CAMBIAR EL FLASH AL VUELO //////
function __GetFlashMovieObject(movieName){
  if (window.document[movieName]) {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1) {
    if (document.embeds && document.embeds[movieName]) return document.embeds[movieName];
  } else{ // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
     return document.getElementById(movieName);
  }
}

function __GoToWebCam(name, title, normal){
  var sSufix = (normal!=undefined && normal!=null) ? '' : 'R';
  var url = "/skin/webcam/viewer.aspx?ID=" + name + "&title=" + title + "&sufix=" + sSufix;
  window.open(url,"webcam_wnd","width=370,height=310");
  //var oFlash = __GetFlashMovieObject(idFlash);
  //oFlash.SetVariable("urlfoto", "http://turiscam2.infocentre.gva.es/webcams/" + name + ".jpg");
}

//***** LLAMADAS AJAX ****
function changeLng(lng_id, domain) {
	document.language_form.action = "http://" + domain + "/inicio.html";
	document.language_form.event.value = 'wbe_i18n_change_lang';
	document.language_form.change_language.value = lng_id;
	document.language_form.submit();
}

function subscribe(posId) {
	var oFormValidator = new WBEFormValidator();
	if (oFormValidator.validateForm(document.forms[0], posId)) {
		document.subscription_form.email.value = eval('document.forms[0].email_' + posId).value;
		document.subscription_form.submit();
	}
}
