var _GamePopWidth = 1018;
var _GamePopHeight = 720;
function addFav() {
      if(navigator.appVersion.indexOf("MSIE 6") != -1) {
        window.external.addFavorite("http://spel.tv4.se/", "spel.tv4.se");
    } else {
        alert("Detta kräver Internet Explorer v5.x  Tryck CTRL + D för att lägga till i favoriter");
    }
}

function mc(){
	if (arguments[0] == 'sport'){
		window.open('/community/spel/mc_sport_frameset.html','Messagecentral','width=700,height=530,left=60,top=60,scrollbars=0');
	}else{
		window.open('/community/spel/mc_frameset.html','Messagecentral','width=700,height=530,left=60,top=60,scrollbars=0');
	}
}

function OpenSymfonigame(gameid, symfoniid, roomid, name){
	var BannerType = '';
	var Height = 615;
	var Resizable = 'no';
	var GotBanner = false;
	var gametype = 'symf';

	if(roomid==2)
	{
		gametype = 'symfguest';
	}
	
	if(BannerType == '1'){
		Height += 62;
		GotBanner = true;
	}else if(BannerType == '18'){
		Height += 92;
		GotBanner = true;
	}
	
	var sH = screen.availHeight;
	sH = parseInt(sH);
	Height = parseInt(Height);
	if(sH < 600){
		sH = 600;
	}

	if(Height > sH){
		Height = sH;
		if(GotBanner){
			Resizable = 'yes';
		}
	}
	
	url = "/gamepop.aspx?";
	if(GotBanner){
		url = url + "height=" + Height + "&";
	}
	url = url + "BannerType=" + BannerType + "&gametype=" + gametype + "&symfid=" + symfoniid + "&symfroom=" + roomid + "&gameid=" + gameid + "&gamename=" + name + "&secondcolor=gfblue";
	curwin = window.open(url, 'spil', 'resizable=' + Resizable + ',scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width='+_GamePopWidth+',height=' + _GamePopHeight + ',left=20,top=20,resizable=no');
}

function OpenSymfonigameTicket(gameid, symfoniid, roomid, name)
{
	var BannerType = '';
	var Height = 615;
	var Resizable = 'no';
	var GotBanner = false;
	var _h = 768;
	var _w = 1024;
	var gametype = 'symfticket';
	
	if(roomid==2)
	{
		gametype = 'symfguest';
	}
	
	// Bortkommenterat av TC eftersom icke-premium fick en för stor popup
	//if(arguments[4]){
	//	BannerType = arguments[4];
	//}
	
	if(BannerType == '1'){
		Height += 62;
		GotBanner = true;
	}else if(BannerType == '18'){
		Height += 92;
		GotBanner = true;
	}
	
	var sH = screen.availHeight;
	sH = parseInt(sH);
	Height = parseInt(Height);
	if(sH < 600){
		sH = 600;
	}

	if(Height > sH){
		Height = sH;
		if(GotBanner){
			Resizable = 'yes';
		}
	}
	
	url = "/gamepop.aspx?";
	if(GotBanner){
		url = url + "height=" + Height + "&";
	}
	url = url + "BannerType=" + BannerType + "&gametype=" + gametype + "&symfid=" + symfoniid + "&symfroom=" + roomid + "&gameid=" + gameid + "&gamename=" + name + "&secondcolor=gfblue";
	curwin = window.open(url, 'spil', 'resizable=' + Resizable + ',scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width='+_GamePopWidth+',height=' + _GamePopHeight + ',left=20,top=20,resizable=no');
}

function OpenSymfonigameTicketMoney(gameid, symfoniid, roomid, name){
	var BannerType = '';
	var Height = 615;
	var Resizable = 'no';
	var GotBanner = false;
	var _h = 768;
	var _w = 1024;

	// Bortkommenterat av TC eftersom icke-premium fick en för stor popup
	//	if(arguments[4]){
	//		BannerType = arguments[4];
	//	}
	
	if(BannerType == '1'){
		Height += 62;
		GotBanner = true;
	}else if(BannerType == '18'){
		Height += 92;
		GotBanner = true;
	}
	
	var sH = screen.availHeight;
	sH = parseInt(sH);
	Height = parseInt(Height);
	if(sH < 600){
		sH = 600;
	}

	if(Height > sH){
		Height = sH;
		if(GotBanner){
			Resizable = 'yes';
		}
	}
	
	url = "/gamepop.aspx?";
	if(GotBanner){
		url = url + "height=" + Height + "&";
	}
	url = url + "BannerType=" + BannerType + "&gametype=symfmoney&symfid=" + symfoniid + "&symfroom=" + roomid + "&gameid=" + gameid + "&gamename=" + name + "&secondcolor=gfblue";
	curwin = window.open(url, 'spil', 'resizable=' + Resizable + ',scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width='+_GamePopWidth+',height=' + _GamePopHeight + ',left=20,top=20,resizable=no');
}

function newWindow(spilnummer,rumnummer) {
    var browser = navigator.appName;
    var bVer    = parseInt(navigator.appVersion);
    var vers
    url         = "http://spel3.tv4.se/startspil.php?spilnummer=" + spilnummer + "&rumnummer=" + rumnummer;
    
    if(browser == "Netscape" && bVer >= 4)
        vers = "n4";
    else
        if(browser == "Netscape" && bVer == 3)
            vers = "n3";
    else
        if(browser == "Netscape" && bVer == 2)
            vers = "n2";
    else
        if(browser == "Microsoft Internet Explorer" && bVer >= 4)
            vers="e4";
    else
        if(browser == "Microsoft Internet Explorer" && bVer >= 2)
             vers="e3";
    else vers = "x";

    if(vers == "n4" && navigator.appVersion.lastIndexOf("Mac") != -1)
        vers = "n3";
    if(vers == "x") return;
    else
    if(vers == "n4")
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
    else
    if(vers == "n3")
    {
        if(navigator.appVersion.lastIndexOf("Mac") != -1)
        {
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
            curwin.location.href=url;
        }
        else
        {
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
            curwin.location.href=url;
        }
    }
    else
    if(vers == "n2")
        window.location.href = url
    else if(vers == "e4")
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
    else if(vers == "e3")
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
}



function newWindow2(spilnummer,rumnummer) {
    var browser = navigator.appName;
    var bVer    = parseInt(navigator.appVersion);
    var vers
    url         = "http://dev.tv4.se/spel/spelpopup.asp?spilnummer=" + spilnummer + "&rumnummer=" + rumnummer;
    
    if(browser == "Netscape" && bVer >= 4)
        vers = "n4";
    else
        if(browser == "Netscape" && bVer == 3)
            vers = "n3";
    else
        if(browser == "Netscape" && bVer == 2)
            vers = "n2";
    else
        if(browser == "Microsoft Internet Explorer" && bVer >= 4)
            vers="e4";
    else
        if(browser == "Microsoft Internet Explorer" && bVer >= 2)
             vers="e3";
    else vers = "x";

    if(vers == "n4" && navigator.appVersion.lastIndexOf("Mac") != -1)
        vers = "n3";
    if(vers == "x") return;
    else
    if(vers == "n4")
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
    else
    if(vers == "n3")
    {
        if(navigator.appVersion.lastIndexOf("Mac") != -1)
        {
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
            curwin.location.href=url;
        }
        else
        {
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
            curwin.location.href=url;
        }
    }
    else
    if(vers == "n2")
        window.location.href = url
    else if(vers == "e4")
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
    else if(vers == "e3")
        curwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width="+_GamePopWidth+",height="+_GamePopHeight+",left=20,top=20,resizable=no");
}

var strErrors
function doDisplayErrors(){
	strErrors = "";
	if (strErrors.length > 0){
		alert(strErrors);
	}
}
function doSave(){
	strErrors = "";
	if (!funcLib.isEmail(document.forms[0].txtEMail.value)){
		strErrors = strErrors + "* Du måste ange din e-postadress eller den epost-address du har angivit är inte korrekt.\n";
	}
	if (document.forms[0].txtPassword.value.length == 0){
		strErrors = strErrors + "* Du måste ange ditt lösenord.\n";
	}
	if (strErrors.length == 0){
		document.forms[0].hdnAction.value = "submit";
                return true;
	}else{
		alert(strErrors);
                return false;
	}
} 
function popup(url,width,height)
{
	_w = 1024;
	_h = 768;
	if(url.indexOf("games.blip.se")!= -1)
	{
		url = "/gamepop.aspx?king="+escape(url);
	}
    popwin = window.open(url, "spil","resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,width=" + _GamePopWidth + ",height=" + _GamePopHeight + ",left=20,top=20,resizable=no");
}

function showMyHelp(msg){
	if (objLib.netscape){
		objLib.showHelp('<TABLE border=0 cellspacing=0 cellpadding=0><TR><TD width=1 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD><TD height=1 width=200 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD><TD width=1 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD></TR><TR><TD width=1 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD><TD width=1 bgCOLOR=ECA007><TABLE border=0 width=200 cellspacing=0 cellpadding=4 bgCOLOR=ECA007><TR><TD VALIGN=TOP><IMG SRC=images/icn_attention.gif></TD><TD width=200 VALIGN=TOP>' + msg + '</TD></TR></TABLE></TD><TD width=1 bgCOLOR=66460C><IMG SRC=images/blank.gif width=1 height=1></TD></TR><TR><TD width=1 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD><TD width=1 bgCOLOR=66460C><IMG SRC=images/blank.gif width=1 height=1></TD><TD width=1 bgCOLOR=66460C><IMG SRC=images/blank.gif width=1 height=1></TD></TR></TABLE>', 0);
	}else{
		objLib.showHelp('<div id="help" style="position:absolute; cursor:hand; filter:Alpha(opacity=90, style=0)"><TABLE border=0 cellspacing=0 cellpadding=0><TR><TD width=1 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD><TD height=1 width=200 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD><TD width=1 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD></TR><TR><TD width=1 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD><TD width=1 bgCOLOR=ECA007><TABLE border=0 width=200 cellspacing=0 cellpadding=4 bgCOLOR=ECA007><TR><TD VALIGN=TOP><IMG SRC=images/icn_attention.gif></TD><TD width=200 VALIGN=TOP>' + msg + '</TD></TR></TABLE></TD><TD width=1 bgCOLOR=66460C><IMG SRC=images/blank.gif width=1 height=1></TD></TR><TR><TD width=1 bgCOLOR=F4C972><IMG SRC=images/blank.gif width=1 height=1></TD><TD width=1 bgCOLOR=66460C><IMG SRC=images/blank.gif width=1 height=1></TD><TD width=1 bgCOLOR=66460C><IMG SRC=images/blank.gif width=1 height=1></TD></TR></TABLE></DIV>', 0);
	}
}