/* -------------------------------------------
Web: http://www.fundacionsansebastian.com
Copyright: (C) 2009 www.seguids.com
Developer: Carlos Mario Segui Tellez
*/

/* Peter-Paul Koch - Alex Tingle. */
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }	
/* Peter-Paul Koch - Alex Tingle. */

/* SSet Position  - (c) 2009 www.seguids.com */
function SetPosition(h,v,x,y,obj,objRX,objRY) {
	object = document.getElementById(obj);
	if (h == "center") {
	object.style.left=-document.getElementById(obj).width/2+document.body.clientWidth/2+x+"px";
	if (y != 'none') {
	object.style.top = y+"px";
	}
	} 
	if (v == "center") {
	object.style.top=-document.getElementById(obj).height/2+document.body.clientHeight/2+y+"px";
	if (x != 'none') {
	object.style.left = x+"px";
	}
	}
	if (h == "left") { 	object.style.left= x+"px"; } 
	if (h == "right") { object.style.right= x+"px"; } 
	if (v == "top") { object.style.top= y+"px"; } 
	if (v == "bottom") { object.style.bottom= y+"px"; } 
	if (h == "relative") {
	relativeX = findPosX(document.getElementById(objRX));
	document.getElementById(obj).style.left=relativeX+x+"px";
	}
	if (v == "relative") {
	relativeY = findPosY(document.getElementById(objRY));
	document.getElementById(obj).style.top=relativeY+y+"px";
	}
}
/* SSet Position  - (c) 2009 www.seguids.com */

function SetHover(obj) {
	obj.style.background = "url(images/btnhover.jpg)";
}

function SetOut(obj) {
	obj.style.background = "url(images/btnbg.jpg)";
	obj.style.backgroundRepeat="no-repeat";
}

function cgbg(obj) {
	if (obj.id == "up") {
obj.style.background = "url(images/btnuphover.png)";
document.getElementById("cont").value = "up"
	} else {
obj.style.background = "url(images/btndownhover.png)";
document.getElementById("cont").value = "down"
	}
obj.style.backgroundRepeat="no-repeat";
obj.style.backgroundPosition="center";
}

function qbg(obj) {
if (obj.id == "up") {
obj.style.background = "url(images/btnup.png)";
document.getElementById("cont").value = "waiting";
	} else {
obj.style.background = "url(images/btndown.png)";
document.getElementById("cont").value = "waiting";
}
obj.style.backgroundRepeat="no-repeat";
obj.style.backgroundPosition="center";
}

/* MenUSSlideIt Script - (c) 2009 www.seguids.com */
function Slide(obj,type,requester,start,end,factor,speed,id) {
this.obj = obj
this.type = type
this.requester = requester
this.start = start
this.end = end
this.factor = factor
this.speed = speed
this.id = "MenuId["+id+"]";
this.Slide = doSlide
	if (type == "down") { /* Si el efecto es Slidedown */
	document.getElementById(obj).style.height = start+"px" 
	}
}

function doSlide() {
this.objHeight = document.getElementById(this.obj).style.height;
this.objHeight = this.objHeight.replace(/px/i,""); 
	if (this.type == "down") {
		document.getElementById(this.obj).style.display = "block"
		if (this.objHeight < this.end) { 
		document.getElementById(this.obj).style.height = parseInt(this.objHeight)+parseInt(this.factor)+"px"
		this.timer = setTimeout(this.id+'.Slide()', this.speed); 
		}
	} 
	else { 
		if (this.objHeight > this.end && hover != this.obj) { 
		this.objHeightCheck = parseInt(this.objHeight)-parseInt(this.factor)
		if (this.objHeightCheck <= 0) {
		document.getElementById(this.obj).style.height = "0px" } else {
		document.getElementById(this.obj).style.height = parseInt(this.objHeight)-parseInt(this.factor)+"px"
		Selected(this.requester,false);
		this.timer = setTimeout(this.id+'.Slide()', this.speed); }
		} else { document.getElementById(this.obj).style.display = "none" }
		if (hover == this.obj) {
		document.getElementById(this.requester).onmouseover()
		}
	}
}

MenuId = new Array() 
hover = 0

function newSlide(obj,type,requester,start,end,factor,speed,id) { /* id: numero otorgado al objeto */
if (MenuId[id] == undefined || MenuId[id] == "undefined") { /* undefined es válido para IE sólo entre comillas */
MenuId[id] = new Slide(obj,type,requester,start,end,factor,speed,id);
MenuId[id].Slide();
} else { /* actualizacion de datos */
MenuId[id].obj = obj
MenuId[id].type = type
MenuId[id].requester = requester
MenuId[id].start = start
MenuId[id].end = end
MenuId[id].factor = factor
MenuId[id].speed = speed
	if (type == "down") { /* ejecucion de la funcion directa */
	Selected(MenuId[id].requester,true);
	MenuId[id].Slide(); 
	} else { /* ejecucion de la funcion con retardo */
	this.timer = setTimeout(MenuId[id].id+'.Slide()', 100); 
	}
}
}

function Selected(obj,value) {
	if (value == true) {
	document.getElementById(obj).style.fontWeight="bold";
} else {
	document.getElementById(obj).style.fontWeight="normal";
}
}
/* MenUSSlideIt Script - (c) 2009 www.seguids.com */

function SetPositionAll() {
SetPosition('center','none',0,0,'newsbar');
SetPosition('center','none',50,20,'divlayer');
SetPosition('center','none',45,33,'Men');
SetPosition('relative','relative',120,860,'copy','divlayer','divlayer');
SetPosition('relative','relative',670,105,'time','divlayer','divlayer');
SetPosition('relative','relative',15,51,'conocenos','Menu2','Menu2');
SetPosition('relative','relative',20,51,'historia','Menu3','Menu3');
SetPosition('relative','relative',12,51,'donaciones','Menu4','Menu4');
SetPosition('relative','relative',15,51,'albumes','Menu5','Menu5');
}

/* ContSSlideIt - (c) 2009 www.seguids.com */
function Slidown() {
clearTimeout(int);
hobj = document.getElementById(fram)
heightobj = hobj.height
heightobj = heightobj.replace(/px/i,"")
if (heightobj < 770) {
hobj.height = parseInt(heightobj)+parseInt(70)+"px"
int2 = setTimeout('Slidown()', 25);
}
}

function Sliup() {
hobj = document.getElementById(fram)
heightobj = hobj.height
heightobj = heightobj.replace(/px/i,"")
if (heightobj > 0) {
hobj.height = parseInt(heightobj)-70+"px"
int = setTimeout('Sliup()', 25);
} else {
document.getElementById(fram).src = file;
document.getElementById(fram).height = "0px"
int = setTimeout('Slidown()', 2000);
}
}

function view(fil,fra) {
var nc = Math.random()*5
if (fil.toLowerCase().indexOf('?')!=-1) { 
file = fil+"&nc="+nc
} else {
file = fil+"?nc="+nc
}
fram = fra
Sliup();
}

/* ContSSlideIt - (c) 2009 www.seguids.com */