
function PoPup(ventana, ancho, alto){
var ventana;
ventana=window.open(ventana+".htm","new","toolbars=no,scrollbars=no,directories=no,menubar=no,resizable=no,status=no,width="+ancho+",height="+alto+",screenx=250,screeny=50,top=50,left=250");
};

function comprova()
{
	if (document.formulario.nom.value==''){alert("Falta el Nom");return false;}
	if (document.formulario.cognom.value==''){alert("Falta el Cognom");return false;}
	else
	{
	document.formulario.action = "enviar.php";
	document.formulario.submit();
	}
}
function SwitchMenu(obj){
	if(document.getElementById)
	{
	var el = document.getElementById(obj);
	var ar = document.getElementById("cont").getElementsByTagName("DIV");
		if(el.style.display == "none")
		{
			//if (0) //tancar tots cuan vols obrir aquest
			for (var i=0; i<ar.length; i++)
			{
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}
		else
		{
			el.style.display = "none";
		}
	}
}
function ChangeClass(menu, newClass)
{ 
	  var navegador = navigator.appName;
	  //alert(navegador);
		if (navegador=="Netscape")
		{
			 if (document.getElementById)
			 { 
				document.getElementById(menu).setAttribute("class",newClass);
				//document.getElementById(menu).class = newClass; 
			 } 
		}
		if (navegador=="Microsoft Internet Explorer")
		{
			 if (document.getElementById)
			 { 
				document.getElementById(menu).className = newClass;
			 } 
		}
} 
document.onselectstart = new Function("return false");

function validate(op,id,idioma,inst,fam,subfam)
{
	doc=document.location.href.split("?");
	if (doc.length!=1)
	{
		document.formulario.action = doc[0];
	}
	
	if (op=='7') document.formulario.action="index.php";
	if (op=='4') document.formulario.action="index.php";
	document.formulario.op.value = op;
	//alert(id);
	document.formulario.id.value = id;
	//alert(idioma);
	document.formulario.idioma.value = idioma;
	//alert(inst);
	document.formulario.inst.value = inst;
	//alert(fam);
	document.formulario.fam.value = fam;
	//alert(subfam);
	document.formulario.subfam.value = subfam;

	document.formulario.submit();
}

function resetear()
{
	document.formulario.reset();
}


function pviiObjbg(obj, new_color) { //v2.1 by Project VII
	obj.style.backgroundColor=new_color;
}

function setfocus() {
document.formulario.username.focus();
return;
}

//function changevaluecheck()
//{
//	//alert(document.formulario.disponible.value);
//	//if (document.formulario.disponible.value == "si" || document.formulario.disponible.value == "on")
//	//document.formulario.disponible.value = "no";
//	//else
//	//document.formulario.disponible.value = "si";
//	//alert(document.formulario.disponible.value);
//	alert(document.formulario.disponible.checked);
//	if (document.formulario.disponible.checked == true) document.formulario.disponible.value = "si";
//	if (document.formulario.disponible.checked == false) document.formulario.disponible.value = "no";
//	alert(document.formulario.disponible.value);
//
//}


//function abrir_ventana_foto(urlfoto,ref)
//{	
//	var img = new Image();
//	img.src = urlfoto;
//	ventana=window.open('','','width='+img.width+',height='+img.height+',scrollbars=no,resizable=0,toolbar=0');
//	ventana.document.write ('<html>\n');
//	ventana.document.write (' <head>\n');
//	ventana.document.write ('  <title>Inmueble Ref.: '+ref+'</title>\n');
	//ventana.document.write ('  <title>'Bercan'</title>\n');
//	ventana.document.write (' </head>\n');
//	ventana.document.write (' <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">\n');
//	ventana.document.write ('  <img src="' + urlfoto + '" height='+img.height+' width='+img.width+'>\n');
//	ventana.document.write (' </body>\n');
//	ventana.document.write ('</html>\n');
//}

function mostrar(ref) {
	//alert(_img_grande.width);
	//alert(_img_grande.height);
	
	if (_img_grande.width<20) 
	_img_grande.width = 300;
	if (_img_grande.height<20) 
	_img_grande.height = 400;
	
	//alert(_img_grande.width);
	//alert(_img_grande.height);
	var ops = "top=" + ((screen.height - _img_grande.height) / 2);
	ops += ",left=" + ((screen.width - _img_grande.width) / 2);
	ops += ",width=" + _img_grande.width + ",height=" + _img_grande.height;
	var contenido = "<html>\n<head>\n<title>Inmueble Ref.: "+ref+"</title>\n<body style='background-image: url(" + _img_grande.src + ")'></body></html>";
	var ventana = window.open("", "", ops);
	
	ventana.document.open();
	ventana.document.write(contenido);
	ventana.document.close();  //caricatos
}

function cargando(ref) {
	if (_img_grande.complete) mostrar(ref);
	else setTimeout("cargando()", 100);
}

function abrir(urlfoto,ref)	{
	_img_grande = new Image();
	_img_grande.src = urlfoto;
	cargando(ref);
}

function abrir_contactar()
{
var ventana;
ventana=window.open("/contacto.php","new","toolbars=no,scrollbars=no,directories=no,menubar=no,resizable=no,status=no,width=520,height=480,screenx=250,screeny=50,top=50,left=250");
}

function paginacion(pg,o)
{
	document.formulario._pagi_pg.value = pg;
	// ejemplo select
	//var miOpcion=document.formulario.vista.selectedIndex;
	//document.formulario.vista.options[miOpcion].value = v;
	document.formulario.op.value = o;
	document.formulario.submit();
	
}
function add_campo(num_camp)
{
	//alert(num_camp);
	num_camp++;
	document.formulario.num_camp.value = num_camp;
	//alert(document.formulario.num_camp.value);
	document.formulario.add.value = "1";
	document.formulario.submit();
}

function gen_cambiar_idioma(idioma)
{
	//alert(idioma);
	document.formulario.idioma.value = idioma;
	document.formulario.add.value = "1";
	document.formulario.submit();
}

function change(img)
{
	document.formulario.imagen.value = img;
	document.formulario.add.value = "1";
	document.formulario.cambio.value = "1";
	document.formulario.submit();
}

function change_corta(combo)
{
	document.formulario.plantilla_corta.value = combo;
	document.formulario.add.value = "1";
	document.formulario.submit();
}

function change_expand(combo)
{
	document.formulario.plantilla_expand.value = combo;
	document.formulario.add.value = "1";
	document.formulario.submit();
}

function contenedor(elem,variable)
{
	var visual = 'visual_'+elem;
	var encontrado = false;
	var i = 0;
	if(document.getElementById)
	{
		val = document.getElementById(visual).value.split('\n');
		while (i<val.length-1 && encontrado==false)
		{
			if (val[i]==variable) 
			{
				encontrado = true;
				val[i]='';
			}
			i++;
		}
	}
	
	if (encontrado) 
	{
		i=0;
		var result = '';
		var result2 = '';
		while (i<val.length-1)
		{
			if (val[i]!='') 
			{
				result = result + val[i] + '\n';
				result2 = result2 + val[i] + ',';
			}
			
			i++;
		}
		document.getElementById(visual).value = result;
		document.getElementById(elem).value = result2;
	}
	else 
	{
		document.getElementById(visual).value = document.getElementById(visual).value + variable + '\n';
		document.getElementById(elem).value = document.getElementById(elem).value + variable + ',';

	}
	
}


