function checkPopoutVideo() {
	if (popoutVideo.closed)  
		changeChannel(currentstream, currentchannel);
	else
		setTimeout("checkPopoutVideo()", 1000); 
}

function checkPopoutChat() {
	if (popoutChat.closed)
		loadIRC(embedwidth, embedheight);
	else
		setTimeout("checkPopoutChat()", 1000); 
}

function popout(type) {
	var LeftPosition = 0;
	var TopPosition = 0;
	var page = null;
	var title = "Live.LordKaT.com " + type;
	var settings = 'width=640,height=410,top=0,left=0,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';

	if (ishighlight == false)
		page = "popout.php?type=" + type + "&stream=" + currentstream + "&channel=" + jsonData[0].jtv[currentchannel].jtvname;
	else
		page = "popout.php?type=" + type + "&stream=" + currentstream + "&channel=" + jsonData[1].highlights[currentchannel].id;

	if (type == "video") {
		popoutVideo = window.open(page, title, settings);
		clearDiv("embed");
		setTimeout("checkPopoutVideo()", 1000);
	}
	else if (type == "chat") {
		popoutChat = window.open(page, title, settings);
		clearDiv("irccontainer");
		setTimeout("checkPopoutChat()", 1000);
	}
	return;
}

function popoutNew(type, stream, channel) {
	var d = new Date();
	var LeftPosition = 0;
	var TopPosition = 0;
	var page = "popout.php?type=" + type + "&stream=" + stream + "&channel=" + channel;
	var title = "" + d.getTime();
	var settings = 'width=640,height=410,top=0,left=0,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
	var win = window.open(page, title, settings);
	var x = window.clearInterval(popoutClickTimer);
	popoutOpenedWindow = true;
	return;
}

function popoutDown(type, stream, channel) {
	popoutClickTimer = setInterval("popoutNew('" + type + "', '" + stream + "', '" + channel + "');", 1000);
	return;	
}

function popoutUp() {
	var x = window.clearInterval(popoutClickTimer);
	return;
}

