//Browsercheck
//var IE4 = (document.all && !document.getElementById) ? true : false;
//var NS4 = (document.layers) ? true : false;
//var IE5 = (document.all && document.getElementById) ? true : false;
//var N6 = (document.getElementById && !document.all) ? true : false;

var ie = 0;
var n = 0;
if (document.all)
  {
	ie=1 ;
	winW=document.body.offsetWidth;
  }
  else if (document.getElementById)
  {
	winW=document.body.scrollWidth;
	ie=1 ;
  }
  else if (document.layers)
  {
	n=1 ;
	winW=window.innerWidth ;
  }


/***************************************************************************
Variables to set.
****************************************************************************/
var retardo=6000;
var retStep = 0; 
var lp_apertura = 15; 	//¿Que capa fue la ultima seleccionada?
var UltimaCapa;			//Pixels between the menus
var pxBetween=5;		//How many menus do you have? (remember to copy and add divs in the body if you add menus)
var numberOfMenus=6;	//The width on the menus (set the width in the stylesheet as well)
	mtwidth = 0;
	mrwidth = new Array()
	mwidth = new Array()
		mwidth[0]=125;
		mwidth[1]=125;
		mwidth[2]=90;
		mwidth[3]=95;
		mwidth[4]=90;
		mwidth[5]=80;
		mwidth[6]=85;

//		mwidth[1]=100;
 
	for(i=0;i<=numberOfMenus;i++){
		mrwidth[i] = mtwidth;
		mtwidth = mtwidth + mwidth[i] + pxBetween;
	}
// mtwidth  	Suma Total Width de los menus	
tempx = (winW/2)-(mtwidth/2) ;		

var fromLeft=tempx;					//The first menus left position (depends number of Menus
var fromTop=10;						//The top position of the menus
var bgColor='#CECFCE';				//The bgColor of the bottom mouseover div  GRIS
var bgColorChangeTo='#ff0000';		//The bgColor to change to - ROJO
									//	'#6380BC'		 AZUL 
var imageHeight=20;				//The position the mouseover line div will stop at when going up! 

/***************************************************************************
You shouldn't have to change anything below this
****************************************************************************/
//Object constructor
function makeNewsMenu(obj,nest){ 
	if (n) {
		nest=(!nest) ? '':'document.'+nest+'.'	;
	} else if (ie) {
		var xz = new getObj(obj);
	}
// var x = new getObj(obj);
// x.obj = document.getElementById("  ") 
// x.style = document.getElementById("  ").style
	this.css=(n) ? eval(nest+'document.'+obj) : xz.style;
	this.scrollHeight=(n) ? this.css.document.height + 10 : xz.obj.offsetHeight;
	if (obj.substr(0,14)=='divTopMenuText' && this.scrollHeight<1 ) {
//		alert(this.scrollHeight); 
		this.scrollHeight = 10;
	}
	this.moveIt=b_moveIt;
	this.bgChange=b_bgChange;
	this.slideUp=b_slideUp; 
	this.slideDown=b_slideDown;
	this.clipTo=b_clipTo;
    this.obj = obj + "Object"; 	
	eval(this.obj + "=this")		
}
//Objects methods
function b_moveIt(x,y){
		this.x=x; 
		this.y=y; 
		this.css.left=this.x; 
		this.css.top=this.y;
		}
function b_bgChange(color){if(ie) this.css.backgroundColor=color; else this.css.bgColor=color}
function b_clipTo(t,r,b,l){
	if(n){this.css.clip.top=t; 				// para Netscape
		this.css.clip.right=r; 
		this.css.clip.bottom=b; 
		this.css.clip.left=l
	}else this.css.clip="rect("+t+","+r+","+b+","+l+")";		// para Iexplorer
}
function b_slideUp(ystop,moveby,speed,fn,wh){
	if(!this.slideactive){
		if(this.y>ystop){
			this.moveIt(this.x,this.y-moveby); 
			eval(wh)
			setTimeout(this.obj+".slideUp("+ystop+","+moveby+","+speed+",'"+fn+"','"+wh+"')",speed)
		}else{
			this.slideactive=false; 
			this.moveIt(0,ystop);
			eval(fn)
		}
	}
}
function b_slideDown(ystop,moveby,speed,fn,wh){
	if(!this.slideactive){				// slideactive solo toma el valor FALSE, no tiene utilidad
		if(this.y<ystop){
			this.moveIt(this.x,this.y+moveby); 
			eval(wh)
			setTimeout(this.obj+".slideDown("+ystop+","+moveby+","+speed+",'"+fn+"','"+wh+"')",speed)
		}else{
			this.slideactive=false; 
			this.moveIt(0,ystop);
			eval(fn)
		}
	}
}
//Initiating the page, making cross-browser objects
function newsMenuInit(){
	oTopMenu=new Array()
	for(i=0;i<=numberOfMenus;i++){
		oTopMenu[i]=new Array()
		oTopMenu[i][0]=new makeNewsMenu('divTopMenu'+i)
		oTopMenu[i][1]=new makeNewsMenu('divTopMenuBottom'+i,'divTopMenu'+i)
		oTopMenu[i][2]=new makeNewsMenu('divTopMenuText'+i,'divTopMenu'+i)
		oTopMenu[i][1].moveIt(0,imageHeight)
		oTopMenu[i][0].clipTo(0,mwidth[i],imageHeight+3,0)
		oTopMenu[i][0].moveIt(mrwidth[i]+fromLeft,fromTop)
		oTopMenu[i][0].css.visibility="visible"
		oTopMenu[i][0].css.width=mwidth[i]-3
		oTopMenu[i][1].css.width=mwidth[i]
		oTopMenu[i][2].css.width=mwidth[i]-13
	}
}
//Moves the menu
function topMenu(num){
	if(oTopMenu[num][1].y==imageHeight) 
		oTopMenu[num][1].slideDown(
			oTopMenu[num][2].scrollHeight+10,		// coordenada y
			lp_apertura,							// longitud de cada paso	
			retStep,								// retardo cada paso		
			'oTopMenu['+num+'][0].clipTo(0,mwidth['+num+'],oTopMenu['+num+'][1].y+3,0)',	// se ejecuta al final
			'oTopMenu['+num+'][0].clipTo(0,mwidth['+num+'],oTopMenu['+num+'][1].y+3,0)')	// se ejecuta en cada paso
}
 
function CerrarMenu(num)
{
	for(i=0;i<=numberOfMenus;i++){
		if(i!=num){	aw = CloseMenu(i); }
	}
}

function CloseMenu(num)
{
	if(oTopMenu[num][1].y==oTopMenu[num][2].scrollHeight+10) 
		oTopMenu[num][1].slideUp(
		 	imageHeight,
			10,
			retStep,
			'oTopMenu['+num+'][0].clipTo(0,mwidth['+num+'],oTopMenu['+num+'][1].y+3,0)',
			'oTopMenu['+num+'][0].clipTo(0,mwidth['+num+'],oTopMenu['+num+'][1].y+3,0)')
}
//Changes background onmouseover
function menuOver(num){
	oTopMenu[num][1].bgChange(bgColorChangeTo);
//	oTopMenu[num][1].css.z-index=10;	
	}
function menuOut(num){oTopMenu[num][1].bgChange(bgColor)}

//Calls the init function onload
onload = newsMenuInit;
//CerrarCapas();

//function CerrarCapas()
//{
//	window.setTimeout("CerrarCapas()",retardo);
//	CerrarMenu(UltimaCapa);
//
//	if (winW != document.body.offsetWidth)
//	{
//		winW=document.body.offsetWidth;
//		tempx = Math.max((winW/2)-97,396-97);
//		fromLeft=tempx;
//		newsMenuInit();
//	}
//}

function getObj(name)  {
if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function OmOver(num,obj) {
	UltimaCapa=num;
	topMenu(num);
	menuOver(num);
	CerrarMenu(num);
	if(ie)obj.blur();
	return false;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {
		if ((appName == "Netscape") && ((parseInt(appVersion) == 4) || (parseInt(appVersion) == 5))) {
		    document.MM_pgW = innerWidth;
			document.MM_pgH = innerHeight;
			onresize = MM_reloadPage; 
		}
		if (appName == "Microsoft Internet Explorer" || appName == "Opera" || appName == "Konqueror") {
			onresize = MM_reloadPage;
		}
  } else if (navigator.appName == "Netscape") {
		if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) { location.reload(); }
  } else if (navigator.appName == "Microsoft Internet Explorer" || navigator.appName == "Opera" || navigator.appName == "Konqueror") {
		location.reload();
  }
}

MM_reloadPage(true);

function flyer(obj) { 
	self.status='';
	obj.style.color ='#ffffff';
}