/* Allows drop menu for IE 6 */

// CALLED FROM include_primary_nav.html

sfHover = function() {
	if($.browser.msie){
		var sfEls = document.getElementById("primary_nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				$('#middle').css("z-index","-1");
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				$('#middle').css("z-index","1");
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}// Drop menus inside menu headers

/***********************
	INCLUDE FUNCTIONS 
***********************/

function writePrimaryNav(){
	$.ajax({ 
		type: "GET",
		url: "includes/include_primary_nav.html",///
		success: function(html){
			$("#top").append(html);
			
		}
	});
}

function writeSecondaryNav(){
	loadAndWriteContent("include_secondary_nav.html","bottom");
}

function writeHeader(country){ ///
    ///
    var url;//alert(country);
    if(country)
	   url='includes/include_utility_nav.php?country='+country;
	else
	   url="includes/include_utility_nav.php";
	   ///
	$.ajax({
		type: "GET",
		url: ""+url,///
		success: function(html){
			$("#top").append(html);
			///writePrimaryNav();	
		}
	});
}

function writeFooter(){
	
	$.ajax({
		type: "GET",
		url: "includes/include_secondary_nav.html", ///
		success: function(html){
			$("#bottom").append(html);
			completeFooter();	
		}
	});
	
}

function completeFooter(){
	
	$.ajax({
		type: "GET",
		url: "includes/include_footer.php", ///
		success: function(html){
			$("#bottom").append(html);	
		}
	});
	
}

function writeMenuOptionsNav(subcat_id, item_id){
	$.ajax({
		type: "GET",
		url: "includes/subright.php", ///
		success: function(html){
			
			$("#right").append(html);
			toggleMenuOptionsNav(subcat_id, item_id);
			
		}
	});
}

function toggleMenuOptionsNav(subcat_id, item_id){
	$('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 13});
			
	$('#menu_options > ul').each(function(i){
		$(this).hide();
	});
	
	if(subcat_id){
		///$('#cat_'+subcat_id).attr("className","expanded");
		$('#cat_'+subcat_id).addClass("expanded");
		$('#subcat_'+subcat_id).show();
	}
	
	if(item_id){
		$('#subcat_' + subcat_id + '_item_' + item_id + " > a").attr("className","on");
	}
}

///
function collapse_expand(id)
{   
	if ( document.getElementById(id).className=="displayBlock")
	{
	    document.getElementById(id).className="displayNone";
		document.getElementById(id+'-a').className="notselected";
		//document.getElementById(id+'-img').src="images/title-close.gif";
	}
	else if ( document.getElementById(id).className=="displayNone")
	{
	    document.getElementById(id).className ="displayBlock";
		document.getElementById(id+'-a').className="selected";
		//document.getElementById(id+'-img').src="images/title-open.gif";
	}
}
function displayNutrition(id,nb)
{ 
	//document.getElementById("no").className="displayNone";
	//document.getElementById('a'+id).className="displayBlock";
	var divs = $('#nut-'+nb).find('div');
	divs.each(function(){ $(this).addClass('displayNone'); } );
	
	$('#nut-'+nb).find('#cal-'+id).removeClass('displayNone');
	$('#nut-'+nb).find('#fat-'+id).removeClass('displayNone');
	$('#nut-'+nb).find('#fib-'+id).removeClass('displayNone');
	$('#nut-'+nb).find('#car-'+id).removeClass('displayNone');
	
	$('#nut-'+nb).find('#cal-'+id).addClass('displayBlock');
	$('#nut-'+nb).find('#fat-'+id).addClass('displayBlock');
	$('#nut-'+nb).find('#fib-'+id).addClass('displayBlock');
	$('#nut-'+nb).find('#car-'+id).addClass('displayBlock');
	
	$('#image-'+nb).find('img').addClass('displayNone');
	$('#image-'+nb).find('#im-'+id).removeClass('displayNone');
	$('#image-'+nb).find('#im-'+id).addClass('displayBlock');
	//
	///document.getElementById('a'+id).className="displayBlock";
}

function Hover(id)
{
	document.getElementById('a-title'+id).className='title-div-hover';
	document.getElementById('im-topleft'+id).className='title-topleft-on';
	document.getElementById('im-topright'+id).className='title-topright-on';
	document.getElementById('im-bottomleft'+id).className='title-bottomleft-on';
	document.getElementById('im-bottomright'+id).className='title-bottomright-on';
	document.getElementById('im-leftright'+id).className='title-leftright-on';
	document.getElementById('im-leftrightS'+id).className='title-leftright-on';
//	document.getElementById('im-topbottom'+id).className='title-topbottom-on';
//	document.getElementById('im-topbottomS'+id).className='title-topbottom-on';
}
function Out(id)
{
	document.getElementById('a-title'+id).className='title-div';
	document.getElementById('im-topleft'+id).className='title-topleft';
	document.getElementById('im-topright'+id).className='title-topright';
	document.getElementById('im-bottomleft'+id).className='title-bottomleft';
	document.getElementById('im-bottomright'+id).className='title-bottomright';
	document.getElementById('im-leftright'+id).className='title-leftright';
	document.getElementById('im-leftrightS'+id).className='title-leftright';
//	document.getElementById('im-topbottom'+id).className='title-topbottom';
//	document.getElementById('im-topbottomS'+id).className='title-topbottom';
}


function toselect(){
	var e = document.getElementById("country"); 
    var strUser = e.options[e.selectedIndex].value;
	if(strUser==0)
	  return false;
	else
	  document.frm_country_select.submit();  
	}
	
function selectCountry(){
  alert('Please select a country from the countries drop down on the top of the page'); 
  document.getElementById('country').focus();
  }	
