// JavaScript Document
function contestOpen() {
	if (isLoggedIn > 0) {
		var newURL = "http://creative.myspacecdn.com/Client/YumBrands/KFC/Tech/pre-submissionPage.html?" + isLoggedIn;
		openWindow(newURL, 'contestWindow', 'toolbar=1,width=880,height=750,scrollbars=yes');
	} else {
		openDialog(loginPop, 350, 310);
	}
}
function hiatusOpen() {
	if (isLoggedIn > 0) {
		var newURL = "http://creative.myspacecdn.com/Client/YumBrands/KFC/Tech/hiatus-submissionPage.html?" + isLoggedIn;
		openWindow(newURL, 'contestWindow', 'toolbar=1,width=880,height=750,scrollbars=yes');
	} else {
		openDialog(loginPop, 350, 310);
	}
}

function voteLoadPage() {
	if (isLoggedIn > 0) {
		var newURL = "http://creative.myspacecdn.com/Client/YumBrands/KFC/Tech/aug09_voting.html?" + isLoggedIn;
		openWindow(newURL, 'contestWindow', 'toolbar=1,width=880,height=750,scrollbars=yes');
	} else {
		openDialog(loginPop, 350, 310);
	}
}

function galleryOpen() {
	openWindow("http://adsupport.myspace.com/index.cfm?fuseaction=advertiser.videogallery&galleryid=1397", 'contestWindow', 'toolbar=1,width=880,height=750,scrollbars=yes');
}

function getDisplayFriendID() { return MySpace.ClientContext.DisplayFriendId; }
	
addthis_offset_top      = 0;
addthis_offset_top_low  = 0;
addthis_offset_left     = 0;

function openWindow(URL, windowName, windowFeatures){ 
		window.open(URL, windowName, windowFeatures); 
}

var win = null;
var index = 1;
function openDialog(id,w,h) {
    Dialog.alert($(id).innerHTML, {className: "alphacube",  width:w, height:h, id: "d" + index})
	document.getElementById('videoPlayer').style.display = "none";
    index++;
}

function lastDialog(id) {
    Dialog.confirm($(id).innerHTML, {className: "alphacube",  width:250, okLabel: "Close All", ok: closeAllModalWindows})
}

function closeAllModalWindows() {
	document.getElementById('videoPlayer').style.display = "block";
	videoSwap(58413616);
    Windows.closeAllModalWindows();
}


function videoSwap(videoId){
	var videoContainer = document.getElementById('videoPlayer');
   	videoContainer.innerHTML = '<embed src="http://lads.myspace.com/videos/vplayer.swf" width="417" height="280" flashvars="ap=1&m='+ videoId +'&sr=0" type="application/x-shockwave-flash" />';
}



