var channelArr = new Array('aboutus','contactus','register','booking','villahotels','services','destinations','buyingaproperty','home', 'membersarea');
var longChannelArr = new Array('ABOUT US','CONTACT US','REGISTER','HOW TO BOOK','VILLA RENTAL','SERVICES','DESTINATIONS','BUYING A PROPERTY', 'HOME', 'REGISTERED USERS');
var searchTab = 0;
var noSearch = 0;

//Channel URL
var channelURLArr = new Array('ghp/aboutus.html','ghp/contact_us.html','properties/html/customer/registration','ghp/howtobook.html','properties/html/customer/index/nimeng','#','countries/destinations.html','ghp/acquisition/ghp_acquisition.html','home.html','properties/html/customer/client/index/0');


//HB
var fdcchannel = displayedChannel;

count=0;
for (i=0;i<channelArr.length;i++) {
	if(channelArr[i] == fdcchannel) {
		break;
	}
	count++;
}

if (count==channelArr.length) fdcchannel = "home";

var displayedChannel = fdcchannel;

/*
if (typeof fdcsponsor == "undefined") {
	var sponsorIndex = this.location.href.indexOf('fdcsponsor=');
	if (sponsorIndex == -1) fdcsponsor = '';
	else {
		fdcsponsor =  this.location.href.substr(sponsorIndex+8);
		var sponsorEnd = fdcsponsor.indexOf('&');
		if (sponsorEnd>-1) fdcsponsor = fdcsponsor.substr(0,sponsorEnd);
	}
}

*/


var homeArr = new Array();
var aboutusArr = new Array();
var contactusArr = new Array();
var registerArr = new Array();
var bookingArr = new Array();
var villahotelsArr = new Array();
var destinationsArr = new Array();
var buyingapropertyArr = new Array();
var servicesArr = new Array();
var membersareaArr = new Array();
var hTimer;
var vTimer;
var thisSection;
var htimer = 0;
var lastSection;
var thisAdDiv;
var vSection;


aboutusArr[0] = new Array("Company Philosophy","ghp/company_philosophy.html");
aboutusArr[1] = new Array("Company People","ghp/company_people.html");
aboutusArr[2] = new Array("Media","ghp/media.html");
aboutusArr[3] = new Array("Privacy Policy","ghp/privacy_policy.html");

//villahotelsArr[0] = new Array("Search","properties/html/customer/");

aboutus0Arr = new Array();
aboutus1Arr = new Array();
aboutus2Arr = new Array();
aboutus3Arr = new Array();
//aboutus0Arr[0]=new Array ("About us 1", "#");
//aboutus0Arr[1]=new Array ("About us 2", "#");


//bookingArr[0] = new Array("Booking a Villa","#");
//bookingArr[1] = new Array("Terms & Conditions","ghp/terms_conditions.html");
//booking0Arr = new Array();
//booking1Arr = new Array();


servicesArr[0] = new Array("Services & Amenities","ghp/service_amenities.html");
servicesArr[1] = new Array("Concierge Services","ghp/concierge.html");
servicesArr[2] = new Array("Events Management","countries/events_management.html");
servicesArr[3] = new Array("Fine Wines","ghp/fine_wines.html");
services0Arr = new Array();
services1Arr = new Array();
services2Arr = new Array();
services3Arr = new Array();


destinationsArr[0] = new Array("France","countries/france_hp.html");
destinationsArr[1] = new Array("Italy","countries/italy_hp.html");
destinationsArr[2] = new Array("Morocco","countries/morocco_hp.html");
destinationsArr[3] = new Array("LuxurySki","countries/skiworld_hp.html");
destinationsArr[4] = new Array("CityScapes","countries/cityscapes_hp.html");
destinationsArr[5] = new Array("Mexico","countries/mexico_hp.html");

destinations0Arr = new Array();
destinations1Arr = new Array();
destinations2Arr = new Array();
destinations3Arr = new Array();
destinations4Arr = new Array();
destinations5Arr = new Array();
destinations0Arr[0]=new Array ("Introduction", "countries/france_intro.html");
destinations0Arr[1]=new Array ("Area Guide", "areaguides/france/area_menu.html");
destinations0Arr[2]=new Array ("Cooking Courses", "countries/france_cooking.html");
destinations0Arr[3]=new Array ("Markets", "countries/france_markets.html");





destinations1Arr[0]=new Array ("Introduction", "countries/italy_intro.html");
destinations1Arr[1]=new Array ("Area Guide", "areaguides/italy/area_menu.html");
destinations1Arr[2]=new Array ("Italian Cuisine", "countries/italy_cuisine.html");
destinations1Arr[3]=new Array ("Cooking Courses", "countries/italy_cooking.html");

destinations2Arr[0]=new Array ("Introduction", "countries/morocco_intro.html");
destinations2Arr[1]=new Array ("Area Guide", "areaguides/morocco/area_menu.html");
destinations2Arr[2]=new Array ("Excursions & Safaris", "countries/morocco_excursions.html");
destinations2Arr[3]=new Array ("Wellness", "countries/morocco_spa.html");





buyingapropertyArr[0] = new Array("How To Get Started","ghp/acquisition/gettingstarted.html");
buyingapropertyArr[1] = new Array("Useful Information","#");
buyingaproperty0Arr = new Array();
buyingaproperty1Arr = new Array();
buyingaproperty1Arr[0] = new Array("What we do","ghp/acquisition/whatwedo.html");
buyingaproperty1Arr[1] = new Array("Unique Services","ghp/acquisition/unique_service.html");
buyingaproperty1Arr[2] = new Array("Areas Covered","ghp/acquisition/areascovered.html");
buyingaproperty1Arr[3] = new Array("Fees","ghp/acquisition/fees.html");
buyingaproperty1Arr[4] = new Array("Post Acquisition Services","ghp/acquisition/postacquisition.html");
buyingaproperty1Arr[5] = new Array("Rental Search","ghp/acquisition/rentalsearch.html");
buyingaproperty1Arr[6] = new Array("Nature of the Market","ghp/acquisition/natureofmarket.html");



//Colors for top navigation bar
function getNavItemClass (fieldName) {
	//alert(fieldName);
	CSS = new Array();
	CSS["villahotels"] = "navitemType2";
	CSS["booking"] = "navitemType3";
	CSS["services"] = "navitemType3";

//	CSS["membersarea"] 		= "navitemType3";
	CSS["home"] 			= "navitemType3";
	CSS["buyingaproperty"] 	= "navitemType3";
	CSS["destinations"] 	= "navitemType3";
	
	var strClassName = CSS[fieldName];
	if (strClassName==null) {
		strClassName = "navitem";
	}
return (strClassName);
}

function getHiColor (channelName) {
var hiColor = 'white'; //selected menu item fore color

	hiColors = new Array();
	hiColors["villahotels"] = "#FFFFCC";
	//hiColors["booking"]="#FFFFCC";
	//hiColors["services"] = "#FFFFCC";	

	//hiColors["destinations"] = "yellow";
	//hiColors["france"] = "purple";	
	
	if (hiColors[channelName]!=null) {
		hiColor=hiColors[channelName];
	}

return hiColor;
}

function getLoColor (channelName) {
var loColor ='#83929C';

	loColors = new Array();
	//loColors["destinations"] = "#ffff99";
	
	loColors["villahotels"] = "#BDBA84";
	//loColors["booking"]="#BDBA84";
//	loColors["services"] = "#BDBA84";

	
	if (loColors[channelName]!=null) {
		loColor=loColors[channelName];
	}

return loColor;
}

function getLoBackColor (channelName) {
var loColor ='transparent';

	loColors = new Array();
	loColors["villahotels"] = "#0E5585";
	loColors["booking"]="#0A3654";
	loColors["services"] = "#0A3654";
	
	loColors["destinations"] = "#0A3654";
	loColors["buyingaproperty"] = "#0A3654";
	loColors["home"] = "#0A3654";
	
	
	
	if (loColors[channelName]!=null) {
		loColor=loColors[channelName];
	}

return loColor;
}

function getHiBackColor (channelName) {
var loColor ='#062337';



	loColors = new Array();
	
//	loColors["villahotels"] = "#0E5585";
//	loColors["booking"]="#0E5585";
//	loColors["services"] = "#0E5585";

//	loColors["destinations"] = "#0A3654";
//	loColors["buyingaproperty"] = "#0A3654";
//	loColors["home"] = "#0A3654";
	
	if (loColors[channelName]!=null) {
		loColor=loColors[channelName];
	}

return loColor;
}

//End of navigation bar colors

var lastColor;
var userIni = 0;
var displayedSectionVar;
var searchBoxTopIsSet = false;
function testSearchTopPos(obj)
{
	if(obj.style.top)
	{
		var tempTop = obj.style.top;
		var PXPos = tempTop.indexOf('p');
		var topNum = tempTop.substr(0,PXPos);
		if(topNum>15)
		{
			return true;
		}
	}
	else
	{
		return false	
	}
}
var attacheTopIsSet = false;

function showHMenu(channel) 
{
/*
	if (fdcsponsor == 'noad') 
	{
		if (document.getElementById('searchbox')) 
		{
			document.getElementById('bigBannerDiv').style.height = 0;
		}
	}
	if ((typeof partner != "undefined") && (partner != "") && ((partner.indexOf("aol")>-1) || (partner.indexOf("msn")>-1) || (partner.indexOf("b365")>-1))) 
	{		
		if(document.getElementById('column')) 
		{
			if(attacheTopIsSet != true)
			{
				setAttacheTop();
			}
		}
	}
	*/
	if (document.getElementById('panel1')) {
		document.getElementById('panel1').style.display = "block";
	}
	if(document.getElementById('column')) document.getElementById('column').style.display = "block";
	keepMenu();
	hideVMenu();
	hover(channel);
	if ((typeof curChannel == 'undefined') || (channel != curChannel) || (channel == fdcchannel)) {
		curChannel = channel;
		hideVMenu();
		thisChannArr = eval(channel+'Arr');
		thisChannStr = "";
		thisWidth = 0;
		thisChannX = document.getElementById(channel+'S').offsetParent.offsetLeft;
		thisChannWidth = document.getElementById(channel+'S').offsetWidth;
		
//		alert("X: [" + thisChannX + "] -- thisChannWidth: [" + thisChannWidth+ "]");
		
		if (navigator.appName == 'Microsoft Internet Explorer') thisChannWidth += 8;
		for(i=0;i<thisChannArr.length;i++) {
			if ((typeof displayedSectionVar != "undefined") && (channel + i == displayedSectionVar)) thisHC = "hirizItem";
			else thisHC = "horizItem";
			thisChannStr += '<span id="'+channel+i+'"onMouseOver="showVMenu(\''+channel+i+'\')" onMouseOut="hideMenu()" class="' + thisHC + '" onMouseUp="javascript:nvg(\''+thisChannArr[i][1]+'\')">'+thisChannArr[i][0]+'<\/span>';
		}
	
		//alert("before: "+document.getElementById('hRO').innerHTML);
		document.getElementById('hRO').innerHTML = thisChannStr;
		//alert("after: "+document.getElementById('hRO').innerHTML);
	
		for(i=0;i<thisChannArr.length;i++) {
			thisWidth += document.getElementById(channel+i).offsetWidth;
		}
		
		//alert("thisWidth: "+thisWidth);
		//thisPadding = (790 - thisWidth)/2;
		var thisPadding = thisChannX + 4; // for neat left alignment
		if (thisChannX + thisWidth>=970) {
			//thisPadding = thisChannX;
			thisPadding = 970 - thisWidth ;
		}
		
		//else if (thisChannX+thisChannWidth>=thisWidth) thisPadding = thisChannX + thisChannWidth - thisWidth -6;
		if (thisPadding<0) thisPadding = 0;
		//alert("thisPadding: "+thisPadding);

	
		document.getElementById('hRO').style.width = thisWidth+"px" ; //append with px for firefox
		document.getElementById('hRO').style.paddingLeft = thisPadding+"px"; //append with px for firefox
		

		
		//if (document.getElementById('hRO').offsetWidth > 790) {
			//document.getElementById('hRO').style.width = 790 - thisPadding;
		//}
		//alert("set width to "+document.getElementById('hRO').style.width);
		if(channel != fdcchannel) {
			for(i=0;i<channelArr.length;i++) {
				thisChannel = channelArr[i];
				if(thisChannel != fdcchannel) {
					document.getElementById(thisChannel+'S').style.backgroundColor = getLoBackColor(thisChannel); //'transparent';
					document.getElementById(thisChannel+'S').style.color = getLoColor(thisChannel);
				}
			}
			document.getElementById(channel+'S').style.backgroundColor = getHiBackColor(channel); //bg color on mouse over.
			document.getElementById(channel+'S').style.color = getHiColor(channel);  //foreground color on mouse over
/*
			document.getElementById(channel+'S').style.borderWidth=1 + " px";
			document.getElementById(channel+'S').style.borderColor="pink";
	*/		
			document.getElementById(fdcchannel+'S').style.backgroundColor = getLoBackColor(fdcchannel);
			document.getElementById(fdcchannel+'S').style.color = getLoColor(fdcchannel);
			

			lastColor = getLoColor(fdcchannel);
			
		} else {
			for(i=0;i<channelArr.length;i++) {
				thisChannel = channelArr[i];
				if(thisChannel != fdcchannel) {
					document.getElementById(thisChannel+'S').style.backgroundColor = getLoBackColor(thisChannel);
				}
			}
			document.getElementById(fdcchannel+'S').style.backgroundColor = getHiBackColor(fdcchannel);; //selected chanel background color
			if (!userIni) document.getElementById(fdcchannel+'S').style.color = getHiColor(fdcchannel);
			lastColor = getHiColor(fdcchannel);
			showSection();
		}
	}
	userIni=0;
}


function hover(channel) {
	document.getElementById(channel+'S').style.color = getHiColor(channel);
}
function hideHMenu() {
	document.getElementById('hRO').innerHTML = "";
	document.getElementById('hRO').style.width = 0;
	showHMenu(fdcchannel);
	//showAd();
}
function hideVMenu() {
	if ((typeof thisSection != "undefined") && (document.getElementById(thisSection))) {
		if((typeof displayedSectionVar != "undefined") && (displayedSectionVar == thisSection)) document.getElementById(thisSection).style.color = getHiColor(thisSection);
		else document.getElementById(thisSection).style.color = getLoColor(thisSection);
	}
	if ((typeof vSection != "undefined") && (document.getElementById(vSection))) document.getElementById(vSection).style.backgroundColor = getLoBackColor(vSection);
	if (lastSection) lastSection = "";

	document.getElementById('vRO').style.display = 'none';
	document.getElementById('vRO').innerHTML = "";
	
}
function hideMenu() {
	if ((typeof thisSection != "undefined") && (document.getElementById(thisSection))) {
		if((typeof displayedSectionVar != "undefined") && (displayedSectionVar == thisSection)) document.getElementById(thisSection).style.color = getHiColor(thisSection);
		else document.getElementById(thisSection).style.color = getLoColor(thisSection);
	}
	for(i=0;i<channelArr.length;i++) {
		thisChannel = channelArr[i];
		if (thisChannel != fdcchannel) document.getElementById(thisChannel+'S').style.color = getLoColor(thisChannel);
		else document.getElementById(thisChannel+'S').style.color = lastColor;
	}
	hTimer = setTimeout('hideHMenu()',1000);
}
function showVMenu(section) {
	keepMenu();
	hideVMenu();
	document.getElementById(section).style.color =getHiColor(section); //horizontal sub-menu hover color
	if (displayedSection != 'Video') {
		if((!thisAdDiv) || (typeof thisAdDiv == "undefined") || (thisAdDiv == "")) {
			if (document.getElementById('adDiv')) thisAdDiv = 'adDiv';
			else if (document.getElementById('dynamicAdColDiv')) thisAdDiv = 'dynamicAdColDiv';
			else if (document.getElementById('dynamicAdWinDiv')) thisAdDiv = 'dynamicAdWinDiv';
		}
		if (document.getElementById(thisAdDiv)) {
			if((document.getElementById(section).offsetLeft+180 > document.getElementById(thisAdDiv).offsetLeft) && (eval(section + 'Arr').length>2)) {
				hideAd();
			}
		}
	}
	thisSection = section;
	showMenu(section);
}
function keepMenu() {
	if (hTimer) clearTimeout(hTimer);
	if (vTimer) clearTimeout(vTimer);
}

function showSection() {
	if ((typeof displayedSection != "undefined") && (displayedSection != "")) {
	   thisChannelArr  = eval(displayedChannel + 'Arr');
	   count = 0;
	   for(i=0;i<thisChannelArr.length;i++) {
		displayedSectionLnk = thisChannelArr[i][0].toLowerCase();
	   	displayedSectionLnk = displayedSectionLnk.replace(/ \& /g,"");
	   	displayedSectionLnk = displayedSectionLnk.replace(/ /g,"");
	   	if (displayedSectionLnk == displayedSection.toLowerCase()) {
			displayedSectionVar = displayedChannel + i;
			break;
		}
		count++;
	   }
	   if(count==thisChannelArr.length) {
	        displayedSectionLnk = displayedSection;
	        displayedSectionLnk = displayedSectionLnk.substr(displayedSection.indexOf(" ")+1,displayedSectionLnk.length);
	   	for(i=0;i<thisChannelArr.length;i++) {
			checkSection = thisChannelArr[i][0].toLowerCase();
	   		if (checkSection.indexOf(displayedSectionLnk)>-1) {
				displayedSectionVar = displayedChannel + i;
				break;
			}
		}
	   }
//stoopid failsafe
	   switch (displayedSection) {
           	case "businesstech":
		displayedSectionVar = "business8";
	        break;
		case "wallstreet":
		displayedSectionVar = "business9";
	        break;
           	case "beltway":
		displayedSectionVar = "business10";
	        break;
           	case "enterprisetech":
		displayedSectionVar = "technology1";
	        break;
           	case "infoimaging":
		displayedSectionVar = "technology2";
	        break;
           	case "ebusiness":
		displayedSectionVar = "technology3";
	        break;
           	case "entrefinance":
		displayedSectionVar = "entrepreneurs0";
	        break;
           	case "entrehr":
		displayedSectionVar = "entrepreneurs1";
	        break;
           	case "entrelaw":
		displayedSectionVar = "entrepreneurs2";
	        break;
           	case "entresales":
		displayedSectionVar = "entrepreneurs3";
	        break;
           	case "entremgmt":
		displayedSectionVar = "entrepreneurs4";
	        break;
           	case "entretech":
		displayedSectionVar = "entrepreneurs5";
	        break;
           	case "estate_planning":
		displayedSectionVar = "personalFinance0";
	        break;
           	case "entertainment":
		displayedSectionVar = "technology1";
	        break;
	   }
	   if (document.getElementById(displayedSectionVar)) document.getElementById(displayedSectionVar).style.color = getHiColor(displayedSection);
	}
}
function showMenu(section) {
	thisSectionArr  = eval(section + 'Arr');
	if((thisSectionArr.length>0) && (displayedSection != "Video")) {
		keepMenu();
		document.getElementById('vRO').style.display = 'block';
		if(document.getElementById(section).offsetLeft>800) document.getElementById('vRO').style.left = 800;

		else 
		document.getElementById('vRO').style.marginLeft = document.getElementById(section).offsetLeft + "px";
		//alert("Section: ["+section+"] left: "+document.getElementById(section).offsetLeft);
		vSection = section;
		dropStr = '';
		for(i=0;i<thisSectionArr.length;i++) {
			dropStr += '<div class="vertItem" onMouseOver="hoverAct(\''+section+i+'\',1)" id="'+section+i+'H"><a href="' + getVertNavURL(thisSectionArr[i][1])+'" class="vertLink" id="'+section+i+'L">'+thisSectionArr[i][0]+'</a></div>';
		}
		document.getElementById('vRO').innerHTML = dropStr;
	}
}

function nvg(URL) {
	if (URL=="" || URL=="#") {
		return;
	}
var baseURL = "http://192.168.0.101:8686/";
		
	URL = baseURL + URL;
	this.location.href=URL;
}

function getVertNavURL (URL) {
	var baseURL = "http://192.168.0.101:8686/";
	URL = baseURL + URL;
	return (URL);
}
function hoverAct(section,on) {
	if (lastSection) {
		document.getElementById(lastSection+'L').style.color = getLoColor(lastSection); 
	}
	document.getElementById(section+'L').style.color = getHiColor(section); // vertical menu hover forecolor
	lastSection = section;
}

///////////// END ENCODING FUNCTS /////////////////

var welcomeCookie = "undefined";




function drawMenu() {






	document.write('<div class="navbg">');
	document.write('<table cellspacing="1" cellpadding="0" border="0" bordercolor="yellow" width="987"><tr align="center">');
	for (i=0;i<channelArr.length;i++) {
		thisChannel = channelArr[i];
		thisLongChannel = longChannelArr[i];
		thisChannelURL = channelURLArr[i];
		myClass = getNavItemClass(thisChannel);
		document.write('<td bgcolor="#000"><div class="'+myClass+'" id="'+thisChannel+'S" onMouseOut="hideMenu();" onMouseOver="showHMenu(\''+thisChannel+'\');" onMouseUp="javascript:nvg(\''+thisChannelURL+'\')">&nbsp;'+thisLongChannel+'&nbsp;<\/div><\/td>');
	
	}
	document.write('</tr></table><\/div>');
	document.write('<div align="left" xstyle="border: 1px solid pink; background-color: pink;" class="horizRO" id="hRO"></div>');
	document.write('<div class="vertRO" id="vRO" onMouseOut="hideMenu();" onMouseOver="keepMenu();"></div>');
	//if (!noSearch) document.write('<div onMouseDown="hideSearchPanel()">');
//	document.write('<br>');
	
	hideMenu();
}

