// Corrector de Bug PNG para Explorer. Opera y Mozilla funcionan correctamente sin este JS



function correctPNG() 
   {
   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;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }

   }
var ua = navigator.userAgent.toLowerCase();
function detect(text) {
   stringposition = ua.indexOf(text) + 1;
   data = text;
   return stringposition;
}

if (detect('opera')) {
	 
 } else if (detect('firefox')){
	 
} else if (detect('msie')){
	 window.attachEvent("onload", correctPNG);	
}	 

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_showHideLayers() { //v6.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; }
}

function openwindow(pie,imagen){
	var centroy=((screen.availHeight - 510)/2);
	var centrox=((screen.availWidth - 510)/2);	
	window.open('/popup.php?pie='+pie+'&imagen='+imagen,'Imagen','resizable=yes,menubar=no,toolbar=no,scrollbars=yes,width=468,height=300,left='+centrox+',top='+centroy);
}

function iecompattest(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}		

function CambiarFotoPortada() {
	imagen= Math.floor(Math.random()*4);
	document.getElementById("FotoPortada").style.backgroundImage="url(http://www.solardeurbezo.c/img/fotos_portada/"+imagen+".jpg)";
}

function ocultarMostrarSubmenu(Menu) {
	var cadenaNone = 'none';
	var cadenaBlock = 'block';	
	
	document.getElementById('LaBodega').style.marginTop="0px";
	document.getElementById('LaBodega').getElementsByTagName('ul')[0].style.display=cadenaNone;
	document.getElementById('LaBodega').getElementsByTagName('a')[0].style.color="#949176";

	document.getElementById('LosVinos').style.marginTop="0px";	
	document.getElementById('LosVinos').getElementsByTagName('ul')[0].style.display=cadenaNone;
	document.getElementById('LosVinos').getElementsByTagName('a')[0].style.color="#949176";
	
	document.getElementById('Actualidad').style.marginTop="0px";
	document.getElementById('Actualidad').getElementsByTagName('ul')[0].style.display=cadenaNone;
	document.getElementById('Actualidad').getElementsByTagName('a')[0].style.color="#949176";

	/*document.getElementById('Boletin').style.marginTop="0px";
	document.getElementById('Boletin').getElementsByTagName('ul')[0].style.display=cadenaNone;
	document.getElementById('Boletin').getElementsByTagName('a')[0].style.color="#949176";*/

	document.getElementById('Visitas').style.marginTop="0px";
	document.getElementById('Visitas').getElementsByTagName('ul')[0].style.display=cadenaNone;
	document.getElementById('Visitas').getElementsByTagName('a')[0].style.color="#949176";

	document.getElementById('Comercializacion').style.marginTop="0px";
	document.getElementById('Comercializacion').getElementsByTagName('ul')[0].style.display=cadenaNone;		
	document.getElementById('Comercializacion').getElementsByTagName('a')[0].style.color="#949176";
	
	if (Menu != 'LaBodega') {
		document.getElementById(Menu).style.marginTop="12px";
	}
	document.getElementById(Menu).getElementsByTagName('ul')[0].style.display=cadenaBlock;
	document.getElementById(Menu).getElementsByTagName('a')[0].style.color="#3A3720";
}

function CambiarFotoPortada(Idioma) {
	imagen= Math.floor(Math.random()*4)+"_"+Idioma;
	document.getElementById("FotoPortada").style.backgroundImage="url(/img/fotos_portada/"+imagen+".jpg)";
}


var EstadoFotoLocalizacion="Apagado";

function CambiarFotoLocalizacion() {
	if (EstadoFotoLocalizacion=="Apagado") {
		NuevaImagen="http://www.solardeurbezo.es/UserFiles/Image/carinena2.gif";
		document.getElementById('FotoLocalizacion').src = NuevaImagen;
		document.getElementById('FotoLocalizacion').alt = "Reducir mapa";
		document.getElementById('FotoLocalizacion').title = "Reducir mapa";				
		EstadoFotoLocalizacion="Encendido";
	}else{
		NuevaImagen="http://www.solardeurbezo.es/UserFiles/Image/espanna.gif";
		document.getElementById('FotoLocalizacion').src = NuevaImagen;	
		document.getElementById('FotoLocalizacion').alt = "Ampliar mapa";
		document.getElementById('FotoLocalizacion').title = "Ampliar mapa";		
		 EstadoFotoLocalizacion="Apagado";		
	}
}

function ComprobarFormBaja(form){
	if(document.getElementById('EMailB').value==''){
		alert('El campo EMail es obligatorio .');
		return false;
	}
	if(!validarEmailModificar(document.getElementById('EMailB').value)){
		return false;
	}
	if(document.getElementById('PasswordB').value==''){
		alert('El campo Clave es obligatorio.');
		return false;
	}
	return true;
}

function ConfirmarSalir(Ruta) {
	if (confirm("&iquest;Est&aacute; seguro de que desea salir?")){
		window.location = Ruta + "salir.php";
	}
}

function ConfirmarBaja(Ruta) {
	if (confirm("&iquest;Est&aacute; seguro de que desea darse de baja?")){
		window.location = Ruta + "baja.php";
	}
}