//var ultimo = 'prueba'
var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)
var finalOption = ''; //Option selected in the menu.
var finalOptionI = ''; //Option selected in the internal menu.
var ccollect=new Array();
var onloadComplete=false; //Set to prevent multiple do_onloads.

/*if (document.getElementById){
document.write('<style type="text/css">')//COLOR="#B0A9A7"
document.write('.switchcontent{cursor:hand; display:none; width:120px;background-color:#951836}')
document.write('</style>')
}*/

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate


//Menús con javascript para ocultar el destino de la página a abrir
var strFrameDestino = "_self";

//FUNCTIONS
function calcHeight(frameID,noscroll)
{
  //find the height of the internal page
  var the_height=document.getElementById(frameID).contentWindow.document.body.scrollHeight;
  //change the height of the iframe
  document.getElementById(frameID).style.height= the_height + 20;
  document.getElementById(frameID).style.visibility = 'visible';
  if (noscroll!=true)scroll(0,0);
}
//-->

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
/*var inc1=0
while (ccollect[inc1]){
//if (ccollect[inc].id!=omit)
ccollect[inc1].style.display="none"
//document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
inc1++
}*/
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){

	if (typeof ccollect!="undefined"){
		if (collapseprevious=="yes")
			contractcontent(cid)
		if(document.getElementById(cid).style.display!="block"){
			//document.getElementById(ultimo).style.display="none";
			document.getElementById(cid).style.display="block";			
			//ultimo=cid;
		}else{
			document.getElementById(cid).style.display="none";
		}
	}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
if (onloadComplete!=true){
    getElementbyClass("switchcontent")
    if (enablepersist=="on" && typeof ccollect!="undefined")
    revivecontent()
}
onloadComplete=true;
}

function selectedMenu( idMenuSelected){
		changeAllSelectedI();
		if(finalOption != idMenuSelected){
			changeAllSelected();
			parent.document.getElementById(idMenuSelected).className='grupovisitado';
			finalOption = idMenuSelected;
			if(idMenuSelected == 'mProducts'){
				expandcontent('sc1');
			}else if(idMenuSelected == 'mAbout'){
				expandcontent('sc2');
			}else if(idMenuSelected == 'mCares'){	
				expandcontent('sc3');
			}else if(idMenuSelected == 'mHealthy'){	
				expandcontent('sc4');
			}else{
				contractcontent("omitnothing");
			}
		}
}
function changeAllSelected(){
		parent.document.getElementById('mProducts').className='grupo';
		parent.document.getElementById('mRecipes').className='grupo';
		parent.document.getElementById('mBenefits').className='grupo';
		parent.document.getElementById('mNew').className='grupo';
		parent.document.getElementById('mPromotions').className='grupo';			
		parent.document.getElementById('mAbout').className='grupo';
		parent.document.getElementById('mCares').className='grupo';
		parent.document.getElementById('mHealthy').className='grupo';
		parent.document.getElementById('mParents').className='grupo';
		parent.document.getElementById('mCareers').className='grupo';
}
function loadLink(){
	//parent.Dialog.info("Loading...", {windowParameters: {className: "loading",width:60, height:60}, showProgress: true});
	return true;
}

function selectedMenuI( idMenuSelectedI){
		if(finalOptionI != idMenuSelectedI){
			changeAllSelectedI();
			parent.document.getElementById(idMenuSelectedI).className='backgi';
			finalOptionI = idMenuSelectedI;
		}else{
			parent.document.getElementById(idMenuSelectedI).className='backgi';
			finalOptionI = idMenuSelectedI;
		}
}
function changeAllSelectedI(){
		parent.document.getElementById('mEfaq').className='backg';
		parent.document.getElementById('mTDC').className='backg';
		parent.document.getElementById('mPR').className='backg';
		parent.document.getElementById('mMR').className='backg';
		parent.document.getElementById('mTDI').className='backg';
		//kparent.document.getElementById('mDYC').className='backg';				
		//parent.document.getElementById('mGA').className='backg';
		parent.document.getElementById('mYYH').className='backg';
		//parent.document.getElementById('mYD').className='backg';
		parent.document.getElementById('mHG').className='backg';
}
function randomRecipes(recipeID){
	//loadLink();

	switch (recipeID){
		case 1:
			document.getElementById('RSSItemContent').src = "../Application/Recipes/mstRecipes.aspx?strRedirect=9";
		break;
		case 2:
			document.getElementById('RSSItemContent').src = "../Application/Recipes/mstRecipes.aspx?strRedirect=10";
		break;
		case 3:
			document.getElementById('RSSItemContent').src = "../Application/Recipes/mstRecipes.aspx?strRedirect=11";
		break;
		case 4:
			document.getElementById('RSSItemContent').src = "../Application/Recipes/mstRecipes.aspx?strRedirect=12";
		break;
		case 5:
			document.getElementById('RSSItemContent').src = "../Application/Recipes/mstRecipes.aspx?strRedirect=13";
		break;
		case 6:
			document.getElementById('RSSItemContent').src = "../Application/Recipes/mstRecipes.aspx?strRedirect=14";
		break;
	}

}
/* DEPRECIATED
function vinculo(index){
	//parent.Dialog.info("Loading...", {windowParameters: {className: "loading",width:60, height:60}, showProgress: true});
	alert ('Vinny'+index);
	switch(index) {
	case 0:
		window.open ("../Pages/rt_home.htm",strFrameDestino);
		break;
	case 1:
		return ("../Pages/rt_ourproducts.html");
		break;
	case 2:
		return ("../Application/FAQ/FAQSearch.aspx");
		break;
	case 3:
		return ("../Application/Recipes/RecipeSearch.aspx");
		break;
	case 4:
		return ("../Pages/rt_benefits.html");
		break;
	case 5:
		return ("../Pages/rt_whatsnew.html");
		break;
	case 6:
		return ("../Pages/rt_promotions.html");
		break;
	case 7:
		return ("../Pages/rt_smile.html");
		break;
	case 8:
		return ("../Pages/rt_aboutdannon.html");
		break;
	case 9:
		return ("../Pages/rt_aboutdannon_dncompany.html");
		break;		
	case 10:
		return ("../Pages/press_releases.aspx");
		break;
	case 11:
		return ("../Pages/rt_aboutdannon_resources.html");
		break;
	case 12:
		return ("../Pages/rt_dannoncares.html");
		break;
	case 13:
		return ("../Pages/rt_dannoncares_dnInstitute.htm");
		break;
	case 14:
		return ("../Pages/rt_dannoncares_your_comunity.htm");
		break;
	case 15:
		return ("../Pages/rt_dannoncares_dnapplication.html");
		break;
	case 16:
		return ("../Pages/rt_healty.html");
		break;
	case 17:
		return ("../Pages/rt_healthy_benefits_yogurt.htm");
		break;
	case 18:
		return ("../Pages/rt_healthy_yogurt_diabetes.htm");
		break;
	case 19:
		return ("../Pages/rt_healthy_ongo.htm");
		break;
	case 20:
		return ("../Pages/rt_forparents.html");
		break;
	case 21:
		return ("../Pages/rt_forkids.html");
		break;
	case 26:
	    window.open ("../templates/dannon.html?idMenu=55", strFrameDestino);
		break;	  
	case 55:	  
	    return ("../Application/Registration/Registration.aspx");
        break; 
//TOP
	case 27:
	    return ("../Pages/rt_privacy.htm");
	    break;
	case 28:
	    return ("../Pages/rt_storelocation.htm");
	    break;
	case 29:
	    return ("../Pages/rt_contact.htm");
	    break;
	case 30:
	    return ("../Pages/rt_sitemap.html");
	    break;
	case 54:
	    return ("../Pages/rt_ourproducts_allnatural.html");
	    break;
	
	//Menu top desde la pagina del home
	//PRIVACY
	case 22:
	    window.open ("../templates/dannon.html?idMenu=27", strFrameDestino);
	    break;
	//STORE LOCATOR
	case 23:
	    window.open ("../templates/dannon.html?idMenu=28", strFrameDestino);
	    break;
	//CONTACT DANNON
	case 24:
	    window.open ("../templates/dannon.html?idMenu=29", strFrameDestino);
	    break;
	//SITE MAP
	case 25:
	    window.open ("../templates/dannon.html?idMenu=30", strFrameDestino);
	    break;
		
		//MENU DEL HOME, DEBE SER DISTINTO AL MENU NORMAL POR QUE ES EN PAGINA DISTINTA
	case 31:
		window.open ("../templates/dannon.html?idMenu=0", strFrameDestino);
		break;
	case 32:
		window.open ("../templates/dannon.html?idMenu=1", strFrameDestino);
		break;
	case 33:
		window.open ("../templates/dannon.html?idMenu=2", strFrameDestino);
		break;
	case 34:
		window.open ("../templates/dannon.html?idMenu=3", strFrameDestino);
		break;
	case 35:
		window.open ("../templates/dannon.html?idMenu=4", strFrameDestino);
		break;
	case 36:
		window.open ("../templates/dannon.html?idMenu=5", strFrameDestino);
		break;
	case 37:
		window.open ("../templates/dannon.html?idMenu=6", strFrameDestino);
		break;
	case 38:
		window.open ("../templates/dannon.html?idMenu=7", strFrameDestino);
		break;
	case 39:
		window.open ("../templates/dannon.html?idMenu=8", strFrameDestino);
		break;
	case 40:
		window.open ("../templates/dannon.html?idMenu=9", strFrameDestino);
		break;		
	case 41:
		window.open ("../templates/dannon.html?idMenu=10", strFrameDestino);
		break;
	case 42:
		window.open ("../templates/dannon.html?idMenu=11", strFrameDestino);
		break;
	case 43:
		window.open ("../templates/dannon.html?idMenu=12", strFrameDestino);
		break;
	case 44:
		window.open ("../templates/dannon.html?idMenu=13", strFrameDestino);
		break;
	case 45:
		window.open ("../templates/dannon.html?idMenu=14", strFrameDestino);
		break;
	case 46:
		window.open ("../templates/dannon.html?idMenu=15", strFrameDestino);
		break;
	case 47:
		window.open ("../templates/dannon.html?idMenu=16", strFrameDestino);
		break;
	case 48:
		window.open ("../templates/dannon.html?idMenu=17", strFrameDestino);
		break;
	case 49:
		window.open ("../templates/dannon.html?idMenu=18", strFrameDestino);
		break;
	case 50:
		window.open ("../templates/dannon.html?idMenu=19", strFrameDestino);
		break;
	case 51:
		window.open ("../templates/dannon.html?idMenu=20", strFrameDestino);
		break;
	case 52:
		window.open ("../templates/dannon.html?idMenu=21", strFrameDestino);
		break;
	case 53:
		window.open ("../templates/dannon.html?idMenu=54", strFrameDestino);
		break;
	}
}



	function onClick_OurProducts(index){
		switch(index) {
		case 0:
			window.open("../templates/dannon.html?idMenu=3", strFrameDestino);
			break;
		}
	}
	
	function onClick_AboutDannon(index){
		switch(index) {
		case 0:
			window.open("http://www.google.com", strFrameDestino);
			break;
		case 1:
			window.open("http://www.google.com", strFrameDestino);
			break;
		case 2:
			window.open("http://www.google.com", strFrameDestino);
			break;
	
		}
	}
	
	function onClick_DannonCares(index){
		switch(index) {
		case 0:
			window.open("Administracion/Maestros/Estatus/insertar.aspx", strFrameDestino);
			break;
		case 1:
			window.open("Administracion/Maestros/Estatus/listar.aspx", strFrameDestino);
			break;
		case 2:
			window.open("Administracion/Maestros/Estatus/listar.aspx", strFrameDestino);
			break;
		}
	}
	
	function onClick_HealthyLifestyles(index){
		switch(index) {
		case 0:
			window.open("administracion/redencion/buscar.aspx", strFrameDestino);
			break;
		case 1:
			window.open("administracion/redencion/buscar.aspx", strFrameDestino);
			break;
		case 2:
			window.open("administracion/redencion/buscar.aspx", strFrameDestino);
			break;
		}
	}

function querystring(name)   // returns a named value from the querystring
{
   var tmp = ( location.search.substring(1) );
   var i   = tmp.toUpperCase().indexOf(name.toUpperCase()+"=");
   if ( i >= 0 )
   {
     tmp = tmp.substring( name.length+i+1 );
      i = tmp.indexOf("&");
      tmp = tmp.substring( 0, (i>=0) ? i : tmp.length );	  
	  return vinculo(parseInt(tmp));
   }
     return("");
   }
*/