var imgs=DIR+"/artworks";

function force_display(ly) {
	veclayers=ly.split(",");
	for (var i=0;i<veclayers.length;i++) {
		ly=document.getElementById(veclayers[i]);
		if (ly!=null) {ly.style.display="";}
	}
}
function force_undisplay(ly) {
	veclayers=ly.split(",");
	for (var i=0;i<veclayers.length;i++) {
		ly=document.getElementById(veclayers[i]);
		if (ly!=null) {ly.style.display="none";}
	}
}
function display_undisplay(id_obj_varios) {
	objetos=id_obj_varios.split(",");
	for (var i=0;i<objetos.length;i++) {
		obj=getObj(objetos[i]);
		if(obj==null) {DHTMLALERT("objeto:"+objetos[i]+"no encontrado."); return;}
		if (obj.style.display=="") {
			obj.style.display="none";
		} else {
			obj.style.display="";
		}
	}
}
function aplicar_quitar_clase(obj,clase,forzar_quitar)
{
 if (typeof(obj) != "object")
 		objeto=getObj(obj);
	else
		objeto = obj;

 if (objeto!=null && objeto.className!=undefined)
 {
	 if ( objeto.className.indexOf(clase)!=-1 || forzar_quitar!=undefined )
	 {
   	objeto.className = objeto.className.split(clase).join("");
   }
   else
   {
   	if ( objeto.className != "" )
   		objeto.className += " ";
   	objeto.className += clase;
	 }
 }
}

function str_replace(str,s,t)
{
return str.split(s).join(t);
}
//MODIFICAR ALTO ELEMENTO
function resize_obj(id_obj, px) {
	obj=getObj(id_obj);
	if (obj.style.height==undefined) return;
	aux_h=parseInt(str_replace(obj.style.height,"px",""));
	if (isNaN(px))
		px=parseInt(str_replace(px.toString(),"px",""));
	aux_h+=px;
	if (aux_h<=0) return;
	obj.style.height=aux_h+"px";
}

//CENTRAR LAYER
function showAndCenter(id, img) {

	var obj = id;
	if (typeof obj != "object")
		obj=getObj(id);
	
	if (obj==null) return;
	
	obj.style.display="";
	obj.style.visibility="visible";

	ancho_layer=obj.style.width;
	ancho_layer=ancho_layer.replace("px","");
	alto_layer=obj.style.height;
	alto_layer=alto_layer.replace("px","");

	if (document.body && document.body.scrollTop)
	{
		var altobody=document.body.scrollTop;
	} else if (document.documentElement && !document.documentElement.scrollTop) {
		var altobody=document.documentElement.scrollTop;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		var altobody=document.documentElement.scrollTop;
	}

	var X = ((document.body.scrollWidth-ancho_layer)/2);
	var Y = ((screen.availHeight-alto_layer)/2);

	obj.style.zIndex=99999999;
	obj.style.left=parseInt((document.body.scrollLeft+(X)))+"px";
	obj.style.top =parseInt((altobody +(Y) - 100))+"px";
}

function DHTMLALERT(msg)
{

	var dalert_msg = getObj("dhtml_alert_MSG");

	if (msg==undefined) msg="";
	
	if (!dalert_msg) return;

	if (msg!="") {

		dalert_msg.innerHTML = msg;
		showAndCenter("dhtml_alert");
		activar_layer_transparente("ly_transparente",cerrar_dhtmlalert);

	} else {

		var dalert = getObj("dhtml_alert");
		dalert_msg.innerHTML = "";
		dalert.style.display="none";
		activar_layer_transparente("ly_transparente",cerrar_dhtmlalert);

		try {
			obj_focus.focus();
			obj_focus=null;
		} catch(err) {}

	}

}

function cerrar_dhtmlalert() {
	DHTMLALERT();
}

function activar_layer_transparente(id_obj,addfunction) {

	var obj=getObj(id_obj);
	if (obj==null) return;

	
	if (obj.style.display=="") {
		obj.style.display="none";
		if (typeof addfunction == "function") {
			
			if (obj.removeEventListener) {
				obj.removeEventListener("click", addfunction, false);
			} if (obj.detachEvent) {
				obj.detachEvent("onclick", addfunction);
			} else {
				obj["click"] = null;
			}
			
		}

	} else {
		
		if (typeof addfunction == "function") {
			
			if (obj.addEventListener) { 
				obj.addEventListener("click", addfunction, false);
			} else if (obj.attachEvent) {
				obj.attachEvent("onclick", addfunction);
			} else {
				obj["onclick"] = addfunction;
			}

		}
		obj.style.display="";
		obj.style.width="100%";
		obj.style.height=getPageSize()[1]+'px';

	}
}

function getPageSize(){
	var xScroll, yScroll;

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

	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

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

	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

function recomendar_web() {
	var ly_transparente=getObj("ly_transparente");
	var obj=getObj("recomendar");

	if (obj.style.display=="") {
		obj.style.display="none";
		ly_transparente.style.display="none";
	} else {
		obj.style.display="";
		ly_transparente.style.display="";
		showAndCenter('recomendar');
		getObj("form_recomendar").minombre.focus();
	}
}
