//ancho maximo de fotos
var ancMaxFot = 640;

//array con IDs de subrubros que se muestran en el pie
var arrIdSubs = new Array('CL52','CL53','CL62','CL70','CL59','CL60','todos');

//array con las posiciones del puntero para cada subrubro
var arrLeftSubs = new Array('57px','200px','330px','450px','580px','705px','830px');

function chgSubRubro(id){
	var canSubs = arrIdSubs.length;
	var puntero = document.getElementById('puntero');

	for(var i=0;i<canSubs;i++){
		if(arrIdSubs[i]==id){
			document.getElementById('sub_'+arrIdSubs[i]).className = "listado-subcategorias on";
			document.getElementById('lnk_'+arrIdSubs[i]).className = "selected";
			puntero.style.left = arrLeftSubs[i];
		}else{
			document.getElementById('sub_'+arrIdSubs[i]).className = "listado-subcategorias off";
			document.getElementById('lnk_'+arrIdSubs[i]).className = "";
		}
	}



}

function getSubsSel(sub){
	var dSub = document.getElementById('sub');
	dSub.innerHTML = "Cargando ...";
	xajax_getSubsSel(sub);
}

/************foot's funcs**************/
var div, inter, posT, altMax = 430, ancMax = 480, eje="y",sum=8, vel=1, opcion;
function submitear(){
	var itsok = true;
	var ids = new Array();
	var datos = new Array();
	ids[0] = "nombre";
	ids[1] = "telefono";
	ids[2] = "direccion";
	ids[3] = "email";
	ids[4] = "mensaje";
	ids[5] = "destino";
	for(i=0;i<ids.length;i++){
		if(document.getElementById(ids[i]).value==""){
			itsok = false;
		}
		datos[ids[i]] = document.getElementById(ids[i]).value;
	}
	if(itsok){
		div.innerHTML ="<div class=\"loading\">Enviando...<br><img src=\"http://www.abc.com.py/general/img/cargando_naranja.gif\" /></div>";
		xajax_send_form(opcion, datos);
	}else{
		document.getElementById('cont_error').style.display = "block";
	}
}

function opendiv(id,opt,altFin,ancFin){

	if(altFin>0){
		altMax = altFin;
	}else{
		altMax = 430;
	}
	if(ancFin>0){
		ancMax = ancFin;
	}else{
		altMax = 480;
	}

	div = document.getElementById(id);
	if(div.style.display!="block"){
		altVent = document.body.offsetHeight;
		ancVent = document.body.offsetWidth;
		scrTop = window.document.documentElement.scrollTop;

		if(window.innerHeight){
			altNav = window.innerHeight;
		}else{
			altNav = document.documentElement.clientHeight;
		}

		if(scrTop<1){
			scrTop = window.document.body.scrollTop;
		}

		resAlt = altNav/2;
		posY = resAlt+scrTop;
		posX = ancVent/2;

		posT = posY - scrTop - (altMax/2);

		div.style.left = posX+"px";
		div.style.top = posY+"px";
		div.style.display = "block";
		inter = setInterval("redim()",vel);
	}else if(opt!=opcion){
		altVent = document.body.offsetHeight;
		scrTop = window.document.documentElement.scrollTop;

		if(window.innerHeight){
			altNav = window.innerHeight;
		}else{
			altNav = document.documentElement.clientHeight;
		}

		if(scrTop<1){
			scrTop = window.document.body.scrollTop;
		}

		resAlt = altNav/2;
		posY = resAlt+scrTop;
		posY -= altMax/2;

		div.style.top = posY+"px";
		div.style.height = altMax+"px";
		div.style.width = ancMax+"px";

		div.innerHTML ="<div class=\"loading\">Cargando...<br><img src=\"http://www.abc.com.py/general/img/cargando_naranja.gif\" /></div>";
		xajax_show_contacto(opt);
	}
	opcion = opt;
}

function redim(){
	//para que haga primero y, y despues x
	switch(eje){
		case "x":
		aux = div.offsetWidth;
		aux += sum;

		aux2 = div.offsetLeft;
		aux2 -= sum-2;

		div.style.left = aux2+"px";
		div.style.width = aux+"px";

		if(aux>=ancMax){
			eje="y";
			clearInterval(inter);
			div.innerHTML ="<div class=\"loading\">Cargando...<br><img src=\"http://www.abc.com.py/general/img/cargando_naranja.gif\" /></div>";
			xajax_show_contacto(opcion);
		}
		break;
		case "y":
		aux = div.offsetHeight;
		aux += sum;

		aux2 = div.offsetTop;
		aux2 -= sum-2;


		div.style.height = aux+"px";
		div.style.top = aux2+"px";
		if(aux>=altMax){
			eje="x";
		}
		break;
	}
}

function closediv(id){
	var obj = document.getElementById(id);
	obj.style.height = "2px";
	obj.style.width = "2px";
	obj.innerHTML = "";
	obj.style.display = "none";
}

function pop(file, ancho, alto, tool, resize, scroll){
	var w = screen.availWidth, h = screen.availHeight;
	var leftPos = (w-ancho)/2, topPos = (h-alto)/2;
	pop_window = window.open(file ,'files','width='+ancho+',height='+alto+',menubar=0'
	+',toolbar='+tool+',status=0,scrollbars='+scroll+',resizable='+resize+',top=' + topPos + ',left=' + leftPos);
}

function showGal(op, ancObt, altObt){
	var overlay = document.getElementById('overlay');
	var info = document.getElementById('info');

	var yScroll, altura;

	if (window.innerHeight && window.scrollMaxY) {
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		yScroll = document.body.scrollHeight;
	} else {
		yScroll = document.body.offsetHeight;
	}

	var windowHeight;
	if (self.innerHeight) {
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowHeight = document.body.clientHeight;
	}

	if(yScroll < windowHeight){
		altura = windowHeight;
	} else {
		altura = yScroll;
	}

	var ancVentana = 0, altVentana = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		ancVentana = window.innerWidth;
		altVentana = window.innerHeight;
	}else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		ancVentana = document.documentElement.clientWidth;
		altVentana = document.documentElement.clientHeight;
	}else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		ancVentana= document.body.clientWidth;
		altVentana = document.body.clientHeight;
	}


	ancVentana = ancVentana/2;
	altVentana = altVentana/2;

	info.style.display="block";


	var ancInfo = ancMaxFot;
	var altInfo = altObt;

	ancInfo = ancInfo/2;
	altInfo = altInfo/2;

	var topInfo = altVentana - altInfo;
	var leftInfo = ancVentana - ancInfo;

	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		scrOfY = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		scrOfY = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		scrOfY = document.documentElement.scrollTop;
	}

	topInfo = topInfo + scrOfY;

	if(topInfo<0){
		topInfo = 10;
	}
	info.style.width = ancMaxFot+"px";

	info.style.top = topInfo + "px";
	info.style.left = leftInfo + "px";

	overlay.style.display="block";
	overlay.style.height=altura+"px";

}

function showImg(srcImg, descImg){
	var imgGal = document.getElementById('imgGal');
	var descGal = document.getElementById('descGal');

	imgGal.src = "/fotos/"+srcImg;
	descGal.innerHTML = "<b>Descripci&oacute;n:</b><br>" + unescape(descImg);
}

function close_overlay(){
	var overlay = document.getElementById('overlay');
	var info = document.getElementById('info');

	overlay.style.display="none";
	info.style.display="none";
	//info.innerHTML="";

	imgCont = 1;
}