/*DETECCIÓN DE NAVEGADOR*/
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}




function showDV(id){
	obj = document.getElementById(id)

	if(obj){
		if(obj.style.display ==""){
			obj.style.display ="none"
		}
		else{
			obj.style.display =""
		}
	}
}

function showDVGrupo(id,grupo){
	
	var arrDvs = document.getElementsByTagName("DIV");
	for(i=0;i<arrDvs.length;i++){
		if (arrDvs[i].id.substring(0,grupo.length)==grupo){
			arrDvs[i].style.display="none";
		}
	}
	obj = document.getElementById(id)
	if(obj){
		if(obj.style.display ==""){
			obj.style.display ="none";
		}
		else{
			obj.style.display ="";
		}
	}
}

function abreFoto(id){
	ancho = 450
	alto = 600
	l = (screen.width/2) - (ancho/2)
	t = (screen.height/2) - (alto/2)
	params = "resizable=no,scrollbars=no,width=" + ancho + ",height=" + alto + ",top=" + t + ",left=" + l;
	ventana = window.open("Foto.aspx?id="+id,null,params);
}

function abreFichero(file,BD){
	ancho = 450
	alto = 600
	l = (screen.width/2) - (ancho/2)
	t = (screen.height/2) - (alto/2)
	params = "resizable=yes,scrollbars=no,width=" + ancho + ",height=" + alto + ",top=" + t + ",left=" + l;
	ventana = window.open("FileDown.aspx?file="+file+"&BD="+BD,null,params);
}

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_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_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];}
}



function showPop(id) {
	  	contenedor = document.getElementById("contenedor_central");
		objPOP = document.getElementById("pop" + id);
				
		objPOP.style.left = contenedor.offsetLeft+295;
		objPOP.style.top = contenedor.offsetTop+285;
	  
		objPOP.style.display="";
		objPOP.style.visibility="visible";
		objPOP.style.position="absolute"; 
	}

function hidePop(id){
	setTimeout("hidePopDelay()",2000);
}

function hidePopDelay(){
	objPOP = document.getElementById('popMenu');
	objPOP.style.display="none";
	objPOP.style.visibility="hidden";
}

	
function abrirPOP(url, ancho, alto){
	l = (screen.width/2) - (ancho/2)
	t = (screen.height/2) - (alto/2)
	params = "resizable=NO,scrollbars=yes,width=" + ancho + ",height=" + alto + ",top=" + t + ",left=" + l;
	ventana = window.open(url,null,params);
	//window.open(url,null,"");
	}
	function abrirPOP2(url,ventananueva, ancho, alto){
	l = (screen.width/2) - (ancho/2)
	t = (screen.height/2) - (alto/2)
	params = "resizable=NO,scrollbars=yes,width=" + ancho + ",height=" + alto + ",top=" + t + ",left=" + l;
	ventana2=window.open(url,ventananueva,params);
	//window.open(url,null,"");
	}
var ventana,fichero;

var headHTML = '<html>\n<head>\n';
headHTML += '<title>Imagen</title>\n';
headHTML += '</head>\n<body>\n\n<div align="center">\n\n';

var footHTML = '</div>\n\n</body>\n</html>';
function popupWin(imgURL) {
	fichero = imgURL;

	tmpImg = new Image();
	tmpImg.src = fichero;

	x = ((screen.width / 2) - (100));
	y = ((screen.height / 2) - (25));
	
	var stbyHTML = '<p><b><i>Descargando Imagen... Por favor espere</i></b></p>';

	ventana = window.open('','ventana','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resize=no,copyhistory=no');
	ventana.resizeTo(200,50);
	ventana.moveTo(x,y);
	ventana.focus();

	ventana.document.write(headHTML);
	ventana.document.write(stbyHTML);
	ventana.document.write(footHTML);
	ventana.document.close();

	if (tmpImg.complete) { showImg(); }
	else { tmpImg.onload = showImg;	}
}


function showImg() {

	if (ventana.closed) { return false; }

	w = tmpImg.width + 40;
	h = tmpImg.height + 60;
	x = ((screen.width / 2) - (w / 2));
	y = ((screen.height / 2) - (h / 2));

	var imgHTML = '   <a href="#" onclick="window.close();return false">\n';
	imgHTML += '   <img border="0" src="'+fichero+'"></a>\n\n';

	ventana.resizeTo(w,h);
	ventana.moveTo(x,y);
	ventana.focus();

	ventana.document.write(headHTML);
	ventana.document.write(imgHTML);
	ventana.document.write(footHTML);
	ventana.document.close();
}

/*MENUS*/
var marca="";
function desp(sec)
{
	if(document.getElementById(sec)){

		if(document.getElementById("eurodomo"))document.getElementById("eurodomo").src = "/img/botones/eurodomo.gif";
		if(document.getElementById("inmobiliaria"))document.getElementById("inmobiliaria").src = "/img/botones/inmobiliaria.gif";
		if(document.getElementById("agroalimentaria"))document.getElementById("agroalimentaria").src = "/img/botones/agroalimentaria.gif";
		if(document.getElementById("desarrollos"))document.getElementById("desarrollos").src = "/img/botones/desarrollos.gif";
		if(document.getElementById("noticias"))document.getElementById("noticias").src = "/img/botones/noticias.gif";
		if(document.getElementById("donde"))document.getElementById("donde").src = "/img/botones/donde.gif";
	
		marca = sec;
		if(document.getElementById(sec))document.getElementById(sec).src = "/img/botones/" + sec + "-act.gif";
				
	}
}

function fotoAnt(){
	var fa = document.getElementById("fotoActual").value
	var tf = document.getElementById("totalFotos").value
	if (fa>1){
		document.getElementById("foto" + fa).style.display = "none"
		document.getElementById("pie" + fa).style.display = "none"
		fa --
		document.getElementById("foto" + fa).style.display = ""
		document.getElementById("pie" + fa).style.display = ""
	}
	document.getElementById("fotoActual").value = fa
}

function fotoSig(){
	var fa = document.getElementById("fotoActual").value
	var tf = document.getElementById("totalFotos").value
	if (fa<tf){
		document.getElementById("foto" + fa).style.display = "none"
		document.getElementById("pie" + fa).style.display = "none"
		fa ++
		
		document.getElementById("foto" + fa).style.display = ""
		document.getElementById("pie" + fa).style.display = ""
	}
	
	document.getElementById("fotoActual").value = fa
}




//codigo de julio

function abreFotoDesarrollo(id){
	ancho = 450
	alto = 600
	l = (screen.width/2) - (ancho/2)
	t = (screen.height/2) - (alto/2)
	
	params = "resizable=no,scrollbars=no,width=" + ancho + ",height=" + alto + ",top=" + t + ",left=" + l;
	ventana = window.open("FotoDesarrollo.aspx?id="+id,null,params);
}
function abreFotoDesarrollourl(url){
	ancho = 450
	alto = 600
	l = (screen.width/2) - (ancho/2)
	t = (screen.height/2) - (alto/2)
	
	params = "resizable=no,scrollbars=no,width=" + ancho + ",height=" + alto + ",top=" + t + ",left=" + l;
	ventana = window.open("FotoDesarrollo.aspx?url="+url,null,params);
}
function abreFichero(file,BD){
	ancho = 450
	alto = 600
	l = (screen.width/2) - (ancho/2)
	t = (screen.height/2) - (alto/2)
	params = "resizable=yes,scrollbars=no,width=" + ancho + ",height=" + alto + ",top=" + t + ",left=" + l;
	ventana = window.open("FileDown.aspx?file="+file+"&BD="+BD,null,params);
}
function abreFicheroDesarrollo(file,BD){
	ancho = 450
	alto = 600
	l = (screen.width/2) - (ancho/2)
	t = (screen.height/2) - (alto/2)
	params = "resizable=yes,scrollbars=no,width=" + ancho + ",height=" + alto + ",top=" + t + ",left=" + l;
	ventana = window.open("FileDown.aspx?file="+file+"&BD="+BD,null,params);
}
function abreVideo(file){
	ancho = 450
	alto = 600
	l = (screen.width/2) - (ancho/2)
	t = (screen.height/2) - (alto/2)
	params = "resizable=yes,scrollbars=no,width=" + ancho + ",height=" + alto + ",top=" + t + ",left=" + l;
	ventana = window.open("VisorVideo.aspx?file="+file,null,params);
}
function abreV(url){

ventana = window.open(url,'ventana','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resize=no,copyhistory=no,width=500,height=500');
}
function abreV(url,w,h){
ventana = window.open(url,'ventana','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resize=no,copyhistory=no,width='+ w + ',height=' + h);
}

