function mouseDown(e) {
        if ((is.ns && e.which!=1) || (is.ie && event.button!=1)) return true
        var x = (is.ns)? e.pageX : event.x+document.body.scrollLeft
        var y = (is.ns)? e.pageY : event.y+document.body.scrollTop
        if (drag.mouseDown(x,y)) {
          	// escribir aquí el código para hacer cualquier cosa al comenzar a arrastrar
			return false
        }
        else return true
}

function mouseMove(e) {
	var x = (is.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (is.ns)? e.pageY : event.y+document.body.scrollTop
	if (drag.mouseMove(x,y)) {
		// escribir aquí el código para hacer cualquier cosa mientras arrastramos
		return false
	}
	else return true
}

function mouseUp(e) {
	var x = (is.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (is.ns)? e.pageY : event.y+document.body.scrollTop
	if (drag.mouseUp()) {
		// escribir aquí el código para hacer cualquier cosa al finalizar el arrastrar 
		return false
	}
	else return true
}

function ocultarPromocion(){
	if(document.getElementById('promocion'))
		document.getElementById('promocion').style.visibility = 'hidden';
	if(document.getElementById('promocionCabecera'))
		document.getElementById('promocionCabecera').style.visibility = 'hidden';
	if(document.getElementById('promocionPequena'))
		document.getElementById('promocionPequena').style.visibility = 'visible';
}
function mostrarPromocion(){
	ocultarPromocion2();
	if(document.getElementById('promocion'))
		document.getElementById('promocion').style.visibility = 'visible';
	if(document.getElementById('promocionCabecera'))
		document.getElementById('promocionCabecera').style.visibility = 'visible';
}

function ocultarPromocion2(){
	if(document.getElementById('promocion2'))
		document.getElementById('promocion2').style.visibility = 'hidden';
	if(document.getElementById('promocionCabecera2'))
		document.getElementById('promocionCabecera2').style.visibility = 'hidden';
	if(document.getElementById('promocionPequena2'))
		document.getElementById('promocionPequena2').style.visibility = 'visible';
}
function mostrarPromocion2(){
	ocultarPromocion();
	if(document.getElementById('promocion2'))
		document.getElementById('promocion2').style.visibility = 'visible';
	if(document.getElementById('promocionCabecera2'))
		document.getElementById('promocionCabecera2').style.visibility = 'visible';
}

function initDivs() {
	// inicializar capas (tantas líneas como capas), donde se debe sustituir nombrecapa por los nombres que hayamos usado al crear las capas
	capa0 = new DynLayer("promocionCabecera",null);
	capa1 = new DynLayer("promocion",null);
	//capa2 = new DynLayer("promocionCabecera2",null);
	//capa3 = new DynLayer("promocion2",null);
	
	// añadir al objeto "drag" las capas que se quieren poder mover
	drag.add(capa0,capa1);
	
	// inicializar eventos de ratón
	document.onmousedown = mouseDown
	document.onmousemove = mouseMove
	document.onmouseup = mouseUp
	if (is.ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

// accessOk
function fCambiarAutologin(){
	document.formCambiarAutologin.action = "CambiarAutologinServlet";
        var input1;
        input1 = document.createElement('INPUT');
        input1.type = "hidden";
        input1.value = "cambiar";
        input1.name = 'AUTOLOGIN' ;
        document.formCambiarAutologin.appendChild(input1);
	document.formCambiarAutologin.submit();
}

function fEnviarMail(){
    if (checkMail(document.formEnviarMail.email)){
		document.formEnviarMail.action = "EnviarDireccionMailServlet";
		document.formEnviarMail.submit();
	}
}

function abrir_ventana(){
	var ancho = 450;
	var alto = 370;
	var xMax = screen.width, yMax = screen.height;
	
	var xOffset = (xMax - ancho)/2, yOffset = (yMax - alto)/2 - 30;
	window.open('CambiarPassword.jsp','CambiarPassword_Flotante','scrollbars=NO,width='+ancho+',height='+alto+',top='+yOffset+',left='+xOffset);
}

function gotoVP(){
	if(document.formVAILLANTPREMIUM_PROFESIONAL){
		document.formVAILLANTPREMIUM_PROFESIONAL.submit();
	}else if(document.formVAILLANTPREMIUM_INT){
	 	document.formVAILLANTPREMIUM_INT.submit();
	}else{
		window.location.href="VaillantPremium.jsp?SELECCION=VAILLANTPREMIUM_PROFESIONAL"
	}
}