code_kopieren = new Image();
code_kopieren.src = "Resources/img/ComponentFolder.gif";
code_kopieren_over = new Image();
code_kopieren_over.src = "Resources/img/ComponentFolderOver.gif";
		
function HighLight(id, changeTo) {
	var imageId = String('_img').concat(id);
	var oldImage = window.document.getElementById(imageId);			
	
	oldImage.src = changeTo.src; 			
}

function FillSelectionCountries(selection){		
	ClearSelection( selection );	

	for (var i = 0; i < countries.length; i = i + 2) {
  
		newEntry = new Option(countries[i], countries[i+1], false, false);
		selection.options[i/2] = newEntry;
	}
}


function FillSelectionCities(selection, country){
	sendRequestCountry(country);
	ClearSelection( selection );
	/*
	for (var i = 0; i < cities[country].length; i = i + 2) {
  
		newEntry = new Option(cities[country][i], cities[country][i+1], false, false);
  		selection.options[i/2] = newEntry;
	}
	*/
}



function FillSelectionHotels(selection, citiy){
	ClearSelection( selection );


	for (var i = 0; i < hotels[citiy].length; i = i + 2) {
  
		newEntry = new Option(hotels[citiy][i], hotels[citiy][i+1], false, false);
		selection.options[i/2] = newEntry;
	}
}


function ClearSelection( selection ){
	if(selection != null)
	{
		for(i = selection.length ; i > 0; i-- ){
			selection.options[i-1] = null;
		}	
	}

}

function ClearSelectionLeaveFirst( selection, text ) {
	for(i = selection.length ; i > 1; i-- ){
		selection.options[i-1] = null;
	}
}


var args = new Array();
var lastInnerPage = null;
var vars = self.location.href.split("?")[1];
if(vars != null){
	if(vars.indexOf("&id=")>-1)
	{
		vars = vars.split("&id")[0];
	}
	var varArray = vars.split(';');
	for (var i = 0; i < varArray.length; i++){								
		if(varArray[i].length > 0){		
			var name = varArray[i].split('=')[0];
			var value = varArray[i].split('=')[1];
			args[i * 2] = name;
			args[i * 2 + 1] = value;
		}
	}
}

function getVar(name){
	for(var i = 0; i < args.length/2; i++){
		if(args[i*2] == name)
			return args[i*2 + 1]
	}
}

function hideElement(elem){
	if(elem != null){
		elem.style.display = "none";
	}
}

function fromCatToHotel(url) {
	var country = getVar('country');
	var city = getVar('city');
	parent.window.location.href = url + '?country=' + country + ';city=' + city + ';';
}

function Init(){
	InitCityPage();
	if(getVar('country') && getVar('city')){
		sendRequestCountry(getVar('country'));
		sendRequestCity(getVar('country'), getVar('city')) 
		document.searchBar.country.selectedIndex = getVar('country');
		//FillSelectionCities(document.searchBar.city, document.searchBar.country.options[document.searchBar.country.selectedIndex].value);
		//debugger;
		setTimeout("document.searchBar.city.selectedIndex = getVar('city');",500);
		//FillSelectionHotels(document.searchBar.hotel, document.searchBar.city.options[document.searchBar.city.selectedIndex].value);
	}
	//alert(getVar('innerPage'));
	if(getVar('innerPage') && getVar('innerPage').length > 0){
		document.getElementById('iframe').src = getVar('innerPage'); 
		lastInnerPage = div.id;
	}
}

function InitCityPage(){
	var display = getVar('display');
	var sort = getVar('sort');								
	switch(sort) {
		case "abc":
			switch(display){
				case "Corporate":
					//hideElement(document.getElementById("div_Voucher_abc"));
					hideElement(document.getElementById("div_Voucher_cat"));
					hideElement(document.getElementById("div_Corporate_cat"));
				break;
				case "Voucher":
					hideElement(document.getElementById("div_Voucher_cat"));
					//hideElement(document.getElementById("div_Corporate_abc"));
					hideElement(document.getElementById("div_Corporate_cat"));
				break;
				default:
					hideElement(document.getElementById("div_Voucher_cat"));
					hideElement(document.getElementById("div_Corporate_cat"));
				break;
			}
		break;									
		default:
			switch(display){
				case "Corporate":
					//hideElement(document.getElementById("div_Voucher_abc"));
					hideElement(document.getElementById("div_Voucher_cat"));
					//hideElement(document.getElementById("div_Corporate_abc"));
				break;
				case "Voucher":
					//hideElement(document.getElementById("div_Voucher_abc"));
					//hideElement(document.getElementById("div_Corporate_abc"));
					hideElement(document.getElementById("div_Corporate_cat"));
				break;
				default:
					//hideElement(document.getElementById("div_Voucher_abc"));
					//hideElement(document.getElementById("div_Corporate_abc"));
				break;
			}
		break;
	}
}							

function changeFocus(string, changePageVar){
	document.getElementById('search').style.color = '#0061ae';
	document.images['search'].style.visibility = 'visible';
	document.getElementById('search').style.backgroundColor = '';
	document.getElementById('allgemein').style.color = '#0061ae';
	document.images['allgemein'].style.visibility = 'visible';
	document.getElementById('allgemein').style.backgroundColor = '';
	document.getElementById('reservierung').style.color = '#0061ae';
	document.images['reservierung'].style.visibility = 'visible';
	document.getElementById('reservierung').style.backgroundColor = '';
	document.getElementById('voucheraus').style.color = '#0061ae';
	document.images['voucheraus'].style.visibility = 'visible';
	document.getElementById('voucheraus').style.backgroundColor = '';
	document.getElementById('faq').style.color = '#0061ae';
	document.images['faq'].style.visibility = 'visible';
	document.getElementById('faq').style.backgroundColor = '';
	document.getElementById('listen').style.color = '#0061ae';
	document.images['listen'].style.visibility = 'visible';
	document.getElementById('listen').style.backgroundColor = '';
	
	if(string && document.getElementById(string)){
		document.getElementById(string).style.color = '#fff';
		document.images[string].style.visibility = 'hidden';
		document.getElementById(string).style.backgroundColor = '#f28e00';
		if(changePageVar == true){
			changePage(string);
		}
	}
	
}

function checkFocus(){
	var string = getVar('highlight');
	if(string == null && document.getElementById('iframe')) {
		document.getElementById('iframe').src = 'start.php';
	} else
	if(string == 'inhalt' || string == 'kontakt'){
		document.getElementById('iframe').src = string + '.htm';
	}
	changeFocus(string, true);

			
}


function changePage(string){	
	var div = document.getElementById(string);
	
	if(string == 'inhalt' || string == 'kontakt'){
		document.getElementById('iframe').src = string + '.htm';
	} else
	if(div == null || string == 'index'){
		document.getElementById('iframe').src = 'start.htm';
	} else
	if(div.id == 'search'){
		document.getElementById('iframe').src = "index2.php";
		lastInnerPage = div.id;

	}else{
		document.getElementById('iframe').src = div.id + '.htm';
	}
	
}

function changeStyleTopNavi(string){
	if(document.getElementById('iframe') != null){
		document.getElementById('iframe').src = string + '.htm';
	}
	else{
		window.location.href = 'index.php?highlight=' + string;
	}
}

function checkHighlight(location) {	
	var pageName = location.substring(location.lastIndexOf('/') + 1, location.lastIndexOf('.'));
	var pageUrl = location.substring(location.lastIndexOf('/') + 1, location.length);
	var higlightPages = "faq, allgemein, reservierung, voucheraus, listen";
	if(pageName != lastInnerPage && higlightPages.indexOf(pageName) >= 0 && pageName.length > 0){
		changeFocus(pageName, true);
		lastInnerPage = pageName;
		//alert('1');
	}else{	
		if(pageName != lastInnerPage){
			changeFocus('', true);
			lastInnerPage = pageName;
			//alert('2');
		}
		if(pageUrl.indexOf('?') > 0){
			var highlight = pageUrl.substring(pageUrl.lastIndexOf('=') + 1, pageUrl.length);
			
			changeFocus(highlight, false);
			lastInnerPage = highlight;
			//alert(highlight);
		}
	}
}


