function initMenu()
{
	// highlight current location
	var path = window.location;
	var home = "/";
	$("a[href='" + [path || home] + "']").each(function() {
		$(this).addClass("menuItemCurrent");
	});

	// change  color on hover
	$(".menuItem").hover(
		function() {
			$(this).addClass("menuItemOver");
			$(".menuItemOver .menuActive").fadeIn(300);
		},
		function() {
			if($(this).hasClass("menuItemCurrent") == false)
			{  
				$(".menuItemOver .menuActive").fadeOut(800);
			}
			$(this).removeClass("menuItemOver");
		}
	);

	$(".menuItem").click(
		function() {
			if($(this).hasClass("menuItemCurrent") == false)
			{
				$('.menuItemCurrent .menuActive').stop().fadeOut(800);
				$(".menuItem").removeClass('menuItemCurrent');
				$(this).addClass('menuItemCurrent');
			}
		}
	);
}





function popImage(image, width, height)
{
	disp = window.open(image,"_blank", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, top=130, left=130, width=" + width + ", height=" + height);
	
	content = '<html>';
	content += '<head></head>';
	content += '<body style="margin:0px;padding:0px">';
	content += '<img  src="' + image + '" height="' + height + '" width="' + width + '" >';
	content += '</body></html>';
	
	disp.document.write(content);
	disp.document.close();
}

function joinEmailList()
{
	if(id('inputJoinEmail').value == '!+ TEXT general joinEmailInputCatch htmlNone +!')
	{
		id('inputJoinEmail').value = '';
	}
	
	id('joinEmailForm').submit();   
}



function submitFormToUrl(form)
// Returns a URL string representing the form, it's target and it's values
// Example of returned value: "http://domain.com/myform.php?value1=2&value2=jorge"
// Example of usage:
// <form [...] onsubmit="window.open(condorjs.submitFormToUrl(this)); return false">
{
	var x = new Array();
	for (var i = 0; i < form.elements.length; i++)
	{
		x.push(form.elements[i].name + "=" + encodeURIComponent(form.elements[i].value));
	}
	x = form.getAttribute("action") + "?" + x.join("&");

	return x;
}

//Functions for booking mask to interact with the flash
function updateMap(cat,sid){
	//alert("list = "+cat+", data = "+sid.value);
	callToActionscript(cat, sid.value);
}


function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}


function callToActionscript(cat, id) {
	//alert(cat+","+id);
	getFlashMovie("mapWide").sendToActionscript(cat, id);
}


function parseDate(dateString) { // MM/DD/YYYY
	var dateArray = dateString.split('/');
	var myInt = parseInt(dateArray[1],10);
	if (isNaN(myInt)) {
		return new Date();
	} else {
		return new Date(dateArray[2], myInt-1, dateArray[0]);
	}
}


//Functions for interaction with the flash
function setRegion(region)
{
	/* Unused, just left for flash movie */
}


function setRegionId(regionId)
{
	/* Unused, just left for flash movie */
}


function zoomOut()
{
	portal.locationSelect.selectedIndex = 0;
	setContentFromCitySelect(portal.locationSelect);
}


function setCity(city)
{
	var cityId = false;

	switch(city)
	{
		case 'Mannheim': 
			cityId = 15;
			break;
		case 'Osnabruck': 
			cityId = 52;
			break;
		case 'Mainz': 
			cityId = 14;
			break;
		case 'Cologne': 
			cityId = 7;
			break;
		case 'Dusseldorf': 
			cityId = 5;
			break;
		case 'Bochum': 
			cityId = 11;
			break;
		case 'Dortmund': 
			cityId = 12;
			break;
		case 'Kamen': 
			cityId = 13;
			break;
		case 'Leipzig': 
			cityId = 9;
			break;
		case 'Dresden': 
			cityId = 3;
			break;
		case 'Berlin': 
			cityId = 1;
			break;
		case 'Hannover': 
			cityId = 17;
			break;
		case 'Bielefeld': 
			cityId = 19;
			break;
		case 'Erfurt': 
			cityId = 16;
			break;	
		case 'Hamburg': 
			cityId = 18;
			break;	
	}

	if(cityId != false)
	{
		for(var i = 0; i < portal.locationSelect.options.length; i++)
		{
			if(portal.locationSelect.options[i].value == 'c' + cityId)
			{
				portal.locationSelect.selectedIndex = i;
			}
		}
		
		//setContentFromCitySelect(portal.locationSelect);
		
	}
	else
	{
		alert(city + ' could not be found');
	}	
}	


function setHotel(hotel)
{
	//Left for flash movie to not cause js error
}


//Convert european to us date format
function eurToUsDate(value)
{
	var date = parseDate(value);
	var day = date.getDate(); 
	var month = date.getMonth() + 1; 
	var year = date.getFullYear();
	return  + month + '/' + day +'/' + year;
	
}

function bookHotel(bookingLink)
{
	bookingLink += '&adults=' + document.getElementById('adults').value;
	bookingLink += '&children=' + document.getElementById('children').value;
	bookingLink += '&length=' + document.getElementById('nights').value;
	
	bookingLink +=  '&datein=' + eurToUsDate(document.getElementById('dateInVisible'));

	if(document.getElementById('promotionCode').value != "")
	{
		bookingLink += '&identifier=' + document.getElementById('promotionCode').value
	}

	if(document.getElementById('corporateCode').value != "")
	{
		bookingLink += '&identifier=' + document.getElementById('corporateCode').value;
	}

	popPage(bookingLink, "Online Hotel Reservations",760, 500);
}

