var imgs=DIR+"/artworks";

var fading_intervalo=10;
var fading_incremento=2;
var timer_fading=0;
var fading_offset=0;
var fading_working=false;
var fading_curropc=0;

//FADING
function fading(ly_name,inter,incr) {

	if (fading_working) {return;}

	fading_intervalo=inter;
	fading_incremento=incr;

    ly=document.getElementById(ly_name);
    if (ly==null) {alert("atencion es null");clearInterval(timer_fading);return;}

		fading_curr=ly.filters.alpha.opacity;

    if(fading_curr == 0)
    {
    	fading_offset=fading_incremento;
    	ly.style.display="";
    }
    else
    {fading_offset=0-fading_incremento;}

		timer_fading = setInterval("dofading('"+ly_name+"')", fading_intervalo);
		fading_working=true;
}
function dofading(ly_name) {

	ly=document.getElementById(ly_name);
	fading_curr+=fading_offset;
	if (fading_curr<0) {
		fading_curr=0;
	} else if (fading_curr>100) {
			fading_curr=100;
	}
	ly.filters.alpha.opacity=fading_curr;
	if (fading_curr==0 || fading_curr==100) {
		clearInterval(timer_fading);fading_working=false;
		if (fading_curr==0) {ly.style.display="none";}
	}
}

//CAMBIAR COLOR TR
function mOvr(src,clrOver) {
	if(clrOver=='') {clrOver = '#B9D7EA'};
	defaultColor = src.bgColor;
	src.bgColor = clrOver;
}
function mOut(src) {
	src.bgColor = defaultColor;
}

// CAMBIO DE BACKROUND
function change_background(obj,img) {obj.background=img;}

//BOOKMARK
function SetBookMark() {
var title=url_tobookmark;
if( window.sidebar && window.sidebar.addPanel ) {
	window.sidebar.addPanel(title,location.href,'');
} else {
	window.external.AddFavorite(location.href,title);
}
}

//AGREGAR CLASE
function MO2(ly,clases) {
	//alert(ly+"-->"+clases+"->"+ly.innerHTML);
	if (!ly) ly=getObj(ly);
	if (ly==null) {return}

	class_def = "class";
	if (BrowserDetect.browser=="Explorer")
		class_def = "className";

	var cn = setget_attr(ly,class_def);
	var oc = setget_attr(ly,'oldclass');
	if (clases==undefined)
	{
		if (oc!=undefined)
			setget_attr(ly,class_def,oc);
		return;
	}

	setget_attr(ly,'oldclass', cn);
	setget_attr(ly,class_def,cn+" "+clases);
//	ly.className=cn+" "+clases;
}

//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);
}
//MODIFICAR ALTO ELEMENTO
function resize_obj(id_obj, px) {
	if (!obj.style.height) return;
	obj=getObj(id_obj);
	aux_h=parseInt(str_replace(obj.style.height,"px",""));
	aux_h+=px;
	if (aux_h<=0) return;
	obj.style.height=aux_h;
}


//TAB MANAGE
function set_tab(id) {
	if (id==6) {id=1;}
	for (var i=1;i<6;i++) {
		o=getObj("tabmenu_"+i);
		if (o==null) {break;}

		tab=getObj("tab_"+i);
		if (id==i) {
			//set
			//tab.style.display="";
		} else {
			//reset
			//tab.style.display="none";
		}
	}
}
function replace(str, s, r)
{
	return str.split(s).join(r);
}

function deselect_menues()
{
	var o=null;
	for (var i=1;i<6;i++) {
		o=getObj("imgmenu"+i);
		o.src=replace(o.src,"on.",".");
	}
}
function select_menu(o)
{
	deselect_menues();
	o.src=replace(o.src,".","on.");
}

function swap_menues(l)
{
	if (l!="menuup")
		return;

	o = getObj(l);
	o2 = getObj("menudown");

	o.innerHTML = replace(o.innerHTML,"menuup","menudown");
	o2.innerHTML = replace(o2.innerHTML,"menudown","menuup");
	aux = o2.innerHTML;
	o2.innerHTML=o.innerHTML;
	o.innerHTML=aux;
	return;
}
//TAB MANAGE

//CENTRAR LAYER
function showAndCenter(id) {
	if (typeof id=="string") {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.documentElement && !document.documentElement.scrollTop) {
		var altobody=document.documentElement.scrollTop;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		var altobody=document.documentElement.scrollTop;
	} else if (document.body && document.body.scrollTop) {
		var altobody=document.body.scrollTop;
	}

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

	obj.style.zIndex=1001;
	obj.style.display="";
	obj.style.visibility="visible";
	obj.style.left=(document.body.scrollLeft+(X))+"px";
	obj.style.top =(altobody +(Y) - 100)+"px";
}

//LIMPIAR LAYER
function clean_layer(ly) {
if (ly==null) {return;}
ly=document.getElementById(ly);
if (ly==null) {return;}
ly.innerHTML="";
}
function change_imgsource(elemento,imgsource){
	var o=getObj(elemento);
	o.src = imgsource;
}

//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";
	}
	
	activar_layer_transparente("ly_transparente");
}

function activar_layer_transparente(id_obj) {
	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];
	}
}
// funciones alto pagina y activar layer trans

// funciones alto pagina y activar layer trans
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("ly_recomendar");

	if (obj.style.display=="") {
		obj.style.display="none";
		ly_transparente.style.display="none";
	} else {
		obj.style.display="";
		ly_transparente.style.display="";
		showAndCenter('ly_recomendar');
		form_recomendar.miemail.focus();
	}
}
