// JavaScript Document

var
	faqColor, infoColor, jobColor, contactColor;

if (parseInt(navigator.appVersion.charAt(0))>=4)
{
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}

/*
	Functie: afterNavigate(main, sub)
	Omschrijving: 	past menukleuren aan
					past statustext aan
	@param: 	main = keuze in hoofdmenu
				sub = keuze in submenu
*/
function afterNavigate(main, sub)
{
	document.getElementById('cont').style.height = '1200 px';
	document.getElementById('wn').style.height = '495 px';
	document.getElementById('menu').style.visibility = 'visible';
	
	var colorNonActive = '#CCCCCC';
	var colorActive = 'red';
	
	//alert('main: ' + main + ' | sub: ' + sub);
	if (main > -1)
	{
		//Alle menupunten wit maken
		//colorLink('lnkHome', colorNonActive);
		//colorLink('lnkWagenPark', colorNonActive);
		//colorLink('lnkReserveren', colorNonActive);
		//colorLink('lnkAgentschappen', colorNonActive);
		//colorLink('lnkB2B', colorNonActive);
		//colorLink('lnkLinks', colorNonActive);
		
		window.status = 'Rent-a-Car ';
		if (main == 1)
		{
			window.status = window.status + ' -> Home';
			colorLink('lnkHome', colorActive);
			makeVisible('subMenuHome');
			setContHeight(610);
		}
		else if (main == 2)
		{
			window.status = window.status + ' -> Wagenpark';
			colorLink('lnkWagenpark', colorActive);
			makeVisible('subMenuWagenpark');
			
			//colorLink('lnkWagenparkWagens', colorNonActive);
			//colorLink('lnkWagenparkLuxury', colorNonActive);
			//colorLink('lnkWagenparkBedrijfsvoertuigen', colorNonActive);
			//colorLink('lnkWagenparkAutomaten', colorNonActive);
			
			if (sub == 1)
			{
					window.status = window.status + ' -> Wagens';
					colorLink('lnkWagenparkWagens', colorActive);
					setContHeight(750);
			}
			else if (sub == 2)
			{
					window.status = window.status + ' -> Luxury';
					colorLink('lnkWagenparkLuxury', colorActive);
					setContHeight(495);
			} 
			else if (sub == 3)
			{
					window.status = window.status + ' -> Bedrijfsvoertuigen';
					colorLink('lnkWagenparkBedrijfsvoertuigen', colorActive);
					setContHeight(495);
			} 
			else if (sub == 4)
			{
					window.status = window.status + ' -> Automaten';
					colorLink('lnkWagenparkAutomaten', colorActive);
					setContHeight(495);
			} 
		}
		else if (main == 3)
		{
			window.status = window.status + ' -> Reserveren';
			colorLink('lnkReserveren', colorActive);
			makeVisible('subMenuReserveren');
			
			if (sub == 1)				//Overzicht
			{
			}
			else if (sub == 2)			//Reservatie
			{
			}
			else if (sub == 3)			//Promos
			{
					window.status = window.status + ' -> Promoties';
					colorLink('lnkReserveren', colorActive);
					setContHeight(660);
			}
			else if (sub == 4)			//Last minutes
			{
			}
		}
		else if (main == 4)
		{
			window.status = window.status + ' -> Agentschappen';
			colorLink('lnkAgentschappen', colorActive);
			makeVisible('subMenuAgentschappen');
			if (document.getElementById('selProvincies'))
				setContHeight(582);
			else
				setContHeight(650);
			
						
			//subMenu zwart maken
			//colorLink('lnkWVlaanderen', colorNonActive);
			//colorLink('lnkOVlaanderen', colorNonActive);
			//colorLink('lnkAntwerpen', colorNonActive);
			//colorLink('lnkLimburg', colorNonActive);
			//colorLink('lnkVlBrabant', colorNonActive);
			//colorLink('lnkBrussel', colorNonActive);
			//colorLink('lnkBrabWallon', colorNonActive);
			//colorLink('lnkHainaut', colorNonActive);
			//colorLink('lnkNamur', colorNonActive);
			//colorLink('lnkLiege', colorNonActive);
			//colorLink('lnkLuxembourg', colorNonActive);
			
			if (sub == 1)		//West-Vlaanderen
			{
				window.status = window.status + ' -> West-Vlaanderen';
				colorLink('lnkWVlaanderen', colorActive);
			}
			else if (sub == 2)	//Oost-Vlaanderen
			{
			window.status = window.status + ' -> Oost-Vlaanderen';
			colorLink('lnkOVlaanderen', colorActive);
			}
			else if (sub == 3)	//Antwerpen
			{
				window.status = window.status + ' -> Antwerpen';
				colorLink('lnkAntwerpen', colorActive);
			}
			else if (sub == 4)	//Limburg
			{
				window.status = window.status + ' -> Limburg';
				colorLink('lnkLimburg', colorActive);
			}
			else if (sub == 5)	//Vlaams-Brabant
			{
				window.status = window.status + ' -> Vlaams-Brabant';
				colorLink('lnkVlBrabant', colorActive);		
			}
			else if (sub == 6)	//Brussel
			{
				window.status = window.status + ' -> Brussel';
				colorLink('lnkBrussel', colorActive);			
			}
			else if (sub == 7)	//Brabant-Wallon
			{
				window.status = window.status + ' -> Brabant-Wallon';
				colorLink('lnkBrabWallon', colorActive);			
			}
			else if (sub == 8)	//Hainaut
			{
				window.status = window.status + ' -> Hainaut';
				colorLink('lnkHainaut', colorActive);		
			}
			else if (sub == 9)	//Namur
			{
				window.status = window.status + ' -> Namur';
				colorLink('lnkNamur', colorActive);			
			}
			else if (sub == 10)	//Liege
			{
				window.status = window.status + ' -> Liege';
				colorLink('lnkLiege', colorActive);
			}
			else if (sub == 11)	//Luxembourg
			{
				window.status = window.status + ' -> Luxembourg';
				colorLink('lnkLuxembourg', colorActive);			
			}
		}
		else if (main == 5)
		{
			window.status = window.status + ' -> B2B';
			colorLink('lnkB2B', colorActive);
			setContHeight(775);
//			if (document.getElementById('lnkB2B'))
//				document.getElementById('lnkB2B').style.color = colorActive;
			makeVisible('subMenuB2B');
			
			//colorLink('lnkB2BAlgemeen', colorNonActive);
			//colorLink('lnkB2BKorteTermijn', colorNonActive);
			//colorLink('lnkB2BLangeTermijn', colorNonActive);
			//colorLink('lnkB2BRACPartner', colorNonActive);
			//colorLink('lnkB2BContact', colorNonActive);
			
			if (sub == 1)
			{
				window.status = window.status + ' -> Fleet';
				colorLink('lnkB2BAlgemeen', colorActive);
				setContHeight(582);
			}
			else if (sub == 2)
			{
				window.status = window.status + ' -> Garagisten / carrossiers';
				colorLink('lnkB2BKorteTermijn', colorActive);
				setContHeight(610);
			}
			else if (sub == 3)
			{
				window.status = window.status + ' -> Assistentiebedrijven';
				colorLink('lnkB2BLangeTermijn', colorActive);
				setContHeight(582);
			}
		}
		else if (main == 6)
		{
			window.status = window.status + ' -> In de kijker';
			colorLink('lnkKijker', colorActive);
//			if (document.getElementById('lnkLinks'))
//				document.getElementById('lnkLinks').style.color = colorActive;
			makeVisible('');
			setContHeight(925);
		}
		else if (main == 7)
		{
			window.status = window.status + ' -> FAQ';
			colorLink('lnkFAQ', 'white');
			if (document.getElementById('tdFAQ'))
			{
				document.getElementById('tdFAQ').bgColor = 'red';
			}
			makeVisible('');
			setContHeight(610);
		}
		else if (main == 8)
		{
			window.status = window.status + ' -> Info';
			colorLink('lnkInfo', 'white');
			if (document.getElementById('tdInfo'))
			{
				document.getElementById('tdInfo').bgColor = 'red';
			}
			makeVisible('');
			setContHeight(582);
		}
		else if (main == 9)
		{
			window.status = window.status + ' -> Jobs';
			colorLink('lnkJobs', 'white');
			if (document.getElementById('tdJobs'))
			{
				document.getElementById('tdJobs').bgColor = 'red';
			}
			makeVisible('');
			setContHeight(582);
		}
		else if (main == 10)
		{
			window.status = window.status + ' -> Contact';
			colorLink('lnkContact', 'white');
			if (document.getElementById('tdContact'))
			{
				document.getElementById('tdContact').bgColor = 'red';
			}
			makeVisible('');
			setContHeight(582);
		}
		else if (main == 11)
		{
			window.status = window.status + ' -> Promo';
			colorLink('lnkPromo', colorActive);
			makeVisible('subMenuPromo');
			setContHeight(495);
			
			//colorLink('lnkPromoXXL', colorNonActive);
			//colorLink('lnkPromoWeekend', colorNonActive);
			
			if (sub == 1)
			{
				window.status = window.status + ' -> XXL';
				colorLink('lnkPromoXXL', colorActive);
				setContHeight(495);
			}
			else if (sub == 2)
			{
				window.status = window.status + ' -> Weekendtips';
				colorLink('lnkPromoWeekend', colorActive);
				setContHeight(495);
			}
			else if (sub == 3)
			{
				window.status = window.status + ' -> Minibus';
				colorLink('lnkMinibus', colorActive);
				setContHeight(495);
			}
		}
		else if (main == 12)
		{
			window.status = window.status + ' -> Links';
			colorLink('lnkLinks', 'white');
			if (document.getElementById('tdLinks'))
			{
				document.getElementById('tdLinks').bgColor = 'red';
			}
			makeVisible('');
			setContHeight(582);
		}
		else if (main == 13)
		{
			window.status = window.status + ' -> Taalkeuze';
			colorLink('lnkTaalKeuze', 'orangered');
			makeVisible('');
			setContHeight(582);
			document.getElementById('menu').style.visibility = 'hidden';
		}
		else if (main == 14)
		{
			window.status = window.status + ' -> Algemene huurvoorwaarden';
			colorLink('lnkAlgVw', 'orangered');
			makeVisible('');
		}
		else if (main == 15)
		{
			window.status = window.status + ' -> Sitemap';
			colorLink('lnkSitemap', 'orangered');
			makeVisible('');
			setContHeight(1700);
		}
		else if (main == 16)
		{
			window.status = window.status + ' -> Reserveren';
			colorLink('lnkReserveren', 'orangered');
			makeVisible('');
			setContHeight(450);
		}
		else if (main == 17)
		{
			window.status = window.status + ' -> Algemene voorw.';
			colorLink('lnkAlgVw', 'orangered');
			makeVisible('');
			setContHeight(5300);
		}
	}
	else
	{
		var temp = window.location.href;
		//alert('1: ' + window.location.href);
		makeVisible('');
		document.getElementById('menu').style.visibility = 'hidden';
		//alert('2: ' + window.location.href);
	}
	initScrollLayer();
}

/*
	Functie: makeVisible
	Omschrijving: 	toont het juiste submenu
					wordt aangeroepen door navigate(i)
	@param: id = i
		1:	Home
		2:	Wagenpark
		3:	Reserveren
		4:	Agentschappen
		5:	B2B
		6:	Links

*/
function makeVisible(id)
{
	if (document.getElementById('subMenuHome'))
		document.getElementById('subMenuHome').style.visibility = 'hidden';
	if (document.getElementById('subMenuWagenpark'))
		document.getElementById('subMenuWagenpark').style.visibility = 'hidden';
	if (document.getElementById('subMenuReserveren'))
		document.getElementById('subMenuReserveren').style.visibility = 'hidden';
	if (document.getElementById('subMenuAgentschappen'))
		document.getElementById('subMenuAgentschappen').style.visibility = 'hidden';
	if (document.getElementById('subMenuB2B'))
		document.getElementById('subMenuB2B').style.visibility = 'hidden';
	if (document.getElementById('subMenuLinks'))
		document.getElementById('subMenuLinks').style.visibility = 'hidden';
	if (document.getElementById('subMenuPromo'))
		document.getElementById('subMenuPromo').style.visibility = 'hidden';
	
	if (document.getElementById(id))
		document.getElementById(id).style.visibility = 'visible';
	document.getElementById('menu').style.visibility = 'visible';
}

/*
	Functie: colorRightMenu(id, over)
	Omschrijving: 	verzorgt de mouseover en mouseout in het rechtse menu(FAQ, info, jobs, contact)
	@param: 	id = de cel waarover of waaruit de muis gaat
				over = muis gaat over of uit de cel
*/
function colorRightMenu(id, over)
{
	if (over == true)
	{
		if (document.getElementById(id).bgColor != '#ff0000' && document.getElementById(id).bgColor != 'red')
			document.getElementById(id).bgColor = 'yellow';
	}
	else
	{
		if (document.getElementById(id).bgColor != '#ff0000' && document.getElementById(id).bgColor != 'red')
			document.getElementById(id).bgColor = 'white';
	}
}

function colorLink(id, color)
{
	if (document.getElementById(id))
		document.getElementById(id).style.color = color;
}

function navigateProvincies(obj)
{
	var i = obj.selectedIndex;
	//alert((window.location.href).indexOf('Agentschappen'));
	if ((window.location.href).indexOf('Agentschappen') > 0)
		window.location.href = './' + obj.options[i].value;
	else
		window.location.href = './Agentschappen/' + obj.options[i].value;
}

function getDealerCode(obj)
{
	var qry = location.search.substring(1);
	if (qry != '')
	{
		obj.src = './Dealers/' + qry + '.xml';
	}
}

function startReservatie(kl, nr)
{
	window.location.href = '../Reserveren/Reservatie.html?kl=' + kl + '&nr=' + nr;
}

function doFaq(id)
{
	if (document.getElementById(id))
	{
		if (document.getElementById(id).style.display == 'block')
		{
			document.getElementById(id).style.display = 'none';
		}
		else
		{
			if (document.getElementById('faqFact'))
				document.getElementById('faqFact').style.display = 'none';
			if (document.getElementById('faqReserv'))
				document.getElementById('faqReserv').style.display = 'none';
			if (document.getElementById('faqOnderweg'))
				document.getElementById('faqOnderweg').style.display = 'none';
			if (document.getElementById('faqHuur'))
				document.getElementById('faqHuur').style.display = 'none';
			if (document.getElementById('faqVerzekering'))
				document.getElementById('faqVerzekering').style.display = 'none';
			if (document.getElementById('faqTeruggave'))
				document.getElementById('faqTeruggave').style.display = 'none';
			
			document.getElementById(id).style.display = 'block';
		}
	}
}

function openFaq()
{
	var faqDiv = location.href.split('?');
	if (faqDiv[1])
	{
		faqDiv = faqDiv[1].split(',');
		if (faqDiv  != '')
			doFaq(faqDiv);
	}
}

function getCookie(name)
{
	var uLangCookie = document.cookie;
	var index = uLangCookie.indexOf(name + "=");
	if (index == -1)
	{
		return null;
	}
	index = uLangCookie.indexOf("=", index) + 1;
	var end = uLangCookie.indexOf(";", index);
	if (end == -1) 
	{
		end = uLangCookie.length;
	}
	return unescape(uLangCookie.substring(index, end));
}

function setCookie(name, value, date)
{
	if (date > 0)
	{
		//alert('2');
		var dt = new Date();
		dt = date;
		dt.setTime(dt.getTime() + 3600000*24*30);

		var curCookie = name + "=" + escape(value) +
						";expires=" + dt.toGMTString();
		//alert(curCookie);
	}
	else
	{
		var curCookie = name + "=" + escape(value) + ";expires=-1";
	}
	document.cookie=curCookie;
	//alert(document.cookie);
	
	if (name == "uLang" && date > 0)
		location.replace(value + "/index.html");
}

function exp_coll(index)
{
	var s = document.getElementById('hm' + index);
		
	if (s.style.display == 'none')
	{
		expand(index);
	}
	else if (s.style.display == 'block')
	{
		coll(index);
	}
}

function coll(index)
{
	var s = document.getElementById('hm' + index);
	var i = document.getElementById('img' + index);

	s.style.display = 'none';
	i.src = '../Images/expand.gif';
}

function expand(index)
{
	var s = document.getElementById('hm' + index);
	var i = document.getElementById('img' + index);

	s.style.display = 'block';
	i.src = '../Images/collapse.gif';
}

function collAll()
{
	coll(2);
	coll(21);
	coll(22);
	coll(23)
	coll(24);
	coll(3);
	coll(31);
	coll(32);
	coll(33);
	coll(34);
	coll(35);
	coll(36);
	coll(37);
	coll(38);
	coll(39);
	coll(4);
	coll(5);
}

function expAll()
{
	expand(2);
	expand(21);
	expand(22);
	expand(23)
	expand(24);
	expand(3);
	expand(31);
	expand(32);
	expand(33);
	expand(34);
	expand(35);
	expand(36);
	expand(37);
	expand(38);
	expand(39);
	expand(4);
	expand(5);
}


function setContHeight(h)
{
	if (isIE)
	{
		document.getElementById('cont').style.height = h + 'px';
	}
	else
	{
		document.getElementById('cont').height = h + 'px';
		//alert(h);
	}
	document.getElementById('cont').style.height = h + 'px';
	document.getElementById('cont').style.clip.bottom = h + 'px';
	//alert(document.getElementById('cont').style.height);
	//alert('ch: ' + getContHeight() + '\n' + 'wh: ' + getWnHeight());
	if (getContHeight() <= getWnHeight())
	{
		document.getElementById('up').style.visibility = 'hidden';
		document.getElementById('track').style.visibility = 'hidden';
		document.getElementById('down').style.visibility = 'hidden';		
		initScrollLayer();
	}
	else
	{
		document.getElementById('up').style.visibility = 'visible';
		document.getElementById('track').style.visibility = 'visible';
		document.getElementById('down').style.visibility = 'visible';		
	}
	initScrollLayer();
}

function getContHeight()
{
	if (isIE)
	{
		var h = document.getElementById('cont').style.height; 
		h = h.substring(0, h.indexOf('px'));
	}
	else 
	{
		var h = document.getElementById('cont').height;
	}
	return parseInt(h);
}

function getWnHeight()
{
	if (isIE)
	{
		var h = document.getElementById('wn').style.height; 
		h = h.substring(0, h.indexOf('px'));
	}
	else
	{
		var h = document.getElementById('wn').height;
		//h = (h).substring(0, h.indexOf('px'));
	}
	return parseInt(h);
}


PositionX = 100;
PositionY = 100;

defaultWidth  = 500;
defaultHeight = 500;

var AutoClose = true;

var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle)
{
	if (isNN)
	{
		imgWin=window.open('about:blank','',optNN);
	}
	if (isIE)
	{
		imgWin=window.open('about:blank','',optIE);
	}

	with (imgWin.document)
	{
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
		writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
		writeln('width=100-(document.body.clientWidth-document.images[0].width);');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
		writeln('window.innerWidth=document.images["George"].width;');
		writeln('window.innerHeight=document.images["George"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
		if (!AutoClose) 
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
		else 
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
		close();		
	}
}

function doIt()
{
	document.getElementById('cont').height ="720px";
}

function startPartner()
{
	var url = location.href;
	if (url.toUpperCase().indexOf("C:") > -1)
	{
		if (url.toUpperCase().indexOf("/FR/") > - 1)
		{
			return "http://127.0.0.1:8757/?";
		}
		else
		{
			return "http://127.0.0.1:8747/?";
		}
	}
	else if (url.toUpperCase().indexOf("N:") > -1)
	{
		if (url.toUpperCase().indexOf("/FR/") > - 1)
		{
			return "http://test.racpartner.be/fr/?";	
		}
		else
		{
			return "http://web03:8747/?";
		}
	}
	else
	{
		if (url.toUpperCase().indexOf("/FR/") > - 1)
		{
			return "http://www1.racpartner.be/fr/?";
		}
		else
		{
			return "http://www1.racpartner.be/?";
		}
	}
}