
// Content: js resize
var w=null;function log(m){if(!w)w=window.open();w.document.write(m+'<br />');}

function updateSize () {
	updateIt();
}

function updateIt () {

	if (top.mainContainer)
	{
		if (document.body.offsetWidth < 988) {
			top.mainContainer.className = "main800";
			var d = document.getElementById("language_selector");
			if (d) d.style.width = "773px";
		}
		else {
			top.mainContainer.className = "main1024";
			var d = document.getElementById("language_selector");
			if (d) d.style.width = "987px";
		}
		/* Force correct positioning */
		if (navigator.product && navigator.product == "Gecko") {
			top.mainContainer.style.position = "relative";
			top.mainContainer.style.position = "";
		}
	}
}
// Content: js navigation
Navigation.prototype.HEIGHT_CLOSED = 25;
Navigation.prototype.BOTTOM_MARGIN = 20;
Navigation.prototype.WIN_IE50 = (navigator.userAgent.toLowerCase().indexOf("msie 5.0") > 0); 
Navigation.prototype.WIN_IE5PLUS = ((navigator.userAgent.toLowerCase().indexOf("msie") > 0) && (navigator.userAgent.toLowerCase().indexOf("msie 5.0") < 0)); 
Navigation.prototype.WIN_IE60 = (navigator.userAgent.toLowerCase().indexOf("msie 6.0") > 0);

function Navigation (container, bottomImage, HTML, extFrame) {
	this.navigation = document.getElementById(container);
	this.navigation.innerHTML = HTML;
	this.closing = -1;
	this.opening = -1;
	this.openImage = document.getElementById(bottomImage);
	this.logoImage = document.getElementById('navlogo');
	this.allItems = this.navigation.getElementsByTagName("li");
	this.initAllItems();
	this.subLists = this.navigation.getElementsByTagName('ul')[0].getElementsByTagName('ul');
	//this.targetHeight = this.getHeight() + this.HEIGHT_CLOSED + this.BOTTOM_MARGIN;
	this.targetHeight = 220 + this.HEIGHT_CLOSED + this.BOTTOM_MARGIN;
	this.isOpen = false;
	if (!document.all || this.WIN_IE50) this.initExtFrame();	
	/* iframe behind navigation for IE 5.5+ to hide selectboxes */
	if (document.all && !this.WIN_IE50) {
		this.selectHider = this.createHider();
	}
	if (this.WIN_IE50) {
		this.selectBoxes = document.getElementsByTagName('select');
	}
	this.navigation.onmouseover = createContextFunction(this, "open");
	this.navigation.onmouseout = createContextFunction(this, "close");
	/* IE initialization for navigation entries */
	if (document.all) {
		this.initIE();
	}
	this.placeItems();
	if (document.getElementById('sitemap')) {
//		generateSitemap();
		if (this.WIN_IE50) window.resizeBy(0, 1);
	}
	this.setFullHeight();
	if (getCookie('jffp')) {if (getCookie('jffp').length > 10) this.clearLoginEntries()};
}
Navigation.prototype.initIE = function () {
	for (var i=0; i < this.allItems.length; i++) {
		var node = this.allItems[i];
		node.onmouseover = function () {
			this.className += "over";
		}
		node.onmouseout = function () {
			this.className = this.className.replace("over", "");
		}
	}
}
Navigation.prototype.initExtFrame = function () {
	this.extFrame = document.getElementById('extFrame');
	if (this.extFrame) this.extFrame.style.position = 'relative'; /* ppkpatch: give iframe position: relative so top can be used instead of marginTop */
	if (this.extFrame) this.extFrame.startPos = calculateTop(this.extFrame);
}
Navigation.prototype.initAllItems = function () {
	for (var i = 0; i < this.allItems.length; i++) {
		if (this.allItems[i].className.indexOf('submenu') != -1) {
			this.allItems[i].submenu = this.allItems[i].getElementsByTagName('ul')[0];
			this.allItems[i].subItem = this.allItems[i].submenu.getElementsByTagName('li')[0];
		} else {
			this.allItems[i].submenu = null;
			this.allItems[i].subItem = null;
		}
	}
}
Navigation.prototype.open = function (e) {
	if (!isSafari()) {
		if (e) if (e.originalTarget.innerHTML == "Home") return;
		if (e) if (e.originalTarget.id == "navigation") return;
	}
	if (e) var dest = e.relatedTarget; else var dest = window.event.toElement;
	if (dest) if (dest.parentNode.id == 'home' || dest.parentNode.id == 'top' || dest.parentNode.id == 'ls_top' || dest.parentNode.id == 'maincontainer') return;
	//alert(dest.parentNode.id);
	//this.allItems[0].getElementsByTagName('a')[0].focus();
	//this.allItems[0].getElementsByTagName('a')[0].blur();
	if (this.WIN_IE50) {
		this.slideOpen()
	} else {
		if (this.closing > 0) {
			clearTimeout(this.closing);
			this.closing = -1;
		}
		if (this.opening < 0 && !this.isOpen) {
			this.opening = setTimeout(createContextFunction(this, "slideOpen"), 300);
		}
	}
}
Navigation.prototype.slideOpen = function () {
	this.openImage.style.display = 'block';
	this.logoImage.style.display = 'block';
	this.navigation.style.height = this.targetHeight + "px";
	if (this.selectHider) this.selectHider.style.display = 'block';
	if (this.selectBoxes) updateSelectBoxes(this.selectBoxes, 'hidden');
	if (this.extFrame && !this.isOpen) {
		this.extFrame.overLap = (this.HEIGHT_CLOSED + this.targetHeight - this.extFrame.startPos);
		this.extFrame.style.top = this.extFrame.overLap + "px"; /* ppkpatch: marginTop -> top */
	}
	if (!this.WIN_IE50) clearTimeout(this.opening);
	this.opening = -1;
	this.isOpen = true;
}
Navigation.prototype.close = function (e) {
	if (e) var dest = e.relatedTarget; else var dest = window.event.toElement;
	if (!isChild(this.navigation, dest)) {
		if (this.WIN_IE50) {
			this.slideClose();
		} else {		
			if (this.opening > 0) {
				clearTimeout(this.opening);
				this.opening = -1;
			}
			if (this.closing < 0 && this.isOpen) {
				this.closing = setTimeout(createContextFunction(this, "slideClose"), 300);
			}
		}
	}
	if (e) e.cancelBubble = true; else window.event.cancelBubble = true;
}
Navigation.prototype.slideClose = function () {
	this.openImage.style.display = 'none';
	this.logoImage.style.display = 'none';
	this.navigation.style.height = this.HEIGHT_CLOSED + "px";
	if (this.selectHider) this.selectHider.style.display = 'none';
	if (this.selectBoxes) updateSelectBoxes(this.selectBoxes, 'visible');
	if (this.extFrame) {
		this.extFrame.style.top = "0"; /* ppkpatch: marginTop -> top */
	}
	if (!this.WIN_IE50) clearTimeout(this.closing);
	this.closing = -1;
	this.isOpen = false;
}
Navigation.prototype.getHeight = function () {
	var targetHeight = 0;
	var height3rdLevel = 0;
	this.show();
	for (var i = 0; i < this.subLists.length; i++) {
		if (this.subLists[i].offsetHeight > targetHeight) targetHeight = this.subLists[i].offsetHeight;
		height3rdLevel = get3rdLevelHeight(this.subLists[i]);
		if (height3rdLevel > targetHeight) targetHeight = height3rdLevel;
	}
	this.hide();
	return targetHeight;
}
Navigation.prototype.show = function () {
	for (var i = 0; i < this.allItems.length; i++) {
		this.allItems[i].persistentClassName = this.allItems[i].className;
		this.allItems[i].className +="over";
		this.allItems[i].className +=" show";
	}
}
Navigation.prototype.hide = function () {
	for (var i = 0; i < this.allItems.length; i++) {
		this.allItems[i].className = this.allItems[i].persistentClassName;
	}
}
Navigation.prototype.setFullHeight = function () {
	for (var i = 0; i < this.subLists.length; i++) {
		this.subLists[i].style.height = "700px";
	}
}
Navigation.prototype.createHider = function () {
	var iframe = document.createElement('iframe');
	iframe.src = 'static/empty.html';
	iframe.style.height = this.targetHeight + "px";
	iframe.style.width = this.navigation.offsetWidth + "px";
	iframe.frameBorder = '0';
	this.navigation.appendChild(iframe);
	return (iframe);
}
Navigation.prototype.clearLoginEntries = function () {
	var a;
	for (var i = 0; i < this.allItems.length; i++) {
		a = this.allItems[i].getElementsByTagName('a')[0];
		if (a.className.indexOf('login') != -1) a.className = '';
	}
}

Navigation.prototype.placeItems = function () {
	var mainItems = new Array();
	
	for (var i = 0; i < this.allItems.length; i++) {
		if (this.allItems[i].parentNode.className == 'level1') mainItems[mainItems.length] = this.allItems[i];
	}
	if (document.body.offsetWidth < 988) {
		mainItems[mainItems.length - 1].className += 'left';
		mainItems[mainItems.length - 1].id = 'lastleft';
		mainItems[mainItems.length - 2].className += 'left';
	}
	// force width of right-side nav items to display properly in ie
	if ((this.WIN_IE50) || (this.WIN_IE5PLUS)) {
		for (var i = 0; i < this.allItems.length; i++) {
			if (this.allItems[i].className == 'submenuleft') { 
				this.menu_item = this.allItems[i];
				this.checkWidth(this.menu_item);
			}
		}
	}
}
Navigation.prototype.checkWidth = function(menu_item) {
	this.menu_item = menu_item;
	this.wid = this.menu_item.offsetWidth;
	this.oddOrEven(this.wid);
	if (!this.WIN_IE60) {
		this.newWid += 15; //add right padding back on for ie6.0
	}
	this.menu_item.style.width = this.newWid;
}
Navigation.prototype.oddOrEven = function(wid) {
	this.wid = wid - 15; //remove right padding
	this.oe = this.wid % 2;
	if ((this.oe == 1) && (this.menu_item.id != "lastleft")) { this.wid++; }
	else if ((this.oe != 1) && (this.menu_item.id == "lastleft")) { this.wid++; }
	this.newWid = this.wid;
}
function get3rdLevelHeight(ul) {
	var height = 0;
	var maxHeight = 0;
	var currentYPos = 0;
	var secondLevelCounter = 0;
	var entries = ul.getElementsByTagName('li');
	
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].parentNode.className == 'level2') {
			if (entries[i].className == 'submenuover') {
				currentYPos = entries[i].offsetTop;
				height = currentYPos + entries[i].getElementsByTagName('ul')[0].offsetHeight;
			}
			if (height > maxHeight) maxHeight = height;
		}
	}
	return maxHeight;
}
function updateSelectBoxes(boxes, visibility) {
	for (var i = 0; i < boxes.length; i++) {
		boxes[i].style.visibility = visibility;
	}
}
// Content: js language selector
var lsFrame;

LanguageSelector.prototype.WIN_IE50 = (navigator.userAgent.toLowerCase().indexOf("msie 5.0") > 0); 

function LanguageSelector () {
	
}
LanguageSelector.prototype.openCountry = function () {
	if (this.WIN_IE50) document.location.href = '../kurdblogger_splash/splashpage.html';
	if (!this.clData) this.getData();
	this.country.style.visibility = 'visible';
	if (this.WIN_IE50) {
		this.country.style.display = 'block';
		this.lang.style.marginLeft = 'auto';
	}
	if (this.initialOption) {
		this.initialOption.selected = true;
		this.updateLanguages();
	}
	this.open();
}
LanguageSelector.prototype.openLang = function () {
	if (!this.clData) this.getData();
	this.country.style.visibility = 'hidden';
	if (this.WIN_IE50) {
		this.country.style.display = 'none';
		this.lang.style.marginLeft = '100px';
	}
	if (this.initialOption) {
		this.initialOption.selected = true;
		this.updateLanguages();
	}
	this.open();
}
LanguageSelector.prototype.open = function () {
	document.getElementById('ls_top').style.display = 'none';
	document.getElementById('ls_content').style.display = 'block';
	document.getElementById('ls_content').style.position = 'relative';
}
LanguageSelector.prototype.close = function (e) {
	if (e) var dest = e.relatedTarget; else var dest = window.event.toElement;
	if (!isChild(this, dest)) {
		if (this.canBeClosed) this.closing = setTimeout(createContextFunction(this, "closeIt"), 500);
	}
	return true;
}
LanguageSelector.prototype.closeIt = function () {
	document.getElementById('ls_top').style.display = 'block';
	document.getElementById('ls_content').style.display = 'none';
	clearInterval(this.closing);
}
LanguageSelector.prototype.updateLanguages = function () {
	var c, l;
	var newLi;
	this.clearLanguages();
	c = this.countrySelector.options[this.countrySelector.selectedIndex].value;
	if (!c) return;
	var entries = this.clData.getHTMLById(c).getElementsByTagName('li');
	for (var i = 0; i < entries.length; i++) {
		newLi = document.createElement('li');
		if (entries[i].getAttribute('url'))
		{
			this.normal.style.display = 'none';
			if (entries[i].getAttribute('img') != "")
			{
				this.external.style.display = 'block';
				this.externalimg.src = entries[i].getAttribute('img');
				this.externallinkimg.href = entries[i].getAttribute('url');
				this.externallink.href = entries[i].getAttribute('url');
			}	
			else
			{
				this.external.style.display = 'none';
				this.normal.style.display = 'block';
				if (entries[i].id == 'selected')
					newLi.innerHTML = '<a href="javascript:changeLanguage(\'' + this.curC + '_' + this.curL + '\', \'' + entries[i].getAttribute('url') + '\');" class="current">' + entries[i].innerHTML + '</a>'
				else 
					newLi.innerHTML = '<a href="javascript:changeLanguage(\'' + this.curC + '_' + this.curL + '\', \'' + entries[i].getAttribute('url') + '\');">' + entries[i].innerHTML + '</a>';
				this.languageList.appendChild(newLi);
			}				
		} else {
			this.external.style.display = 'none';
			this.normal.style.display = 'block';
			if (entries[i].id == 'selected')
				newLi.innerHTML = '<a href="javascript:changeLanguage(\'' + this.curC + '_' + this.curL + '\', \'' + c + '_' + entries[i].className + '\');" class="current">' + entries[i].innerHTML + '</a>'
			else 
				newLi.innerHTML = '<a href="javascript:changeLanguage(\'' + this.curC + '_' + this.curL + '\', \'' + c + '_' + entries[i].className + '\');">' + entries[i].innerHTML + '</a>';
			this.languageList.appendChild(newLi);
		}
	}
	this.countrySelector.blur();
}
LanguageSelector.prototype.clearLanguages = function () {
	var list;
	list = this.languageList;
	while (list.hasChildNodes()) {
		list.removeChild(list.firstChild);
	}
}
LanguageSelector.prototype.fill = function () {
	this.clData = lsFrame;
	var entries = this.clData.getHTMLByTag('li')
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].className == 'selected') this.curC = entries[i].id;
	}
	var l = this.clData.getHTMLById('selected');
	this.curL = l.className;
	this.fillSelectbox();
	this.updateLanguages();
}
LanguageSelector.prototype.fillSelectbox = function () {
	var current;
	var newOption;
	var txt, value;
	var entries = this.clData.getHTMLByTag('li');
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].parentNode.parentNode.id == 'langdata') {
			txt = entries[i].innerHTML.substr(0, entries[i].innerHTML.toUpperCase().indexOf('<UL>'));
			value = entries[i].id;
			newOption = document.createElement('option');
			newOption.innerHTML = txt;
			newOption.value = value;
			this.countrySelector.appendChild(newOption);
			if (entries[i].className == 'selected') {
				newOption.selected = true;
				this.initialOption = newOption;
			}
		}
	}
}
LanguageSelector.prototype.getData = function () {
	lsFrame = new RPCFrame(window);
	lsFrame.setLocation('languages.html', createContextFunction(this, "fill"));
}

function changeLanguage (cur, fut) {
	if (fut.indexOf('http:') != -1)
			document.location.href = fut;
	else
	{
		if (document.frmLs.remember.checked == true) {
			setCookie('countryLanguage', fut, 365);
		}
		var params = fut.split("_");
		var curr_params = cur.split("_");

		// if the country has changed, then do not pass a forward URL
		if (curr_params[0] != params[0])
		{
			document.location.href = "../kurdblogger_splash/index.html@country=" + params[0] + "&language=" + params[1] + "&remember=" + document.frmLs.remember.checked;
		}
		else
		{
			var newURL = document.location.href.replace('../../' + cur + '../../default.htm', '../../' + fut + '../../');
			var newHREF = "../kurdblogger_splash/index.html@country=" + params[0] + "&language=" + params[1] + "&remember=" + document.frmLs.remember.checked + "&forwardURL=" + newURL;
			document.location.href = newHREF;		
		}
	}	
}
// Content: js cookies
// Content: js cookies
function setCookie(inName, inValue, inNumberOfDays)
{
	var expDate = new Date ();
	var cookieString;
	
	expDate.setTime (expDate.getTime() + (86400000 * inNumberOfDays));
	var gmtExpDate = expDate.toGMTString();
	
	cookieString = inName + "=" + inValue;
	if (inNumberOfDays != 0)
		cookieString += ";expires=" + gmtExpDate;	
	
	cookieString += ";path=/";	
	document.cookie = cookieString;
}

//this function gets the value of a cookie given it's name
function getCookie (inName)	{
	var dCookie = document.cookie; 
	var cName = inName + "=";
	var cLen = dCookie.length;
	var cBegin = 0;
	while (cBegin < cLen) 	{
		var vBegin = cBegin + cName.length;
		if (dCookie.substring(cBegin, vBegin) == cName) { 
			var vEnd = dCookie.indexOf (";", vBegin);
		    if (vEnd == -1) 
				vEnd = cLen;
			return unescape(dCookie.substring(vBegin, vEnd));
		}
		cBegin = dCookie.indexOf(" ", cBegin) + 1;
		if (cBegin == 0)
			 break;
	}
	return null;
}

//this function will delete a cookie by setting the expiration date in the past
function deleteCookie(inName)	{
	document.cookie = inName + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
// Content: js global
var navFrame, fbFrame;
var arDestinations = new Array();

function initHome() {
	// If the navigation in not loaded on the page, we load in on init.
	// This can be removed after version 1.13 or higher is deployed.
	try {
		if (!(n)) {
			loadNav();
		}
	} catch (e) {
		loadNav();
	}
	// End of temporary fix.
	checkBrowser();
	top.mainContainer = document.getElementById('maincontainer');
	updateSize();
	if (document.getElementById('language_selector')) ls = new LanguageSelector();
	FBfill(true);
	setTriggersHome();
	setOtherKLMSites();
	webSensor();
}
function initLocalHome() {
	// If the navigation in not loaded on the page, we load in on init.
	// This can be removed after version 1.13 or higher is deployed.
	try {
		if (!(n)) {
			loadNav();
		}
	} catch (e) {
		loadNav();
	}
	// End of temporary fix.
	setTriggersHome();
	setOtherKLMSites();
	webSensor();
}
function webSensor() {
	// If the navigation in not loaded on the page, we load in on init.
	// This can be removed after version 1.13 or higher is deployed.
	try {
		if (!(n)) {
			loadNav();
		}
	} catch (e) {
		loadNav();
	}
	// End of temporary fix.
	var cook=document.cookie;
	var i=cook.indexOf('KLMCOM_SESSIONCOOKIE');
	var strResolutie=window.screen.width+"x"+window.screen.height;
	if(i<0)
	{
		var id1=parseInt(Math.random()*2147418112);		
		document.cookie='KLMCOM_SESSIONCOOKIE='+id1+new Date().getTime()+'--'+strResolutie+';path=/;domain=.kurdblogger.com'
	}	
	
	
	strCDom=document.location.host.substring(document.location.host.lastIndexOf('.',document.location.host.lastIndexOf('.') - 1));
	keepdays=180;
	
	cook=document.cookie;
	i=cook.indexOf('MfTrack_js');
	if(i<0){
	        // the cookie was not yet present, create a new cookie
	        id1=parseInt(Math.random()*2147418112);
	        strCVal=id1+'.'+new Date().getTime()+'--'+strResolutie;
	        document.cookie='MfTrack_js='+strCVal+'; path=/; domain='+strCDom;
	}
	strPVal='';
	i=cook.indexOf('MfPers_js=');
	if(i<0){
	        // the cookie was not yet present, create a new cookie
	        id1=parseInt(Math.random()*2147418112);
	        strPVal=id1+'.'+new Date().getTime()+'--'+strResolutie;
	} else {
	        // change expire date of persistent cookie, with same value
	        j=cook.indexOf(";",i+11);
	        if (j<0)
	                strPVal=cook.substring(i+11);
	        else
	                strPVal=cook.substring(i+11, j - i);
	}
	expires=new Date();
	expires.setTime(expires.getTime()+(keepdays*24*60*60*1000));
	document.cookie='MfPers_js='+strPVal+'; path=/; domain='+strCDom+'; expires='+expires.toGMTString();
	
	var qs = window.location.search
	var adcamp = getParameter(qs, "adcamp")
	if (adcamp)
	{
		expires=new Date();
		expires.setTime(expires.getTime()+(30*24*60*60*1000));
		var content = "&adcamp=" + adcamp + "&adchan=" + getParameter(qs, "adchan") + "&adtype=" +
			getParameter(qs, "adtype") + "&adctry=" + getParameter(qs, "adctry") + "&adlang=" +
			getParameter(qs, "adlang") + "&http_referrer=" + document.referrer;
		document.cookie="SADCAMP=" + content + "; path=/; domain=" + strCDom;
		document.cookie="PADCAMP=" + content + "; path=/; domain=" + strCDom + "; expires="+expires.toGMTString();
	}
}
function init() {
	checkBrowser();
	top.mainContainer = document.getElementById('maincontainer');
	if (document.getElementById('language_selector')) ls = new LanguageSelector();
	FBfill();
	updateSize();
	setTriggers();
	setOtherKLMSites();
	webSensor();
}
function FBfill (home) {
	if (document.getElementById('jffp_login')) {
		fbFrame = new RPCFrame(window);
		if (home)
			fbFrame.setLocation('jffp.htm@loadProfile=true&date=' + new Date(), FBfillItHome, 'GET')
		else
			fbFrame.setLocation('jffp.htm@loadProfile=true&date=' + new Date(), FBfillIt, 'GET')
	}
}
function FBfillIt () {
	if (!fbFrame.getHTMLById('content'))
		return;
	toggleMilesPlus();
	try {
		checkBB();
	} catch (e) {}
	var fbNumber = getCookie('fbNumber');
	if (fbNumber)
	{
		var elems = document.getElementsByName('miles');
		for (var i = 0; i < elems.length; i++)
		{
			elems[i].value = fbNumber;
		}
	}
}

function FBfillItHome () {
	
	document.getElementById('bottom').innerHTML = '';
	var fbNumber = getCookie('fbNumber');
	if (fbNumber)
	{
		var elems = document.getElementsByName('miles');
		for (var i = 0; i < elems.length; i++)
		{
			elems[i].value = fbNumber;
		}
	}
}
function loadNav() {
	if (document.getElementById('navigation')) {
		navFrame = new RPCFrame(window);
		navFrame.setLocation('navigation.html', initNavigation);
		try {
			clearInterval(n);
		} catch (e) {
		}
	}
	else {
		return false;
	}
}
function initNavigation () {
	
}
function isChild(ancestor, candidate) {
	if (!ancestor || !ancestor.parentNode || !candidate) return false;
	while (candidate && candidate != ancestor.parentNode) {
		if (candidate == ancestor) return true;
		try {
			candidate = candidate.parentNode;
		} catch (c) {return false}
	}
}
function createContextFunction(context, method, method2) {
	return (function(x){
		method = (method == "post") ? method2 : method;
		eval("context."+method+"(x)");
		return false;
	});
}
function initSpecials() {
	var entries = document.getElementsByTagName('div');
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].className == 'specials') {
			var specials = entries[i].getElementsByTagName('li');
			for (var j = 0; j < specials.length; j++) {
				if (specials[j].getElementsByTagName('a').length > 0)
				{
					specials[j].link = specials[j].getElementsByTagName('a')[0].href;
					specials[j].getElementsByTagName('a')[0].removeAttribute("href");
					if (specials[j].getElementsByTagName('a')[0].target=='_blank')
						specials[j].onclick = function () {window.open(this.link)};
					else
						specials[j].onclick = function () {document.location.href = this.link};
				}
				specials[j].onmouseover = function () {this.className = "over"}
				specials[j].onmouseout = function () {this.className = ""};
			}
		}
	}
}
function initSpecials_mp() {
	var entries = document.getElementsByTagName('div');
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].className == 'specials_jffp') {
			var specials = entries[i].getElementsByTagName('li');
			for (var j = 0; j < specials.length; j++) {
				specials[j].link = specials[j].getElementsByTagName('a')[0].href;
				specials[j].getElementsByTagName('a')[0].removeAttribute("href");
				specials[j].onclick = function () {document.location.href = this.link};
				specials[j].onmouseover = function () {this.className = "over"}
				specials[j].onmouseout = function () {this.className = ""};
			}
		}
	}
}
function setTriggers() {
	var entries = document.getElementsByTagName('div');
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].className.indexOf('TRIG') != -1) {
			entries[i].outline = entries[i].getElementsByTagName('div')[0];
			// create an exception for specials trigger
			if(entries[i].outline.className.indexOf('specials') == -1) {
				entries[i].link = entries[i].getElementsByTagName('a')[0];
				entries[i].onmouseover = function (e) {
					this.outline.oldClassName = this.outline.className;
					this.outline.className += "over";
				}
				entries[i].onmouseout = function (e) {
					this.outline.className = this.outline.oldClassName;
				}
				entries[i].onclick = function () {
					if (this.className.indexOf('newWin') != -1) {
						if (this.className.indexOf('KANA') !=-1) {
							window.open(this.link,'kana','width=400,height=300');
						}
						else if (this.className.indexOf('LSW') !=-1) { //local shop window
							window.open(this.link,'lsw','width=815,height=600,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,status=yes');
						}
						else {
							window.open(this.link);
						}	
					}
					else {
						document.location.href = this.link;
					}
				}
			}
		}
	}
}
function setTriggersHome() {
	var entries = document.getElementsByTagName('div');
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].className.indexOf('TRIG') != -1) {
			entries[i].link = entries[i].getElementsByTagName('a')[0];
			entries[i].onmouseover = function (e) {
				this.className += " TRIGOVER";
			}
			entries[i].onmouseout = function (e) {
				this.className = this.className.replace(" TRIGOVER","");
			}
			entries[i].onclick = function () {
				if (this.className.indexOf('newWin') != -1) {
					if (this.className.indexOf('KANA') !=-1) {
						window.open(this.link,'kana','width=400,height=300');
					}
					else if (this.className.indexOf('LSW') !=-1) { //local shop window
						window.open(this.link,'lsw','width=815,height=600,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,status=yes');
					}
					else {
						window.open(this.link);
					}
					this.link.disabled = true;
				}
				else {
					document.location.href = this.link;
				}
			}
		}
	}
}
function setPromos() {
	var entries = document.getElementsByTagName('div');
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].className.indexOf('nonair') != -1) {
			entries[i].outline = entries[i].getElementsByTagName('span')[0];
			entries[i].link = entries[i].getElementsByTagName('a')[0];
			entries[i].onclick = function () {document.location.href = this.link};
			entries[i].onmouseover = function (e) {
				this.outline.oldClassName = this.outline.className;
				this.outline.className += "over";
			}
			entries[i].onmouseout = function (e) {
				this.outline.className = this.outline.oldClassName;
			}
		}
	}
}

function toggleMilesPlus() {
	var miles = document.getElementById('mpopen');
	var milesplusblock = document.getElementById('jffpcontentcontainer');
	var seealsoblock = document.getElementById('seealso');
	if (milesplusblock != null) {
		milesplusblock.style.display = "none";
		var milesclose = document.getElementById('bottom');
		miles.onclick = function() {
			setCookie("mpopen", "true", 0);
			if (milesplusblock.style.display == 'none') {
				milesplusblock.style.display = 'block';
				if (seealsoblock) seealsoblock.style.top = (milesplusblock.offsetHeight- 35) + "px";
			} else {
				milesplusblock.style.display = 'none';
				if (seealsoblock) seealsoblock.style.top = "0";
			}
		}
		milesclose.onclick = function() {
			setCookie("mpopen", "false", 0);
			if (milesplusblock.style.display == 'none') {
				milesplusblock.style.display = 'block';
				if (seealsoblock) seealsoblock.style.top = (milesplusblock.offsetHeight - 35) + "px";
			} else {
				milesplusblock.style.display = 'none';
				if (seealsoblock) seealsoblock.style.top = "0";
			}
		}
		var mpopen = getCookie("mpopen");
		var b_open = mpopen == null ? top.FBopen : (mpopen == "true");
		if (b_open) {
			milesplusblock.style.display = 'block';
			if (seealsoblock) seealsoblock.style.top = (milesplusblock.offsetHeight - 35) + "px";
		}
	}
}
function addEventHandler(element, type, handler) {
	try {
		element.addEventListener(type, handler, false);
	} catch(inferiorBrowserException) {
		if(element.attachEvent) 
			element.attachEvent('on'+type, handler);
		else 
			element['on'+type] = handler;
	}
	return [element, type, handler];
}
function isSafari() {
	return (/safari/i).test(navigator.userAgent);
}

function removeEventHandler(o, eventName, handler) {
	if (o.removeEventListener) {
		o.removeEventListener(eventName, handler, true);
	} else {
		o.detachEvent("on"+eventName, handler);
	}
}
function cancelEvent(e) {
	try {
		e.preventDefault();
		e.stopPropagation();
	} catch (someException) {
		e.cancelBubble = true;
		e.returnValue = false;
	}
	if (isSafari()) {
		var target = e.target;
		while (target.nodeType > 1) target = target.parentNode;
	 	if (/^a$/i.test(target.nodeName)) {
	 		target.onclick = function() {
				return false;
			};
		}
	}
	return false;
}

function calculateTop(object) {if (object) return object.offsetTop + calculateTop(object.offsetParent); else return 0;}
function calculateLeft(object) {if (object) return object.offsetLeft + calculateLeft(object.offsetParent); else return 0;}

function scaleFrame() {
	var f = document.getElementById('extFrame');
	var top;
	top = calculateTop(f);
	f.style.height = getWindowHeight() - top + "px";
	document.body.style.overflow = "hidden"; // for firefox and mozilla
	document.body.parentNode.style.overflow = "hidden"; // for ie
}
function getWindowHeight() {
var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight=window.innerHeight;
	} else {
		if (document.documentElement&&document.documentElement.clientHeight) {
			windowHeight=document.documentElement.clientHeight;
		} else if (document.body&&document.body.clientHeight) windowHeight=document.body.clientHeight;
	}
	return parseInt(windowHeight);
}
function setOtherKLMSites() {
	var s = document.getElementById('otherKLMsites');
	if (s) {
		s.onchange = function () {
			var strArr = this.options[this.selectedIndex].value.split("|");
			if (strArr[0] != "#") {
				if (strArr[1] == "New window" || strArr[1] == "Popup") {
					window.open(strArr[0],"_blank");
				} else {
					document.location.href = strArr[0];
				}
			}
		}
	}
}

function logOutJFFP () {
	deleteCookie('jffp');
	var location = '../logon/ae_en@logOut=true';
	if (typeof(currentDashboard) != "undefined")
		location += "&db=" + currentDashboard.selectedTab;
	document.location.href = location
}
function checkBB () {
	if (getCookie('kurdbloggercomcaas') == 'b2b') {
		document.getElementById('loginbar').style.display = 'none';
		document.getElementById('loggedinbar').style.display = 'block';
	} else {
		document.getElementById('loginbar').style.display = 'block';
		document.getElementById('loggedinbar').style.display = 'none';
	}
}
function checkLoggedin () {
	if (getCookie('jffp')) {
		if (getCookie('jffp').length > 10) {
			return true;
		}
	}
	return false;
}

function checkLogin () {
	if (getCookie('jffp')) {
		if (getCookie('jffp').length > 10) {
			document.getElementById('IN').style.display = 'block';
		} else {
			document.getElementById('OUT').style.display = 'block';
		}
	} else {
		document.getElementById('OUT').style.display = 'block'
	}
}

function initConditions() {
	var entries = document.getElementsByTagName('a');
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].className == 'CONDITIONS') {
			entries[i].layer = entries[i].parentNode.getElementsByTagName('div')[0];
			entries[i].container = entries[i].parentNode.parentNode.parentNode.parentNode.parentNode;
			entries[i].layer.closer = entries[i].layer.getElementsByTagName('div')[0];
			entries[i].layer.closer.container = entries[i].container;
			entries[i].layer.closer.onclick = function () {
				this.parentNode.style.display = 'none';
				//this.container.style.position = 'static';
			}
			entries[i].onclick = function () {
				closeOthers();
				//this.container.style.position = 'relative';
				this.layer.style.display = 'block';
				var high = this.layer.offsetHeight;
				var newY = 0 - high + 'px';
				this.layer.style.marginTop=newY;
			}
		}
	}
}
function closeOthers () {
	var entries = document.getElementById('content').getElementsByTagName('div');
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].className == 'conditionslayer')
			entries[i].style.display = 'none';
		if (entries[i].className == 'webawards')
			entries[i].style.position = 'static';
	}
}
function initWABanner () {
	var wa = document.getElementById('webawards');
	if (wa) {
		wa.link = wa.getElementsByTagName('a')[0].href;
		wa.onclick = function () {document.location.href = this.link};
	}
}
function milesPlusLogon(){
	var strLocation;
	strLocation = "../../../https@/" + document.location.hostname + "/travel/logon/ae_en?forwardurl=/ae_en";
	if (currentDashboard)
		strLocation += "@db=" + currentDashboard.selectedTab;
	document.forms.frmJFFP.action=strLocation;
	document.forms.frmJFFP.submit();
}

function checkBrowser() {
	var browser = 'unknown';
	browser = getBrowser();
	if ((browser == 'TUX_FF') || (browser == 'TUX_MOZ') || (browser == 'TUX_OP') || (browser == 'MAC_OP') || (browser == 'WIN_OP') || (browser == 'WIN_IE7') || (browser == 'WIN_IE6') || (browser == 'WIN_IE55') || (browser == 'WIN_IE50') || (browser == 'WIN_MOZ')|| (browser == 'WIN_FF') || (browser == 'MAC_SAF') || (browser == 'MAC_FF') || (browser == 'MAC_MOZ')) {
		//browser ok, so to 'normal' site
		return;
	}
	else {
		//wrong browser, so to 'browsersupport' page
		document.location.href = '../kurdblogger_splash/browsersupport.html';
	}
}
function getParameter ( queryString, parameterName ) {
	var parameterName = parameterName + "=";
	if ( queryString.length > 0 ) {
		begin = queryString.indexOf ( parameterName );
		if ( begin != -1 ) {
			begin += parameterName.length;
			end = queryString.indexOf ( "&" , begin );
			if ( end == -1 ) {
				end = queryString.length
			}
			return unescape ( queryString.substring ( begin, end ) );
		}
	return null;
	}
}
function getBrowser () {
	var mvIndex;
	var mozVers;
	var os = navigator.platform.toLowerCase(); 
	var agt = navigator.userAgent.toLowerCase(); 
	var ver = navigator.appVersion.toLowerCase();
	
	if (os.indexOf('win') != -1) {
		if (agt.indexOf("opera")!=-1) return "WIN_OP";
		else if (agt.indexOf("msie 7.0")!=-1) return "WIN_IE7";
		else if (agt.indexOf("msie 6.0")!=-1) return "WIN_IE6";
		else if (agt.indexOf("msie 5.5")!=-1) return "WIN_IE55";
		else if (agt.indexOf("msie 5.0")!=-1) return "WIN_IE50";
		else if (agt.indexOf("netscape")!=-1) return "Netscape";
		else if (agt.indexOf("firefox")!=-1) return "WIN_FF";
		else if (agt.indexOf("mozilla")!=-1) {
			var mvIndex = agt.indexOf('; rv:1.');
			var mozVers = agt.substr(mvIndex + 7, 1); 
			if (mozVers > 3) return "WIN_MOZ";
		}
	}
	else if (os.indexOf('mac') != -1) {
		if (agt.indexOf("opera")!=-1) return "MAC_OP";
		else if (agt.indexOf("safari")!=-1) {
			var safIndex = agt.indexOf('safari/');
			var safVers = agt.substr(safIndex + 7, 3);
			if (safVers >= 110) return "MAC_SAF";
		}
		else if (agt.indexOf("netscape")!=-1) return "Netscape";
		else if (agt.indexOf("firefox")!=-1) return "MAC_FF";
		else if (agt.indexOf("mozilla")!=-1) {
			var mvIndex = agt.indexOf('; rv:1.');
			var mozVers = agt.substr(mvIndex + 7, 1); 
			if (mozVers > 3) return "MAC_MOZ";
		}
	}
	else {
		if (agt.indexOf("opera")!=-1) return "TUX_OP";
		else if (agt.indexOf("netscape")!=-1) return "Netscape";
		else if (agt.indexOf("firefox")!=-1) return "TUX_FF";
		else if (agt.indexOf("mozilla")!=-1) {
			return "TUX_MOZ";
		}
	}	
}

function checkReturnKey(event, varForm, blnMilesPlusLogon)
{
	var key;
	if(window.event)
		key = window.event.keyCode;     //IE
	else
		key = event.which;     //firefox

	if (key == 13)
	{
		if (blnMilesPlusLogon)
			milesPlusLogon();
		else
		{
			if(varForm!=null)
				varForm.submit();
			return true; // handle submittingoutside after exiting this function if varForm==null
		}
	}
	return false;
}
// Content: js RPCFrame
var autoID = 1;
function OldRPCFrame(targetWindow) {
	this.ID = autoID++;
	this.parent = targetWindow;
	if ((window.navigator.appVersion.search("MSIE 5.0") != -1) && (navigator.platform.indexOf('Mac')==-1)) {
		this.IE50 = true;
		var newFrameHTML = "<iframe id='iframe"+this.ID+"' style='position:absolute;top:" + this.ID + "px;display:block;border:0px;width:1px;height:1px;'></iframe>";
		var d = document.createElement("div");
		d.innerHTML = newFrameHTML;
		document.body.appendChild(d);
		this.HTMLObject = targetWindow.document.getElementById('iframe'+this.ID);
	} else {
		this.IE50 = false;
		var newFrame = document.createElement("iframe");
		newFrame.setAttribute("id", "iframe"+this.ID);
		newFrame.style.position = "absolute";
		newFrame.style.border = "0px";
		newFrame.style.width = "0px";
		newFrame.style.height = "0px";
		this.HTMLObject = document.body.appendChild(newFrame);
	}
	return this;
}
OldRPCFrame.prototype.setLocation = function (newURL, callBack) {
	this.HTMLObject.src = newURL;
	addEventHandler(this.HTMLObject, "load", callBack);
	if (this.IE50) {
		if (callBack) top.callBack = callBack; else top.callBack = null;
		this.getDocument().onreadystatechange = this.returnToCaller;
	}
}
OldRPCFrame.prototype.returnToCaller = function () {
	if (this.readyState == "complete") {
		if (top.callBack) top.callBack();
	}
}

OldRPCFrame.prototype.getDocument = function () {
	if (this.HTMLObject.contentDocument) {
		return this.HTMLObject.contentDocument;
	} else if (this.HTMLObject.contentWindow) {
		return this.HTMLObject.contentWindow.document;
	} else if (this.HTMLObject.document) {
		if (navigator.platform.indexOf('Mac') != -1) {
			return this.parent.document.frames["iframe"+this.ID].document;
		} else {
			return this.parent.frames["iframe"+this.ID].document;
		}
	}
}
OldRPCFrame.prototype.destroy = function () {
	this.ID = null;
	this.HTMLObject.removeNode(true);
}
OldRPCFrame.prototype.getHTMLById = function (id) {
	return this.getDocument().getElementById(id);
}
OldRPCFrame.prototype.getHTMLByTag = function (tag) {
	return this.getDocument().getElementsByTagName(tag);
}

function getHTMLById(element, id) {
	var children = element.childNodes
	for (var i=0;i<children.length;i++) {
		if (children[i].id) {
			if (children[i].id == id) {
				return children[i];
			}
		}
		var child = getHTMLById(children[i], id);
		if (child != null) {
			return child;
		}
	}
	return null;	
}

var oldResponseText="";
function RPCFrame(targetWindow) {
	this.setLocation = function (newURL, callBack) {
		mycallback = callBack;
		xmlhttp.open("GET", newURL ,true);
		xmlhttp.onreadystatechange = this.myonreadystatchange;
		xmlhttp.send(null);
	}

	this.myonreadystatchange = function() {
		if (xmlhttp.readyState == 4 && oldResponseText!=xmlhttp.responseText) {
			var container = document.createElement("DIV");
			container.innerHTML = xmlhttp.responseText; 
                                                oldResponseText=xmlhttp.responseText;
			mycontent = container;
			mycallback();
		}
	}
	
	this.getDocument = function () {
		return mycontent;
	}

	this.destroy = function () {
		mycontent = null;;
	}

	this.getHTMLById = function (id) {
		return getHTMLById(mycontent, id);
	}

	this.getHTMLByTag = function (tag) {
		return mycontent.getElementsByTagName(tag);
	}


	var xmlhttp;
	var mycallback;
	var mycontext;
	var mycontent;
	try {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	} catch (e) {
		try {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		} catch (E) {
			xmlhttp=false
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	// In case xmlrpc is not supported we will fallback to the old method.
	if(!xmlhttp) {
		return new OldRPCFrame(targetWindow);
	}
	return this;
}
// Content: js dashboard
var currentDashboard = null; // ppkpatch

function Dashboard (home, selected, app) {
	this.loadtext = null;
	this.container = document.getElementById('dashboard');
	home ? this.home = true : this.home = false;
	app ? this.app = true : this.app = false;
	this.toolContainer = document.getElementById('tool');
	this.initTabs();
	this.selectedTab = null;
	this.images = null; // ppkpatch
	this.sourceFrame = new RPCFrame(window);
	if (!this.home) {
		this.bottomImage = document.getElementById('db_bottom');
		this.toolContainer.style.display = 'none';
	} else {
		var tabId = 0;
		if (selected) {
			if (checkLoggedin() && selected == "db_ici")
				selected = "db_ici_jffp";
			else if (!checkLoggedin() && selected == "db_ici_jffp")
				selected = "db_ici";
			else if (selected == "db_tt" && this.tabs[selected] == null)
				selected = "db_tt2";
			tabId = selected;
		} else {
		}
		// Check if dashboard is inline or it needs to be loaded
		if (tabId == "db_ebt" && document.getElementById("destinationcontainer") != null)
		{
			this.selectTab(tabId);
			fill_ebt();
			this.toolContainer.style.display = 'block';
		} else
			this.openTab(tabId);
	}
}
Dashboard.prototype.initTabs = function () {

}
Dashboard.prototype.initTab = function (i) {
	var li = this.tabs[i];
	li.a = li.getElementsByTagName('a')[0];
	if (this.app) li.a.href = 'emptycontentdashboardpage.htm@db=' + li.id;
	//if user is logged in (jffp cookie) then set ici tab to jffp version
	if (checkLoggedin() && li.id == "db_ici") {
			li.id = "db_ici_jffp";
	}
	if (i == 0) li.className = 'first';
	li.dashboard = this;
	li.onclick = function () {
		if (this.dashboard.app) {
			document.location.href = 'emptycontentdashboardpage.html@db=' + this.id;
		} else {
			this.a.blur();
			this.dashboard.openTab(this.id);
		}
	}
}
Dashboard.prototype.openTab = function (id) {
	if (id == this.selectedTab && (!this.home)) {
		this.close();
		return;
	}
	this.selectTab(id);
	if (this.loadtext = null) {
		this.loadtext = setTimeout(createContextFunction(this, "showLoadText"), 500);
	}
	this.tabId = id;	
	this.sourceFrame.setLocation("dashboard/" + id + ".html", createContextFunction(this, "loadContentInitialize")); // ppkpatch -> Initialize
	if (!this.home) this.bottomImage.style.display = 'none';
}
Dashboard.prototype.showLoadText = function () {
	this.toolContainer.innerHTML = "loading...";
}
/* Start ppkpatch */

/* Principle: the new page is only loaded into the Dashboard when all images have finished loading.
	loadContentInitialize() prepares this check. checkNumberOfImages() checks if all images have
	been loaded (readyState == 'complete'). If they haven't, set a timeout to try again in 100
	milliseconds.
	Drawback: there may be a slight waiting period between the clicking of the tab and the 
	appearance of the new content.
*/

Dashboard.prototype.loadContentInitialize = function () {
}

Dashboard.prototype.checkNumberOfImages = function()
{
	var numberOfImages = this.images.length;
	if (!this.images[0].readyState) // Mozilla
	{
		this.loadContent();
		return;
	}
	var imageCounter = 0;
	for (var i=0;i<numberOfImages;i++)
	{
		if (this.images[i].readyState == 'complete')
			imageCounter++;
	}
	if (imageCounter != numberOfImages)
		setTimeout('currentDashboard.checkNumberOfImages()',100)
	else
		this.loadContent();
	
}

/* End ppkpatch */

Dashboard.prototype.loadContent = function () {
	if (this.loadtext) {clearTimeout(this.loadtext);this.loadtext = null}
	this.toolContainer.innerHTML = this.sourceFrame.getHTMLById('content').innerHTML;
	this.toolContainer.style.display = 'block';
	if (!this.home) this.createCloser();
	fill_db(this.tabId);	
}
Dashboard.prototype.createCloser = function () {
	var c = document.createElement('div');
	c.id = 'db_close';
	c.onclick = createContextFunction(this, "close");
	this.toolContainer.appendChild(c);
}
Dashboard.prototype.getTabIndex = function (selected) {
	for (var i=0; i < this.tabs.length; i++) {
		if (this.tabs[i].id == selected) return i;
	}
	return 0;
}
Dashboard.prototype.selectTab = function (i) {
	if (this.selectedTab != null) {
		this.tabs[this.selectedTab].className =  this.tabs[this.selectedTab].className.replace('selected', '');
	}
	this.selectedTab = i;
}
Dashboard.prototype.close = function () {
	if (this.selectedTab != null) this.tabs[this.selectedTab].className =  this.tabs[this.selectedTab].className.replace('selected', '');
	this.selectedTab = null;
	this.toolContainer.style.display = 'none';
	if (!this.home) this.bottomImage.style.display = 'block';
}

function switchBox(action, element) {	
	
	if(action == 'show'){
		document.getElementById(element).style.display = 'block';
	}
	if(action == 'hide'){
		document.getElementById(element).style.display = 'none';
	}
	
}

function getAirportName(sAirport)
{
	var ret;
	
	ret = sAirport;
	
	// check for space bracket in the airport name
	var posBracket = sAirport.indexOf(" (");
	
	// if found, remove the end part to return only the city name 
	if (posBracket > 0)
	{
		ret = sAirport.substring(0, posBracket);
	}
	return ret;
}


function addURLParam(sURL, sParam, sValue)
{
	var strSep = "";
	
	strSep = "?";
	if (sValue != "")
	{
		if (sURL.indexOf("?") >= 0)
			strSep = "&";

		return (sURL + strSep + sParam + "=" + sValue);
	}
	else
		return (sURL);	

}

function doSubmitTP(appPageURL1, appPageURL2)
{
	var nrRooms, nrAdults, nrChildren, nrSeniors, pkgType;
	var i, n;
	var sBaseURL;
	
	// check to which URL we will submit
	nrRooms = document.frmTp.nrRooms.value;
	nrAdults = document.frmTp.nrAdults.value;
	nrSeniors = document.frmTp.nrSeniors.value;
	nrChildren = document.frmTp.nrChildren.value;

	// get the selected package type
	for (i=0, n=document.frmTp.arrangement.length; i<n; i++) 
	{
    		if (document.frmTp.arrangement[i].checked)
    		{
        		pkgType = document.frmTp.arrangement[i].value;
	        	break;
    		}
	}

	var origin = document.frmTp.origin.value;

	// the packages wizard needs a city name, so use this name without possible (airport name) in it
	var dest = getAirportName(document.frmTp.destination_free.value);
	var depDate = document.frmTp.departureDay.value + "../../" + document.frmTp.departureMonthYear.value.substr(4) + "../../" + document.frmTp.departureMonthYear.value.substring(0,4);
	var retDate = document.frmTp.returnDay.value + "../../" + document.frmTp.returnMonthYear.value.substr(4) + "../../" + document.frmTp.returnMonthYear.value.substring(0,4);

	if (dest == "Other")
	{
		sBaseURL = appPageURL2;
		sBaseURL = addURLParam(sBaseURL, "PackageType", pkgType);
		sBaseURL = addURLParam(sBaseURL, "FrAirport", origin);
		sBaseURL = addURLParam(sBaseURL, "DestID", dest);
		sBaseURL = addURLParam(sBaseURL, "FromDate", depDate);
		sBaseURL = addURLParam(sBaseURL, "ToDate", retDate);
		sBaseURL = addURLParam(sBaseURL, "NumAdult", nrAdults);
		sBaseURL = addURLParam(sBaseURL, "NumSenior", nrSeniors);
		sBaseURL = addURLParam(sBaseURL, "NumChild", nrChildren);
		sBaseURL = addURLParam(sBaseURL, "NumRoom", nrRooms);
	}
	else if (nrRooms >= 2 && nrAdults == 2 && nrChildren == 0 && nrSeniors == 0)
	{
		sBaseURL = appPageURL1;
		sBaseURL = addURLParam(sBaseURL, "PackageType", pkgType);
		sBaseURL = addURLParam(sBaseURL, "FrAirport", origin);
		sBaseURL = addURLParam(sBaseURL, "DestID", dest);
		sBaseURL = addURLParam(sBaseURL, "FromDate", depDate);
		sBaseURL = addURLParam(sBaseURL, "ToDate", retDate);
		sBaseURL = addURLParam(sBaseURL, "NumAdult", 2);
		sBaseURL = addURLParam(sBaseURL, "NumAdult1", 1);		
		sBaseURL = addURLParam(sBaseURL, "NumAdult2", 1);				
		sBaseURL = addURLParam(sBaseURL, "NumSenior", 0);
		sBaseURL = addURLParam(sBaseURL, "NumChild", 0);
		sBaseURL = addURLParam(sBaseURL, "NumRoom", 2);
	}
	else if (nrRooms <= 1 && nrAdults <= 3 && nrChildren == 0 && nrSeniors <= 3)
	{
		sBaseURL = appPageURL1;
		sBaseURL = addURLParam(sBaseURL, "PackageType", pkgType);
		sBaseURL = addURLParam(sBaseURL, "FrAirport", origin);
		sBaseURL = addURLParam(sBaseURL, "DestID", dest);
		sBaseURL = addURLParam(sBaseURL, "FromDate", depDate);
		sBaseURL = addURLParam(sBaseURL, "ToDate", retDate);
		sBaseURL = addURLParam(sBaseURL, "NumAdult", nrAdults);
		sBaseURL = addURLParam(sBaseURL, "NumSenior", nrSeniors);
		sBaseURL = addURLParam(sBaseURL, "NumChild", nrChildren);
		sBaseURL = addURLParam(sBaseURL, "NumRoom", nrRooms);
	}
	else
	{
		sBaseURL = appPageURL2;
		sBaseURL = addURLParam(sBaseURL, "PackageType", pkgType);
		sBaseURL = addURLParam(sBaseURL, "FrAirport", origin);
		sBaseURL = addURLParam(sBaseURL, "DestID", dest);
		sBaseURL = addURLParam(sBaseURL, "FromDate", depDate);
		sBaseURL = addURLParam(sBaseURL, "ToDate", retDate);
		sBaseURL = addURLParam(sBaseURL, "NumAdult", nrAdults);
		sBaseURL = addURLParam(sBaseURL, "NumSenior", nrSeniors);
		sBaseURL = addURLParam(sBaseURL, "NumChild", nrChildren);
		sBaseURL = addURLParam(sBaseURL, "NumRoom", nrRooms);
	}
	sBaseURL = addURLParam(sBaseURL, "rfrr", "-37510");

	document.frmTp.action = sBaseURL;
	document.frmTp.submit();
}

function doSubmitReservation(sUrl)
{
	document.res_book.action = sUrl;
	document.res_book.submit();
}
// Content: js dashboard data
var months = [			
	['Jan','January'],
	['Feb','February'],
	['Mar','March'],
	['Apr','April'],
	['May','May'],
	['Jun','June'],
	['Jul','July'],
	['Aug','August'],
	['Sep','September'],
	['Oct','October'],
	['Nov','November'],
	['Dec','December']];

function fillDataSelector(id, fullMonthNames, addDays)
{
	var now = new Date();
	var start = new Date(now.getTime() + addDays * 3600 * 24 * 1000);
	var year = now.getFullYear();
	var month = now.getMonth();
	var selector = document.getElementById(id);
	for (c = 0; c < 12; c++) {
		var value = String(year) + String(month<9 ? "0" : "") + String(month + 1);
		var name = months[month][fullMonthNames ? 1:0] + " " + year;
		selector[c] = new Option(name, value);
		if (++month >= 12) {
			month = 0;
			year++;
		}
	}
	selector.selectedIndex = start.getYear() > now.getYear() ? 1 : (start.getMonth() > now.getMonth() ? 1 : 0);
}

function fillDaySelector(idDay, addDays)
{
	var daySelector = document.getElementById(idDay);
	var index = 0;
	for (var c = 1; c <= 31; c++)
	{
		var value = String(c<=9 ? "0" : "") + String(c);
		daySelector.options[index++] = new Option(c, value);
	}	
}

function setDay(idDay, addDays)
{
	var start = new Date(new Date().getTime() + addDays * 3600 * 24 * 1000);
	document.getElementById(idDay).selectedIndex = start.getDate() - 1;
}

function checkDepDate(dep_date, dep_month, ret_date, ret_month)
{
	var dds = document.getElementById(dep_date);
	var rds = document.getElementById(ret_date);
	var dms = document.getElementById(dep_month);
	var rms = document.getElementById(ret_month);
	if (dms.selectedIndex > rms.selectedIndex ||
		(dms.selectedIndex == rms.selectedIndex && dds.selectedIndex > rds.selectedIndex))
		{
			rms.selectedIndex = dms.selectedIndex;
			rds.selectedIndex = dds.selectedIndex;
		}	
}

function fillFromXml(file, id, className, addEmpty)
{
	var xmlhttp = getXmlHttp();
	xmlhttp.open("GET", file ,false);
	xmlhttp.send(null);
	var dataDocument = xmlhttp.responseXML;
	var entries = dataDocument.getElementsByTagName('li');
	var selector = document.getElementById(id);
	var index = 0;
	if (addEmpty) {
		var option = new Option("", "");
		selector.options[index++] = option;
	}
	for (var i = 0; i < entries.length; i++)
	{
		if (entries[i].parentNode.attributes.length > 0 && entries[i].parentNode.attributes[0].nodeValue != className)
			continue;
		
		var name = entries[i].firstChild.data;
		var value = entries[i].attributes.length > 0 ? entries[i].attributes[0].nodeValue : name;
		var isDefault = entries[i].getAttribute("default") != null;
		if (value == "KL")
			isDefault = true;
		var option = new Option(name, value);
		if (isDefault) {
			option.selected = true;
			selector.options[index] = option;
			selector.selectedIndex = index++;
		} else {
			selector.options[index++] = option;		
		}
	}
}

function fill_ebt()
{
	fillDataSelector('dep_month', 0, 7);
	fillDataSelector('ret_month', 0, 14);
	fillDataSelector('calendarmonth', 1, 0);
	
	fillDaySelector('dep_day', 7);
	setDay('dep_day', 7);
	fillDaySelector('ret_day', 14);
	setDay('ret_day', 14);

	new TravelAgent();

	var bbmember = getParameterTD("bb");
	if (bbmember) {
		document.book2.corporateSupport.checked = true;
	}
}

function fill_ici()
{
	fillFromXml("../xfd/ici/departures/en/departures.xml", "flightnumb", "carriers", false);
}
function fill_ici_jffp()
{
	var dateSelection = document.getElementById("ffSearchDay");
	var today = new Date();
	var tomorrow = new Date(today.getTime() + 24 * 3600000);
	var date0 = today.getDate() + " " + months[today.getMonth()][1];
	var date1 = tomorrow.getDate() + " " + months[tomorrow.getMonth()][1];
	dateSelection.options[0] = new Option(date0, 0);
	dateSelection.options[1] = new Option(date1, 1);
}

function fill_tt()
{
	fillDataSelector('dep_month', 0, 7);
	fillDataSelector('ret_month', 0, 14);
	fillDataSelector('calendarmonth', 1, 0);
	
	fillDaySelector('dep_day', 7);
	setDay('dep_day', 7);
	fillDaySelector('ret_day', 14);
	setDay('ret_day', 14);
	var xmlhttp = getXmlHttp();
	xmlhttp.open("GET", location.protocol + "//www.kurdblogger.com/passage/onlinetimetable/TaskManager/Timetable/OTTData-v.5.asp?lang=en&cc=ae" ,false);
	xmlhttp.send(null);
	var dataDocument = xmlhttp.responseXML;
	var stations = dataDocument.getElementsByTagName('station');
	var options1 = "";
	var options2 = "";
	for (var i = 0; i < stations.length; i++)
	{
		var code = stations[i].getAttribute("code");
		var content = stations[i].firstChild.data;
		var option = "<option value=\"" + code + "\">" + content + "</option>";
		options2 = options2 + option;
		if (stations[i].getAttribute("preferred") != null || stations[i].getAttribute("preselect") != null)
			options1 = options1 + option;
	}
	var options = options1 + "<option>--------------------------------------------------</option>" + options2;
	var dest = "<select name=\"Dest\" class=\"dest_hide\" id=\"from\">"  + options + "</select>"
	var org  = "<select name=\"Org\" class=\"dest_hide\" id=\"to\">"  + options + "</select>"

	document.getElementById("DestSelect").innerHTML = dest;
	document.getElementById("OrgSelect").innerHTML = org;
	// The following lines are there to make sure that the select boxes are displayed correctly in IE
	document.getElementById("OrgSelect").contentEditable = true;
	document.getElementById("OrgSelect").contentEditable = false;
	document.getElementById("DestSelect").contentEditable = true;
	document.getElementById("DestSelect").contentEditable = false;
}
function fill_tp()
{
	fillDataSelector('dep_month', 0, 7);
	fillDataSelector('ret_month', 0, 14);
	fillDataSelector('calendarmonth', 1, 0);
	
	fillDaySelector('dep_day', 7);
	setDay('dep_day', 7);
	fillDaySelector('ret_day', 14);
	setDay('ret_day', 14);

	new TPAgent();
}

/* TPAgent */
TPAgent = function() {

	var aRE = /^a$/i
	
	var travelagent = this;
	var traveldata = new TravelData();
	var origins = new Origins(document.getElementById("from"));
	
	var fillAirport = function(airport) {
		var from = document.getElementById("from");
		var fromClass = origins.classes[from[from.selectedIndex].value];
		travelagent.destination.value = airport;
		var xmlelem = traveldata.getAirport(airport);
		travelagent.dest_airportcode.value = xmlelem.getAttribute("code");
		travelagent.dest_classcode.value = xmlelem.getAttribute("class");
		// set classes
		travelagent.setClasses(fromClass, travelagent.dest_classcode.value);
	}
}


function fill_db(db_id)
{
	switch(db_id)
	{
		case 'db_ebt':
		case 'db_ebr':
			fill_ebt();
			break;
		case 'db_tt2':
		case 'db_tt':
			fill_tt();
			break;
		case 'db_ici':
			fill_ici();
			doPrefill();
			break;
		case 'db_ici_jffp':
			fill_ici_jffp();
			break;
		case 'db_tp':
			fill_tp();
			break;
	}
	
}


function getXmlHttp() {
	var xmlhttp;
	if (window.ActiveXObject) {
		try {
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
		} catch (e) {
			try {
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
			} catch (E) {
				xmlhttp=false
			}
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	// In case xmlrpc is not supported we will fallback to the old method.
	if(!xmlhttp) {
		alert("incompatible browser version");
	}
	return xmlhttp;
}

function Transformer(xmlDocument, xslPath) {
	if (window.ActiveXObject) {
		return IETransformer(xmlDocument, xslPath);
	} else {
		return FFTransformer(xmlDocument, xslPath);
	}
}

function FFTransformer(xmlDocument, xslPath) {
	var xmlhttp = getXmlHttp();
	xmlhttp.open("GET", xslPath ,false);
	xmlhttp.send(null);
	var xsltProc = new XSLTProcessor();
	xsltProc.importStylesheet(xmlhttp.responseXML);
	var resultDoc =	xsltProc.transformToDocument(xmlDocument);
	var xmlSerial = new	XMLSerializer();
	return xmlSerial.serializeToString(resultDoc);
}

function IETransformer(xmlDocument, xslPath) {
	var xmlhttp = getXmlHttp();
	xmlhttp.open("GET", xslPath ,false);
	xmlhttp.send(null);
	return xmlDocument.transformNode(xmlhttp.responseXML);
}

function doPrefill() {
	var queryStr = unescape(window.location.search);
	var args;
	var tabToSelect = null;
	if (queryStr != "") {
		queryStr = queryStr.substr(1, queryStr.length);
		var pairs = queryStr.split("&"); //Separate name value pairs
		for (var i = 0; i < pairs.length; i++) {
			args = pairs[i].split("=");

			//ICI param conversion
			if (args[0] == 'eticketAirlineCode') {args[0]="flightnumb";}
			if (args[0] == 'eticketFlightNumber') {args[0]="flightnumb2";}

			var element = document.getElementById(args[0]);
			if (element) {
				try {
					element.value = args[1];
				} catch (e) {}
			}
		}
	}
}
// Content: js kana
function iqWindow(url) {
  var w=740;
  var h=527;
  var X=(screen.width-w)/2;
  var Y=(screen.height-h)/2;
  if(X<=0){
    X=0;
    Y=0;
  }
  url = 'http://faq.kurdblogger.com/SRVS/CGI-BIN/WEBCGI.EXE?New,Kb=e-service_en,Company={D392491E-D19F-494D-AA01-0D1A08B839C6},VarSet=C:ae,VarSet=L:en,' + url;
  newwindow=window.open(url,'sc','top='+Y+',left='+X+',width='+w+',height='+h);
  if (!newwindow.opener) newwindow.opener = self;
}
/* 
	lostboys, december 2006

	De inhoud van dit bestand is in opdracht vervaardigd en eigendom van onze opdrachtgever.
	Niet hergebruiken zonder toestemming. Neem voor vragen contact op met Lost Boys, www.lostboys.nl.
	The contents of this file have been produced for and are the property of our client.
	Do not reuse without permission. Any questions? Please contact Lost Boys, www.lostboys.nl.
*/
Animator = function (startValue, endValue, f, t, r) {
	this.step  = 5;		//The step by which timer counts from 0 to 100
	this.rate  = 5;		//The rate in ms at which steps are taken
	this.power = 2;		//The steepness of the animation curve
	this.type  = this.EASEINOUT;	//The type of easing
	this.duration = 0;		//The total duration
	this.min = startValue;
	this.max = endValue;
	this.isReversing = false;
	this.animateFunction = f;
	this.terminateFunction = t;
	this.reversalFunction = r;
	this.precalc = new Array(100);
	for (var i=0; i <= 100; i++) this.precalc[i] = this.calculate(i);
}
Animator.prototype.NONE      = 0;
Animator.prototype.EASEIN    = 1;
Animator.prototype.EASEOUT   = 2;
Animator.prototype.EASEINOUT = 3;
Animator.prototype.setDuration = function (duration) {
	this.duration = duration;
}
Animator.prototype.setStep = function (step) {
	this.step = step;
}
Animator.prototype.setRate = function (rate) {
	this.rate = rate;
}
Animator.prototype.setPower = function (power) {
	this.power = power;
	for (var i=0; i <= 100; i++) this.precalc[i] = this.calculate(i);
}
Animator.prototype.setType = function (type) {
	this.type = type;
	for (var i=0; i <= 100; i++) this.precalc[i] = this.calculate(i);
}
Animator.prototype.setAnimateFunction = function (f) {
	this.animateFunction = f;
}
Animator.prototype.start = function () {
	if (this.interval) return;
	this.time = 0;
	this.startTime = new Date();
	this.isReversing = false;
	this.interval = setInterval(this.method(this.animate), this.rate);
}
Animator.prototype.reverse = function () {
	this.isReversing = (this.isReversing) ? false : true;
}
Animator.prototype.stop = Animator.prototype.pause = function () {
	if (this.interval) clearInterval(this.interval);
	this.interval = null;
}
Animator.prototype.resume = function () {
	this.interval = setInterval(this.method(this.animate), this.rate);
}
Animator.prototype.isAnimating = function () {
	return Boolean(this.interval);
}
Animator.prototype.animate = function () {
	var finished = false;
	if (this.duration) {
		var now = new Date() - this.startTime;
		if (now < this.duration) {
			this.animateFunction(this.calculate(now/this.duration));
		} else finished = true;
	} else {
		if (this.time >= 0 && this.time <= 100) {
			this.animateFunction(this.precalc[this.time]);
			this.time = (this.isReversing) ? this.time - this.step : this.time + this.step;
		} else finished = true;
	}
	if (finished) {
		this.animateFunction(this.max);
		clearInterval(this.interval);
		this.interval = null;
		if (!this.isReversing && this.terminateFunction) this.terminateFunction();
		if (this.isReversing && this.reversalFunction) this.reversalFunction();
	}
}
Animator.prototype.calculate = function (t) {
	if (!this.duration) t = t/100;
	var factor;
	switch (this.type) {
		case this.NONE      : factor = this.easeNone(t);break;
		case this.EASEIN    : factor = this.easeIn(t);break;
		case this.EASEOUT   : factor = this.easeOut(t);break;
		case this.EASEINOUT : factor = this.easeInOut(t);break;
	}
	return parseInt(this.min + factor*(this.max-this.min));
}
Animator.prototype.easeNone = function (t) {
	return t;
}
Animator.prototype.easeIn = function (t) {
	return Math.pow(t,this.power);
}
Animator.prototype.easeOut = function (t) {
	return 1-this.easeIn(1-t);
}
Animator.prototype.easeInOut = function (t) {
	if (t < 0.5) return this.easeIn(t*2)/2;
	return 0.5+this.easeOut((t-0.5)*2)/2;
}
Animator.prototype.method = function (method) {
	var context = this;
	return function () {
		method.apply(context, arguments);
	}
}
strQgoPopup="0"; 
function initSupportCenterApp4Col() {
	strQgoPopup = "1";
	initSupportCenter();
}
function initSupportCenter() {
	window.supportCenter = new SupportCenter(document.getElementById('qgo'), 382, 54, 870, 400);
	supportCenter.setLocation("../../../https@customer.q-go.net/kurdblogger_ae_en@popup="+strQgoPopup);
	updateSC();
	addEventHandler(window, "resize", updateSC);
}
function updateSC () {
	if (!window.supportCenter) return;
	if (document.body.offsetWidth < 988) {
		supportCenter.resizeWindow(187, 54, 673, 400);
	} else {
		supportCenter.resizeWindow(382, 54, 870, 400);
	}
}
function KeyUp () {
	KeysTyped = true;
}
function SupportCenter(hook, w, h, wo, ho) {
	KeysTyped = false;
	this.hook = hook;
	this.qgo = document.getElementById('qgo');
	this.container = this.hook.appendChild(document.createElement('div'));
	this.container.id = 'supportcenter';
	this.container.innerHTML = 
		'<form method="get" action="#" target="supportframe" onsubmit="return false">\
			<fieldset>\
				<a class="sc-close" href="#">&nbsp;</a>\
				<div id="zoektab" class="actief" onclick="zetActief(\'zoektab\');">\
					<input type="text" class="text" value="Ask your question here (in multiple words)" name="q" maxlength="128" onkeyup="KeyUp();" />\
					<a href="javascript:supportCenter.open(\'../../../https@customer.q-go.net/kurdblogger_ae_en@popup='+strQgoPopup+'\',\'zoektab\',\'\');void(0);" class="qgo-button" id="supportZoekLink"><span>Ask</span></a>\
				</div>\
				<div id="tabcat"><a href="../../../https@customer.q-go.net/kurdblogger_ae_en/faq_cat.ku@popup='+strQgoPopup+'" target="supportframe" onclick="zetActief(\'categorie\');">FAQ overview by category</a></div>\
				<div id="tabfaq"><a href="../../../https@customer.q-go.net/kurdblogger_ae_en/faq.ku@popup='+strQgoPopup+'" target="supportframe" onclick="zetActief(\'top10\');">Top 10 FAQ</a></div>\
				<div id="endtab"></div>\
			</fieldset>\
		</form>\
		<iframe id="supportIEframe" src="static/empty.html" frameborder="0"></iframe>\
		<iframe name="supportframe" id="supportframe" src="static/empty.html" frameborder="0"></iframe>';
	this.closeLink = this.container.getElementsByTagName('a')[0];
	this.buffer = document.getElementById("supportIEframe");
	this.iframe = document.getElementById("supportframe");
	this.form = this.container.getElementsByTagName('form')[0];
	this.form.onsubmit = this.scope(this.open);
	var q = this.form.q;
	q.onfocus = function() {
		if (!KeysTyped) this.value = '';
	}
	q.onblur = function() {
		if(!this.value) {
			this.value = 'Ask your question here (in multiple words)';
			KeysTyped = false;
		}
	}
	this.searchLink = document.getElementById("supportZoekLink");
	this.searchLink.onclick = this.scope(this.open);
	this.closeLink.onclick = this.scope(this.close);
	this.resizeWindow(w,h,wo,ho);
	this.opened = false;
	this.opener = new Animator(0, 100, this.scope(this.resize), this.scope(this.delayToggle));
	this.opener.setDuration(700);
	this.closer = new Animator(100, 0, this.scope(this.resize), this.scope(this.toggle));
	this.closer.setDuration(700);
}
SupportCenter.prototype = {
	isIE6:/msie 6/i.test(navigator.userAgent),
	isSafari:/safari/i.test(navigator.userAgent),
	setLocation:function(url) {
		this.form.action = url;
	},

	open:function(url,functie) {
		if(!this.opened) {
			this.opener.start();
			this.hook.className = 'active';
			this.container.className = 'supportcenter-active';
			if (!url.indexOf)
			{
				url = "../../../https@customer.q-go.net/kurdblogger_ae_en@popup="+strQgoPopup;
				functie = "zoektab";
			}
			if(url.indexOf("http")!= -1)
			{
				this.setLocation(url);
				zetActief(functie)
			}
			if(this.isIE6) this.buffer.style.visibility = 'visible'; // open in IE before animation
		} else {
			this.form.submit();
		}
		return false;
	},

	close:function() {
		if(this.opened) {
			this.display(this.closeLink, false);
			this.container.className = 'supportcenter-active';
			this.show(this.iframe, false);
			this.closer.start();
		}
	},
	
	resizeWindow:function(w, h, wo, ho) {		
		this.width = w;
		this.height = h;
		this.openWidth = wo - w;
		this.openHeight = ho - h;
		this.qgo.style.width = '';
		this.container.style.width = '';
		this.close();
	},

	resize:function(i) {
		var width = Math.round(this.width + (i/100 * this.openWidth));
		var height = Math.round(this.height + (i/100 * this.openHeight));
		var css = this.container.style;
		css.width = width + 'px';
		css.height = height + 'px';	
	},

	delayToggle:function() {
		var call = this.scope(this.toggle);
		setTimeout(call, 200);
	},

	toggle:function() {
		this.opened = !this.opened;
		this.display(this.closeLink, this.opened);
		if(this.opened) {
			this.container.className += ' supportcenter-open';
			this.show(this.iframe, true);
			this.form.submit();
		} else {
			this.hook.className = '';
			this.container.className = '';
			if(this.isIE6) this.buffer.style.visibility = 'hidden'; // close in IE after animation
		}
	},

	display:function(element, display) {
		element.style.display = display? 'block':'none';
	},

	show:function(element, display) {
		element.style.visibility = display? 'visible':'hidden';
		if (display == false) { 
			element.style.width = 1 + 'px'; 
		}
		else if (display == true) {
			resizeSupportIframe(element);
		}
	},

	scope:function(method) {
		var scope = this;
		return function() {
			return method.apply(scope, arguments);
		}
	}
}
function resizeSupportIframe(iframe) {
	var sc = document.getElementById('supportcenter');
	var maxWidth = parseInt(sc.style.width, 10) -1;
	var maxHeight = parseInt(sc.style.height, 10) - 39;
	iframe.style.width = maxWidth + 'px';
	iframe.style.height = maxHeight + 'px';
}
//set active tab for supportcenter
function zetActief(dit){
		document.getElementById('zoektab').className = '';
		document.getElementById('tabcat').className = '';
		document.getElementById('tabfaq').className = '';
		if(dit=='zoektab') {
			document.getElementById('zoektab').className = 'actief';
		}
		else if(dit=='categorie') {
			document.getElementById('tabcat').className = 'actief';
		}
		else if(dit=='top10') {
			document.getElementById('tabfaq').className = 'actief';
		}
		else {
				document.getElementById('zoektab').className = 'actief';
		}
}
//send query to supportcenter
function sendToSupportcenter() {
	sourceInput = document.getElementById('sendtosupportcenter');
	targetInput = document.getElementById('supportcenter').getElementsByTagName('input')[0];
	targetInput.value = sourceInput.value;
	supportCenter.open('../../../https@customer.q-go.net/kurdblogger_ae_en@popup='+strQgoPopup,'zoektab', '');
	void(0);
}
function focusvalue(dit) {
	if(dit.value == 'Ask your question here (in multiple words)') {
		dit.value = '';
	}
}
function blurvalue(dit){
	if(dit.value == '') {
		dit.value = 'Ask your question here (in multiple words)';
	}
}
// Content: js myKLM
// JavaScript Document
// Start myKLM
var frame = null;

function triggerLoader(tD, requestId) {
	
	this.sT = null;
	this.pT = null;
	this.requestId = requestId;
	
	this.init = function (tD) {
		if (tD.className.indexOf('MYKLM') == -1) return false;
		var cD = tD.getElementsByTagName('div');
		for (var i=0;i<cD.length;i++) {
			if (cD[i].className.indexOf("t_s") != -1) this.sT = cD[i];
			if (cD[i].className.indexOf("t_p") != -1) this.pT = cD[i];

		}
		return true;
	}
	
	this.isTargeted = function () {
		return (getCookie("fbNumber") != null);	
	}
	
	this.showS = function() {
		this.sT.className = this.sT.className.replace(/t_s/gi, "t_s_display");
	}
	
	this.loadPT = function () {
		this.pT.className = this.pT.className.replace(/t_p/gi, "t_p_display");
		frame = document.createElement("iframe");
		var newFrame = frame;
		newFrame.className = "mykurdbloggerframe";
		var link = this.pT.getElementsByTagName("a")[0];
		link.href = link.href + "&fbNumber=" + getCookie("fbNumber");
		link.href = link.href + "&requestId=" + this.requestId;
		link.href = link.href.replace("http:", document.location.protocol);
		newFrame.scrolling = "no";
		newFrame.frameBorder=0;
		newFrame.src = link.href;
		this.pT.appendChild(newFrame);
		this.pT.removeChild(link);
	}
	
	if (this.init(tD)) {
		if (this.isTargeted()) {
			this.loadPT();
		} else {
			this.showS();	
		}
	}
}

function setPTs() {
	var requestId = Math.random();
	if (document.getElementById('last')) {
		try {
			clearInterval(tt);
		} catch (e) {
		}
		var entries = document.getElementsByTagName('div');
		for (var i = 0; i < entries.length; i++) {
			if (entries[i].className.indexOf('MYKLM') != -1) {
				var loader = new triggerLoader(entries[i], requestId);
			}
		}

	} else {
		return false;
	}
}

// As soon as the javascript load's we want to initialize the triggers.
var tt = setInterval('setPTs()', 50);

// End myKLM
// Content: js EBT dashboard
/* Utils */
function addEvent(elm, evt, fn) {
	if (elm.addEventListener) {
		elm.addEventListener(evt, fn, false);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on'+evt, fn);
		return r;
	}
	else {
		elm['on'+evt] = fn;
	}
}

function debug(msg) {
	if (!document.all) setTimeout(function() { throw new Error("[debug] " + msg); }, 0);
}

function getXmlHttp() {
	var xmlhttp;
	if (window.XMLHttpRequest) {
	  xmlhttp = new XMLHttpRequest();
	  if (xmlhttp.overrideMimeType) {xmlhttp.overrideMimeType('text/xml')};
	} else if (window.ActiveXObject) {
	  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
	  alert('Perhaps your browser does not support xmlhttprequests?');
	}
	return xmlhttp;
}
	
/* TravelAgent */
TravelAgent = function() {

	var aRE = /^a$/i
	
	var travelagent = this;
	var traveldata = new TravelData();
	var origins = new Origins(document.getElementById("from"));
	
	var fillAirport = function(airport) {
		var from = document.getElementById("from");
		var fromClass = origins.classes[from[from.selectedIndex].value];
		travelagent.destination.value = airport;
		var xmlelem = traveldata.getAirport(airport);
		travelagent.dest_airportcode.value = xmlelem.getAttribute("code");
		travelagent.dest_classcode.value = xmlelem.getAttribute("class");
		// set classes
		travelagent.setClasses(fromClass, travelagent.dest_classcode.value);
	}
	
	var selectAirportFromAutoFill = function(evt) {
		evt = (evt) ? evt : ((window.event) ? event : null);
		if (evt) {
		   	var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
		   	if (elem && aRE.test(elem.nodeName)) {
				var airport = elem.innerHTML;
				fillAirport(airport);
				// close suggestions
				travelagent.dest_suggest.style.display = "none";
			}
		}
	}
	
	var selectAirportFromCountry = function(evt) {
		evt = (evt) ? evt : ((window.event) ? event : null);
		if (evt) {
		   	var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
		   	if (elem) {
				var airport = travelagent.dest_airport.options[travelagent.dest_airport.selectedIndex].innerHTML;
				fillAirport(airport);
			   	closeFindDestination();
		   	}
		}
	}
	
	var fillDestinations = function(evt) {
		// open suggestions
		travelagent.dest_suggest.style.display = "block";
		if (traveldata) {
			// fill box
			travelagent.removeDestinations();
			var searchString = travelagent.destination.value;
			if (searchString == "") {
				travelagent.dest_suggest.style.display = "none";
				if (evt.type == "keyup")
					travelagent.setClasses("all", "all");
				return;
			}
			var elems = traveldata.selectAirportData(searchString);
			if (elems.length > 0) {
				for (var i=0;i < elems.length; i++) {
					var a = document.createElement("a");
					a.setAttribute("href", "#");
					a.setAttribute("onclick", "return false;");
					a.innerHTML = elems[i];
					travelagent.dest_suggest.appendChild(a);
				}
			}
			else {
				travelagent.dest_suggest.style.display = "none";
				//travelagent.setClasses("all", "all");
				return;
			}
		}
	}
	
	/* Destination Finder */
	var showFindDestination = function(evt) {
		// fill only the first time
		if (travelagent.dest_country.childNodes.length < 5) {
			var elems = traveldata.getCountryData();
			if (elems.length > 0) {
				for (var i=0;i < elems.length; i++) {
					var tag = document.createElement("option");
					tag.innerHTML = elems[i];
					travelagent.dest_country.appendChild(tag);
				}
			}
		}
		var containerd = document.getElementById('destinationcontainer');
		if (document.all) {
			var entries = document.getElementsByTagName('select');
			for (var i = 0; i < entries.length; i++) {
				if (entries[i].className == 'dest_hide') {
					entries[i].style.display = 'none';
				}
			}
		}
		containerd.style.display = 'block';
	}
	var closeFindDestination = function(evt) {
		var containerd = document.getElementById('destinationcontainer');
		if (document.all) {
			var entries = document.getElementsByTagName('select');
			for (var i = 0; i < entries.length; i++) {
				if (entries[i].className == 'dest_hide') {
					entries[i].style.display = 'block';
				}
			}
		}
		containerd.style.display = 'none';
	}
	var findAirports = function(evt) {
		evt = (evt) ? evt : ((window.event) ? event : null);
		if (evt) {
		   	var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
		   	if (elem) {
				var country = elem.options[elem.selectedIndex].innerHTML;
				var elems = traveldata.getAirportData(country);
				if (elems.length > 0) {
					travelagent.dest_airport.options.length = 0;
					for (var i=0;i < elems.length; i++) {
						var tag = document.createElement("option");
						tag.innerHTML = elems[i];
						travelagent.dest_airport.appendChild(tag);
					}
					// prefill first airport in form
					var default_airport = elems[0];
					fillAirport(default_airport);
				}
			}
		}
	}

	this.destination = document.getElementById("dest_fill");
	addEvent(this.destination, "focus", fillDestinations);
	addEvent(this.destination, "keyup", fillDestinations);
	
	this.dest_airportcode = document.getElementById("dest_code_fill");
	this.dest_classcode = document.getElementById("dest_class_fill");
	
	this.dest_country = document.getElementById("dest_country");
	addEvent(this.dest_country, "change", findAirports);
	
	this.dest_airport = document.getElementById("dest_airport");
	addEvent(this.dest_airport, "change", selectAirportFromCountry);
	
	this.sel = document.getElementById("sel");
	addEvent(this.sel, "click", selectAirportFromCountry);
	
	
	this.dest_suggest = document.getElementById("autofill");
	addEvent(this.dest_suggest, "click", selectAirportFromAutoFill);
	
	this.finddestination = document.getElementById("finddestination");
	addEvent(this.finddestination, "click", showFindDestination);
	
	this.closedestination = document.getElementById("closed");
	addEvent(this.closedestination, "click", closeFindDestination);
	
}

TravelAgent.prototype.removeDestinations = function() {
	var dest_suggest = document.getElementById("autofill");
	var elems = dest_suggest.childNodes;
	if (elems.length > 0) {
		for (var i=elems.length-1; i >= 0 ; i--) {
			//elems[i].innerHTML = "";
			elems[i].parentNode.removeChild(elems[i]);
		}
	}
}

TravelAgent.prototype.setClasses = function(classFrom, classTo) {


	var flyclass = document.getElementById("class");
	var index = Math.min(flyclass.selectedIndex, 1);
	flyclass.options.length = 1;
	var optionBF1 = new Option("Europe Select", "B", null, null);
	var optionBF2 = new Option("World Business Class", "B", null, null);
	if ((classFrom.toLowerCase() == "eur" && classTo.toLowerCase() == "eur") || classFrom.toLowerCase() == "all") flyclass.options[flyclass.options.length] = optionBF1;
	if (classFrom.toLowerCase() == "ica" || classTo.toLowerCase() == "ica" || classFrom.toLowerCase() == "all") flyclass.options[flyclass.options.length] = optionBF2;
	if (classFrom.toLowerCase() == "all")
		flyclass.selectedIndex = 0;
	else
		flyclass.selectedIndex = index;
}

/* origins selectbox */
Origins = function(selectBox) {
	
	var origins = this;
	var xmlurl = "../xfd/ebt_nr/origins/ae_en/origins.xml";
	var xmlhttp = null;
	var classes = new Array();
	
	this.selectBox = selectBox;
	this.classes = classes;
	
	var processRequest = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			var selected = 0;
			var airports = xmlhttp.responseXML.getElementsByTagName("origin");
			for (var i=0; i < airports.length; i++) {
				var code = airports[i].getAttribute("code");
				origins.selectBox[i] = new Option(airports[i].firstChild.nodeValue, code, false, false);
				if (airports[i].getAttribute("default"))
					selected = i;
				classes[code]=airports[i].getAttribute("class");

			}
			origins.selectBox.selectedIndex = selected;
		}
	}

	xmlhttp = getXmlHttp();
	if (xmlhttp) {
		xmlhttp.onreadystatechange = processRequest;
		xmlhttp.open('GET', xmlurl, true);
		xmlhttp.send(null);
	}
}

/* TravelData */
TravelData = function(url) {
	
	var traveldata = this;
	var xmlurl = "../xfd/ebt/destinations/ae_en/showdestinations.xml";
	var xmlhttp = null;
	
	this.airportdata = new Array();
	this.countrydata = new Array();
	this.xmldata = null;
	
	var processRequest = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			traveldata.xmldata = xmlhttp.responseXML;
			traveldata.populateData();
		}
	}

	xmlhttp = getXmlHttp();
	if (xmlhttp) {
		xmlhttp.onreadystatechange = processRequest;
		xmlhttp.open('GET', xmlurl, true);
		xmlhttp.send(null);
	}
}

TravelData.prototype.populateData = function() {
	var elems;
	// put airport names is array for searching
	elems = this.xmldata.getElementsByTagName("airport");
	if (elems && this.airportdata && !this.airportdata.length > 0) {
		for (var i=0; i<elems.length; i++) {
			this.airportdata[i] = elems[i].firstChild.nodeValue;
		}
		this.airportdata.sort();
	}
	// put country names is array for searching
	elems = this.xmldata.getElementsByTagName("country");
	if (elems && this.countrydata && !this.countrydata.length > 0) {
		for (var i=0; i<elems.length; i++) {
			this.countrydata[i] = elems[i].getAttribute("name");
		}
		this.countrydata.sort();
	}
}

TravelData.prototype.selectAirportData = function(searchString) {
	// get subset of the airport array
	var selectedData = new Array();
	if (this.airportdata && this.airportdata.length > 0) {
		for (var i=0; i<this.airportdata.length; i++) {
			if (this.airportdata[i].toLowerCase().indexOf(searchString.toLowerCase()) == 0)
				selectedData.push(this.airportdata[i]);
			if (this.airportdata[i].substring(0,searchString.length).toLowerCase() > searchString.toLowerCase())
				return selectedData;
		}
	}
	return selectedData;
}

TravelData.prototype.getCountryData = function() {
	// get country array
	return this.countrydata;
}

TravelData.prototype.getAirportData = function(country) {
	// get country array
	var selectedData = new Array();
	var elem = this.getCountry(country);
	if (elem.childNodes.length > 0) {
		for (var i=0; i<elem.childNodes.length; i++) {
			if (elem.childNodes[i].tagName && elem.childNodes[i].tagName.toLowerCase() == "airport") 
				selectedData.push(elem.childNodes[i].firstChild.nodeValue);
		}
	}
	return selectedData;
}

TravelData.prototype.getAirport = function(airport) {
	var elems = this.xmldata.getElementsByTagName("airport");
	// get the xml node that belongs 2 value
	if (elems && this.airportdata.length > 0) {
		for (var i=0; i<elems.length; i++) {
			if (elems[i].firstChild.nodeValue.toLowerCase() == airport.toLowerCase())
				return elems[i];
		}
	}
	return null;
}

TravelData.prototype.getCountry = function(country) {
	var elems = this.xmldata.getElementsByTagName("country");
	// get the xml node that belongs 2 country
	if (elems) {
		for (var i=0; i<elems.length; i++) {
			if (elems[i].getAttribute("name").toLowerCase() == country.toLowerCase())
				return elems[i];
		}
	}
	return null;
}
//getElementsByClassName
function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : 
    oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

function fareSelect() {
	var priceBlock = getElementsByClassName(document.getElementById("fares"), "div", "priceblock");
	for (var i=0;i<priceBlock.length;i++) {
		if(priceBlock[i].className != 'priceblock hover') {
			priceBlock[i].onmouseover = function() {
				addClass(this,'hover');
				var btn = this.getElementsByTagName("div");
				
			}
			priceBlock[i].onmouseout = function() {
				removeClass(this,'hover');
			}
			// follow link in priceblock select-button
			priceBlock[i].onclick = function(e) {
				var source = (e) ? e.target : window.event.srcElement;
				// only follow href when click did not originate from info button or called-up dialog
				if(
					(source.className != "info" && source.className != "clickable" && source.className != "moreinfo")
					&& !isChild(source, document.getElementById("frmPopup"))
				) {
					document.location = getElementsByClassName(this, "div", "btn-select")[0].getElementsByTagName("a")[0].href;
					return false;
				}
			}
		}
	}
}
isChild = function (ancestor, candidate) {
	if (!ancestor || !ancestor.parentNode || !candidate) return false;
	while (candidate && candidate != ancestor.parentNode) {
		if (candidate == ancestor) return true;
		try {
			candidate = candidate.parentNode;
		} catch (c) {return false}
	}
}
function calendarSelect() {
	var calendars = document.getElementById("calendars");
	var as = calendars.getElementsByTagName("span");
	for (i=0;i<as.length;i++) {
		if (as[i].id !="recalc") {		
			as[i].onmouseover = function() {
				addClass(this,'hover');
			}
			as[i].onmouseout = function() {
				removeClass(this,'hover');
			}
		}
	}
}
addClass=function(obj,cName) { 
	removeClass(obj,cName); 
	return obj.className+=(obj.className.length>0?' ':'')+cName; 
}

removeClass=function(obj,cName) {
	return obj.className=obj.className.replace(new RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),''); 
}

// type radio toggle
function toggleTypeMethod(inputname) {
	var paymentReg = new RegExp("^" + inputname + "$");///^paymenttype$/i;
	var radioReg = /^radio$/i;
	var tbodyReg = /^tbody$/i;
	var radios = document.getElementsByTagName("input");
	var currentFoldout = null;

	function toggleFoldout() {
		if(currentFoldout)	
			removeClass((currentFoldout),"show");
		var foldout = this;
		while(foldout&&!tbodyReg.test(foldout.nodeName)) foldout = foldout.parentNode;
		if(foldout) {
			addClass((currentFoldout = foldout),"show");
			//alert("toggle on " + inputname + " " + foldout.nodeName + foldout.className);
		}
	}
	//Search for radio buttons that habe  a name that equals [inputname] to initialise payment type toggle.
	for(var radio,i=0; i<radios.length; i++) {
		radio = radios.item(i);
		if(paymentReg.test(radio.name) && radioReg.test(radio.type) && radio.id) {
			radio.onclick = toggleFoldout;
			if(radio.checked) radio.onclick();
		}
	}
}
// Payment radio toggle
function togglePaymentMethod() {
	var trclassRE = /\bpaymentContainer\b/
	var trs = document.getElementsByTagName("tr");
	//Search for all tr elements with classname 'paymentContainer' to initialise payment type toggle
	for (var i = 0; i < trs.length; i++) {
		if (trclassRE.test(trs[i].className)) {
			togglePaymentByType(trs[i]);
		}
	}
}
function togglePaymentByType(typeO) {
	var paymentReg = /\bpayment/i;
	var radioReg = /^radio$/i;
	var radios = typeO.getElementsByTagName("input");
	var currentFoldout = null;

	function toggleFoldout() {
		if(currentFoldout)	
			removeClass((currentFoldout),"show");
		var foldout = this.parentNode;
		while (foldout&&!paymentReg.test(foldout.className)) foldout = foldout.parentNode;
		if(foldout) {
			addClass((currentFoldout = foldout),"show");
		}
	}
	//Search all radio buttons with a name that starts with 'payment' to initialize payment toggle.
	for(var radio,i=0; i<radios.length; i++) {
		radio = radios.item(i);
		if(paymentReg.test(radio.name) && radioReg.test(radio.type)) {
			radio.onclick = toggleFoldout;
			if(radio.checked) radio.onclick();
		}
	}
}
// Payment radio value storage
function storePaymentMethod() {
	var classRE = /\bpayfinal\b/
	var inputs = document.getElementsByTagName("input");
	//Search for all input elements with classname 'payfinal' to initialise payment type storage
	for (var i = 0; i < inputs.length; i++) {
		if (classRE.test(inputs[i].className)) {
			paymentStore(inputs[i]);
		}
	}
}

function paymentStore(input) {
	var tbody = input.parentNode;
	var tbRE = /^tbody$/i;
	while (tbody.parentNode && !tbRE.test(tbody.nodeName)) tbody = tbody.parentNode;
	function storeValue(e) {
		var e = e||event;
		var target = e.target||e.srcElement;
		if (target&&target.type&&target.type=="radio") {
			input.value = target.value;
			//alert(input.value);
		}
	}
	if (tbody.parentNode) tbody.onclick = function (e) {
		storeValue(e);
	};
}

function openPopup() {
	var infos = getElementsByClassName(document.getElementById("fares"), "img", "info");
	for (i=0;i<infos.length;i++) {
		infos[i].onclick = function(e) {
			document.getElementById("faresPopup").style.display = "block";
			var inputs = getElementsByClassName(document.getElementById("choosedates"), "span", "bgradio");
			for(var i=0; i<inputs.length; i++){
				inputs[i].style.zIndex = "-1";
			}
			return false;
		}
	} return false;
}
function closePopup() {
	var closer = getElementsByClassName(document.getElementById("faresPopup"), "a", "closefarespopup");
	for (i=0;i<closer.length;i++) {
		closer[i].onclick = function(e) {
			document.getElementById("faresPopup").style.display = "none";
			var inputs = getElementsByClassName(document.getElementById("choosedates"), "span", "bgradio");
			for(var i=0; i<inputs.length; i++){
				inputs[i].style.zIndex = "1";
			}
			return false;
		}
	} return false;
}
function toggleBreakdown() {
	var breakdownlink = document.getElementById("breakdown_link");
	var breakdown = document.getElementById("breakdown");
	breakdownlink.onclick = function() {
		var currentValue = breakdown.style.display;
		var newValue = (currentValue == "block") ? "none" : "block";
		breakdown.style.display = newValue;
		return false;
	}
}
function toggleBreakdownup() {
	var breakdownlinkup = document.getElementById("breakdown_link_up");
	var breakdownup = document.getElementById("breakdown_up");
	breakdownlinkup.onclick = function() {
		var currentValue = breakdownup.style.display;
		var newValue = (currentValue == "block") ? "none" : "block";
		breakdownup.style.display = newValue;
		return false;
	}
}
function availableTime() {
	var trs = document.getElementById("choosedates").getElementsByTagName("tr");
	for (i=0;i<trs.length;i++) {
		trs[i].onmouseover = function() {
			if(this.className.indexOf(' double') > 0) {
				addClass(this,'sel');
				addClass(this.parentNode.rows[this.rowIndex+1],'sel');
			}
			if(this.className.indexOf(' continued') > 0) {
				addClass(this,'sel');
				addClass(this.parentNode.rows[this.rowIndex-1],'sel');
			}
			else {
				addClass(this,'sel');
			}
		}
		trs[i].onmouseout = function() {
			if(this.className.indexOf(' double') > 0) {
				removeClass(this,'sel');
				removeClass(this.parentNode.rows[this.rowIndex+1],'sel');
			}
			if(this.className.indexOf(' continued') > 0) {
				removeClass(this,'sel');
				removeClass(this.parentNode.rows[this.rowIndex-1],'sel');
			}
			else {
				removeClass(this,'sel');
			}
		}
	}
}

var allContainers = new Array;
function popupMenu(oLoc, title, body){
	var oFrm = document.getElementById("frmPopup");
	oFrm.getElementsByTagName("SPAN")[0].lastChild.nodeValue = title;
	oFrm.getElementsByTagName("DIV")[0].innerHTML = body;
	oLoc.parentNode.insertBefore(oFrm, oLoc);
	addClass(oFrm,"show");
	return false;
}

function frmAlertClose() {
	var frmAlert = document.getElementById("frmAlert");
	var frmAlertX = frmAlert.getElementsByTagName('a');
	for (i=0;i<frmAlertX.length;i++) {
		frmAlertX[i].onclick = function() {
			frmAlert.style.display = "none";
			return false;
		}
	}
}
function showBluebiz() {
	var bbcheck = document.getElementById('bluebiz');
	if (!bbcheck.checked) {
		document.getElementById('bluebiznr').style.display = 'none';
	}
	else {
		document.getElementById('bluebiznr').style.display = 'block';
	}
	return false;
}
function emptyBluebiz() {
	var nr = document.getElementById('bluebiznr');
	if (nr == null)
		return false;
	if(nr.value == 'Fill in your BlueBiz number here') nr.value = '';
	return false;
}
function fillinBluebiz() {
	var nr = document.getElementById('bluebiznr');
	if(nr.value == '') nr.value = 'Fill in your BlueBiz number here';
	return false;
}
function syncDate(origin) {
	var depDay = document.getElementById('dep_day');
	var depMonth = document.getElementById('dep_month');
	var retDay = document.getElementById('ret_day');
	var retMonth = document.getElementById('ret_month');
	if((depMonth.options.selectedIndex == retMonth.options.selectedIndex && depDay.options.selectedIndex > retDay.options.selectedIndex) || depMonth.options.selectedIndex > retMonth.options.selectedIndex) {
		if(origin == depDay || origin == depMonth) {
			retDay.selectedIndex = depDay.selectedIndex;
			retMonth.selectedIndex = depMonth.selectedIndex;
		} else {
			depDay.options.selectedIndex = retDay.options.selectedIndex;
			depMonth.options.selectedIndex = retMonth.options.selectedIndex;			
		}
	}
}
function closePopupHandler(e) {
	var e = e||event;
	var target = e.target||e.srcElement;
	while (target.nodeType > 1) target = target.parentNode;
	
	if ((target.nodeName == "A" || target.nodeName == "a") && target.rel == "closePopup") {
		var popup = target	;
		var showRE = / ?\bshow\b/i
		while(!showRE.test(popup.className) && popup.parentNode) popup = popup.parentNode;
		removeClass(popup, "show");
		return cancelEvent(e);
	}
	else return true;
}

addEventHandler(document,"click", closePopupHandler);

function ChooseFlights(id) {
	this.calendar = document.getElementById(id);
	var self = this;
	addEventHandler(this.calendar, "click", function(e) {
		self.clickHandler(e);
	});
}

ChooseFlights.prototype = {
	aRE:/^a$/i,
	trRE:/^tr$/i,
	atRE:/^availabletime/,
	dblRE:/double/,
	dblCRE:/continued/,
	currentRE:/ ?\bcurrent\b/i,
	clickHandler:function(e) {
		var e = e||event;
		var target = e.target||e.srcElement;

		while (target.nodeType>1)target = target.parentNode; //Safari targets textnodes.

		if (this.aRE.test(target.nodeName)) {//It's a link, change fare's filter
			var aParent = target.parentNode;
			var as = aParent.getElementsByTagName("a");

			//Purge calendar of current filter
			for (var i=0; i < as.length; removeClass(this.calendar, as.item(i++).className));

			//Add filter to calendar
			addClass(this.calendar, target.className);

			//Cancel clickevent
			return cancelEvent(e);
		} else { //Somewhere else, look for a table-row
			while(!this.trRE.test(target.nodeName)&&target.parentNode) target = target.parentNode;
			if (this.atRE.test(target.className)) { //It's a time tabelrow
				//Check if it's second of doublerow, ifso get it's previousSibling.
				if (this.dblCRE.test(target.className)) target = target.parentNode.rows[target.rowIndex-1];

				//Get the second tablerow of a doublerow
				var target2 = null;
				if (this.dblRE.test(target.className)) target2 = target.parentNode.rows[target.rowIndex+1];

				//Get the radiobutton
				var radio = target.getElementsByTagName("input").item(0);

				//'de-select' current selected nodes.
				var tParent = target.parentNode;
				for (i=0; i<tParent.rows.length; i++) {
					var row = tParent.rows[i];
					if (this.currentRE.test(row.className)) row.className = row.className.replace(this.currentRE,"");
				}

				//Set selected state and select radio
				addClass(target," current");
				if (target2!=null) {
					//Remove lingering hover class
					removeClass(target2,"sel");
					//Add current class
					addClass(target2," current");
				}
				radio.checked = true;

				//Enable recalc button?
				var button = document.getElementById("recalcon");
				addClass(button, "enable");
				
				//Cancel original click
				//return cancelEvent(e);
			}
		}
		return true;
	}
}
BreakdownHandler  = {
	aRE:/^a$/i,
	bdRE:/\bbreakdown_link\b/,
	showRE:/ ?\bshow\b/,
	clickHandler:function(e){
		var e = e||event;
		var target=e.target||e.srcElement;
		while (target.nodeType > 1) target = target.parentNode; //Get element, Safari fires on text_nodes.
		
		if (this.aRE.test(target.nodeName)&&this.bdRE.test(target.className)) { //It's a breakdown_link.
			//Get relevant information and nodes
			var toggle = target.parentNode;
			var targetId = target.getAttribute("href");
			targetId = targetId.substring(targetId.indexOf("#") + 1);
			var targetBreakdown = document.getElementById(targetId);
			var altTextNode = toggle.getElementsByTagName("span").item(0);
			var text = target.firstChild;
			var altText = altTextNode.firstChild;
			
			//Toggle the status of relevant breakdown
			if (this.showRE.test(targetBreakdown.className)){
				targetBreakdown.className = targetBreakdown.className.replace(this.showRE,"");
				toggle.className = toggle.className.replace(this.showRE,"");
			} else {
				targetBreakdown.className+=" show";
				toggle.className+=" show";
			}
			
			//Switch the textnodes.
			target.appendChild(altText);
			altTextNode.appendChild(text);
			
			return cancelEvent(e);
		}
	}	
}

addEventHandler(document, "click", function(e) {
	BreakdownHandler.clickHandler(e);
});

function doSubmitEBT(sCmd, sUrl)
{
	emptyBluebiz();
	document.book2.commandToExecute.value = sCmd;
	document.book2.action = sUrl;
	if (document.book2.destination.value == "") {
		document.book2.destination.value = document.book2.destination_free.value;
	}
	document.book2.productTypeCabin.value = document.book2.productType.value.substring(0,1);
	document.book2.productTypeCondition.value = document.book2.productType.value.substring(1);
	document.book2.submit();
}
// Content: js calendar
/* calendar functions */
var type = '';
var days = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];

function showCalendar(depret, txt) {
	top.type = depret;
	var container = document.getElementById('calendarcontainer');
	var header = document.getElementById('calendartop');
	header.innerHTML = txt; 
	if (document.all) {
		var entries = document.getElementsByTagName('select');
		for (var i = 0; i < entries.length; i++) {
			if (entries[i].className == 'cal_hide') {
				entries[i].style.display = 'none';
			}
		}
	}
	var today = new Date();
	var index = document.getElementById(depret + '_month').options.selectedIndex;
	document.getElementById('calendarmonth').options.selectedIndex = index;
	updateMonth(today.getFullYear() + "" + (today.getMonth()+1+index), index);
	container.style.display = 'block';
}
function fill(type, day, month) {
	closeCalendar();
	document.getElementById(type + '_day').options.selectedIndex = day;
	document.getElementById(type + '_month').options.selectedIndex = month;
	syncDate(document.getElementById(type + '_month'));
}
function closeCalendar () {
	var container = document.getElementById('calendarcontainer');
	if (document.all) {
		var entries = document.getElementsByTagName('select');
		for (var i = 0; i < entries.length; i++) {
			if (entries[i].className == 'cal_hide') {
				entries[i].style.display = 'block';
			}
		}
	}
	container.style.display = 'none';
}
function updateMonth(monthyear, selection) {
	var month = monthyear.substr(4,2);
	var year = monthyear.substr(0,4);
	var noOfDays = getNumberOfDays(month, year);
	var firstDay = getFirstDay(month, year);
	fillMonth(month, firstDay, noOfDays, selection);
}
function getNumberOfDays(m, y) {
	var days = 31;
	switch (parseInt(m)) {
		case 4: case 6: case 9: case 11:
			days = 30;
			break;
		case 2:
		  if ((y % 4 == 0) ^ (y % 100 == 0) ^ (y % 400 == 0))
			days = 29;
		  else
			days = 28;
		  break;
	}
	return days;
}
function getFirstDay(m, y) {
	d = new Date(y, m-1, 1);
	d.setHours(12);
	return (d.getDay() - 1 >= 0 ? d.getDay() - 1 : d.getDay() + 6);
}
function fillMonth(month, firstDay, noOfDays, monthIndex) {
	var firstSet = false;
	var dayCounter = 1;
	var today = new Date();
	dateToday = today.getDate();
	monthToday = today.getMonth() + 1;
	var sHTML = '<table cellspacing="0"><tr class="head">'
	for (var i = 0; i < days.length; i ++) {
		sHTML += '<td>' + days[i] + '</td>\n';
	}
	sHTML += '</tr>';
	while (dayCounter <= noOfDays) {
		sHTML += '<tr>';
		for (i = 0; i < 7; i++) {
			if (!firstSet && i < firstDay) {
				sHTML += '<td>&nbsp;</td>\n';
			} else {
				firstSet = true;
				if (dayCounter <= noOfDays) {
					if ((monthToday == month) && (dayCounter < dateToday)) {
						sHTML += '<td>' + dayCounter + '</td>\n';
					} else {
						sHTML += '<td><a href="javascript:fill(top.type, ' + (dayCounter - 1) + ' , ' + monthIndex + ');">' + dayCounter + '</a></td>\n';
					}

				} else {
					sHTML += '<td>&nbsp;</td>\n';
				}
				dayCounter++;
			}
		}
		sHTML += '</tr>'
	}
	sHTML += '</table>';
	document.getElementById('monthtable').innerHTML = sHTML;
}
function RecalcCalendar(id,days) { //,matchdates) {
	this.calendar = document.getElementById(id);
	this.days = days||new Array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
	/*this.minMatch = false;
	this.maxMatch = false;
	if (matchdates!=null) {
		if (matchdates.minMatch!=null) {
			this.minMatch = true;
			this.matchCalendar = document.getElementById(matchdates.minMatch);
		} else if(matchdates.maxMatch!=null) {
			this.maxMatch = true;
			this.matchCalendar = document.getElementById(matchdates.maxMatch);
		}
	}*/
	var self = this;
	addEventHandler(this.calendar, "click", function(e) {
		return self.clickHandler(e);
	});
}

RecalcCalendar.prototype = {
	aRE:/a/i,
	relRE:/date/i,
	divRE:/div/i,
	dateRE:/\b[0-9]{1,2}\b/,
	dayRE:/^[^ ]*/,
	clickHandler:function(e) {
		var e = e||event;
		var target = e.target||e.srcElement;
		var eventResult = true;

		while (target.nodeType>1)target = target.parentNode; //Safari targets textnodes.

		if (this.aRE.test(target.nodeName) && this.relRE.test(target.getAttribute("rel"))) {//It's a date link
			//de-select current date
			var selSpans = getElementsByClassName(this.calendar, "span", "sel");
			removeClass(selSpans[0], "sel");

			//select current date
			var span = target.parentNode;
			addClass(span, "sel");

			//change date-string
			var div = target;
			while (div.parentNode && !this.divRE.test(div.nodeName)) div = div.parentNode;
			if (this.divRE.test(div.nodeName)) {
				var strong = div.getElementsByTagName("strong").item(0);
				var sDate = strong.firstChild.nodeValue;
				sDate = sDate.replace(this.dateRE, target.firstChild.nodeValue);

				//count how many-eth day this is
				var td = target.parentNode.parentNode;
				var day = this.days[td.cellIndex];
				sDate = sDate.replace(this.dayRE, day);
				strong.replaceChild(document.createTextNode(sDate),strong.firstChild);
			} else alert("Could not find a div");

			//set variable on button-action
			var button = document.getElementById("recalcon"), buttonlink = button.getElementsByTagName("a").item(0), buttonhref = buttonlink.getAttribute("href"), href="";
			var re = new RegExp("([\\?&]" + this.calendar.id + "=)[^&]*");
			if (re.test(buttonhref)) {
				href = buttonhref.replace(re, "$1" + target.firstChild.nodeValue);
			} else {
				href = buttonhref + (buttonhref.indexOf("?")>0?"&":"?") + this.calendar.id + "=" + target.firstChild.nodeValue;
			}
			buttonlink.setAttribute("href",href);

			//enable recalcButton
			addClass(button, "enable");
			//cancel original event
			eventResult = cancelEvent(e);
		}
		return eventResult;
	}
}
// Content: js tradedoubler
function initTradedoubler(strOrgID, strEventID, strReportInfo)
{

	var strLeadNumber = getParameterTD("email");
	var refImage = new Image();
	//var srcImage = "../../../tracker.tradedoubler.com/report@organization=" + strOrgID + "&event=" + strEventID + "&leadNumber=" + escape(strLeadNumber) + "&reportInfo=" + escape(strReportInfo);
	var srcImage = "report@organization=" + strOrgID + "&event=" + strEventID + "&leadNumber=" + escape(strLeadNumber) + "&reportInfo=" + escape(strReportInfo);
	refImage.src = srcImage;
}

function getParameterTD(strName) 
{
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	var blnFound = false;
	var i, retValue;
	
	retValue = "";
	i = 0;	
	while (i != parms.length && !blnFound)
	{
		var pos = parms[i].indexOf('=');
		if (pos > 0) 
		{
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			blnFound = (strName == key);
			if (blnFound)
				retValue = val;
		}
		i++;
	}
	return retValue;
}