/*
if (self != top) {
    if (document.images)
        top.location.replace(window.location.href);
    else
        top.location.href = window.location.href;
}
*/
function setFocus(){
	document.forms[0].uName.focus();
}
function spambot(mailbox, domain, name) {
	 if (name == null){
   name = mailbox + "@" + domain
   }
   document.write("<a href=\"mailto");
   document.write(":" + mailbox + "@");
   document.write(domain + "\">" + name + "<\/a>");
}
function showLarge(largeImg) {
	showImage = window.open(largeImg, 'showImg', 'width=640,height=485,resizable=1,status=0,scrollbars=0,toolbar=0,menubar=0');
	showImage.focus()
}
function setMenuItem(num){
	if(document.getElementById("menu" + num)){
		menu = document.getElementById("menu" + num);
		var menuStatus = (menu.style.display == 'none') ? 'block' : 'none';
		menu.style.display = menuStatus;
	}
}

$(document).ready(
	function() {
		if ($('div#livestream').length) {
		   $.ajax( {
		        type: "GET",
				url: "http://xninjalanex.api.channel.livestream.com/2.0/livestatus.json",
				dataType: "jsonp",
				success: function(data){
					if (data.channel.isLive) {
						$('div#livestream').append("<div id='lsbox' class='bodytext'>");
						$('div#lsbox').append("<div id='lsheader' class='pagetitle'>Live Broadcast<br />");
						$('div#lsheader').append("<span class='smalltext'>Click below to view broadcast</span></div>");			
						$('div#lsbox').append("<a href='livestream.aspx'><img id='thumbnail' style='width:260px; height:195px;' border='0'></a>");
						$('div#lsbox').append("<div id='viewers'></div>");
						$('div#livestream').append("</div>");
						updateThumb();
						setInterval("updateThumb()", 10000);
						//$('img#thumbnail').attr({src:"http://thumbnail.api.livestream.com/thumbnail?name=ninjalane&t=" + new Date().valueOf()});
						$('div#viewers').html(data.channel.currentViewerCount + ' Viewers');
					} else {
						$('div#livestream').remove();
					}
				}
			});
		}
	});

function updateThumb() {
	thumbnail = document.getElementById('thumbnail');
	thumbnail.src = "http://thumbnail.api.livestream.com/thumbnail?name=ninjalane&t=" + new Date().valueOf();
}
