var imgs=DIR+"/artworks";

//OCULTAR LAYERS
function force_hide(ly) {
	veclayers=ly.split(",");
	for (var i=0;i<veclayers.length;i++) {
		ly=document.getElementById(veclayers[i]);
		if (ly!=null) {ly.style.visibility="hidden";}
	}
}
function force_unhide(ly) {
	veclayers=ly.split(",");
	for (var i=0;i<veclayers.length;i++) {
		ly=document.getElementById(veclayers[i]);
		if (ly!=null) {ly.style.visibility="visible";}
	}
}
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 hide_unhide(id_obj) {
	obj=getObj(id_obj);
	if(obj==null) {DHTMLALERT("objeto:"+id_obj+"no encontrado."); return;}
	if (obj.style.visibility=="visible") {
		obj.style.visibility="hidden";
	} else {
		obj.style.visibility="visible";
	}
}
function display_undisplay(id_obj) {
	obj=getObj(id_obj);
	if(obj==null) {DHTMLALERT("objeto:"+id_obj+"no encontrado."); return;}
	if (obj.style.display=="") {
		obj.style.display="none";
	} else {
		obj.style.display="";
	}
}


function str_replace(str,s,t)
{
	return str.split(s).join(t);
}

//CENTRAR LAYER
function showAndCenter(id, img) {

	var obj = id;
	if (typeof obj != "object") 
		obj=getObj(id);
	
	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.display="";
	obj.style.visibility="visible";
	obj.style.left=parseInt((document.body.scrollLeft+(X)))+"px";
	obj.style.top =parseInt((altobody +(Y) - 100))+"px";

//	alert("ancho_layer:"+ancho_layer+"\n"+"alto_layer:"+alto_layer+"\n"+"altobody:"+altobody+"\n"+"X:"+X+"\n"+"Y:"+Y+"\n");
}

//alert dinamico
function DHTMLALERT(msg)
{
	var dalert_msg = getObj("dhtml_alert_MSG");

	if (!dalert_msg)
		return;
	if (msg!="")
	{
		dalert_msg.innerHTML = msg;
		showAndCenter("dhtml_alert");
	} else {
		var dalert = getObj("dhtml_alert");
		dalert_msg.innerHTML = "";
		dalert.style.display="none";
		if (obj_focus!=null) {obj_focus.focus();obj_focus=null;}
	}

	activar_layer_transparente("ly_transparente");
}

function activar_layer_transparente(id_obj) {
	var obj=getObj(id_obj);
	if (obj.style.display=="") {
		obj.style.display="none";
	} else {
		obj.style.display="";
		obj.style.width=getPageSize()[0];
		obj.style.height=getPageSize()[1];
	}
}

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){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		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');
		form_recomendar.minombre.focus();
	}
}

function forzar_mostrar_layer_transparente() {
	obj=getObj("ly_transparente");
	obj.style.display="";
	obj.style.width=getPageSize()[0];
	obj.style.height=getPageSize()[1];
}

function forzar_ocultar_layer_transparente() {
	obj=getObj("ly_transparente");
	if (obj==null)
	{
		alert("layer_transparente no encontrado"); return;
	}
	obj.style.display="none";
}
