/*
 * 5/2: Eric -> replace mouseover/mouseover mouseleave/mouseout
 */
var array = new String(window.location);
var LocationComplete=array.split("/");
var Len=LocationComplete.length-1;
var locationPath="";
var oldleftMenuHeight=0;
var antoldleftMenuHeight=0;
for(i=0; i<=Len-1; i++){
	locationPath+=LocationComplete[i]+"/";
}

if (window.ie6)
{
	locationPath = base_url + "front/img/menu_"+lang_s+"_ie6/";
}
else
{
	locationPath = base_url + "front/img/menu_"+lang_s+"/";
}

//alert(lang_s);

var openCompany=0;
var openCompromiso=0;
var openInfovida=0;
var leftMenuHeight=0;
if(window.ie){
	var companyHeight=163;
	var compromisoHeight=121;
	var infovidaHeight=121;
}
else
{
	var companyHeight=149;
	var compromisoHeight=107;
	var infovidaHeight=107;
}
////Agregado por marco 15/9
var secciones = new Array();
secciones["compania"]=0;
secciones["compromiso"]=0;
secciones["productos"]=0;
secciones["informacion"]=0;
secciones["proveedores"]=0;
////Agregado por marco 15/9
////Agregado por marco 16/9
var section = new Array("compania","compromiso","productos","informacion","proveedores");
for(i=0;i<=LocationComplete.length-1;i++){
	for(j=0;j<=section.length-1;j++){
		if(LocationComplete[i]==section[j]){
			secciones[LocationComplete[i]]=1;
			Len=i;
		}

	}
}
////Agregado por marco 16/9
imgCompany=new Array('compania_delegaciones','compania_filosofia','compania_intramed','compania_prodfarma','compania_rrhh','compania_trayectoria');
imgCompromiso=new Array('compromiso_campanias','compromiso_cultura','compromiso_medicosres_10','compromiso_medicosres');
imgInfovida=new Array('info_calendario','info_consumidor','info_dietas','info_enfermedades');
window.addEvent('domready',function (){

	/* FIX BOTONERA CACHE */
	var imgSecciones = new Array('company', 'compromiso', 'productos', 'infovida', 'proveedores');
	imgSecciones.each(function(item, index){
		if($(item)){
			var imgsrc = $(item).src.split('/').pop();
			$(item).src = locationPath + imgsrc;
		}
	});
	/* FIX BOTONERA CACHE */
	
	alto = window.getHeight();
	ancho = window.getWidth();
	if($('contenido_central')){
		if(window.ie6){$('contenido_central').style.marginLeft="15px";}else{$('contenido_central').style.marginLeft="30px";}
	}
	SetPropierties();

	var company = new Fx.Styles($('submenuCompany'), {duration:300, wait:false});
	var compromiso = new Fx.Styles($('submenuCompromiso'), {duration:300, wait:false});
	var infovida = new Fx.Styles($('submenuInfovida'), {duration:300, wait:false});
	if($('content') && $('content'))
	{
	// $('leftMenu').style.top=(offsetTop+33)+"px";
	 leftMenuHeight=$('content').offsetHeight;
	 oldleftMenuHeight=$('content').offsetHeight;
	 antoldleftMenuHeight=$('content').offsetHeight;
	}

	$('company').addEvent('mouseover', function(e){
		$('company').src=locationPath+'compania_on.gif';
		if(openCompany==1)
		{
		 company.start({'height': companyHeight+'px'});
		}
	});

	$('company').addEvent('mouseout', function(e){
		if(LocationComplete[Len]!="compania" && secciones["compania"]==0){
			$('company').src=locationPath+'compania_off.gif';
		}
	});

	if(LocationComplete[Len]=="compania" && secciones["compania"]==1){
		$('company').src=locationPath+'compania_on.gif';
	}

	$('company').addEvent('mousedown', function(e){
		company.start({
				'height':  companyHeight+'px'
			});
		leftMenuGrowing(companyHeight,1,300);
		lefMenuSelected=2;
		openCompany=1;
	});

	$('company').addEvent('mouseout', function(e){
		company.start({
				'height': '0px'
			});
		leftMenuGrowing(companyHeight,0,300);
		lefMenuSelected=0;
		openCompany=0;
	});

	$('submenuCompany').addEvent('mouseover', function(e){
		company.start({
				'height': companyHeight+'px'
			});
		leftMenuGrowing(companyHeight,1,300);
		lefMenuSelected=2;
		openCompany=1;
	});

	$('submenuCompany').addEvent('mouseout', function(e){
		company.start({
				'height': '0px'
			});
	leftMenuGrowing(companyHeight,0,300);
		lefMenuSelected=0;
		openCompany=0;
	});



	$('compromiso').addEvent('mouseover', function(e){

		$('compromiso').src=locationPath+'compromiso_on.gif';
		if(openCompromiso==1)
		{
		 compromiso.start({'height': compromisoHeight+'px'});
		}
	});
	$('compromiso').addEvent('mouseout', function(e){
		////Agregado por marco 15/9
		if(LocationComplete[Len]!="compromiso" && secciones["compromiso"]==0){
			$('compromiso').src=locationPath+'compromiso_off.gif';
		}

		////Agregado por marco 15/9
	});

	////Agregado por marco 15/9
	if(LocationComplete[Len]=="compromiso" && secciones[LocationComplete[Len]]==1){
		$('compromiso').src=locationPath+'compromiso_on.gif';
	}
	////Agregado por marco 15/9
	$('compromiso').addEvent('mousedown', function(e){
		compromiso.start({
				'height': compromisoHeight+'px'
			});
		leftMenuGrowing(compromisoHeight,1,300);
		lefMenuSelected=2;
		openCompromiso=1;
	});

	$('compromiso').addEvent('mouseout', function(e){
		compromiso.start({
				'height': '0px'
			});
		leftMenuGrowing(compromisoHeight,0,300);
		lefMenuSelected=0;
		openCompromiso=0;
	});


	$('submenuCompromiso').addEvent('mouseover', function(e){
		compromiso.start({
				'height': compromisoHeight+'px'
			});
		leftMenuGrowing(compromisoHeight,1,300);
		lefMenuSelected=2;
		openCompromiso=1;
	});

	$('submenuCompromiso').addEvent('mouseout', function(e){
		compromiso.start({
				'height': '0px'
			});
		leftMenuGrowing(compromisoHeight,0,300);
		lefMenuSelected=0;
		openCompromiso=0;
	});



	$('productos').addEvent('mouseover', function(e){
		$('productos').src=locationPath+'producto_on.gif';
	});


	$('productos').addEvent('mouseout', function(e){
		if(LocationComplete[Len]!="productos" && secciones["productos"]==0){
			$('productos').src=locationPath+'producto_off.gif';
		}

	});

	if(LocationComplete[Len]=="productos" && secciones[LocationComplete[Len]]==1){
		$('productos').src=locationPath+'producto_on.gif';
	}



	$('infovida').addEvent('mouseover', function(e){
		$('infovida').src=locationPath+'info_on.gif';
		if(openInfovida==1)
		{
		 infovida.start({'height': infovidaHeight+'px'});
		}
	});
	$('infovida').addEvent('mouseout', function(e){
		if(LocationComplete[Len]!="informacion" && secciones["informacion"]==0){
			$('infovida').src=locationPath+'info_off.gif';
		}
	});

	if(LocationComplete[Len]=="informacion" && secciones[LocationComplete[Len]]==1){
		$('infovida').src=locationPath+'info_on.gif';
	}



	$('infovida').addEvent('mousedown', function(e){
		infovida.start({
				'height': infovidaHeight+'px'
			});
		leftMenuGrowing(infovidaHeight,1,300);
		lefMenuSelected=2;
		openInfovida=1;
	});

	$('infovida').addEvent('mouseout', function(e){
		infovida.start({
				'height': '0px'
			});
		leftMenuGrowing(infovidaHeight,0,300);
		lefMenuSelected=0;
		openInfovida=0;
	});


	$('submenuInfovida').addEvent('mouseover', function(e){
		infovida.start({
				'height': infovidaHeight+'px'
			});
		leftMenuGrowing(infovidaHeight,1,300);
		lefMenuSelected=1;
		openInfovida=1;
	});

	$('submenuInfovida').addEvent('mouseout', function(e){
		infovida.start({
				'height': '0px'
			});
		leftMenuGrowing(infovidaHeight,0,300);
		lefMenuSelected=2;
		openInfovida=0;
	});




	$('proveedores').addEvent('mouseover', function(e){
		$('proveedores').src=locationPath+'proveedores_on.gif';
	});
	$('proveedores').addEvent('mouseout', function(e){
		$('proveedores').src=locationPath+'proveedores_off.gif';
	});






	$('imgCompany0').addEvent('mouseover', function(e){$('imgCompany0').src=locationPath+imgCompany[0]+'_on.gif';});
	$('imgCompany0').addEvent('mouseout', function(e){$('imgCompany0').src=locationPath+imgCompany[0]+'_off.gif';});

	$('imgCompany1').addEvent('mouseover', function(e){$('imgCompany1').src=locationPath+imgCompany[1]+'_on.gif';});
	$('imgCompany1').addEvent('mouseout', function(e){$('imgCompany1').src=locationPath+imgCompany[1]+'_off.gif';});

	$('imgCompany2').addEvent('mouseover', function(e){$('imgCompany2').src=locationPath+imgCompany[2]+'_on.gif';});
	$('imgCompany2').addEvent('mouseout', function(e){$('imgCompany2').src=locationPath+imgCompany[2]+'_off.gif';});

	$('imgCompany3').addEvent('mouseover', function(e){$('imgCompany3').src=locationPath+imgCompany[3]+'_on.gif';});
	$('imgCompany3').addEvent('mouseout', function(e){$('imgCompany3').src=locationPath+imgCompany[3]+'_off.gif';});

	$('imgCompany4').addEvent('mouseover', function(e){$('imgCompany4').src=locationPath+imgCompany[4]+'_on.gif';});
	$('imgCompany4').addEvent('mouseout', function(e){$('imgCompany4').src=locationPath+imgCompany[4]+'_off.gif';});

	$('imgCompany5').addEvent('mouseover', function(e){$('imgCompany5').src=locationPath+imgCompany[5]+'_on.gif';});
	$('imgCompany5').addEvent('mouseout', function(e){$('imgCompany5').src=locationPath+imgCompany[5]+'_off.gif';});



	$('imgCompromiso0').addEvent('mouseover', function(e){$('imgCompromiso0').src=locationPath+imgCompromiso[0]+'_on.gif';});
	$('imgCompromiso0').addEvent('mouseout', function(e){$('imgCompromiso0').src=locationPath+imgCompromiso[0]+'_off.gif';});

	$('imgCompromiso1').addEvent('mouseover', function(e){$('imgCompromiso1').src=locationPath+imgCompromiso[1]+'_on.gif';});
	$('imgCompromiso1').addEvent('mouseout', function(e){$('imgCompromiso1').src=locationPath+imgCompromiso[1]+'_off.gif';});

	$('imgCompromiso2').addEvent('mouseover', function(e){$('imgCompromiso2').src=locationPath+imgCompromiso[2]+'_on.gif';});
	$('imgCompromiso2').addEvent('mouseout', function(e){$('imgCompromiso2').src=locationPath+imgCompromiso[2]+'_off.gif';});

	$('imgCompromiso3').addEvent('mouseover', function(e){$('imgCompromiso3').src=locationPath+imgCompromiso[3]+'_on.gif';});
	$('imgCompromiso3').addEvent('mouseout', function(e){$('imgCompromiso3').src=locationPath+imgCompromiso[3]+'_off.gif';});



	$('imgInfovida0').addEvent('mouseover', function(e){$('imgInfovida0').src=locationPath+imgInfovida[0]+'_on.gif';});
	$('imgInfovida0').addEvent('mouseout', function(e){$('imgInfovida0').src=locationPath+imgInfovida[0]+'_off.gif';});

	$('imgInfovida1').addEvent('mouseover', function(e){$('imgInfovida1').src=locationPath+imgInfovida[1]+'_on.gif';});
	$('imgInfovida1').addEvent('mouseout', function(e){$('imgInfovida1').src=locationPath+imgInfovida[1]+'_off.gif';});

	$('imgInfovida2').addEvent('mouseover', function(e){$('imgInfovida2').src=locationPath+imgInfovida[2]+'_on.gif';});
	$('imgInfovida2').addEvent('mouseout', function(e){$('imgInfovida2').src=locationPath+imgInfovida[2]+'_off.gif';});

	$('imgInfovida3').addEvent('mouseover', function(e){$('imgInfovida3').src=locationPath+imgInfovida[3]+'_on.gif';});
	$('imgInfovida3').addEvent('mouseout', function(e){$('imgInfovida3').src=locationPath+imgInfovida[3]+'_off.gif';});

	/*if($('contentMenu')){
		$('contentMenu').style.height="33px";
	}*/
});
window.addEvent('resize',function(){

	alto = window.getHeight();
	ancho = window.getWidth();

	SetPropierties();
});
function SetPropierties()
{
	if($('main')){
 		margen= (ancho - $('main').offsetWidth)/2;
//		$('main').style.marginLeft=margen+"px";
	}

	if(window.ie6){
			if($('contentInfo')){
				$('contentInfo').style.overflow='hidden';
			}
		}
}
function leftMenuGrowing(Height,state,Duration)
{
/* var leftMenu = new Fx.Styles($('leftMenu'), {duration:Duration, wait:false});
 if(state==1){
	 aux=leftMenuHeight+Height;
	 if(Duration==400)
	 {
		aux=aux-187;
	 }
	 leftMenu.start({ 'height':  aux+'px','marginTop': '0px','top': '0px;'});
	 oldleftMenuHeight=leftMenuHeight;
	 leftMenuHeight=aux;
	 //console.log("antoldleftMenuHeight: "+antoldleftMenuHeight+" oldleftMenuHeight: "+oldleftMenuHeight+" leftMenuHeight: "+leftMenuHeight);
 }
 else
 {
	if(oldleftMenuHeight==leftMenuHeight){oldleftMenuHeight=antoldleftMenuHeight}
	leftMenu.start({'height':  oldleftMenuHeight+'px','marginTop': '0px','top': '0px;'});
	leftMenuHeight=oldleftMenuHeight;
	//console.log("antoldleftMenuHeight: "+antoldleftMenuHeight+" oldleftMenuHeight: "+oldleftMenuHeight+" leftMenuHeight: "+leftMenuHeight);
 }*/
}
function print_href(link_,target,name){
	if(link_.trim() != ""){
		document.write('<a href="'+link_+'" target="'+target+'">'+name+'</a>');
	}else{
		if(name.trim() != ""){
			document.write("<span style='color:#848484'>"+name+"</span>");
		}
	}
}
