function getParam(param) {
	alert("WARNING getParam used: "+param)
}		

function getLang() {
	return SYSPARAM_LANGUAGE;
}


//var ROUND_CORNER_SETTINGS = {
//		tl: { radius: 4 },
//		tr: { radius: 4 },
//		bl: { radius: 4 },
//		br: { radius: 4 },
//		autoPad: true,
//		antiAlias: true,
//		validTags: ["div"]
//	};

var f1;
function openPopupc(){
	f1=window.open('/modrewrite/sound/steuerung.html','symbols','height=150,width=300,left=800,scrollbars=no,locationbar=no,resizable=no');
	f1.focus();
}
 
function globalFadeInOut(obj, speed) {
//	alert (obj + " - " + speed);
	if ($("#"+obj).length > 0) {
		if ($("#"+obj).is(":visible")) {
			$("#"+obj).fadeOut(speed);
		} else {
			$("#"+obj).fadeIn(speed);
		}
	}
	
	return false;
}

function showMail(user, domain, tld) {
	location.href = "mailto:" + user + "@" + domain + "." + tld;
}

//function centerOverlay(selector) {
//	var obj = $(selector);
//	if (obj) {
//		var clientHeight = window.document.body.clientHeight;
//		var height = obj.outerHeight(true);
//		
//		var top = 0;
//		if (clientHeight > height) {
//			top += (clientHeight - height) / 2;
//		}
//		
//		var clientWidth = window.document.body.clientWidth;		
//		var width = obj.outerWidth(true);
//		var left = 0;
//		if (clientWidth > width) {
//			left += (clientWidth - width) / 2;
//		}
//		
//		var scroll = getScrollXY();
//		left += scroll[0];
//		top += scroll[1];
//		
////		alert('top: ' + top + " ; left: " + left);
//		obj.css("top", Math.floor(top) + "px");
//		obj.css("left", Math.floor(left) + "px");
//	}
//}

/*
function setOffset(obj) {
	if (obj) {
		var offset = obj.offset();
		var topOffset = eval(getScrollXY()[1] + offset.top);
		var leftOffset = offset.left;
		if ($.browser.mozilla) {
			leftOffset += 250;
		}
		obj.offset({ top: topOffset, left: leftOffset });	
	}
}
 */

//function getScrollXY() {
//	var scrOfX = 0, scrOfY = 0;
//	
//	if (typeof (window.pageYOffset) == 'number') {
//		//Netscape compliant
//		scrOfY = window.pageYOffset;
//		scrOfX = window.pageXOffset;
//	} else if (document.body
//			&& (document.body.scrollLeft || document.body.scrollTop)) {
//		//DOM compliant
//		scrOfY = document.body.scrollTop;
//		scrOfX = document.body.scrollLeft;
//	} else if (document.documentElement
//			&& (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
//		//IE6 standards compliant mode
//		scrOfY = document.documentElement.scrollTop;
//		scrOfX = document.documentElement.scrollLeft;
//	}
//	return [scrOfX,scrOfY];
//}







/* =========================================================================================== */
/* =========================================================================================== */

/* =========================================================================================== */
/* ===============================  GOOGLE MAPS (PARKEN SEITE) =============================== */
/* =========================================================================================== */


var LAT_DEFAULT = 50.878232;
var LNG_DEFAULT = 7.122515;

var LAT_T1_D = 50.878232;
var LNG_T1_D = 7.122515;

var LAT_T1_A = 50.878263;
var LNG_T1_A = 7.122295;

var LAT_T2_D = 50.880179;
var LNG_T2_D = 7.119436;

var LAT_T2_A = 50.880118;
var LNG_T2_A = 7.119232;

var LAT_ADMIN = 50.873689;
var LNG_ADMIN = 7.127687;

var LAT_CARGO = 50.872738;
var LNG_CARGO = 7.109485;


var map;
var marker;
var markerTitle = "Köln Bonn Airport";

function initializeMap() {
	var latlng = new google.maps.LatLng(LAT_DEFAULT, LNG_DEFAULT);
	var myOptions = {
		zoom : 16,
		center : latlng,
		mapTypeControl : true,
		mapTypeControlOptions : {
			style : google.maps.MapTypeControlStyle.HORIZONTAL_BAR
		},
		navigationControl : true,
		navigationControlOptions : {
			style : google.maps.NavigationControlStyle.SMALL
		},
		mapTypeId : google.maps.MapTypeId.ROADMAP
	};

	map = new google.maps.Map(document.getElementById("map_canvas"),
			myOptions);

	marker = new google.maps.Marker({
		position : latlng,
		map : map,
		title : markerTitle
	});
}

function moveToDarwin(lat, lng) {
	marker.setMap(null);
	map.setZoom(16);
	var darwin = new google.maps.LatLng(lat, lng);
	map.setCenter(darwin);
	
	marker = new google.maps.Marker({
		position : darwin,
		map : map,
		title : markerTitle
	});
	
	
	$('#map_link').attr('href', getGoogleMapsLink(lat, lng));	
	
	return false;
}

function getGoogleMapsLink(lat, lng) {
	return "http://maps.google.de/maps?f=q&source=s_q&hl=de&q="+lat+","+lng+"&sll="+lat+","+lng+"&ie=UTF8&z=13";	
}

$(document).ready(function() {
	$("#t1D").click(function() {
		markerTitle = "Terminal 1 Departure";
		moveToDarwin(LAT_T1_D, LNG_T1_D);
	});
	$("#t1A").click(function() {
		markerTitle = "Terminal 1 Arrival";
		moveToDarwin(LAT_T1_A, LNG_T1_A);
	});
	$("#t2D").click(function() {
		markerTitle = "Terminal 2 Departure";
		moveToDarwin(LAT_T2_D, LNG_T2_D);
	});
	$("#t2A").click(function() {
		markerTitle = "Terminal 2 Arrival";
		moveToDarwin(LAT_T2_A, LNG_T2_A);
	});
	$("#admin").click(function() {
		markerTitle = "Administration";
		moveToDarwin(LAT_ADMIN, LNG_ADMIN);
	});
	$("#cargo").click(function() {
		markerTitle = "Cargo";
		moveToDarwin(LAT_CARGO, LNG_CARGO);
	});
	
	// Navigation Paging Suche
	$('.searchModuleNavi .navi-left').click(function () {
		if (!$(this).hasClass('disable-left')) {
//			$(this).parent().prev().fadeTo('fast',0.33);
			var obj = $(this).next().find('.currentPage');
			var currentPage = parseInt(obj.html());
			var numOfPages = parseInt($(this).next().find('.numOfPages').html());
			if (currentPage > 1) {
				currentPage--;
				obj.html(currentPage);
			} 
			
			if (currentPage == 1) {
				$(this).addClass('disable-left');
			} else {
				$(this).removeClass('disable-left');
			}
			
			var rightArrow = $(this).next().next();
			if (currentPage == numOfPages) {
				rightArrow.addClass('disable-right');
			} else {
				rightArrow.removeClass('disable-right');
			}
			doSearchPaging($(this), currentPage);
		}
	});
		
	$('.searchModuleNavi .navi-right').click(function () {
		if (!$(this).hasClass('disable-right')) {
//			$(this).parent().prev().fadeTo('fast',0.33);
			var obj = $(this).prev().find('.currentPage');
			var currentPage = parseInt(obj.html());
			var numOfPages = parseInt($(this).prev().find('.numOfPages').html());
			if (currentPage < numOfPages) {
				currentPage++;
				obj.html(currentPage);
			} 
			
			if (currentPage == numOfPages) {
				$(this).addClass('disable-right');
			} else {
				$(this).removeClass('disable-right');
			}
			
			var leftArrow = $(this).prev().prev();
			if (currentPage == 1) {
				leftArrow.addClass('disable-left');
			} else {
				leftArrow.removeClass('disable-left');
			}	
			doSearchPaging($(this), currentPage);		
		}
	});
}); 

$(window).load(function(){
	if (IS_IPAD || IS_IPHONE || IS_IPOD) {
		if ($('.tx-flugziele-pi1 .box-wrapper h3:first').length > 0) {
			$('.tx-flugziele-pi1 .box-wrapper h3:first').hide();
			$('#accWrapperHLink1').trigger('click');
		}
	}
});

function doSearchPaging(obj, currentPage) {
	var list = obj.parent().prev().children();
	if (list) {
		$.each(list, function(index, value) {
			if ($(value).attr('page') == currentPage) {
				$(value).show();
			} else {
				$(value).hide();
			}
		});	
//		obj.parent().prev().fadeTo('slow',1);
	}
}

var prevDest = "";

function showDestination(destinationId) {
//	alert(destinationId + '/' + prevDest);
	if (destinationId != 'undefined' && destinationId != prevDest) {
		var obj = $('div[dest="'+destinationId+'"]').clone();
		obj.removeAttr('dest');
		
		
//		alert(obj.find('.ol_accordion_el3 a').attr('href'));
		
		var button = obj.find('.ol_accordion_el3 a').clone();
		button.removeClass();
		button.removeAttr('style');
		button.removeAttr('onmouseover');
		button.removeAttr('onmouseout');
		button.addClass('button');
		button.css('margin-top','10px');
		button.find('span').removeClass();
		var label = "Flug suchen";
		if (getLang() == 1) label = "Search flight";
		if (getLang() == 2) label = "Vlucht zoeken";
		
		button.find('span').html(label);
		obj.find('.ol_accordion_details_el2').append(button);
		
//		obj.find('.ol_accordion').attr('id', '123_ol_accordion').addClass('ol_accordion_clicked');
//		obj.find('.ol_accordion_details').attr('id', '123_ol_accordion_details').css('display','block');
		obj.css('margin-top','5px');
		
		var toClose = $($('#destHolder').html());
		var idToAnimate = toClose.find('div:first').attr('id')
		
		if (idToAnimate) {
			var element = $("#" + idToAnimate);
			var element_d = $("#" + idToAnimate + "_details");
			element_d.slideUp("slow", function() {
			    // Animation complete.
				doSetTimeoutAnimation(obj, '#destHolder', 250);
			});			
		} else {
			doSetTimeoutAnimation(obj, '#destHolder', 250);
		}
		prevDest = destinationId;
	}
}

function doSetTimeoutAnimation(obj, dest, timeout) {
	$(dest).html(obj);
	var idToAnimate = obj.find('div:first').attr('id');
	window.setTimeout(
			"animateDetails('"+idToAnimate+"', 'backgroundColor_blue_sec','', '', false, true)" , 
			timeout
	);
	
}


//is this an IPad ?
var IS_IPAD = (navigator.userAgent.match(/iPad/i) != null);

// is this an iPhone ?
var IS_IPHONE = (navigator.userAgent.match(/iPhone/i) != null);

// is this an iPod ?
var IS_IPOD = (navigator.userAgent.match(/iPod/i) != null);


var HOST = window.location.protocol + "//" + window.location.host; 


/*======================= JQuery IE fix ===========================*/
jQuery.fn.fadeTo = function(speed,to,callback) { 
	return this.animate({opacity: to}, speed, function() { 
	    if (to == 1 && jQuery.browser.msie)  
	        this.style.removeAttribute('filter');  
	    if (jQuery.isFunction(callback)) 
	        callback();  
	});
};
/*===========================================================*/

jQuery.fn.centerDIV = function () {
	//alert($(window).scrollTop());
    this.css("position","absolute");
    this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
    this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    return this;
}

