// JavaScript Document
function popUp(url, ancho, alto){
		parametros="width="+ ancho +", height="+ alto +",left=150,top=150, resizable=no, menubar=no,toolbar=no,directories=no,location=no,scrollbars=no,status=no";
		window.open(url,"popup",parametros);
}

function viewHide(id, nombre_formulario) {
	if(nombre_formulario != "") { for(var i=0;i<nombre_formulario.length;i++) { if(id != nombre_formulario[i].value) { document.getElementById(nombre_formulario[i].value).style.display = 'none'; } } }
	/*if(document.getElementById(id).style.display == 'block') { document.getElementById(id).style.display = 'none'; }
	else {*/ document.getElementById(id).style.display = 'block'; //} 
}

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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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];}
}

var xmlhttp = false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
catch (e) {
	try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } 
	catch (E) {	xmlhttp = false; }
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); }

function cargarPagina(destino, url){
	xmlhttp.open('GET', url, true);	
	xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById(destino).innerHTML = xmlhttp.responseText; } }
	xmlhttp.send(null);
}
/*
function cambiarMarquesina(accion){
	if(accion == 'pause'){
		document.getElementById('marquesina').stop();
		document.getElementById('btn_mar_pause').className = 'btn_ocu';
		document.getElementById('btn_mar_play').className = 'btn_vis';
	}
	else if(accion == 'play'){
		document.getElementById('marquesina').start();		
		document.getElementById('btn_mar_play').className = 'btn_ocu';
		document.getElementById('btn_mar_pause').className = 'btn_vis';			
	}
	else if(accion == 'izda'){
		document.getElementById('marquesina').direction = 'left';
		document.getElementById('btn_mar_izda').className = 'btn_ocu';
		document.getElementById('btn_mar_dcha').className = 'btn_vis';
	}
	else if(accion == 'dcha'){
		document.getElementById('marquesina').direction = 'right';
		document.getElementById('btn_mar_dcha').className = 'btn_ocu';
		document.getElementById('btn_mar_izda').className = 'btn_vis';
	}
	else if(accion == 'entrar'){ if(document.getElementById('btn_mar_play').className == 'btn_ocu'){ document.getElementById('marquesina').stop(); } }
	else if(accion == 'salir'){ if(document.getElementById('btn_mar_play').className == 'btn_ocu'){ document.getElementById('marquesina').start(); } }
}*/

function comprobarInput(evento, id, txt_def){ 
	if(evento == 'focus'){ if(document.getElementById(id).value == txt_def){ document.getElementById(id).value = ''; } }
	else{ if(document.getElementById(id).value == ''){ document.getElementById(id).value = txt_def; } }
}

function validarContacto(){
	if(!document.frm_contacto['oficina'].value){
		alert("El campo oficina es obligatorio");
		document.frm_contacto['oficina'].focus();
	}
	else if(!document.frm_contacto['nombre'].value || document.frm_contacto['nombre'].value == 'Inserte su nombre...'){
		alert("El campo nombre es obligatorio");
		document.frm_contacto['nombre'].focus();
	}
	else if(!document.frm_contacto['email'].value || document.frm_contacto['nombre'].value == 'Inserte su e-mail...'){
		alert("El campo e-mail es obligatorio");
		document.frm_contacto['email'].focus();
	}
	else if(!document.frm_contacto['consulta'].value || document.frm_contacto['nombre'].value == 'Inserte su consulta...'){
		alert("El campo consulta es obligatorio");
		document.frm_contacto['consulta'].focus();
	}
	else {
		document.frm_contacto['enviar_formulario'].value = 1;
		document.frm_contacto.submit();
	}
}

function validarQuiereVender(){
	if(!document.frm_quiere_vender['nombre'].value || document.frm_quiere_vender['nombre'].value == 'Inserte su nombre...'){ alert("El campo nombre es obligatorio"); document.frm_quiere_vender['nombre'].focus(); }
	else if(!document.frm_quiere_vender['apellidos'].value || document.frm_quiere_vender['apellidos'].value == 'Inserte sus apellidos...'){ alert("El campo apellidos es obligatorio"); document.frm_quiere_vender['apellidos'].focus(); }
	else if(!document.frm_quiere_vender['direccion'].value || document.frm_quiere_vender['direccion'].value == 'Inserte su dirección...'){ alert("El campo dirección es obligatorio"); document.frm_quiere_vender['direccion'].focus(); }
	else if(!document.frm_quiere_vender['ciudad'].value || document.frm_quiere_vender['ciudad'].value == 'Inserte su ciudad...'){ alert("El campo ciudad es obligatorio"); document.frm_quiere_vender['ciudad'].focus(); }
	else if(!document.frm_quiere_vender['provincia'].value || document.frm_quiere_vender['provincia'].value == 'Inserte su provincia...'){ alert("El campo provincia es obligatorio"); document.frm_quiere_vender['provincia'].focus(); }
	else if(!document.frm_quiere_vender['codigo_postal'].value || document.frm_quiere_vender['codigo_postal'].value == 'Inserte su código postal...'){ alert("El campo código postal es obligatorio"); document.frm_quiere_vender['codigo_postal'].focus(); }
	else if(!document.frm_quiere_vender['email'].value || document.frm_quiere_vender['email'].value == 'Inserte su e-mail...'){ alert("El campo e-mail es obligatorio"); document.frm_quiere_vender['email'].focus(); }
	else if(!document.frm_quiere_vender['telefono'].value || document.frm_quiere_vender['telefono'].value == 'Inserte su teléfono...'){ alert("El campo teléfono es obligatorio"); document.frm_quiere_vender['telefono'].focus(); }
	else if(!document.frm_quiere_vender['tipo'].value || document.frm_quiere_vender['tipo'].value == 'Inserte el tipo...'){ alert("El campo tipo es obligatorio"); document.frm_quiere_vender['tipo'].focus(); }
	else if(!document.frm_quiere_vender['superficie'].value || document.frm_quiere_vender['superficie'].value == 'Inserte la superficie...'){ alert("El campo superficie es obligatorio"); document.frm_quiere_vender['superficie'].focus(); }
	else if(!document.frm_quiere_vender['direccion_inm'].value || document.frm_quiere_vender['direccion_inm'].value == 'Inserte la dirección...'){ alert("El campo dirección es obligatorio"); document.frm_quiere_vender['direccion_inm'].focus(); }
	else if(!document.frm_quiere_vender['ciudad_inm'].value || document.frm_quiere_vender['ciudad_inm'].value == 'Inserte la ciudad...'){ alert("El campo ciudad es obligatorio"); document.frm_quiere_vender['ciudad_inm'].focus(); }
	else if(!document.frm_quiere_vender['provincia_inm'].value || document.frm_quiere_vender['provincia_inm'].value == 'Inserte la provincia...'){ alert("El campo provincia es obligatorio"); document.frm_quiere_vender['provincia_inm'].focus(); }
	else if(!document.frm_quiere_vender['codigo_postal_inm'].value || document.frm_quiere_vender['codigo_postal_inm'].value == 'Inserte el código postal...'){ alert("El campo código postal es obligatorio"); document.frm_quiere_vender['codigo_postal_inm'].focus(); }	
	else if(!document.frm_quiere_vender['consulta'].value || document.frm_quiere_vender['consulta'].value == 'Inserte su consulta...'){ alert("El campo consulta es obligatorio"); document.frm_quiere_vender['consulta'].focus(); }
	else { document.frm_quiere_vender['enviar_formulario'].value = 1; document.frm_quiere_vender.submit(); }
}

function verDetalle(url){
	document.frm_que_busca.action = url;
	document.frm_que_busca.submit(); 
}

$(document).ready(function() {
													 
	/* Fancy Box
	var images = $('#gallery a');
	images.attr('rel','fancybox');
	images.fancybox();
	
	// Slider
	$('#slider ul').jcarousel({
		wrap: 				'circular',
		animation:		'slow',
		scroll:				1,
		auto:					1,
		animation:		3000,
		initCallback: function(jc, state) {
			if (state == 'init') {
				jc.startAutoOrig = jc.startAuto;
				jc.startAuto = function() {
					if (!jc.paused) {
						jc.startAutoOrig();
					}
				}
				jc.pause = function() {
					jc.paused = true;
					jc.stopAuto();							
				};
				jc.play = function() {
					jc.paused = false;
					jc.startAuto();
				};
				$('#slider ul li').mouseover(function() {																				 
						jc.pause();
				});
				$('#slider ul li').mouseout(function() {			
						jc.play();
				});
			}
			jc.play(); 
		}
	});	 */
});								
