// JavaScript Document

function fixLength()	{
	if (document.getElementById('mainContent') && document.getElementById('sideContent'))	{
		var mc = document.getElementById('mainContent');
		var mch = mc.offsetHeight;
		var sc = document.getElementById('sideContent');
		var sch = sc.offsetHeight;
		var lc = document.getElementById('leftNav');
		if (!lc) { lc = document.getElementById('sideContent_Right'); }
		var lch = lc.offsetHeight;
		
		if( sch >= mch )	{
			mc.style.height = (sch + 10) + "px";
		} else {
			mc.style.height = mch + "px";
		}
		if ( parseInt(mc.style.height) < lch) { 
			sc.style.height = lch + "px"; 
			mc.style.height = lch + "px"; 
		}		
	} 
}

function checkHeaderHeight()	{
	var hAll = document.getElementById('meTall');
	var hAll_height = hAll.offsetHeight;
	var hLeft = document.getElementById('headL');
	var hLeft_height = hLeft.offsetHeight;
	var hRight = document.getElementById('headR');
	var hRight_height = hRight.offsetHeight + 35; //add 35 because of the top-margin
	
	if(hLeft_height <= hRight_height)	{
		hAll.style.height = (hRight_height) + "px";
		hLeft.style.height = (hRight_height) + "px";
	}
}


function checkPage(a)	{
	
/*	var coconut = document.getElementById(a);
	var whichOne = new Array('business_units','bookstore','conferences_events','membership','nrf_foundation','stores_magazine');
	var thisOne = new Array('finance','government_relations','human_resources','information_technology','loss_prevention','marketing','merchandising','online_multichannel_retail','supply_chain','store_operations','issues');
//	alert(a);
	
	for(var i=0; i <= whichOne.length; i++)	{
		if( a == whichOne[i] )	{	
			coconut.className = 'leftNav1_selected';
		}
	}
			
	for(var i=0; i <= thisOne.length; i++)	{
		if( a == thisOne[i] )	{
			coconut.className = 'leftNav2_selected';
		}
	}
*/
}



var lockBar=0;
var aOffset = new Array(150,150,150,150,150); 
var bOffset = new Array(164,195,224,283,45);

function mDsp(menuId) {
  var tmpWidth = 0; lockBar = menuId
  for (ii=2; ii<6;ii++) {
    if (menuId == ii) 
			{
		  document.getElementById("tpMnu"+ii).style.display = "block";
		  document.getElementById("tpMnu"+ii).style.left=aOffset[ii-1]+"px";
		  document.getElementById("tpMnu"+ii).style.top=bOffset[ii-1]+"px";
		  document.getElementById("mnSpn"+ii).style.backgroundColor = "#597e11";
		  document.getElementById("mnSpn"+ii).getElementsByTagName('a')[0].style.backgroundColor = "#597e11";
		  document.getElementById("mnSpn"+ii).getElementsByTagName('a')[0].style.backgroundImage = "none";		  
    		}else{document.getElementById("tpMnu"+ii).style.display = "none";
		  document.getElementById("mnSpn"+ii).getElementsByTagName('a')[0].style.backgroundColor = "#7eac25";
		  document.getElementById("mnSpn"+ii).getElementsByTagName('a')[0].style.backgroundImage = "url(http://www.nrf.com/themes/nrf/images/left_navigation/leftNav02.gif)";	
			}
  }
}
function mOff(menuId) 
	{
	lockBar=0;
	setTimeout("mHide("+menuId+")",0);
	document.getElementById("mnSpn"+menuId).getElementsByTagName('a')[0].style.backgroundColor = "#7eac25";
	document.getElementById("mnSpn"+menuId).getElementsByTagName('a')[0].style.backgroundImage = "url(http://www.nrf.com/themes/nrf/images/left_navigation/leftNav02.gif)";	
	}
function mHide(menuId) {if (menuId != lockBar) {document.getElementById("tpMnu"+menuId).style.display = "none";document.getElementById("mnSpn"+menuId).style.backgroundImage = "none";}}


// Function to get the file name from the url

function returnDocument() {
    var file_name = document.location.href;
    var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
    return file_name.substring(file_name.lastIndexOf("/")+1, end);
}

function returnParameterFromDocumentString() {
    var file_name = document.location.href;
    var end = file_name.length;
    return file_name.substring(file_name.lastIndexOf("?")+1, end);	
}

function surveyCodeString(pageNameParam) {
	switch (pageNameParam) {
		case 'name=Dashboard&id=20&pmenu_id=5': result = 'retailers_dash'; break;
		case 'name=Dashboard&id=21&pmenu_id=8': result = 'solutionproviders_dash'; break;
		case 'name=Dashboard&id=44&pmenu_id=11': result = 'industryinfo_dash'; break;
		case 'name=Dashboard&id=22&pmenu_id=11': result = 'industryinfo_dash'; break;
		case 'name=Dashboard&id=2&pmenu_id=14': result = 'governmentrelations_dash'; break;
		case 'name=Dashboard&id=23&pmenu_id=17': result = 'press_dash'; break;
		case 'name=Pages&sp_id=391': result = '4-5-4-calendar'; break;		
		case 'name=News&op=viewlive&sp_id=790': result = 'Halloween 2009'; break;	
		
		default: result = 'unknown';
	}
	if (result != 'unknown') {
		var itzcode = '<div id="GH" style="position:absolute; z-index:999; left:0; top:0"><script language=javascript src=\'http://invite.insightexpress.com/InviteServer/2/Invite.aspx?surveyID=158626&source=' + result + '\'></script></div>';
		return itzcode;
	}else{
		return '';
	}

		
}
