addEvent(window, "load", f_colapsar_ini );

addEvent(window, "load", f_email_ini );

addEvent(window, "load", f_contacto_ini );

addEvent(window, "load", f_menu_ini );


function enviarContacto(formulario)
{
	nombre       = formulario.nombreCon.value;
	correo       = formulario.emailCon.value;
	departamento = formulario.depCon.options[formulario.depCon.selectedIndex].value;
	asunto       = formulario.asuntoCon.value;
	
	parametros   = 'nombre=' + nombre + '&email=' + correo + '&dep=' + departamento + '&asunto=' + asunto;
	
	lanzarPagina('contacto.php',1,parametros,1);
	
}

function enviarSuscripcion(formulario)
{
	nombre       = formulario.nombreSus.value;
	correo       = formulario.emailSus.value;
	oOperacion   = formulario.operacionSus;
	
	if (oOperacion[0].checked)
		operacion = 1;
	else
		operacion = 2;
	
	parametros   = 'nombre=' + nombre + '&email=' + correo + '&operacion=' + operacion;
	
	lanzarPagina('subscripcion.php',1,parametros,2);
	
}
 
 

function f_menu_ini() 

{
validarBrowser();
//alert(brw)
	if (brw!='NN')

	{

		if (document.all&&document.getElementById) 

		{

			navRoot = document.getElementById("menubodegas");

			if(navRoot) 

			{

				navRoot.onmouseover=function() {this.className+=" over";}

				navRoot.onmouseout=function() {this.className=this.className.replace(" over", "");	}

			}

		}

	}

}







function f_recuerde_close()

{

	f_contacto_close(); 

	if (document.getElementById){}else{ return true } ; 

	losh = f_getElementsByClassName (document , "div" , "recuerde") ;

	if (losh.length>0)

	{

		for(i=0; i<losh.length; i++) 

		{

			losh[i].style.display="none";

		}

	}

}

function f_comer_recuerde(este)
{

	f_recuerde_close(); 

	//hideSelectBoxes();

	if( document.getElementById ("comer_recuerde_texto") )

	{

		var subobj = document.getElementById ("comer_recuerde_texto") ; 

		subobj.style.display=(subobj.style.display!="block")? "block" : "none"	

		var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 

		var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)

		//	if( brw=="NN")

			ypos = ypos-230;

			xpos = xpos-50; 

		subobj.style.left=xpos+"px"

		subobj.style.top=ypos+"px"

		return false

	}

	else{return true;}

}



function f_recuerde_visita(este)

{

	f_recuerde_close(); 

	//hideSelectBoxes();	

	if( document.getElementById ("comer_visita_texto") )

	{

		var subobj = document.getElementById ("comer_visita_texto") ; 

		subobj.style.display=(subobj.style.display!="block")? "block" : "none"	

		var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 

		var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)

		//	if( brw=="NN")

			ypos = ypos-270;

			xpos = xpos-50; 

		subobj.style.left=xpos+"px"

		subobj.style.top=ypos+"px"

		return false

	}

	else{return true; }

}

function f_recuerde_visita_premium(este)

{

	f_recuerde_close(); 

	//hideSelectBoxes();	

	if( document.getElementById ("comer_visita_premium_texto") )

	{

		var subobj = document.getElementById ("comer_visita_premium_texto") ; 

		subobj.style.display=(subobj.style.display!="block")? "block" : "none"	

		var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 

		var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)

		//	if( brw=="NN")

			ypos = ypos-290;

			xpos = xpos-50; 

		subobj.style.left=xpos+"px"

		subobj.style.top=ypos+"px"

		return false

	}

	else{return true; }

}









function hideSelectBoxes()

{

	var selects = document.getElementsByTagName("select");

	for (i = 0; i != selects.length; i++) {selects[i].style.visibility = "hidden";}

}



function f_contacto_ini()

{

	validarBrowser();

	if (document.getElementById){}else{ return true };

	if (document.getElementById ("comer_recuerde") )

	{

		document.getElementById ("comer_recuerde").onclick = function () { f_comer_recuerde(this); } 

		document.getElementById ("comer_recuerde").href = 'javascript:void("null")'; 

	}

	if (document.getElementById ("recuerde_visita") )

	{

		document.getElementById ("recuerde_visita").onclick = function () { f_recuerde_visita(this); } 

		document.getElementById ("recuerde_visita").href = 'javascript:void("null")'; 

	}

	if (document.getElementById ("recuerde_visita_premium") )

	{

		document.getElementById ("recuerde_visita_premium").onclick = function () { f_recuerde_visita_premium(this); } 

		document.getElementById ("recuerde_visita_premium").href = 'javascript:void("null")'; 

	}

	if (document.getElementById ("situacion") )

	{

		document.getElementById ("situacion").onclick = function () { f_situacion(this); } 

		document.getElementById ("situacion").href = 'javascript:void("null")'; 

	}

	if (document.getElementById ("contacto") )

	{

		document.getElementById ("contacto").onclick = function () { f_contacto(this); }  	

		document.getElementById ("contacto").href = 'javascript:void("null")';

	}

	if (document.getElementById ("boletin") )

	{

		document.getElementById ("boletin").onclick = function () { f_boletin(this); }  	

		document.getElementById ("boletin").href = 'javascript:void("null")';

	}

	

	if (document.getElementById ("contacto_cerrar")) { document.getElementById ("contacto_cerrar").onclick = function () {  f_contacto_close(); } }

	if (document.getElementById ("situacion_cerrar")){ document.getElementById ("situacion_cerrar").onclick = function () {  f_contacto_close(); } }



	if (document.getElementById ("recuerde_comer_cerrar")){ document.getElementById ("recuerde_comer_cerrar").onclick = function () {  f_recuerde_close(); } }

	if (document.getElementById ("recuerde_visita")){ document.getElementById ("recuerde_visita_cerrar").onclick = function () {  f_recuerde_close(); } }

	if (document.getElementById ("recuerde_visita_premium")){ document.getElementById ("recuerde_visita_premium_cerrar").onclick = function () {  f_recuerde_close(); } }



	

	



if( document.getElementById("situacion_popup") ){}else{return true; }

var html_situacion_popup = '';

html_situacion_popup +='<div>	';

html_situacion_popup +='	<p><a id="situacion_cerrar" href="javascript:f_contacto_close()"><span>Cerrar</span></a></p>	';

html_situacion_popup +='	<ul>	';

html_situacion_popup +='	<li class="contacto_cune">	';

html_situacion_popup +='		<h2><span><span>Cune</span></span></h2>	';

html_situacion_popup +='		<address>	';

html_situacion_popup +='			Barrio de la Estación S/N';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			26200 Haro (La Rioja)';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			Tel: (+34) 941 304 800	';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			Fax: (+34) 941 304 815	';

html_situacion_popup +='		</address>	';

html_situacion_popup +='		<a target="_blank" href="http://maps.google.es/maps/ms?ie=UTF8&hl=es&msa=0&msid=107614556547118384881.00046077d9014ece9d006&ll=42.581984,-2.847669&spn=0.006762,0.019312&t=h&z=16">Ver Mapa</a>	';

html_situacion_popup +='	</li>	';

html_situacion_popup +='	<li class="contacto_vinareal">	';

html_situacion_popup +='		<h2><span><span>Viña Real</span></span></h2>	';

html_situacion_popup +='		<address>	';

html_situacion_popup +='			Ctra. Logroño–Laguardia km 4,8';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			01300 Laguardia (Alava)';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			Tel: (+34) 945 625 255	';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			Tel: (+34) 945 625 211	';

html_situacion_popup +='		</address>	';

html_situacion_popup +='		<a target="_blank" href="http://maps.google.es/maps/ms?ie=UTF8&hl=es&msa=0&msid=107614556547118384881.000460384be67c55148bd&ll=42.500595,-2.496214&spn=0.003386,0.009656&t=h&z=17">Ver Mapa</a>	';

html_situacion_popup +='	</li>	';

html_situacion_popup +='	<li class="contacto_contino">	';

html_situacion_popup +='		<h2><span><span>Contino</span></span></h2>	';

html_situacion_popup +='		<address>	';

html_situacion_popup +='			Finca San Rafael';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			01321 Laserna (Alava)';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			Tel: (+34) 945 600 201';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			Fax: (+34) 945 621 114';

html_situacion_popup +='		</address>	';

html_situacion_popup +='		<a target="_blank" href="http://maps.google.es/maps/ms?ie=UTF8&hl=es&msa=0&msid=107614556547118384881.00046077b7151fd3ccaaf&ll=42.496403,-2.506814&spn=0.006771,0.019312&t=h&z=16">Ver Mapa</a>	';

html_situacion_popup +='	</li>	';

html_situacion_popup +='	<li class="contacto_distribucion">	';

html_situacion_popup +='	<h2><span><span>Distribución</span></span></h2>	';

html_situacion_popup +='		<address>	';

html_situacion_popup +='			P.I. Los  Nogales	';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			C/Rio Duero Nº1 Nave 6	';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			28110 Algete (Madrid)	';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			Tel: (+34) 916 289 380	';

html_situacion_popup +='			<br/>	';

html_situacion_popup +='			Fax: (+34) 916 289 381	';

html_situacion_popup +='		</address>	';

html_situacion_popup +='		<a target="_blank" href="http://maps.google.es/maps/ms?ie=UTF8&hl=es&msa=0&msid=107614556547118384881.0004603865355256ae45c&z=17">Ver Mapa</a>	';

html_situacion_popup +='	</ul>	';

html_situacion_popup +='</div>	';

document.getElementById("situacion_popup").innerHTML = html_situacion_popup ;

				





if( document.getElementById("contacto_popup") ){}else{return true; }

var html_contacto_popup='';

html_contacto_popup+='<div>	';

html_contacto_popup+='<p><a id="contacto_cerrar" href="javascript:f_contacto_close()"><span>Cerrar</span></a></p>	';

html_contacto_popup+='<form action="#" name="formPesContacto" id="formPesContacto" method="post">	';

html_contacto_popup+='<ul>	';

html_contacto_popup+='	<li>	';

html_contacto_popup+='		<label for="nombreCon">	';

html_contacto_popup+='			<span>Nombre y Apellidos:</span>	';

html_contacto_popup+='			<input type="text" name="nombreCon"  id="nombreCon" />	';

html_contacto_popup+='		</label>	';

html_contacto_popup+='	</li>	';

html_contacto_popup+='	<li>	';

html_contacto_popup+='		<label for="emailCon">	';

html_contacto_popup+='			<span>E-mail:</span>	';

html_contacto_popup+='			<input type="text" name="emailCon"  id="emailCon" />	';

html_contacto_popup+='		</label>	';

html_contacto_popup+='	</li>	';

html_contacto_popup+='	<li>	';

html_contacto_popup+='		<label for="depCon">	';

html_contacto_popup+='			<span>Dirigido a:</span>	';

html_contacto_popup+='			<select name="depCon"  id="depCon" >	';

html_contacto_popup+='				<option value="1">Bodegas</option>	';

html_contacto_popup+='				<option value="2">Visitas</option>	';

html_contacto_popup+='			</select>	';

html_contacto_popup+='		</label>	';

html_contacto_popup+='	</li>	';

html_contacto_popup+='	<li>	';

html_contacto_popup+='		<label for="asuntoCon">	';

html_contacto_popup+='			<span>Asunto:</span>	';

html_contacto_popup+='			<textarea type="text" name="asuntoCon"  id="asuntoCon" ></textarea>	';

html_contacto_popup+='		</label>	';

html_contacto_popup+='	</li>	';

html_contacto_popup+='	<li>	';

html_contacto_popup+='		<button type="button" onclick="enviarContacto(document.formPesContacto);"><span>Enviar</span></button>	';

html_contacto_popup+='	</li>	';

html_contacto_popup+='	</ul>	';

html_contacto_popup+='	</form>	';

html_contacto_popup+='	</div>	';

document.getElementById("contacto_popup").innerHTML = html_contacto_popup ;

	

	





if( document.getElementById("boletin_popup") ){}else{return true; }

var html_boletin_popup='';

html_boletin_popup+='<div>	';

html_boletin_popup+='<p><a id="boletin_cerrar" href="javascript:f_contacto_close()"><span>Cerrar</span></a></p>	';

html_boletin_popup+='<form name="formPesBoletin" id="formPesBoletin" method="post">	';

html_boletin_popup+='<ul>	';

html_boletin_popup+='	<li>	';

html_boletin_popup+='		<label for="nombreSus">	';

html_boletin_popup+='			<span>Nombre y Apellidos:</span>	';

html_boletin_popup+='			<input type="text" name="nombreSus"  id="nombreSus" />	';

html_boletin_popup+='		</label>	';

html_boletin_popup+='	</li>	';

html_boletin_popup+='	<li>	';

html_boletin_popup+='		<label for="emailSus">	';

html_boletin_popup+='			<span>E-mail:</span>	';

html_boletin_popup+='			<input type="text" name="emailSus"  id="emailSus" />	';

html_boletin_popup+='		</label>	';

html_boletin_popup+='	</li>	';

// he tenido que meter una clase a este <li para pasarle estilos a los radios

html_boletin_popup+='	<li class="radios">	';

html_boletin_popup+='		<label>	';

html_boletin_popup+='			<input type="radio" name="operacionSus" checked="checked" value="1" />	';

html_boletin_popup+='			<span>Alta del boletín:</span>	';

html_boletin_popup+='			<input type="radio" name="operacionSus" value="2" />	';

html_boletin_popup+='			<span>Baja del boletín:</span>	';

html_boletin_popup+='		</label>	';

html_boletin_popup+='	</li>	';

// le quito el submit al boton para que ejecute la función f_boletin_ok()

// si se llama a f_boletin_ko() pues sale la otra

html_boletin_popup+='	<li>	';

//html_boletin_popup+='		<button type="submit" onclick=><span>Enviar</span></button>	';

html_boletin_popup+='		<button type="button" onclick="javascript:enviarSuscripcion(document.formPesBoletin)"><span>Enviar</span></button>	';

html_boletin_popup+='	</li>	';

html_boletin_popup+='	</ul>	';

html_boletin_popup+='	</form>	';

html_boletin_popup+='	</div>	';

document.getElementById("boletin_popup").innerHTML = html_boletin_popup ;

}





function f_respuesta_ok(objeto,operacion,frase)
{

	if( document.getElementById(objeto) ){}else{return true; }

	var html_respuesta_popup='';

	html_respuesta_popup+='<div>';

	html_respuesta_popup+='	<p><a id="boletin_cerrar" href="javascript:f_contacto_close()"><span>Cerrar</span></a></p>	';

	html_respuesta_popup+='	<ul>	';

	html_respuesta_popup+='		<li>	';

	html_respuesta_popup+='			<p>' + frase + '</p>	';

	html_respuesta_popup+='		</li>	';

	html_respuesta_popup+='	</ul>	';

	html_respuesta_popup+='</div>	';

	document.getElementById(objeto).innerHTML = html_respuesta_popup ;

}





function f_respuesta_ko(objeto,operacion,frase)
{
	
	if( document.getElementById(objeto) ){}else{return true; }

	var html_respuesta_popup='';

	html_respuesta_popup+='<div>	';

	html_respuesta_popup+='	<p><a id="boletin_cerrar" href="javascript:f_contacto_close()"><span>Cerrar</span></a></p>	';

	html_respuesta_popup+='	<ul>	';

	html_respuesta_popup+='		<li>	';

	html_respuesta_popup+='			<p>' + frase + '</p>	';

	html_respuesta_popup+='		</li>	';

	html_respuesta_popup+='	</ul>	';

	html_respuesta_popup+='</div>	';


	document.getElementById(objeto).innerHTML = html_respuesta_popup ;

}





function f_situacion(este)

{

	f_recuerde_close(); 

	f_contacto_close(); 

	if( document.getElementById ("situacion_popup") ){}else{return true; }

	var subobj = document.getElementById ("situacion_popup") ; 

	subobj.style.display=(subobj.style.display!="block")? "block" : "none"	

	var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 

	var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)

//	if( brw=="NN")

		ypos = ypos+10;

		xpos = xpos-253; 



	subobj.style.left=xpos+"px"

	subobj.style.top=ypos+"px"

	return false

}



function f_contacto(este)

{

	f_recuerde_close(); 

	f_contacto_close(); 

	if( document.getElementById ("contacto_popup") ){}else{return true; }

	var subobj = document.getElementById ("contacto_popup") ; 

	subobj.style.display=(subobj.style.display!="block")? "block" : "none"	

	var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 

	var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)

//	if( brw=="NN")

		ypos = ypos+10;

		xpos = xpos-313; 



	subobj.style.left=xpos+"px"

	subobj.style.top=ypos+"px"

	return false

}





function f_boletin(este)

{

	f_recuerde_close(); 

	f_contacto_close(); 

	if( document.getElementById ("boletin_popup") ){}else{return true; }

	var subobj = document.getElementById ("boletin_popup") ; 

	subobj.style.display=(subobj.style.display!="block")? "block" : "none"	

	var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 

	var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)

//	if( brw=="NN")

		ypos = ypos+10;

		xpos = xpos-313; 



	subobj.style.left=xpos+"px"

	subobj.style.top=ypos+"px"

	return false

}







function f_contacto_close()

{



	if (document.getElementById){}else{ return true } ; 

	if (document.getElementById ("situacion_popup") )

	{

		document.getElementById ("situacion_popup").style.display = "none" ; 	

	}

	if (document.getElementById ("contacto_popup") )

	{

		document.getElementById ("contacto_popup").style.display = "none" ; 	

	}

	if (document.getElementById ("boletin_popup") )

	{

		document.getElementById ("boletin_popup").style.display = "none" ; 	

	}

	

}









function f_email_ini()

{



	if (document.getElementById("email_no_span"))

	{

		var emailriddlerarray=[109,97,114,107,101,116,105,110,103,64,99,118,110,101,46,99,111,109];

		var encryptedemail_id35='';

		for (var i=0; i<emailriddlerarray.length; i++)

		encryptedemail_id35+=String.fromCharCode(emailriddlerarray[i])

		document.getElementById("email_no_span").innerHTML=	'<a href="mailto:'+encryptedemail_id35+'">marketing@cvne.com</a>' ;

	}

	if (document.getElementById("email_no_span_2"))

	{

		var emailriddlerarray=[118,105,115,105,116,97,115,64,99,118,110,101,46,99,111,109]

		var encryptedemail_id35='';

		for (var i=0; i<emailriddlerarray.length; i++)

		encryptedemail_id35+=String.fromCharCode(emailriddlerarray[i])

		document.getElementById("email_no_span_2").innerHTML=	'<a href="mailto:'+encryptedemail_id35+'">'+encryptedemail_id35+'</a>' ;

	}

	



	

	

}//











function f_colapsar_ini()

{

var losh ;

var loshof ;



	losh = f_getElementsByClassName (document , "table" , "abierta") ;

	if (losh.length>0)

	{

		for(i=0; i<losh.length; i++) 

		{

			caption = losh[i].getElementsByTagName("caption");

			if (caption.length>0)

			{

				caption[0].onclick = function () { colapsa(this); } 

			}

		}	

	}

	

	loshof = f_getElementsByClassName (document , "table" , "cerrada") ;

	if (loshof.length>0)

	{

		for(ii=0; ii<loshof.length; ii++) 

		{

			caption = loshof[ii].getElementsByTagName("caption");

			if (caption.length>0)

			{

				caption[0].onclick = function () { colapsa(this); } 

			}

		}	

	}

}//	



function colapsa(este)

{

	var latabla; 

	latabla = f_getParent(este , "table" );

	if (latabla.className=="abierta")

	{

		latabla.className="cerrada";

	}

	else

	{

		latabla.className="abierta";

	}

	



}//





function f_getParent(el, pTagName) 

{

	if (el == null){return null;}

	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()){return el;}else{return f_getParent(el.parentNode, pTagName);}

}

function tc_getParent2(el, pTagName) 

{

	el = el.parentNode

	if (el == null){return null;}

	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()){return el;}else{return tc_getParent(el.parentNode, pTagName);}

}







function f_getElementsByClassName(ele, eltag, strClassName)

{

	var arrElements = (eltag == "*" && ele.all)? ele.all : ele.getElementsByTagName(eltag);

	var arrReturnElements = new Array();

	strClassName = strClassName.replace(/-/g, "\-");

	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");

	var oElement;

	for ( var i=0; i<arrElements.length; i++ ) { oElement = arrElements[i];if(oRegExp.test(oElement.className)){arrReturnElements.push(oElement);}}

	return (arrReturnElements)

}





 function addEvent(elm, evType, fn, useCapture)

{

  if (elm.addEventListener){

    elm.addEventListener(evType, fn, useCapture);

    return true;

  } else if (elm.attachEvent){

    var r = elm.attachEvent("on"+evType, fn);

    return r;

  } else {

    alert("No se puede acceder al evento");

  }

} 



function validarBrowser(){

  if(document.getElementById){

	

	if(navigator.appName == "Netscape")

		brw='NN';

	else if(navigator.appName == "Microsoft Internet Explorer"){

		if(navigator.appVersion.indexOf("MSIE 5.0"))

			brw='IE5.0';

		else

			brw='IE';

	}

	return true;

  }

  else	

	return false;

}



function getposOffset(overlay, offsettype)

{

	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;

	var parentEl=overlay.offsetParent;

	while (parentEl!=null)

	{

		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;

		parentEl=parentEl.offsetParent;

	}

return totaloffset;

}

function abrirPopUp(nombre,url,ancho,alto)
{	
	window.open(url, nombre,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=' + ancho + ',height=' + alto);
}