
gln_cookie = new Cookie(document, "gsc_launch_notify", 8765, "/");
gln_cookie.load();
show_launch = true;
if (gln_cookie.show_launch == 0)
	show_launch = false;
var gscLaunchMouseX;
var gscLaunchMouseY;
$(document).ready(function()
{
	//TRACK MOUSE POSITION
	$("body").mousemove(
		function(e)
		{
			gscLaunchMouseX = e.pageX;
			gscLaunchMouseY = e.pageY;
		}
	);
	//CREATE POPUP DIV
	e = document.createElement("div");
	e.id = "EXTAPPPOP";
	e.style.display = "none";
	e.style.position = "absolute";
	e.style.top = "0px";
	e.style.left = "0px";
	e.style.zIndex = 1000;
	e.style.width = "250px";
	e.innerHTML = '\
	<!-- EXP APP POP -->\n\
	<table width="100%" style="color:white; font-size:8pt; border-style:none; border-width:0px; border-spacing:0px 0px; border-collapse:collapse;">\n\
		<tr>\n\
			<td style="width:9px; height:40px; overflow:hidden; padding:0px; margin:0px; background-image:url(/images/global/PopupGT/PopupGT_TL.gif); background-repeat: no-repeat;">\n\
				&nbsp;&nbsp;&nbsp;\n\
			</td>\n\
			<td valign="top" style="height:40px; overflow:hidden; padding:0px; margin:0px; background-image:url(/images/global/PopupGT/PopupGT_TM.gif); background-repeat: repeat-x;">\n\
				<div style="height:36px; background-image:url(/images/global/PopupGT/PopupGT_title.gif); background-repeat:no-repeat; background-position: 50% 50%;" >\n\
						<div style="float:left;">\n\
							<img style="display:block; padding-top:8px;" src="/images/global/PopupGT/PopupGT_logo.gif" alt="GT" />\n\
						</div>\n\
						<div style="float:right;">\n\
							<img style="display:block; padding-top:8px; cursor:pointer;" onclick="javascript:gscHideLaunch();" src="/images/global/PopupGT/PopupGT_close.gif" alt="Close" />\n\
						</div>\n\
						<div style="clear:both;">\n\
						</div>\n\
				</div>\n\
			</td>\n\
			<td style="width:9px; height:40px; overflow:hidden; padding:0px; margin:0px; background-image:url(/images/global/PopupGT/PopupGT_TR.gif); background-repeat: no-repeat;">\n\
				&nbsp;&nbsp;&nbsp;\n\
			</td>\n\
		</tr>\n\
		<tr>\n\
			<td style="width:9px; overflow:hidden; padding:0px; margin:0px; background-image:url(/images/global/PopupGT/PopupGT_ML.gif); background-repeat: repeat-y;">\n\
				&nbsp;\n\
			</td>\n\
			<td valign="center" style="background-color:#171B20;">\n\
				<div id="EXTAPPPOP_CONTENT" style="padding:20px; text-align:center;">\n\
				</div>\n\
			</td>\n\
			<td style="width:9px; overflow:hidden; padding:0px; margin:0px; background-image:url(/images/global/PopupGT/PopupGT_MR.gif); background-repeat: repeat-y;">\n\
				&nbsp;\n\
			</td>\n\
		</tr>\n\
		<tr>\n\
			<td style="width:9px; height:9px; overflow:hidden; padding:0px; margin:0px; background-image:url(/images/global/PopupGT/PopupGT_BL.gif); background-repeat: no-repeat;">\n\
				&nbsp;\n\
			</td>\n\
			<td style="height:9px; overflow:hidden; padding:0px; margin:0px; background-image:url(/images/global/PopupGT/PopupGT_BM.gif); background-repeat: repeat-x;">\n\
				&nbsp;\n\
			</td>\n\
			<td style="width:9px; height:9px; overflow:hidden; padding:0px; margin:0px; background-image:url(/images/global/PopupGT/PopupGT_BR.gif); background-repeat: no-repeat;">\n\
				&nbsp;\n\
			</td>\n\
		</tr>\n\
	</table>\n';
	//INSERT POPUP INTO DOM
	n1 = document.body.firstChild;
	while(n1.nodeType != 1)
		n1 = n1.nextSibling;
	document.body.insertBefore(e, n1);
})
function gscShowLaunch(launchLinkText)
{
	var extapppop	= document.getElementById('EXTAPPPOP');
	var type		= launchLinkText.toString().match(/[^:\/\/]+/);
	var action		= '';
	if (type == "gt")
	{
		action = launchLinkText.toString().match(/:\/\/[^:]+/);
		action = action.toString().substring(3);
		type = type + '_' + action;
	}
	if (type == "gsc")
	{
		action = launchLinkText.toString().match(/:\/\/[^:]+/);
		action = action.toString().substring(3);
		type = type + '_' + action;
	}
	if (type == "gsc_join")
	{
		if(launchLinkText.toString().search(/(\.)+/) == -1)
			type = type + "v1";
		else
			type = type + "v2";
	}
	//alert(type);
	//DIRECT LAUNCH
	if (!show_launch)
	{
		if (type == "ventrilo")
		{
			window.location.href = launchLinkText;
			return;
		}
		if (type == "teamspeak")
		{
			window.location.href = launchLinkText;
			return;
		}
		if (type == "gt_joinGame")
		{
			window.location.href = launchLinkText;
			return;
		}
		if (type == "gsc_joinv1")
		{
			window.location.href = launchLinkText;
			return;
		}
		if (type == "gsc_joinv2")
		{
			window.location.href = launchLinkText;
			return;
		}
		if (type == "gsc_openChat")
		{
			window.location.href = launchLinkText;
			return;
		}
	}
	//SHOW LAUNCH POPUP
	else
	{
		if (type == "ventrilo")
		{
			var temp = '\
			<div style="text-align:left;">\n\
				<b>Launch with Ventrilo!</b>\n\
				<br/>\n\
				To join Ventrilo voice servers through your internet browser, you MUST have Ventrilo installed on your computer.\n\
			<div>\n\
			<div style="margin-top:10px; color:white; font-size:8pt;">\n\
				<input type="checkbox" id="EXTAPPPOP_DISABLE" value="y" style="position: relative; top: 2px;">&nbsp;&nbsp;Don\'t show this message again.\n\
			</div>\n\
			<div style="margin-top:8px; text-align:center;">\n\
				<a style="color:#FF9900;" onclick="javascript:gscHideLaunch();" href="' + launchLinkText + '">\n\
					Join Ventrilo Server\n\
				</a>\n\
				|\n\
				<a style="color:#FF9900;" href="javascript:gscHideLaunch()">\n\
					Cancel\n\
				</a>\n\
			</div>\n';
		}
		else if (type == "teamspeak")
		{
			var temp = '\
			<div style="text-align:left;">\n\
				<b>Launch with TeamSpeak!</b>\n\
				<br/>\n\
				To join Teamspeak voice servers through your internet browser, you MUST have TeamSpeak installed on your computer.\n\
			<div>\n\
			<div style="margin-top:10px; color:white; font-size:8pt;">\n\
				<input type="checkbox" id="EXTAPPPOP_DISABLE" value="y" style="position: relative; top: 2px;">&nbsp;&nbsp;Don\'t show this message again.\n\
			</div>\n\
			<div style="margin-top:8px; text-align:center;">\n\
				<a style="color:#FF9900;" onclick="javascript:gscHideLaunch();" href="' + launchLinkText + '">\n\
					Join Teamspeak Server\n\
				</a>\n\
				|\n\
				<a style="color:#FF9900;" href="javascript:gscHideLaunch()">\n\
					Cancel\n\
				</a>\n\
			</div>\n';
		}
		else if (type == "gt_joinGame")
		{
			var temp = '\
			<div style="text-align:left;">\n\
				<b>Launch with GameTracker Lite!</b>\n\
				<br/>\n\
				To join games through your internet browser, you MUST have GameTracker Lite installed on your computer.\n\
				<br/>\n\
				<br/>\n\
				<b>Don\'t have GameTracker Lite?</b>\n\
				<br/>\n\
				<a style="color:#FF9900;" href="http://www.gametracker.com/downloads/" target="_blank">Click here to download!</a>\n\
			<div>\n\
			<div style="margin-top:10px; color:white; font-size:8pt;">\n\
				<input type="checkbox" id="EXTAPPPOP_DISABLE" value="y" style="position: relative; top: 2px;">&nbsp;&nbsp;Don\'t show this message again.\n\
			</div>\n\
			<div style="margin-top:8px; text-align:center;">\n\
				<a style="color:#FF9900;" onclick="javascript:gscHideLaunch();" href="' + launchLinkText + '">\n\
					Join Game Server\n\
				</a>\n\
				|\n\
				<a style="color:#FF9900;" href="javascript:gscHideLaunch()">\n\
					Cancel\n\
				</a>\n\
			</div>\n';
		}
		else if (type == "gsc_joinv1")
		{
			var temp = '\
			<div style="text-align:left;">\n\
				<b>Launch with GSC v1.0!</b>\n\
				<br/>\n\
				To join GSC v1.0 voice channels through your internet browser, you MUST have GSC v1.0 installed on your computer.\n\
				<br/>\n\
				<br/>\n\
				<b>Don\'t have GSC v1.0?</b>\n\
				<br/>\n\
				<a style="color:#FF9900;" href="http://www.getgsc.com/gsc/downloads/" target="_blank">Click here to download!</a>\n\
			<div>\n\
			<div style="margin-top:10px; color:white; font-size:8pt;">\n\
				<input type="checkbox" id="EXTAPPPOP_DISABLE" value="y" style="position: relative; top: 2px;">&nbsp;&nbsp;Don\'t show this message again.\n\
			</div>\n\
			<div style="margin-top:8px; text-align:center;">\n\
				<a style="color:#FF9900;" onclick="javascript:gscHideLaunch();" href="' + launchLinkText + '">\n\
					Join Voice Channel\n\
				</a>\n\
				|\n\
				<a style="color:#FF9900;" href="javascript:gscHideLaunch()">\n\
					Cancel\n\
				</a>\n\
			</div>\n';
		}
		else if (type == "gsc_joinv2")
		{
			var temp = '\
			<div style="text-align:left;">\n\
				<b>Launch with GSC v2.0!</b>\n\
				<br/>\n\
				To join GSC v2.0 voice channels through your internet browser, you MUST have GSC v2.0 installed on your computer.\n\
				<br/>\n\
				<br/>\n\
				<b>Don\'t have GSC v2.0?</b>\n\
				<br/>\n\
				<a style="color:#FF9900;" href="http://www.getgsc.com/gsc/downloads/" target="_blank">Click here to download!</a>\n\
			<div>\n\
			<div style="margin-top:10px; color:white; font-size:8pt;">\n\
				<input type="checkbox" id="EXTAPPPOP_DISABLE" value="y" style="position: relative; top: 2px;">&nbsp;&nbsp;Don\'t show this message again.\n\
			</div>\n\
			<div style="margin-top:8px; text-align:center;">\n\
				<a style="color:#FF9900;" onclick="javascript:gscHideLaunch();" href="' + launchLinkText + '">\n\
					Join Voice Channel\n\
				</a>\n\
				|\n\
				<a style="color:#FF9900;" href="javascript:gscHideLaunch()">\n\
					Cancel\n\
				</a>\n\
			</div>\n';
		}
		else if (type == "gsc_openChat")
		{
			var temp = '\
			<div style="text-align:left;">\n\
				<b>Open a chat session with GSC!</b>\n\
				<br/>\n\
				To start a chat session with another user you MUST have GSC installed on your computer.\n\
				<br/>\n\
				<br/>\n\
				<b>Don\'t have GSC?</b>\n\
				<br/>\n\
				<a style="color:#FF9900;" href="http://www.getgsc.com/gsc/downloads/" target="_blank">Click here to download!</a>\n\
			<div>\n\
			<div style="margin-top:10px; color:white; font-size:8pt;">\n\
				<input type="checkbox" id="EXTAPPPOP_DISABLE" value="y" style="position: relative; top: 2px;">&nbsp;&nbsp;Don\'t show this message again.\n\
			</div>\n\
			<div style="margin-top:8px; text-align:center;">\n\
				<a style="color:#FF9900;" onclick="javascript:gscHideLaunch();" href="' + launchLinkText + '">\n\
					Open Chat\n\
				</a>\n\
				|\n\
				<a style="color:#FF9900;" href="javascript:gscHideLaunch()">\n\
					Cancel\n\
				</a>\n\
			</div>\n';
		}
		else
		{
			return;
		}
		//document.getElementById('EXTAPPPOP').style.width = "100%";
		var height = $('#EXTAPPPOP').height() / 2;
		var width = $('#EXTAPPPOP').width() / 2;
		extapppop.style.left = (gscLaunchMouseX - width) + "px";
		extapppop.style.top = (gscLaunchMouseY - height) + "px";
		document.getElementById('EXTAPPPOP_CONTENT').innerHTML = temp;
		extapppop.style.display = 'block';
		return;
	}
}
function gscHideLaunch()
{
	if (document.getElementById('EXTAPPPOP_DISABLE').checked)
	{
		show_launch = false;
		gln_cookie.show_launch = 0;
		gln_cookie.store();
	}
	document.getElementById('EXTAPPPOP').style.display = 'none';
}