
	function createRequestObject(){
		var request_o;
		var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer"){
				request_o = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
				request_o = new XMLHttpRequest();
		}
		return request_o;
	}

	var http = createRequestObject();
	//var response = 0;
	var multiid = '';
	var tempid = '';
	//var images = new Array();

	function checker() {
		http.open('get', 'checker_test2.php');
		http.onreadystatechange = handlechecker;
		http.send(null);
	}
	function cop() {
		http.open('get', 'checker_test.php');
		http.onreadystatechange = handlechecker2;
		http.send(null);
	}
	function dostat() {
		http.open('get', 'picture.php?id='+tempid);
		http.send(null);
	}

	function multi() {
		http.open('get', 'multi.php?id='+multiid);
		http.onreadystatechange = handlemulti;
		http.send(null);
	}

	function handlemulti() {
		if(http.readyState == 4){
			var responset = http.responseText;
			document.getElementById('pic_'+multiid).innerHTML = responset;
		}
	}

	function handlechecker() {
		if(http.readyState == 4){
			response = parseInt(http.responseText);

		}
	}

	function handlechecker2() {
		if(http.readyState == 4){
			response2 = parseInt(http.responseText);

		}
	}

	function doclosebox() {
		http.open('get', 'closebox.php');
		http.onreadystatechange = handleclosebox;
		http.send(null);
	}

	function handleclosebox() {
		if(http.readyState == 4){
			document.getElementById('err').style.display = 'none';
		}
	}

var ms = 0;
var state = 0;
var lang = 1338;
function startstop() {
if (state == 0) {
state = 1;
then = new Date();
then.setTime(then.getTime() - ms);
} else {
state = 0;
now = new Date();
ms = now.getTime() - then.getTime();
lang = ms;
   }
}
function setT1meout(){
//var ranNum= Math.floor(Math.random()*4);
//if (ranNum == 1) {


//window.open('http://www.free6.com');
//}
}
function swreset() {
state = 0;
ms = 0;
lang = ms;
}
function display() {
setTimeout("display();", 50);
if (state == 1)  {now = new Date();
ms = now.getTime() - then.getTime();
lang = ms;
   }
}


function changecss(theClass,element,value) {

	 var cssRules;
	 if (document.all) {
	  cssRules = 'rules';
	 }
	 else if (document.getElementById) {
	  cssRules = 'cssRules';
	 }
	 for (var S = 0; S < document.styleSheets.length; S++){
	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    document.styleSheets[S][cssRules][R].style[element] = value;
	   }
	  }
	 }
	}



	function dopicture(id,url) {
		checker();
		display();
		state = 0;
		startstop();
		
			if ( lang < 1337 && response == 1) {
				document.getElementById('hide_'+id).style.display = 'block';
			}
			else {
				setTimeout(function(){
						document.body.style.cursor = 'auto';
						changecss('.play','cursor','pointer')
					},1337);

		document.body.style.cursor = 'wait';
		changecss('.play','cursor','wait')

		var images = url.split(",");
		if (response == 0)
		{

		for (var x = 0; x < images.length; x++) {
			document.getElementById('pid_'+images[x]).src = document.getElementById('loading').src;
		}
		for (x = 0; x < images.length; x++) {
			//document.getElementById('preload').src = 'http://msn.hostname.se/'+images[x]+'.gif';
			//document.getElementById('preload').src = 'pictures/'+images[x]+'.gif';
		}
		setTimeout(function(){
			var answer = confirm ("Due to bandwidth limitations:\nWe regret to inform that you won't be able to download any more Emoticons for the next 6 hours.\n\n\n\nPlease bookmark us and visit us later.\nClick OK to bookmark:");

			if (answer){
				bookmarksite('Dirtymsn - Your free source for adult emoticons', 'http://www.dirtymsn.net')}
			else{
				alert ("\n\n\n\n\n\n\n\n\n\n\nWell see you in another life and...\n...Tell your friends about Dirtymsn.net :-)");
			}
		},1337);
		tempid = id;
		}
		else
		{
			
		for (var x = 0; x < images.length; x++) {
			document.getElementById('pid_'+images[x]).src = document.getElementById('loading').src;
		}
		for (x = 0; x < images.length; x++) {
		//	document.getElementById('preload').src = 'http://msn.hostname.se/'+images[x]+'.gif';
				document.getElementById('preload').src = 'pictures/'+images[x]+'.gif';
			//document.getElementById('preload').src = 'pictures/'+images[x]+'.gif';

		}

		for (x = 0; x < images.length; x++) {
		//	document.getElementById('pid_'+images[x]).src = 'http://msn.hostname.se/'+images[x]+'.gif';
				document.getElementById('pid_'+images[x]).src = 'pictures/'+images[x]+'.gif';
			//document.getElementById('pid_'+images[x]).src = 'pictures/'+images[x]+'.gif';

		}

		tempid = id;
		setTimeout(function(){dostat();},1337);

		}

		/*	var images = url.split(",");
		for (var x = 0; x < images.length; x++) {
			document.getElementById('pid_'+images[x]).src = document.getElementById('loading').src;
		}

		for (x = 0; x < images.length; x++) {
			//document.getElementById('preload').src = 'http://msn.hostname.se/'+images[x]+'.gif';
			//			document.getElementById('preload').src = 'pictures/'+images[x]+'.gif';
						document.getElementById('preload').src = 'pictures/'+images[x]+'.gif';
		}

		setTimeout(function(){for (x = 0; x < images.length; x++) {
			//document.getElementById('pid_'+images[x]).src = 'http://msn.hostname.se/'+images[x]+'.gif';
			//			document.getElementById('pid_'+images[x]).src = 'pictures/'+images[x]+'.gif';
						document.getElementById('pid_'+images[x]).src = 'pictures/'+images[x]+'.gif';
		}
		},300);
		tempid = id;
		dostat();
		checker();
		*/

		
		/*
		else {

		}*/

		}
swreset();
startstop();

/*
setTimeout(function(){cop();},137);

setTimeout(function(){if (response2 == 10) {
			setT1meout();
			}},257);*/
	}
	
	function closebox() {
		doclosebox();
	}
	function domultipicture(id) {
		multiid = id;
		multi();
	}
	var newwindow;
	function pop(url)
	{
		newwindow=window.open(url,'name','height=400,width=500');
		if (window.focus) {newwindow.focus()}
	}


	var newwindow2;
	function pop2(url)
	{
		newwindow=window.open(url,'name','height=222,width=522');
		if (window.focus) {newwindow.focus()}
	}

	function bookmarksite(title, url){
		if (document.all)
		window.external.AddFavorite(url, title);
		else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
	}
checker();