// Quick browser detection
var isMoz = (document.getElementById && !document.all);
var isIE = (document.getElementById && document.all);
var isNav = (document.layers && !document.getElementById);

// window.status message system
function showStatus(msg) {
	window.status = msg;
	return true;
}

// onmouseover rollovers
function on(imgName) {
	if (document.images) {
		eval("var " + imgName + "_on" + "= new Image()");
		eval(imgName.toString() + "_on.src = \"img\/" + imgName + "-on.gif\"");
		document[imgName].src = eval(imgName + "_on.src");
	}
}

// onmouseout rollovers
function off(imgName) {
	if (document.images) {
		eval("var " + imgName + "_off" + "= new Image()");
		eval(imgName.toString() + "_off.src = \"img\/" + imgName + "-off.gif\"");
		document[imgName].src = eval(imgName + "_off.src");

		return showStatus('');

	}
}

// Inline Secure Flash placement function
function secureflash(file,id,width,height,quality,bgcolor,wmode) {

	var mode;
	if (wmode) mode = "transparent";
	else mode = "opaque";

	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"https:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,0,0\" width=\"" + width + "\" height=\"" + height + "\" id=\"" + id + "\"><param name=\"movie\" value=\"" + file + "\" \/><param name=\"quality\" value=\"" + quality + "\" \/><param name=\"bgcolor\" value=\"" + bgcolor + "\" \/><param name=\"wmode\" value=\"" + mode + "\" \/><param name=\"menu\" value=\"false\" \/><embed src=\"" + file + "\" quality=\"" + quality + "\" bgcolor=\"" + bgcolor + "\" width=\"" + width + "\" height=\"" + height + "\" menu=\"false\" name=\"" + id + "\" type=\"application\/x-shockwave-flash\" pluginspage=\"https:\/\/www.macromedia.com\/go\/getflashplayer\"><\/embed><\/object>");

}

// Inline Flash placement function
function flash(file,id,width,height,quality,bgcolor,wmode) {

	var mode;
	if (wmode) mode = "transparent";
	else mode = "opaque";

	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,0,0\" width=\"" + width + "\" height=\"" + height + "\" id=\"" + id + "\"><param name=\"movie\" value=\"" + file + "\" \/><param name=\"quality\" value=\"" + quality + "\" \/><param name=\"bgcolor\" value=\"" + bgcolor + "\" \/><param name=\"wmode\" value=\"" + mode + "\" \/><param name=\"menu\" value=\"false\" \/><embed src=\"" + file + "\" quality=\"" + quality + "\" bgcolor=\"" + bgcolor + "\" width=\"" + width + "\" height=\"" + height + "\" menu=\"false\" name=\"" + id + "\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\"><\/embed><\/object>");

}

function flashSwap(file,id,width,height,quality,bgcolor,wmode,div) {

	var mode;
	if (wmode) mode = "transparent";
	else mode = "opaque";

	var temp = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,0,0\" width=\"" + width + "\" height=\"" + height + "\" id=\"" + id + "\"><param name=\"movie\" value=\"" + file + "\" \/><param name=\"quality\" value=\"" + quality + "\" \/><param name=\"bgcolor\" value=\"" + bgcolor + "\" \/><param name=\"wmode\" value=\"" + mode + "\" \/><param name=\"menu\" value=\"false\" \/><embed src=\"" + file + "\" quality=\"" + quality + "\" bgcolor=\"" + bgcolor + "\" width=\"" + width + "\" height=\"" + height + "\" menu=\"false\" name=\"" + id + "\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\"><\/embed><\/object>";
	eval("document.getElementById('" + div + "').innerHTML = temp");

}

function flashLogout() {

	document.location = "http://www.ytv.com/members/logout.asp";
	//document.reload(true);
}

var today = new Date();
var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000);

function flashLogin() {
	document.cookie = "TARGET=" + escape(document.location)+"; path=/; expires" + expiry.toGMTString() + "; domain=ytv.com ";

}

function flashLoginButton() {
	document.cookie = "TARGET=" + escape(document.location)+"; path=/; expires" + expiry.toGMTString() + "; domain=ytv.com ";

	var is_mac, is_ie

	var agt=navigator.userAgent.toLowerCase();
	var is_mac=(agt.indexOf("mac")!=-1);
	var is_op=(agt.indexOf("opera") !=-1);
	var is_ie=(is_op==false && agt.indexOf("msie") !=-1);

	if ((is_mac) && (is_ie)) {

		if (document.location != "http://www.ytv.com/members/login.asp") {
			document.location = "http://www.ytv.com/members/login.asp";
		}
	}

}

function setTimeZone(timezone) {
	var today = new Date();
	var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000);
	document.cookie = "YTVguide=TimeZone="+escape(timezone)+"; path=/; expires="+expiry.toGMTString();
	document.location = document.location;
}


// leaving Ytv.com alert box
function openWindow(url, width, height, options, name) {
	var newWin = window.open(url, name, "width=" + width + ",height=" + height + "," + options);
}

function linkOutside(strURL) {
	if (confirm('You are now leaving the YTV site!\n\nTo return to YTV.com simply close the new window.')) {
		var winSite = window.open(strURL);
	}
}

function launchSKActivate()
{
	//win = window.open("http://www.ytv.com/sitekick/activate_sitekick.asp", "win", "height=400,width=550,scrollbars=no,location=no,menu=no,resize=no");
	win = window.open("http://www.ytv.com/common/inc/sitekick/checkSKStatus.asp", "win", "height=400,width=550,scrollbars=no,location=no,menu=no,resize=no");
}

function launchSKKickstart()
{
	win = window.open("http://www.ytv.com/sitekick/kickstart.asp", "win", "height=400,width=550,scrollbars=no,location=no,menu=no,resize=no");
}

function launchSKDeactivate()
{
	win = window.open("http://www.ytv.com/common/inc/sitekick/deactivateSitekick.asp", "win", "height=400,width=550,scrollbars=no,location=no,menu=no,resize=no");
}

function launchGameFromAnywhere(folder,gameID) {
	link = window.open("http://www.ytv.com/games/game.asp?gameFolder=/games/" + folder + "/&swf=game.swf&gameID=" + gameID,"","width=550,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0");
}

function launchGameFromAnywhereNoPreloader(folder,gameID) {
	link = window.open("http://www.ytv.com/games/" + folder + "/game.asp?gameID=" + gameID,"","width=550,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0");
}

function launchPromoFromAnywhereNoPreloader(folder,gameID,promoURL) {
	link = window.open("http://www.ytv.com/games/" + folder + "/game.asp?gameID=" + gameID,"","width=550,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0");
	document.location = promoURL;
}

function launchSpiderman()
{
	win = window.open("http://www.ytv.com/programming/shows/spiderman/minisite/index.html", "win", "height=560,width=800,scrollbars=no,location=no,menu=no,resize=no");
}

function openVideo(id) {
	link = window.open("video.asp?videoID=" + id,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,width=320,height=240,left=250,top=250");
}

function openPic(url, w, h) {
	link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,width="+w+",height="+h+",left=250,top=250");
}

function reloadSelf() {
	var s = window.location;
	window.location = s;
	delete s;
}

function openDebug() {
	var l = String(document.location);
	if (l.indexOf("debug") != -1 || l.indexOf("dev") != -1) {
		var d = window.open("http://www.ytv.com/test/debug/debug.html","debug","width=550,height=400,scrollbars=no,menubar=no,toolbar=no,location=no,status=no,resizable=yes");
	}
	delete l;
	delete d;
}


// opens po-up window for the Media Player
function VideoPlayerPopUp(URL)
{
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=730,height=620,left = 0,top = 0');");
}







