/*

############################################################################################################################

# This file contains all function used by the website visit-it.com. Before each script you find a short description.

# Read the comments before you make any changes!

# © ontwerplijn|nl

############################################################################################################################

This file contains the following functions:
-  change_theme()

*/
/* Google Maps */
function marker(id, cat, title, address, lat, lng, ahref, logo) {
	this.id = id;
	this.cat = cat;
	this.title = title;
	this.address = address;
	this.lat = lat;
	this.lng = lng;
	this.ahref = ahref;
	this.logo = logo;
};

/* AJAX */
function initRequest() {
    var request;
	if (window.ActiveXObject) {
		request = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		request = new XMLHttpRequest();
	}
    return request;
};


function refresh_home(){

	 var loginclass = document.getElementById('loginbox').className;
	 var registerclass = document.getElementById('registerbox').className;

	 if(loginclass == 'hide' && registerclass == 'hide'){
		window.location.reload();
		//alert('Refresh by Richard © :P\n\nRegisterbox.className='+registerclass+'\nLoginbox.className='+loginclass+'\n\ndč lčkt dus te wčrkuh!');
	 }

	 setTimeout("refresh_home()", 100000); // 100000

};

/* This function allows the user to set visit-it.com as homepage */
function HomeMe(country){

	var url 		= 	'http://'+country+'.visit-it.com';

	document.body.style.behavior='url(#default#homepage)';
	document.body.SetHomepage(url);

	return false;
}

/* This function opens the iPod for tuning in internetradio, or playing a song */
function OpenPlayer(value,type,defurl,width,height){

 // Define the name and size:
 if(type == 'radio'){

	var win_title	=	'mediaplayer';

		if(width == "" || width == 0 || height == "" || height == 0){
 		 var win_width	=	384;
 		 var win_height	=	302;
		} else {
 		 var win_width	=	width;
 		 var win_height	=	height;
		}

 	var win_var		=	'?listen_to='+value;

 } else {

 	var win_title	=	'videoplayer';

		if(width == "" || width == 0 || height == "" || height == 0){
		 var win_width	=	384;
		 var win_height	=	450;
		} else {
 		 var win_width	=	width;
 		 var win_height	=	height;
		}

	var win_var	 = '?view_to='+value;

 }

 		if(defurl == "" || defurl != "" && width == 0){
			var win_location = "http://nl.visit-it.com/content/mediaplayer.php"+win_var+"&type="+type;
		} else {
			var win_location = defurl;
		}

 // Open the window:
 window.open(win_location, ''+win_title+'', 'width='+win_width+', height='+win_height+', toolbar=0, scrollbars=0, location=0, status=0, menubar=0, resizable=0, screenX=' + ((screen.width - win_width) / 2) + ', screenY=' + ((screen.height - win_height) / 2) + ', top=' + ((screen.height - win_height) / 2) + ', left=' + (((screen.width - win_width) / 2) - 80) + '');

};


/* This function opens the iPod for tuning in internetradio, or playing a song */
function open_ondemand_broadcast(id,url,channel){

 // Define the name and size:
 if(channel == 'nederland_1' || channel == 'nederland_2' || channel == 'nederland_3' || channel == 'uitzending_gemist'){
  var win_title	=	'uitzending_gemist';
 	var win_width	=	800;
 	var win_height	=	600;
 } else if(channel == 'rtl_4' || channel == 'rtl_7' || channel == 'rtl_8'){
 	var win_title	=	'rtl_gemist';
 	var win_width	=	1008;
 	var win_height	=	675;
 } else if(channel == 'rtl_5'){
 	var win_title	=	'rtl_gemist';
 	var win_width	=	1008;
 	var win_height	=	635;
 } else if(channel == 'sbs_6' || channel == 'net_5' || channel == 'veronica'){
 	var win_title	=	'sbs_programma_gemist';
 	var win_width	=	1000;
 	var win_height	=	510;
 }

  // Update
  var ViewReq = 	initRequest();
  var rand 		= 	Math.random();

  ViewReq.open('POST', 'scripts/visit.count_views.php?rand=' + rand + '');
  ViewReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  ViewReq.onreadystatechange = function() {

    if (ViewReq.readyState == 4 && ViewReq.status == 200) {

	  }
	}

  // Send the values
  ViewReq.send('id=' + id + '&url=' + url + '&channel=' + channel + '');

 // Open the window:
 window.open(''+url+'', ''+win_title+'', 'width='+win_width+', height='+win_height+', toolbar=0, scrollbars=0, location=0, status=0, menubar=0, resizable=0, screenX=' + ((screen.width - win_width) / 2) + ', screenY=' + ((screen.height - win_height) / 2) + ', top=' + ((screen.height - win_height) / 2) + ', left=' + (((screen.width - win_width) / 2) - 80) + '');

};

/* This function opens the iPod for tuning in internetradio, or playing a song */
function order_downloads(sessionid){

	var win_url		=	'http://system.aim4music.com/hostedshops/visit-it/view_cart.aspx?session_id='+sessionid;
	var win_title	=	'order_downloads';
 	var win_width	=	485;
 	var win_height	=	485;

 // Open the window:
 window.open(''+win_url+'', ''+win_title+'', 'width='+win_width+', height='+win_height+', toolbar=0, scrollbars=0, location=0, status=0, menubar=0, resizable=0, screenX=' + ((screen.width - win_width) / 2) + ', screenY=' + ((screen.height - win_height) / 2) + ', top=' + ((screen.height - win_height) / 2) + ', left=' + (((screen.width - win_width) / 2) -80) + '');

};

function print_map(querystring){

	var win_url		=	'content/visit.tourism.print.php?'+querystring;
	var win_title	=	'print_map';
 	var win_width	=	645;
 	var win_height	=	970;

 // Open the window:
 window.open(''+win_url+'', ''+win_title+'', 'width='+win_width+', height='+win_height+', toolbar=0, scrollbars=0, location=0, status=0, menubar=0, resizable=0, screenX=' + ((screen.width - win_width) / 2) + ', screenY=' + ((screen.height - win_height) / 2) + ', top=' + ((screen.height - win_height) / 2) + ', left=' + (((screen.width - win_width) / 2) -80) + '');

};

/* This function loads the localtime in the div defined in the paper */
function Clock(){

//clearTimeout(ClockTimert);

var currenttime = new Date();
var hours = currenttime.getHours();
var minutes = currenttime.getMinutes();
var seconds = currenttime.getSeconds();
var timesuffix = "AM";

if (hours>11) {
 timesuffix = "PM"; //  // hours = hours - 12;
}
if(hours==0){
 hours = 24;
}
if(hours<10){
 hours = "0" + hours;
}
if(minutes<10){
 minutes = "0" + minutes;
}
if(seconds < 10){
 seconds = "0" + seconds;
}

//var clocklocation = document.getElementById('papertime');
//clocklocation.innerHTML = hours + ":" + minutes + ":" + seconds;

//var ClockTimert = setTimeout("Clock()", 1000);

};

function StopClock(){
 //if(ClockTimert){
 // clearTimeout(ClockTimert);
 //}
};

/* This function handles the ringtone preview and order screens */
function Ringtone(type,orderid) {

 // Check wich type of call the user made
 if(type=='play'){

  // Define the name and size:
  var win_title	=	'playpop';
  var win_width	=	300;
  var win_height=	160;

  // Open the previewscreen
  window.open("http://www.ringtonio.nl/play/?id="+orderid+"&rtaff=16602&clx=1&rtlo=35194", ''+win_title+'', 'width='+win_width+'px, height='+win_height+'px, toolbar=0, scrollbars=0, location=0, status=0, menubar=0, resizable=0, screenX=' + ((screen.width - win_width) / 2) + ', screenY=' + ((screen.height - win_height) / 2) + ', top=' + ((screen.height - win_height) / 2) + ', left=' + ((screen.width - win_width) / 2) + '');

 } else if(type=='order'){

  // Define the name and size:
  var win_title	=	'sendpop';
  var win_width	=	600;
  var win_height=	450;

  // Open the orderscreen
  window.open("http://www.ringtonio.nl/send/?id="+orderid+"&rtaff=16602&clx=1&rtlo=35194", ''+win_title+'', 'width='+win_width+'px, height='+win_height+'px, toolbar=0, scrollbars=0, location=0, status=0, menubar=0, resizable=0, screenX=' + ((screen.width - win_width) / 2) + ', screenY=' + ((screen.height - win_height) / 2) + ', top=' + ((screen.height - win_height) / 2) + ', left=' + ((screen.width - win_width) / 2) + '');

 }

};


/* This function must be use to open or close the loginbox in the rightcorner */
function LoginBox(){

 // Jump to `top`
 //var	url		 =		window.location;
 //url.replace("#top", "");
 //window.location = url+'#top';

 // Get the current class
 var loginclass = document.getElementById('loginbox').className;

 document.getElementById("loginbox").innerHTML = '<div id="loading_login"><div id="loader"><img src="images/visitit.loading.gif" border="0" alt="loading..."></div></div>';

 // Handle the request, depended on the class value
 if(loginclass=='show'){
  document.getElementById('loginbox').className = 'hide';
  document.getElementById('login').className = '';
  document.getElementById('register').className = '';
  //alert('hide');
 } else {
  document.getElementById('loginbox').className = 'show';
  document.getElementById('login').className = 'active';
  document.getElementById('register').className = '';
  document.getElementById('registerbox').className = 'hide';
  //alert('show');


		 var loginBoxreq	= 	initRequest();
		 var rand 		= 	Math.random();

		 loginBoxreq.open('GET', 'components/visit.loginbox.php?ajax=1&rand='+rand+'');
		 loginBoxreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 loginBoxreq.onreadystatechange = function() {
				if (loginBoxreq.readyState == 4 && loginBoxreq.status == 200) {

				 //alert(loginreq.responseText);
				 document.getElementById("loginbox").innerHTML = loginBoxreq.responseText;

				 //window.location=window.location+'/#top';
				}
			}

		 // Send the values
		 loginBoxreq.send(null);

 }

 scrollTo(0,0);
// document.getElementById("login_username").focus();
};


/* This function must be use to open or close the loginbox in the rightcorner */
function PassBox(){

		 var passBoxreq	= 	initRequest();
		 var rand 		= 	Math.random();

		 document.getElementById("loginbox").innerHTML = '<div id="loading_login"><div id="loader"><img src="images/visitit.loading.gif" border="0" alt="loading..."></div></div>';

		 passBoxreq.open('GET', 'components/visit.getpassword.php?ajax=1&rand='+rand+'');
		 passBoxreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 passBoxreq.onreadystatechange = function() {
				if (passBoxreq.readyState == 4 && passBoxreq.status == 200) {

				 //alert(loginreq.responseText);
				 document.getElementById("loginbox").innerHTML = passBoxreq.responseText;
				}

		}

		 // Send the values
		 passBoxreq.send(null);


// document.getElementById("login_username").focus();
};


/* This function must be use to open or close the REGISTER box in the rightcorner */
function RegisterBox(){

 // Get the current class
 var currentclass = document.getElementById('registerbox').className;

 document.getElementById("registerbox").innerHTML = '<div id="loading_register"><div id="loader"><img src="images/visitit.loading.gif" border="0" alt="loading..."></div></div>';

 // Handle the request, depended on the class value
 if(currentclass=='show'){
  document.getElementById('registerbox').className = 'hide';
  document.getElementById('register').className = '';
 } else {
  document.getElementById('registerbox').className = 'show';
  document.getElementById('register').className = 'active';
  document.getElementById('loginbox').className = 'hide';
  document.getElementById('login').className = '';

  	 	 var registerBoxreq	= 	initRequest();
		 var rand 		= 	Math.random();

		 registerBoxreq.open('GET', 'components/visit.registerbox.php?ajax=1&rand='+rand+'');
		 registerBoxreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 registerBoxreq.onreadystatechange = function() {
				if (registerBoxreq.readyState == 4 && registerBoxreq.status == 200) {

				 //alert(loginreq.responseText);
				 document.getElementById("registerbox").innerHTML = registerBoxreq.responseText;
				}
			}

		 // Send the values
		 registerBoxreq.send(null);

}

scrollTo(0,0);

};


/* This function must be use to open or close the REGISTER box in the rightcorner */
function SettingsBox(){

 // Get the current class
 var currentclass = document.getElementById('settingsbox').className;
 document.getElementById("settingsbox").innerHTML = '<div id="loading_register"><div id="loader"><img src="images/visitit.loading.gif" border="0" alt="loading..."></div></div>';

 // Handle the request, depended on the class value
 if(currentclass=='show'){
  document.getElementById('settingsbox').className = 'hide';
  document.getElementById('register').className = '';
 } else {

  document.getElementById('settingsbox').className = 'show';
  document.getElementById('register').className = 'active';
  // document.getElementById('login').className = '';

  	 	 var settingsBoxreq	= 	initRequest();
		 var rand 		= 	Math.random();

		 settingsBoxreq.open('GET', 'components/visit.settingsbox.php?ajax=1&rand='+rand+'');
		 settingsBoxreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 settingsBoxreq.onreadystatechange = function() {
				if (settingsBoxreq.readyState == 4 && settingsBoxreq.status == 200) {

				 //alert(loginreq.responseText);
				 document.getElementById("settingsbox").innerHTML = settingsBoxreq.responseText;

				}
			}

		 // Send the values
		 settingsBoxreq.send(null);

}

};


/* This function handles the loginform */
function SubmitLogin(){

 document.loginform.username.disabled	=	true;
 document.loginform.password.disabled	=	true;
 document.loginform.send.disabled		=	true;

 // Get the formvalues and set other vars
 var username	=	document.loginform.username.value;
 var password	=	document.loginform.password.value;
 var loginreq 	= 	initRequest();
 var rand 		= 	Math.random();

 loginreq.open('POST', 'scripts/visitit.login.ajax.php?rand='+rand+'');
 loginreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 loginreq.onreadystatechange = function() {
		if (loginreq.readyState == 4 && loginreq.status == 200) {

		 if(loginreq.responseText=='true'){
			 window.location=window.location;
		 } else {
			 alert(''+loginreq.responseText+'');

 document.loginform.username.disabled	=	false;
 document.loginform.password.disabled	=	false;
 document.loginform.send.disabled		=	false;

		 }

		 //alert(loginreq.responseText);
		 //document.getElementById(""+container+"").innerHTML = loginreq.responseText;
	    }
	}

 // Send the values
 loginreq.send('username='+username+'&password='+password+'');

};


/* This function handles the passwordform */
function SubmitNewPassword(){

 document.passform.email.disabled		=	true;
 document.passform.send.disabled		=	true;

 // Get the formvalues and set other vars
 var email		=	document.passform.email.value;
 var passreq 	= 	initRequest();
 var rand 		= 	Math.random();

 passreq.open('POST', 'scripts/visitit.newpass.ajax.php?rand='+rand+'');
 passreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 passreq.onreadystatechange = function() {
		if (passreq.readyState == 4 && passreq.status == 200) {

		 if(passreq.responseText=='true'){
 			 alert('Je wachtwoord is gewijzigd. Je ontvangt deze zometeen via een e-mailbericht.');
			 document.getElementById('loginbox').className='hide';
			 LoginBox();
		 } else {
			 alert(''+passreq.responseText+'');

 		document.passform.email.disabled	=	false;
 		document.passform.send.disabled		=	false;

		 }

		 //alert(loginreq.responseText);
		 //document.getElementById(""+container+"").innerHTML = loginreq.responseText;
	    }
	}

 // Send the values
 passreq.send('email='+email+'');

};


/* This function handles the logout request */
function SubmitLogout(){

 // Get the formvalues and set other vars
 var logoutreq 	= 	initRequest();
 var rand 		= 	Math.random();

 logoutreq.open('POST', 'scripts/visitit.logout.ajax.php?rand='+rand+'');
 logoutreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 logoutreq.onreadystatechange = function() {
		if (logoutreq.readyState == 4 && logoutreq.status == 200) {
		  //alert(''+logoutreq.responseText+'');
		  window.location=window.location;
		  //window.reload;
		}

 }
 // Send the values
 logoutreq.send('username=&password=');

};


/* This function handles the loginform */
function SubmitRegister(){

 // Disable all fields
 document.registerform.username.disabled	=	true;
 document.registerform.password.disabled	=	true;
 document.registerform.email.disabled		=	true;
 document.registerform.paperid.disabled		=	true;
 document.registerform.radioid.disabled		=	true;
 document.registerform.send.disabled		=	true;

 // Get the formvalues and set other vars
 var username	=	document.registerform.username.value;
 var password	=	document.registerform.password.value;
 var email		=	document.registerform.email.value;
 var paperid	=	document.registerform.paperid.value;
 var radioid	=	document.registerform.radioid.value;

 var registerreq= 	initRequest();
 var rand 		= 	Math.random();

 registerreq.open('POST', 'scripts/visitit.register.ajax.php?rand='+rand+'');
 registerreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 registerreq.onreadystatechange = function() {
		if (registerreq.readyState == 4 && registerreq.status == 200) {

		 if(registerreq.responseText=='true'){

			 //check_for_winner();

			 // Redirect the user to home
			 window.location='./';

		 } else {

			 alert(''+registerreq.responseText+'');

			 document.registerform.username.disabled	=	false;
			 document.registerform.password.disabled	=	false;
			 document.registerform.email.disabled		=	false;
			 document.registerform.paperid.disabled		=	false;
			 document.registerform.radioid.disabled		=	false;
			 document.registerform.send.disabled		=	false;

		 }



		 //alert(loginreq.responseText);
		 //document.getElementById(""+container+"").innerHTML = loginreq.responseText;
	    }
	}

 // Send the values
 registerreq.send('username='+username+'&password='+password+'&email='+email+'&paperid='+paperid+'&radioid='+radioid+'');

};


/* This function handles the loginform */
function SubmitSettings(){

 // Disable all fields
 document.settingsform.username.disabled	=	true;
 document.settingsform.password.disabled	=	true;
 document.settingsform.email.disabled		=	true;
 document.settingsform.paperid.disabled		=	true;
 document.settingsform.radioid.disabled		=	true;
 document.settingsform.send.disabled		=	true;

 // Get the formvalues and set other vars
 var username	=	document.settingsform.username.value;
 var password	=	document.settingsform.password.value;
 var email		=	document.settingsform.email.value;
 var paperid	=	document.settingsform.paperid.value;
 var radioid	=	document.settingsform.radioid.value;

 if(document.settingsform.newsletter.checked == true){
   var newsletter	=	"1";
 } else{
   var newsletter	=	"0";
 }

 var settingsreq= 	initRequest();
 var rand 		= 	Math.random();

 settingsreq.open('POST', 'scripts/visitit.settings.ajax.php?rand='+rand+'');
 settingsreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 settingsreq.onreadystatechange = function() {
		if (settingsreq.readyState == 4 && settingsreq.status == 200) {

		 if(settingsreq.responseText=='true'){
			 window.location='./';
		 } else {
			 alert(''+settingsreq.responseText+'');

			 document.settingsform.username.disabled	=	false;
			 document.settingsform.password.disabled	=	false;
			 document.settingsform.email.disabled		=	false;
			 document.settingsform.paperid.disabled		=	false;
			 document.settingsform.radioid.disabled		=	false;
			 document.settingsform.send.disabled		=	false;

         }

		 //alert(loginreq.responseText);
		 //document.getElementById(""+container+"").innerHTML = loginreq.responseText;
	    }
	}

 // Send the values
 settingsreq.send('username='+username+'&password='+password+'&email='+email+'&paperid='+paperid+'&radioid='+radioid+'&newsletter='+newsletter+'');

};


/* Write a new note in the notepad */
function UpdateNotepad() {
 alert('true');
}


/* Update credits by click */
function PayCredits(dataid,clicktype,dstring){

 // Prepare the AJAX-request and make a random number
 var payreq		= 	initRequest();
 var rand 		= 	Math.random();

 // Make the request
 payreq.open('POST', 'scripts/visitit.pay.ajax.php?ajax=1&rand='+rand+'');
 payreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 payreq.onreadystatechange = function() {
		if (payreq.readyState == 4 && payreq.status == 200) {

			if(payreq.responseText!='false'){
			 document.getElementById('credits').innerHTML = payreq.responseText;
			}

			//window.location = window.location;
			//document.getElementById('toolspan').innerHTML = toolreq.responseText;
			//Sortable.create("sortable_list");
			//alert(payreq.responseText);

		}

 }

 // Send the values
 payreq.send('pay=1&dataid='+dataid+'&type='+clicktype+'&dstring='+dstring+'');

};

/* Update credits by click */
function pay_on_click(dataid,clicktype,dstring,pagekey){

 // Prepare the AJAX-request and make a random number
 var payreq		= 	initRequest();
 var rand 		= 	Math.random();

 // Make the request
 payreq.open('POST', 'scripts/visit.pay.ajax.php?ajax=1&rand='+rand+'');
 payreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 payreq.onreadystatechange = function() {
		if (payreq.readyState == 4 && payreq.status == 200) {

			if(payreq.responseText!='false'){
			 document.getElementById('credits_amount').innerHTML = payreq.responseText;
			}

			//window.location = window.location;
			//document.getElementById('toolspan').innerHTML = toolreq.responseText;
			//Sortable.create("sortable_list");
			//alert(payreq.responseText);

		}

 }

 // Send the values
 payreq.send('pay=1&dataid='+dataid+'&type='+clicktype+'&dstring='+dstring+'&pagekey='+pagekey+'');

};


/* Search in phoneregister (only in the netherlands) */
function DoPhoneSearch(){

 // Get the current values
 var who 	= document.telefoonboek_nl.who.value;
 var where	= document.telefoonboek_nl.where.value;

 // Open new window with search results
 window.open('http://www.telefoonboek.nl/Gadget/Beide/'+who+'/'+where+'');

}


/* Disable selection on targeted elements */
function disableSelection(element) {
    element.onselectstart = function() {
        return false;
    };
    element.unselectable = "on";
    element.style.MozUserSelect = "none";
    element.style.cursor = "default";
};


/* Load the tools */
function Tools(page,subpage){

 if(page == ""){
	 var page = 'home';
 }

  if(subpage == ""){
	 var subpage = '';
 }

 // Prepare the AJAX-request and make a random number
 var ToolLoadReq= 	initRequest();
 var rand 		= 	Math.random();

 // Make the request
 ToolLoadReq.open('GET', 'components/visit.tools.php?ajax=1&rand='+rand+'&page='+page+'&subpage='+subpage+'');
 ToolLoadReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 ToolLoadReq.onreadystatechange = function() {
		if (ToolLoadReq.readyState == 4 && ToolLoadReq.status == 200) {

			document.getElementById('toolspan').innerHTML = ToolLoadReq.responseText;
			// Sortable.create("sortable_list");


		}

 }

 // Send the values
 ToolLoadReq.send(null);

};


/* Open gamepopup */
function open_game(popupURL) {

 var width = 700;
 var height = 550;
 var leftPosition = (screen.width) ? (screen.width-width)/2 : 0;

 if (screen.height && (screen.height <= 600)) {
 	var topPosition = 0;
 } else {
 	var topPosition = (screen.height) ? (screen.height-height)/2 : 0;
 }

 var settings='width='+width+',height='+height+',left='+(leftPosition -80)+',top='+topPosition+'toolbar=0,location=0,directories=0,menubar=0,scrollbar=0,resizable=0,status=0';
 var popup=window.open(popupURL, 'gamepopup', settings);

 popup.focus();

};

/* This function alows users to change the background of the website */
function change_theme(value){

 var theme_req	= 	initRequest();
 var rand 		= 	Math.random();

 theme_req.open('POST', 'scripts/visit.change_theme.ajax.php?rand='+rand+'');
 theme_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 theme_req.onreadystatechange = function() {

		if (theme_req.readyState == 4 && theme_req.status == 200) {

		/*if(settingsreq.responseText=='true'){
			 window.location='./';
		 } else {
			 alert(''+settingsreq.responseText+'');
         }
		 */

		 //alert(loginreq.responseText);
		 //document.getElementById(""+container+"").innerHTML = loginreq.responseText;
	    }

	}

 // Send the values
 theme_req.send('value='+value+'');

 document.body.className = value;
};

function ftvlaunch(url) {
	  var LeftPosition = (screen.width) ? (screen.width-665)/2 : 0;
	  var TopPosition = (screen.height) ? (screen.height-430)/2 : 0;
	  var popwin = window.open(url,'MTV6_window','toolbar=no,width=665,height=430,top='+TopPosition+',left='+(LeftPosition-80)+',directories=no,status=no,statusbar=0,scrollbars=no,resizable=no,menubar=no');
      popwin.focus();
};


function toggle_product_search(fieldname,type){

	 var string 	 =	document.getElementById(fieldname).value;
	 var s_request	 = 	initRequest();
	 var rand 		 = 	Math.random();

	 // Make the request
	 s_request.open('GET', 'components/visit.product_search.php?ajax=1&rand='+rand+'');
	 s_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 s_request.onreadystatechange = function() {

			if (s_request.readyState == 4 && s_request.status == 200) {

				document.getElementById('toolspan').innerHTML = s_request.responseText;

			}

	 }

 // Send the values
 s_request.send(null);

};

function set_active(id){

	document.getElementById('news').className='';
	document.getElementById('music').className='';
	document.getElementById('television').className='';
	document.getElementById('games').className='';
	document.getElementById('movies').className='';
	document.getElementById('men').className='';
	document.getElementById('women').className='';
	document.getElementById('senior').className='';
	document.getElementById('boys').className='';
	document.getElementById('girls').className='';

	document.getElementById(id).className='active'

};

function set_session(name,value){

	 var session_rq	 = 	initRequest();
	 var rand 		 = 	Math.random();

	 // Make the request
	 session_rq.open('POST', 'scripts/visit.set_session.php?ajax=1&rand='+rand+'');
	 session_rq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 session_rq.onreadystatechange = function() {

			if (session_rq.readyState == 4 && session_rq.status == 200) {

				//alert('session is set\n\nname:\t'+name+'\nvalue:\t'+value+'');
				//document.getElementById('toolspan').innerHTML = s_request.responseText;

			}

	 }

 // Send the values
 session_rq.send("name="+name+"&value="+value+"");

};

function booking_start_process(dataid, hotel_id){
 window.open("https://secure.booking.com/book.html?aid=315426&hostname=www.booking.com&hotel_id="+hotel_id+"", 'booking_com', 'width=800, height=600, toolbar=0, scrollbars=1, location=0, status=0, menubar=0, resizable=0, screenX=' + ((screen.width - 800) / 2) + ', screenY=' + ((screen.height - 600) / 2) + ', top=' + ((screen.height - 600) / 2) + ', left=' + (((screen.width - 800) / 2) - 80) + '');
};

function check_for_winner(){

 // Get the formvalues and set other vars
 var winreq 	= 	initRequest();
 var rand 		= 	Math.random();

 winreq.open('POST', 'scripts/visit.select_winner.php?rand='+rand+'');
 winreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 winreq.onreadystatechange = function() {
		if (winreq.readyState == 4 && winreq.status == 200) {

		 if(winreq.responseText=='true'){

			 window.location='./?win=1';

		 } else {
			 window.location='./';
		 }

	    }
	}

 // Send the values
 winreq.send('ajax=1');

};

function Play (bundle, nr) {

 //var path = '<object id="Player" width="0" height="0" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"><param name="URL" value="http://download.aim4music.com/shopsupport/download_process/track$prelisten.aspx?media_partner_id=90&bundle_id='+bundle+'&sequence_nr='+nr+'"><param name="Volume" value="50"><param name="AutoStart" value="true"><param name="mute" value="false"><embed src="http://download.aim4music.com/shopsupport/download_process/track$prelisten.aspx?media_partner_id=90&bundle_id='+bundle+'&sequence_nr='+nr+'" autostart="true" loop="false" hidden="true" height="0" width="0"></embed></object>';
 //var path = '<object id="Player" width="0" height="0" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"><param name="URL" value="http://download.aim4music.com/shopsupport/download_process/track$prelisten.aspx?media_partner_id=90&bundle_id='+bundle+'&sequence_nr='+nr+'"><param name="Volume" value="50"><param name="AutoStart" value="true"><param name="mute" value="false"><embed width="0" height="0" src="http://download.aim4music.com/shopsupport/download_process/track$prelisten.aspx?media_partner_id=90&bundle_id='+bundle+'&sequence_nr='+nr+'" id="Player" volume="50" autoStart="true" mute="false"></object></embed>';

 var path = '<object id="Player" width="0" height="0" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" style="visibility: hidden; display: none;"><param name="URL" value="plugins/sample.php?bundle='+bundle+'&sequence='+nr+'"><param name="Volume" value="50"><param name="AutoStart" value="true"><param name="mute" value="false"><embed width="0" height="0" src="plugins/sample.php?bundle='+bundle+'&sequence='+nr+'" id="Player" volume="50" autoStart="true" mute="false" style="visibility: hidden; display: none;"></object></embed>';


 document.getElementById ("" + bundle + "_" + nr + "").innerHTML = path + '<img src="images/visit.sound.stop.gif" style="cursor:pointer;" onclick="Stop(' + bundle + ','+ nr +')"  class=\"download_icon\">';

 // Automatic stop after 25 seconds (this is only for the button, samples are 30 secs each)
 setInterval('Stop (\''+ bundle +'\',\'' + nr + '\')', 25000);

};

function Stop (bundle, nr) {
 document.getElementById ("" + bundle + "_" + nr + "").innerHTML = '<img src="images/visit.sound.play.gif" style="cursor:pointer;" onclick="Play(' + bundle + ','+ nr +');"  class=\"download_icon\">';
};

function bundle_info(trackid){

  document.getElementById('title_' + trackid + '').append = 'TEST';

/* if(document.getElementById("track_" + trackid +"").style.visibility == "visible"){

  document.getElementById("track_" + trackid +"").style.display = "none";
  document.getElementById("track_" + trackid +"").style.visibility = "hidden";

  document.getElementById("span_track_" + trackid +"").style.display = "none";
  document.getElementById("span_track_" + trackid +"").style.visibility = "hidden";


 } else {

  document.getElementById("track_" + trackid +"").style.display = "block";
  document.getElementById("track_" + trackid +"").style.visibility = "visible";

  document.getElementById("span_track_" + trackid +"").style.display = "block";
  document.getElementById("span_track_" + trackid +"").style.visibility = "visible";

 }
*/
};

function SetHomePageFF(){

 alert("Welkom FireFox gebruiker! Neem de volgende stappen om van visit-it.com jouw gratis startpagina te maken:\n\n1. Klik op Extra in het menu bovenin de browser\n2. Klik vervolgens in het submenu op Opties waarna er een nieuw scherm in beeld komt.\n3. Klik op het eerste tabblad Algemeen, en vul achter Startpagina: http://nl.visit-it.com in\n4. Klik op Ok\n\nGefeliciteerd! visit-it.com is vanf nu jouw startpagina!");

};
