﻿<!--//
/*Popup Window Functions*/
var popUpWin;
var popDefWidth = 570;
var popDefHeight = 400;
var lastWidth;
var lastHeight;

//Open URL in new window with fixed dimensions
function openWin(url, pixWidth, pixHeight, canScroll){
	var winFeatures = "width=" + pixWidth + ",height=" + pixHeight + "," + getCentered(pixWidth,pixHeight) + ",resizable=no,scrollbars=";
	if (canScroll){
		winFeatures += "yes";
	} else {
		winFeatures += "no";
	}
	if (popUpWin != null){
		if (popUpWin.closed){
			popUpWin = window.open(url, "popwin", winFeatures);
			popUpWin.focus();
		} else if ((lastWidth == pixWidth) && (lastHeight == pixHeight)){
			popUpWin.location.href = url;
			popUpWin.focus();
		} else {
			popUpWin.close();
			var timeDelay = 0;
			if (navigator.userAgent.indexOf("Safari") != -1){
				timeDelay = 1000;
			}
			var winWait = window.setTimeout('popUpWin = window.open("' + url + '", "popwin", "' + winFeatures + '");popUpWin.focus();', timeDelay);
		}	
	} else {
		popUpWin = window.open(url, "popwin", winFeatures);
		if (!popUpWin){
			var swfMovie = getObject("lufthansa");
			swfMovie.openRules();
		} else {
			popUpWin.focus();
		}
	}
	lastWidth = pixWidth;
	lastHeight = pixHeight;
}

//Get coordinates for centering window
function getCentered(popupWidth, popupHeight){
	var indentNetscapeWidth = 'screenX=' + getIndent(popupWidth, false);
	var indentNetscapeHeight = 'screenY=' + getIndent(popupHeight, true);
	var indentMSIEWidth = 'left=' + getIndent(popupWidth, false);
	var indentMSIEHeight = 'top=' + getIndent(popupHeight, true);
	var centerCoordinates = indentNetscapeWidth + ',' + indentNetscapeHeight + ',' + indentMSIEWidth + ',' + indentMSIEHeight;
	return centerCoordinates;
}

//Determine top and left margins for window
function getIndent (popupDimension, isHeight){
	if (isHeight){
		return ((screen.availHeight - popupDimension) / 2);
	} else {
		return ((screen.availWidth - popupDimension) / 2);
	}
}

function popRules(){
	openWin("rules.aspx", 500, 500, false);
}

//Close popup and redirect parent to URL
function closeAndGo(url){
	var newWin;
	if (window.opener != null){
		if (window.opener.closed){
			newWin = window.open(url,'newwin','width=' + screen.availWidth + ',height=' + screen.availHeight + ',toolbar=yes,status=yes,directories=yes,location=yes,menubar=yes,personalbar=yes,resizable=yes,scrollbars=yes');
			newWin.focus();
		} else {
			window.opener.location.href = url;
			window.opener.focus();
		}
	} else {
		newWin = window.open(url,'newwin','width=' + screen.availWidth + ',height=' + screen.availHeight + ',toolbar=yes,status=yes,directories=yes,location=yes,menubar=yes,personalbar=yes,resizable=yes,scrollbars=yes');
		newWin.focus();
	}
	window.close();
}
//-->
