function cambiaDisplay(idString) {
	var objs = idString.split("|");
	for (i=0; i<objs.length;i++) {
		if ( document.getElementById(objs[i])) {
			obj = document.getElementById(objs[i]);
			if (obj.style.display!='none' ) obj.style.display = 'none';
  			else obj.style.display = 'block';
		}
	}
}

mapLoaded = 0;
function loadMap(num) {
	if (mapLoaded == 0) {
		thisDiv = document.getElementById('gmapiframe');
		thisDiv.src = 'http://files.mueblesdevalencia.com/panel/includes/gmap.php?r='+num;
		mapLoaded=1;
	}
}

function cargaFoto(srcFoto, imgId) {
	img = document.getElementById(imgId);
	img.src=srcFoto;
}

function enviaConsulta(idArticulo, tipo) {
	var camposRek = new Array('nombre', 'email', 'telefono', 'mensaje');
	var camposTxtRek = new Array('Name', 'Email', 'Phone', '');

	var formOk = 1;

	for(i=0; i<camposRek.length;i++) {
		thisCampo = document.getElementById('cons_'+camposRek[i]);
		if (thisCampo.value=='' || thisCampo.value==camposTxtRek[i]) {
			formOk = 0;
			thisCampo.style.border="1px solid #C40001";
			thisCampo.style.color="#C40001";
		}
	}
	if (formOk == 0) alert("Fields with (*) are required");

	var filter  = /^(.+\@.+\..+)$/;

	if (formOk==1) {
		if (!filter.test(document.getElementById('cons_email').value)) alert("Check the spelling of your email");
		else {
			var nombre = document.getElementById('cons_nombre').value;
			var email = document.getElementById('cons_email').value;
			var telefono = document.getElementById('cons_telefono').value;
			var horario = document.getElementById('cons_horario').value;
			var mensaje = document.getElementById('cons_mensaje').value;

			xajax_envia_consulta(idArticulo, tipo, nombre, email, telefono, horario, mensaje);
		}
	}
}

function cambiaPestEmp(numId) {
	for (i=1; i<5;i++) {
		if (document.getElementById('pest_busc_'+i)) {
			document.getElementById('pest_busc_'+i).className = '';
			document.getElementById('busc_emp_'+i).style.display = 'none';
		}
	}
	document.getElementById('pest_busc_'+numId).className = 'current';
	document.getElementById('busc_emp_'+numId).style.display = 'block';
}

function cambiaPestOpor(numId) {
	for (i=1; i<5;i++) {
		if (document.getElementById('pest_opor_'+i)) {
			document.getElementById('pest_opor_'+i).className = '';
			document.getElementById('busc_opor_'+i).style.display = 'none';
		}
	}
	document.getElementById('pest_opor_'+numId).className = 'current';
	document.getElementById('busc_opor_'+numId).style.display = 'block';
}

function cambiaPestBusc(numId) {
	for (i=1; i<4;i++) {
		if (document.getElementById('pest_topbusc_'+i)) {
			document.getElementById('pest_topbusc_'+i).className = '';
			document.getElementById('search_'+i).style.display = 'none';
		}
	}
	document.getElementById('pest_topbusc_'+numId).className = 'current';
	document.getElementById('search_'+numId).style.display = 'block';
}

function searchEmpresas() {
	thisForm = document.getElementById('form_busc_empresas');
	var checksRek = new Array('tipos[]', 'estilos[]', 'niveles[]', 'provincias[]');

	formOk = 0;

	for(i=0; i<checksRek.length;i++) {
		thisCampo = thisForm[checksRek[i]];
		auxOn = 0;
		if (formOk == 0 && (thisCampo=='[object]' || thisCampo=='[object NodeList]')) {
			for (j=0; j<thisCampo.length; j++) {
				if (thisCampo[j].checked === true) formOk = 1;
			}
		}
	}
	if (formOk == 0) alert("");
	else thisForm.submit();
}

function updateInput(txtLabel, thisInput, opcion) {
	if (opcion == 1) {
		if (thisInput.value == txtLabel) thisInput.value = '';
	}
	else {
		if (thisInput.value == '') thisInput.value = txtLabel;
	}
}

function search(zona) {
	thisForm = document.getElementById('form_search_'+zona);
	if (zona == 'producto') {
		thisSel = thisForm.cat;
		if (thisSel.options[thisSel.selectedIndex].value=='o') thisForm.action = 'http://www.furniturefromvalencia.com/oportunidades.php';
		else thisForm.action = 'http://www.furniturefromvalencia.com/producto_listado.php';
	}
	thisForm.submit();
}


function checkRegister() {
	thisForm = document.getElementById('form_check');
	var camposRek = new Array('nombre', 'email', 'user', 'password1', 'password2');
	var selectsRek = new Array( 'provincia', 'pais');
	var checksRek = new Array( 'tipo');

	var formOk = 1;
	var continua = 1;

	for(i=0; i<camposRek.length;i++) {
		if (document.getElementById(camposRek[i]+'-1')) {
			thisCampo = document.getElementById(camposRek[i]+'-1');
			if (thisCampo.value=='') {
				formOk = 0;
				thisCampo.style.border="1px solid #C40001";
				thisCampo.style.color="#C40001";
			}
		}
		else alert(camposRek[i]);
	}

	for(i=0; i<selectsRek.length;i++) {
		thisCampo = document.getElementById(selectsRek[i]+'-1');
		if (thisCampo.options[thisCampo.selectedIndex].value=='') {
			formOk = 0;
			thisCampo.style.border="1px solid #C40001";
			thisCampo.style.color="#C40001";
		}
	}

	if (formOk == 0) alert("Fields with (*) are required");

	if (formOk==1) {
		for(i=0; i<checksRek.length;i++) {
			thisCampo = thisForm[checksRek[i]];
			auxOn = 0;
			if (auxOn==0 && formOk == 1 && (thisCampo=='[object]' || thisCampo=='[object NodeList]')) {
				for (j=0; j<thisCampo.length; j++) {
					if (thisCampo[j].checked === true) auxOn = 1;
				}
				if (auxOn == 0) {
					formOk = 0;
					alert("Fields with (*) are required");
				}
			}
		}
	}

	var filter  = /^(.+\@.+\..+)$/;

	if (formOk==1) {
		if (!filter.test(document.getElementById('email-1').value)) alert("Check the spelling of your email");
		else if (document.getElementById('password1-1').value !== document.getElementById('password2-1').value) alert("Passwords entered do not match");
		else if (document.getElementById('acepto_cond-1').checked === false) alert("You must read and accept service conditions.");
		else {
			thisForm.submit();
			thisForm.action="javascript:void(0)";
		}
	}
}


function checkContacto() {
	thisForm = document.getElementById('form_check');
	var camposRek = new Array('nombre', 'apellidos', 'email', 'direccion', 'cp', 'localidad', 'telefono');
	var selectsRek = new Array( 'provincia', 'pais');

	var formOk = 1;
	var continua = 1;

	for(i=0; i<camposRek.length;i++) {
		if (document.getElementById(camposRek[i]+'-1')) {
			thisCampo = document.getElementById(camposRek[i]+'-1');
			if (thisCampo.value=='') {
				formOk = 0;
				thisCampo.style.border="1px solid #C40001";
				thisCampo.style.color="#C40001";
			}
		}
		else alert(camposRek[i]);
	}

	for(i=0; i<selectsRek.length;i++) {
		thisCampo = document.getElementById(selectsRek[i]+'-1');
		if (thisCampo.options[thisCampo.selectedIndex].value=='') {
			formOk = 0;
			thisCampo.style.border="1px solid #C40001";
			thisCampo.style.color="#C40001";
		}
	}

	if (formOk == 0) alert("Fields with (*) are required");

	var filter  = /^(.+\@.+\..+)$/;

	if (formOk==1) {
		if (!filter.test(document.getElementById('email-1').value)) alert("Check the spelling of your email");
		else if (document.getElementById('acepto_cond-1').checked === false) alert("You must read and accept service conditions.");
		else {
			thisForm.submit();
			thisForm.action="javascript:void(0)";
		}
	}
}
function verSec (sec)
    {
	numsec = document.getElementById('numsec'+sec);
	thisElem = document.getElementById('titsec'+sec);
	numcats = 10;
	if (numsec.style.display=="none")
	    { numsec.style.display="block";}
	else { numsec.style.display="none";}

	for (i=1;i<=numcats;i++)
	    {
		
	        if ( i != sec && (numsec = document.getElementById('numsec'+i)))
	            {
		numsec = document.getElementById('numsec'+i);
		numsec.style.display="none";
		
	            }
	    }
    }


function verSec2 (sec)
    {
	idsec = document.getElementById('idsec'+sec);
	thisElem = document.getElementById('titsec'+sec);
	numcats = 10;
	if (idsec.style.display=="none") idsec.style.display="block";

	for (i=1;i<=numcats;i++)
	    {
	        if ( i != sec && (idsec = document.getElementById('idsec'+i)))
	            {
		idsec = document.getElementById('idsec'+i);
		idsec.style.display="none";
	            }
	    }
    }


function addBoletin() {
	thisForm = document.getElementById('form_newsletter');
	var formOk = 1;

	var filter  = /^(.+\@.+\..+)$/;

	if (formOk==1) {
		if (!filter.test(thisForm.email.value)) alert("Check the spelling of your email");
		else {
			var email = thisForm.email.value;

			tipoParti = document.getElementById('tiponews_1');
			tipoPro = document.getElementById('tiponews_2');

			if (tipoParti.checked==true) var tipo = tipoParti.value;
			else var tipo = tipoPro.value;

			xajax_add_boletin(email, tipo);
		}
	}
}

function checkLogin() {
	thisForm = document.getElementById('form_login');
	var user = thisForm.user.value;
	var pwd = thisForm.pwd.value;
	xajax_check_user(user, pwd);
}

function sendLogin() {
	thisForm = document.getElementById('form_login');
	thisForm.submit();
}

function recuerdaPwd() {
	thisForm = document.getElementById('form_login');
	thisEmail = document.getElementById('login_user');
	if (thisEmail.value=='' || thisEmail.value=='User') {
		thisEmail.style.border='1px solid #FF0000';
		thisEmail.style.borderTop='2px solid #FF0000';
		thisEmail.style.color='#FF0000';
		alert('Introduzca su email en el campo usuario y haga click en -¿ Olvidó su contraseña ?-');
	}
	else xajax_recordar_pwd(thisEmail.value);
}

var ultimTextt = 'ninnngun';

function cargaPubli (titulo, imagen, texto) {
	if (document.getElementById(ultimTextt)) {
		ultimText = document.getElementById(ultimTextt);
		ultimText.style.display='none';
	}
	thisTit = document.getElementById('tit_bans');
	thisTit.innerHTML = titulo;
	thisImg = document.getElementById('img_publi_ban');
	thisImg.src = 'http://files.mueblesdevalencia.com/web/images/publi/'+imagen;
	thisText = document.getElementById(texto);
	thisText.style.display='block';

	ultimTextt = texto;
}