// Window - PopUp Script
// IE und NS kompatibel
// by TVC The Virtual Company, www.tvc.at

var wHnd;
var IsOpen = 0;

function PopUp(u,w,h) {
	
	cmd = "resizable=yes,scrollbars=no";
	PopUpVar(u,w,h,cmd);
}

function PopUpScrollBar(u,w,h) {
	
	cmd = "resizable=yes,scrollbars=yes";
	PopUpVar(u,w,h,cmd);
}

function PopUpFix(u,w,h) {
	
	cmd = "resizable=no,scrollbars=no";
	PopUpVar(u,w,h,cmd);
}

function PopUpAVStream(u) {
	
	cmd = "resizable=yes,scrollbars=no";
	PopUpVar(u,400,460,cmd);
}

function PopUpAStream(u) {
	
	cmd = "resizable=no,scrollbars=no";
	PopUpVar(u,400,200,cmd);
}

function PopUpVar(u,w,h,cmd) 
{
	var TheURL = "";
	if (IsOpen) 
	{
		if (document.layers) 
		{
			if (wHnd.name == "PopUp") 
			{
				wHnd.close();
			}
		}
		else 
		{
			if (navigator.appVersion.substr(22,1) != "4" && navigator.appVersion.indexOf("Windows") >= 0 ) 
			{ 
				wHnd.close(); 
			} // IE4
		}
	}

	cmd = "width=" + w + ",height=" + h + ",alwaysRaised=yes,depend=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no," + cmd
	TheURL = fixIEMacCharProblem(u); // Setzt TheURL (wegen IE-Fehler)
	wHnd = window.open(TheURL, "PopUp", cmd);
	IsOpen = true;
}

// IE (Version 5) für MAC hat Probleme mit Sonderzeichen wie ü,ä, ... in JavaScript,
// es passiert offensichtlich ein Überlauf aufgrund von signed char
function fixIEMacCharProblem(str){
	var newstr="";
	for (i=0;i<str.length;i++){
		theChar = str.charCodeAt(i);
		if(theChar<0){
			//alert("before: "+theChar);
			newstr = newstr + String.fromCharCode(theChar+256);
			//alert("after: "+String.fromCharCode(theChar+256));
		}
		else {
			newstr = newstr + str.charAt(i);
		}
	}
	return newstr;
}
