// PAGE LOAD //
function initializePage(ttype,tid) {
	// Track pages
	if ((ttype != "") && (tid != "")) pageTracking(ttype,tid);
	// Load captcha
	if ((document.getElementById('hash')) && (document.getElementById('captcha'))) loadCaptcha();
	// Display response text
	resultText();
	// Load top boxes
	leftboxInclude();
	rightboxInclude();
	// VIP data
	if (document.getElementById('venue-data-swap')) loadVipData(tid);
	// VIP promos
	if (document.getElementById('vip-state-swap')) checkVipState(ttype);
	// VIP page
	if (document.getElementById('vip-info-swap')) loadVipPage();
	if (document.getElementById('vip-aside-swap')) loadVipAside();
	// Account aside
	if (document.getElementById('account-info-swap')) loadAccountAside();
	// Friends page
	if (document.getElementById('friend-list-swap')) loadFriendList();
	if (document.getElementById('friend-request-swap')) loadFriendRequests();
	if (document.getElementById('friend-options')) loadFriendOptions(tid);
	// Photos page
	if (document.getElementById('photo-info-swap')) loadPhotoInfo();
	if (document.getElementById('photo-wall')) loadPhotoWall();
	// Private messaging
	if (document.getElementById('contacts-compose-swap')) loadContacts(1);
	if (document.getElementById('contacts-swap')) loadContacts(0);
}


// Toggle top venues
function topVenues(id) {
	if (id == 0) document.getElementById("most-viewed").style.display = "block";
	if (id == 0) document.getElementById("trending").style.display = "none";
	if (id == 1) document.getElementById("most-viewed").style.display = "none";
	if (id == 1) document.getElementById("trending").style.display = "block";
	if (id == 0) document.getElementById("featured-select-0").className = "active";
	if (id == 0) document.getElementById("featured-select-1").className = "";
	if (id == 1) document.getElementById("featured-select-1").className = "active";
	if (id == 1) document.getElementById("featured-select-0").className = "";
}

// Confirm URL click
function confHref(id,text)
{
 var question = confirm(text);
 if (question == true)
 {
   window.location= id;
 }
}

// List regions
var regionHttp
function listRegions() {
	document.getElementById("region-wrap").innerHTML="<img src='/images/loading.gif'>"
	country = document.getElementById("country").value;
	regionHttp=GetXmlHttpObject()
	if (regionHttp==null) return
	var url="/ajax/regions/" + country + "/"
	regionHttp.onreadystatechange=regionState
	regionHttp.open("GET",url,true)
	regionHttp.send(null)
}
function regionState() {
	if (regionHttp.readyState==4 || regionHttp.readyState=="complete") {
		document.getElementById("region-wrap").innerHTML=regionHttp.responseText
	} 
}


//Add venue
function addVenue(id) {
	outthumb = thumb[id];
	outname = venname[id];
	v1 = document.getElementById("venue1").value;
	v2 = document.getElementById("venue2").value;
	v3 = document.getElementById("venue3").value;
	v4 = document.getElementById("venue4").value;
	use = 0;
	if (v4 == "0") use = 4;
	if (v3 == "0") use = 3;
	if (v2 == "0") use = 2;
	if (v1 == "0") use = 1;
	if ((id == v1) || (id == v2) || (id == v3) || (id == v4)) use = 0;
	if (use > 0) {
		if (use == 1) {
			document.getElementById("venue1").value = id;
			document.getElementById("top" + use).innerHTML = "<img src='" + outthumb + "' width='102' height='77' /><br />" + outname + "<br /><a href='javascript: clearVenue(1);' title='Remove " + outname + "'>[remove]</a>";
		}
		if (use == 2) {
			document.getElementById("venue2").value = id;
			document.getElementById("top" + use).innerHTML = "<img src='" + outthumb + "' width='102' height='77' /><br />" + outname + "<br /><a href='javascript: clearVenue(2);' title='Remove " + outname + "'>[remove]</a>";
		}
		if (use == 3) {
			document.getElementById("venue3").value = id;
			document.getElementById("top" + use).innerHTML = "<img src='" + outthumb + "' width='102' height='77' /><br />" + outname + "<br /><a href='javascript: clearVenue(3);' title='Remove " + outname + "'>[remove]</a>";
		}
		if (use == 4) {
			document.getElementById("venue4").value = id;
			document.getElementById("top" + use).innerHTML = "<img src='" + outthumb + "' width='102' height='77' /><br />" + outname + "<br /><a href='javascript: clearVenue(4);' title='Remove " + outname + "'>[remove]</a>";
		}
	}
}
// Clear venue
function clearVenue(id) {
	document.getElementById("top" + id).innerHTML = "<img src='/uploads/venue-thumb.jpg' width='102' height='77' /><br />&nbsp;<br />&nbsp;";
	document.getElementById("venue" + id).value = "0";
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

// Pop-up login
function popupLogin(id) {
	if (id == 0) document.getElementById("floating-login").style.display = "none";
	if (id == 1) document.getElementById("floating-login").style.display = "block";
}
// Count charcters
function countChar(obj,limit,target)
{
	if (obj.value.length > limit) obj.value = obj.value.substring(0, limit);
	numDisp = limit-obj.value.length;
	document.getElementById(target).innerHTML = (numDisp);
}
// Contact information
function contactInformation() {
	output = "";
	query = document.getElementById("query").value;
	if (query == 1) output = "Nettleden.com only publishes access and location details for venues on this website to privalidged members, these are registered users who have upgraded their memberships or been promoted. This is due to the risks involved in entering these sites.<br /><br />Many of the location are extremely dangerous places and many of the sites do not allow public access.<br /><br />If you have experience and are seriously interested in visiting some of these locations we recommend that you reviews our suggested equipment page.<br /><br />If this has not answered your question please continue to submit your question below.";
	if (query == 2) output = "Nettleden.com does not organise visits or events, we have no official connection to any of the venues featured on this website.<br /><br />We do not recommend visiting any of the venues listed, places which allow public visits are very rare due to health and safety restrictions.<br /><br />If this has not answered your question please continue to submit your question below.";
	if (query == 3) output = "Please note that at the bottom of each page there is a further reading list where you may find the answer to your question.<br /><br />Alternatively, visit our shop page where you will find a selection of books and DVDs containing more information about the venues featured on this website.<br /><br />If this has not answered your question please continue to submit your question below.";
	if (query == 4) output = "All photos on Nettleden.com are taken and upload by our members, in order to use a photo or video you would need to approach the user who uploaded the video directly.<br /><br />The major exclusion to this is the photographs of Burlington, these photos were commissioned by the Ministry of Defence, they are Crown Copyright and used with permission of the Ministry of Defence.<br /><br />You can request copies of these photos through the Freedom of Information Act.<br />DCSA Secretariat Head<br />Defence Communication Services Agency,<br />Room 124,<br />Building 111,<br />Basil Hill Site,<br />Corsham,<br />Wiltshire<br />SN13 9NR<br /><br />Intellectual Property Group<br />Directorate of Intellectual Property Rights<br />Defence Procurement Agency<br />Poplar 2 #2218<br />MoD Abbey Wood,<br />Bristol<br />BS34 8JH.<br /><br />If this has not answered your question please continue to submit your question below.";
	if (query == 5) output = "If you would like to learn more about Nettleden.com, why it exists and what we do please visits the about us page.<br /><br />If this has not answered your question please continue to submit your question below.";
	if (query == 6) output = "The easiest way to report an infringement of copyright is to click the 'report' option on the page where your image or video appears.<br /><br />If you need to report more than one peice of content, you can report a user by visiting their profile and clicking on the 'report' option, you will then be given a series of option to determin the nature of the complaint.<br /><br />If this has not answered your question please continue to submit your question below.";
	if (query == 7) output = "We receive many requests to take part in interviews for radio, TV and print, we are more than happy to accomodate these requests. You can find previous interviews (including audio samples) on our media relations page.<br /><br />We also receive many requests to help out with student films or projects, due to time restriction we are unable to commit to these projects.<br /><br />If you would like to contact us to discuss this further please click the continue button below to be taken to an online contact form or call Steve Higgins on 07899 910869.<br /><br />If this has not answered your question please continue to submit your question below.";
	if (output != "") output = "<p class='msg warning'>" + output + "</p>";
	document.getElementById("contact-information").innerHTML = output;
}

// Venue rating
function rateVenue(venue,rating) {
	rating1 = "off";
	rating2 = "off";
	rating3 = "off";
	rating4 = "off";
	rating5 = "off";
	if (rating > 0) rating1 = 'on';
	if (rating > 1) rating2 = 'on';
	if (rating > 2) rating3 = 'on';
	if (rating > 3) rating4 = 'on';
	if (rating > 4) rating5 = 'on';
	text = "<ul>";
	text = text + "<li id='star1' class='" + rating1 + "' title='You gave this venue " + rating + " stars'></li>";
	text = text + "<li id='star2' class='" + rating2 + "' title='You gave this venue " + rating + " stars'></li>";
	text = text + "<li id='star3' class='" + rating3 + "' title='You gave this venue " + rating + " stars'></li>";
	text = text + "<li id='star4' class='" + rating4 + "' title='You gave this venue " + rating + " stars'></li>";
	text = text + "<li id='star5' class='" + rating5 + "' title='You gave this venue " + rating + " stars'></li>";
	text = text + "</ul>";
	document.getElementById("stars").innerHTML = text;
	var rateHttp
	rateHttp=GetXmlHttpObject()
	if (rateHttp==null) return
	var url="/submit/rate/" + venue + "/" + rating + "/"
	rateHttp.onreadystatechange=rateState
	rateHttp.open("GET",url,true)
	rateHttp.send(null)
	function rateState() {
	if (rateHttp.readyState==4 || rateHttp.readyState=="complete") {
		document.getElementById("result-text").innerHTML = rateHttp.responseText
	}
	}
}

function rateOn(pos) {
	document.getElementById("star1").className = 'off';
	document.getElementById("star2").className = 'off';
	document.getElementById("star3").className = 'off';
	document.getElementById("star4").className = 'off';
	document.getElementById("star5").className = 'off';
	if (pos > 0) document.getElementById("star1").className = 'on';
	if (pos > 1) document.getElementById("star2").className = 'on';
	if (pos > 2) document.getElementById("star3").className = 'on';
	if (pos > 3) document.getElementById("star4").className = 'on';
	if (pos > 4) document.getElementById("star5").className = 'on';
}

function rateOff(rating) {
	document.getElementById("star1").className = 'off';
	document.getElementById("star2").className = 'off';
	document.getElementById("star3").className = 'off';
	document.getElementById("star4").className = 'off';
	document.getElementById("star5").className = 'off';
	if (rating > 0) document.getElementById("star1").className = 'on';
	if (rating > 1) document.getElementById("star2").className = 'on';
	if (rating > 2) document.getElementById("star3").className = 'on';
	if (rating > 3) document.getElementById("star4").className = 'on';
	if (rating > 4) document.getElementById("star5").className = 'on';
}

function changeHistory(id) {
	if (id == 0) {
		document.getElementById("full-history").style.display = "none";
		document.getElementById("short-history").style.display = "block";
	}
	if (id == 1) {
		document.getElementById("full-history").style.display = "block";
		document.getElementById("short-history").style.display = "none";
	}
}

// Like content
var likeHttp
function likeThis(docid,id,from) {
	if (id == 1) {
		document.getElementById(from).href = "javascript: likeThis('" + docid + "',0," + from + ");";
		likeHttp=GetXmlHttpObject()
		if (likeHttp==null) return
		var url="/submit/like/" + docid + "/"
		likeHttp.onreadystatechange=likeState
		likeHttp.open("GET",url,true)
		likeHttp.send(null)
	}
}
function likeState() {
	if (likeHttp.readyState==4 || likeHttp.readyState=="complete") {
		document.getElementById("result-text").innerHTML=likeHttp.responseText
	} 
}

// Flag content
var flagHttp
function flagThis(docid,id,from) {
	if (id == 1) {
		document.getElementById(from).href = "javascript: flagThis('" + docid + "',0," + from + ");";
		flagHttp=GetXmlHttpObject()
		if (flagHttp==null) return
		var url="/submit/flag/" + docid + "/"
		flagHttp.onreadystatechange=flagState
		flagHttp.open("GET",url,true)
		flagHttp.send(null)
	}
}
function flagState() {
	if (flagHttp.readyState==4 || flagHttp.readyState=="complete") {
		document.getElementById("result-text").innerHTML=flagHttp.responseText
	} 
}


// AJAX username check
function checkUsername(id) {
	username = ajaxClean(document.getElementById("username").value);
	username = username.split(" ");
	username = username.join("");
	username = username.split("@");
	username = username.join("");
	username = username.split(".");
	username = username.join("");
	username = username.split("-");
	username = username.join("");
	username = username.split("_");
	username = username.join("");
	username = username.split("+");
	username = username.join("");
	username = username.split("/");
	username = username.join("");
	username = username.split("'");
	username = username.join("");
	document.getElementById("username").value = username;
	if (username == "") id = 0;
	if (id == 0) document.getElementById("username-result").innerHTML = "";
	if (id == 1) document.getElementById("username-result").innerHTML = "<img src='/images/loading.gif'>";
	if (id == 1) ajaxUsername(username);
}
var checkuserHttp
function ajaxUsername(username) {
	checkuserHttp=GetXmlHttpObject()
	if (checkuserHttp==null) return
	var url="/ajax/username/" + username + "/"
	checkuserHttp.onreadystatechange=checkuserState
	checkuserHttp.open("GET",url,true)
	checkuserHttp.send(null)
}
function checkuserState() {
	if (checkuserHttp.readyState==4 || checkuserHttp.readyState=="complete") {
		document.getElementById("username-result").innerHTML=checkuserHttp.responseText
	} 
}

// name check
function checkName(id) {
	fullname = ajaxClean(document.getElementById("fullname").value);
	fullname = fullname.split("@");
	fullname = fullname.join("");
	fullname = fullname.split(".");
	fullname = fullname.join("");
	fullname = fullname.split("_");
	fullname = fullname.join("");
	fullname = fullname.split("+");
	fullname = fullname.join("");
	fullname = fullname.split("/");
	fullname = fullname.join("");
	document.getElementById("fullname").value = fullname;
	if (id == 0) document.getElementById("name-result").innerHTML = "";
	if (id == 1) {
		error = 0;
		chars = fullname.length;
		if (chars < 6) error = 1;
		space = fullname.indexOf(" ");
		if (space < 2) error = 1;
		if (space == (chars - 1)) error = 1;
		if (error == 0) document.getElementById("name-result").innerHTML = "<span class='msg done'>OK</span>";
		if (error == 1) document.getElementById("name-result").innerHTML = "<span class='msg error'>Not valid</span>";
	}
}

// AJAX email check
function checkEmail(id) {
	email = ajaxClean(document.getElementById("email").value);
	email = email.split("@");
	email = email.join("--at--");
	email = email.split(".");
	email = email.join("--dot--");
	email = email.split("+");
	email = email.join("--plus--");
	email = email.split("/");
	email = email.join("");
	if (email == "") id = 0;
	if (id == 0) document.getElementById("email-result").innerHTML = "";
	if (id == 1) document.getElementById("email-result").innerHTML = "<img src='/images/loading.gif'>";
	if (id == 1) ajaxEmail(email);
}
var checkemailHttp
function ajaxEmail(email) {
	checkemailHttp=GetXmlHttpObject()
	if (checkemailHttp==null) return
	var url="/ajax/email/" + email + "/"
	checkemailHttp.onreadystatechange=checkemailState
	checkemailHttp.open("GET",url,true)
	checkemailHttp.send(null)
}
function checkemailState() {
	if (checkemailHttp.readyState==4 || checkemailHttp.readyState=="complete") {
		document.getElementById("email-result").innerHTML=checkemailHttp.responseText
	} 
}

// AJAX dob check
function checkDob(id) {
	dob = ajaxClean(document.getElementById("dob").value);
	dob = dob.split("/");
	dob = dob.join("--s--");
	dob = dob.split("@");
	dob = dob.join("");
	dob = dob.split(".");
	dob = dob.join("");
	dob = dob.split("_");
	dob = dob.join("");
	dob = dob.split("+");
	dob = dob.join("");
	dob = dob.split(" ");
	dob = dob.join("");
	dob = dob.split("'");
	dob = dob.join("");
	if (dob == "") id = 0;
	if (id == 0) document.getElementById("dob-result").innerHTML = "";
	if (id == 1) document.getElementById("dob-result").innerHTML = "<img src='/images/loading.gif'>";
	if (id == 1) ajaxDob(dob);
}
var checkdobHttp
function ajaxDob(dob) {
	checkdobHttp=GetXmlHttpObject()
	if (checkdobHttp==null) return
	var url="/ajax/dob/" + dob + "/"
	checkdobHttp.onreadystatechange=checkdobState
	checkdobHttp.open("GET",url,true)
	checkdobHttp.send(null)
}
function checkdobState() {
	if (checkdobHttp.readyState==4 || checkdobHttp.readyState=="complete") {
		document.getElementById("dob-result").innerHTML=checkdobHttp.responseText
	} 
}

// SCROLL THUMBNAILS
function startThumbScroll(direction) {
	clearTimeout(scrolltimer);
	if (direction > 0) doThumbScroll(direction);
}
function doThumbScroll(direction) {
	scrolltimer = setTimeout("doThumbScroll("+direction+")", 1);
	moveThumbnails(direction);
}
function moveThumbnails(direction) {
	if (direction == 1) position = position + 3;
	if (direction == 2) position = position - 3;
	if (position > 0) position = 0;
	if (position < scrolllimit) position = scrolllimit;
	document.getElementById("thumbnails").style.left = position + "px";
}


function ajaxClean(text) {
	text = text.split(",");
	text = text.join("");
	text = text.split("!");
	text = text.join("");
	text = text.split("&");
	text = text.join("");
	text = text.split("[");
	text = text.join("");
	text = text.split("]");
	text = text.join("");
	text = text.split("{");
	text = text.join("");
	text = text.split("}");
	text = text.join("");
	text = text.split("|");
	text = text.join("");
	text = text.split("~");
	text = text.join("");
	text = text.split("?");
	text = text.join("");
	text = text.split("£");
	text = text.join("");
	text = text.split("$");
	text = text.join("");
	text = text.split("%");
	text = text.join("");
	text = text.split("^");
	text = text.join("");
	text = text.split("*");
	text = text.join("");
	text = text.split("(");
	text = text.join("");
	text = text.split(")");
	text = text.join("");
	text = text.split("=");
	text = text.join("");
	text = text.split(";");
	text = text.join("");
	text = text.split(":");
	text = text.join("");
	text = text.split('"');
	text = text.join("");
	text = text.split(">");
	text = text.join("");
	text = text.split("<");
	text = text.join("");
	text = text.split("`");
	text = text.join("");
	return text;
}

function lettersOnly(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1))
   return true;
else
   return false;
}

function lettersSpaceOnly(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789'- ").indexOf(keychar) > -1))
   return true;
else
   return false;
}

function emailOnly(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789-_.@").indexOf(keychar) > -1))
   return true;
else
   return false;
}

function dateOnly(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// alphas and numbers
else if ((("0123456789/").indexOf(keychar) > -1))
   return true;
else
   return false;
}

function numbersOnly(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// alphas and numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;
else
   return false;
}

function webcharsOnly(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789=-_.@?&/:").indexOf(keychar) > -1))
   return true;
else
   return false;
}

// Toggle photo title field
function toggleTitle() {
	id = document.getElementById("notvenue").checked;
	if (id == true) document.getElementById("not-venue").style.display = "block";
	if (id == false) document.getElementById("not-venue").style.display = "none";
	if (id == true) document.getElementById("venue").disabled = true;
	if (id == false) document.getElementById("venue").disabled = false;
}

// Add contact to form
function sendMessage(username) {
	tonames = document.getElementById("toname").value;
	if (tonames !== "") tonames =  username + "," + tonames;
	if (tonames == "") tonames = username;
	document.getElementById("toname").value = tonames;
}

// Show access details
function accessStatus(venue,detail) {
	if ((venue == 0) && (detail == 0)) {
		output = "";
	} else {
		output = "<div class='access-details'>";
		output = output + "<a href='javascript:accessStatus(0,0)' style='float: right; padding: 5px;'>[close]</a>";
		output = output + "<div class='access-text'>";
		output = output + "<h3>" + venue + "</h3>";
		output = output + "<p>" + detail + "</p>";
		output = output + "</div>";
		output = output + "</div>";
	}
	document.getElementById("access-details-wrap").innerHTML = output;
}




function infoon(venue,place,region,obj) {
	curleft = obj.offsetLeft - 27;
	curtop = obj.offsetTop - 90;
	document.getElementById("linkinfo").innerHTML = venue + "<br />" + place + "<br />" + region;
	document.getElementById("linkinfo").style.display = "block";
	document.getElementById("linkinfo").style.left = curleft + "px";
	document.getElementById("linkinfo").style.top = curtop + "px";
}

function infooff() {
	document.getElementById("linkinfo").innerHTML = "";
	document.getElementById("linkinfo").style.display = "none";
}







var trackingHttp
function pageTracking(ttype,tid)
{
trackingHttp=GetXmlHttpObject()
if (trackingHttp==null) return
trackingHttp.onreadystatechange=trackingState
var url = "/ajax/tracking/" + ttype + "/" + tid + "/"
trackingHttp.open("GET",url,true)
trackingHttp.send(null)
}
function trackingState() 
{
if (trackingHttp.readyState==4 || trackingHttp.readyState=="complete")
 {
 //alert(trackingHttp.responseText)
 }
}

var captchaHttp
function loadCaptcha() {
	captchaHttp=GetXmlHttpObject()
	if (captchaHttp==null) return
	var url="/ajax/captcha/"
	captchaHttp.onreadystatechange=captchaState
	captchaHttp.open("GET",url,true)
	captchaHttp.send(null)
}
function captchaState() {
	if (captchaHttp.readyState==4 || captchaHttp.readyState=="complete") {
		guid = captchaHttp.responseText
		document.getElementById("hash").value = guid
		document.getElementById("captcha").src = "/captcha/" + guid + ".gif"
	} 
}

var resultHttp
function resultText()
{
resultHttp=GetXmlHttpObject()
if (resultHttp==null) return
var url="/ajax/response/"
resultHttp.onreadystatechange=resultState
resultHttp.open("GET",url,true)
resultHttp.send(null)
}
function resultState() 
{
if (resultHttp.readyState==4 || resultHttp.readyState=="complete")
 {
 document.getElementById("result-text").innerHTML=resultHttp.responseText
 }
}

var leftboxHttp
function leftboxInclude()
{
leftboxHttp=GetXmlHttpObject()
if (leftboxHttp==null) return
var url="/ajax/top-box/left/"
leftboxHttp.onreadystatechange=leftboxState
leftboxHttp.open("GET",url,true)
leftboxHttp.send(null)
}
function leftboxState() 
{
if (leftboxHttp.readyState==4 || leftboxHttp.readyState=="complete")
 {
 document.getElementById("top-box-left").innerHTML=leftboxHttp.responseText
 document.getElementById("top-box-left").style.background = "#83bf00"
 }
}

var rightboxHttp
function rightboxInclude()
{
rightboxHttp=GetXmlHttpObject()
if (rightboxHttp==null) return
var url="/ajax/top-box/right/"
rightboxHttp.onreadystatechange=rightboxState
rightboxHttp.open("GET",url,true)
rightboxHttp.send(null)
}
function rightboxState() 
{
if (rightboxHttp.readyState==4 || rightboxHttp.readyState=="complete")
 {
 document.getElementById("top-box-right").innerHTML=rightboxHttp.responseText
 document.getElementById("top-box-right").style.background = "#bee26e"
 }
}

var vipdataHttp
function loadVipData(venue)
{
vipdataHttp=GetXmlHttpObject()
if (vipdataHttp==null) return
var url="/ajax/vip/" + venue + "/"
vipdataHttp.onreadystatechange=vipdataState
vipdataHttp.open("GET",url,true)
vipdataHttp.send(null)
}
function vipdataState() 
{
if (vipdataHttp.readyState==4 || vipdataHttp.readyState=="complete")
 {
 document.getElementById("venue-data-swap").innerHTML=vipdataHttp.responseText
 document.getElementById("venue-data-swap").style.background = "#FFFFFF"
 }
}

var checkvipHttp
function checkVipState(page)
{
checkvipHttp=GetXmlHttpObject()
if (checkvipHttp==null) return
var url="/ajax/vip-state/" + page +"/"
checkvipHttp.onreadystatechange=checkvipState
checkvipHttp.open("GET",url,true)
checkvipHttp.send(null)
}
function checkvipState() 
{
if (checkvipHttp.readyState==4 || checkvipHttp.readyState=="complete")
 {
 document.getElementById("vip-state-swap").innerHTML=checkvipHttp.responseText
 document.getElementById("vip-state-swap").style.background = "#FFFFFF"
 }
}

var vippageHttp
function loadVipPage()
{
vippageHttp=GetXmlHttpObject()
if (vippageHttp==null) return
var url="/ajax/vip-page/"
vippageHttp.onreadystatechange=vippageState
vippageHttp.open("GET",url,true)
vippageHttp.send(null)
}
function vippageState() 
{
if (vippageHttp.readyState==4 || vippageHttp.readyState=="complete")
 {
 document.getElementById("vip-info-swap").innerHTML=vippageHttp.responseText
 }
}

var vipasideHttp
function loadVipAside()
{
vipasideHttp=GetXmlHttpObject()
if (vipasideHttp==null) return
var url="/ajax/vip-aside/"
vipasideHttp.onreadystatechange=vipasideState
vipasideHttp.open("GET",url,true)
vipasideHttp.send(null)
}
function vipasideState() 
{
if (vipasideHttp.readyState==4 || vipasideHttp.readyState=="complete")
 {
 document.getElementById("vip-aside-swap").innerHTML=vipasideHttp.responseText
 }
}

var accountasideHttp
function loadAccountAside()
{
accountasideHttp=GetXmlHttpObject()
if (accountasideHttp==null) return
var url="/ajax/account-info/"
accountasideHttp.onreadystatechange=accountasideState
accountasideHttp.open("GET",url,true)
accountasideHttp.send(null)
}
function accountasideState() 
{
if (accountasideHttp.readyState==4 || accountasideHttp.readyState=="complete")
 {
 document.getElementById("account-info-swap").innerHTML=accountasideHttp.responseText
 document.getElementById("account-info-swap").style.background = "#FFFFFF"
 }
}

var imgToolsHttp
function showImageTools(photo)
{
imgToolsHttp=GetXmlHttpObject()
if (imgToolsHttp==null) return
var url="/ajax/image-tools/" + photo + "/"
imgToolsHttp.onreadystatechange=imgToolsState
imgToolsHttp.open("GET",url,true)
imgToolsHttp.send(null)
}
function imgToolsState() 
{
if (imgToolsHttp.readyState==4 || imgToolsHttp.readyState=="complete")
 {
 document.getElementById("image-tools").innerHTML=imgToolsHttp.responseText
 }
}

var friendlistHttp
function loadFriendList()
{
friendlistHttp=GetXmlHttpObject()
if (friendlistHttp==null) return
var url="/ajax/friends/"
friendlistHttp.onreadystatechange=friendlistState
friendlistHttp.open("GET",url,true)
friendlistHttp.send(null)
}
function friendlistState() 
{
if (friendlistHttp.readyState==4 || friendlistHttp.readyState=="complete")
 {
 document.getElementById("friend-list-swap").innerHTML=friendlistHttp.responseText
 document.getElementById("friend-list-swap").style.background = "#FFFFFF"
 }
}

var friendrequHttp
function loadFriendRequests()
{
friendrequHttp=GetXmlHttpObject()
if (friendrequHttp==null) return
var url="/ajax/friend-requests/"
friendrequHttp.onreadystatechange=friendrequState
friendrequHttp.open("GET",url,true)
friendrequHttp.send(null)
}
function friendrequState() 
{
if (friendrequHttp.readyState==4 || friendrequHttp.readyState=="complete")
 {
 document.getElementById("friend-request-swap").innerHTML=friendrequHttp.responseText
 document.getElementById("friend-request-swap").style.background = "#FFFFFF"
 }
}

var friendoptionsHttp
function loadFriendOptions(user)
{
friendoptionsHttp=GetXmlHttpObject()
if (friendoptionsHttp==null) return
var url="/ajax/friend-options/" + user + "/"
friendoptionsHttp.onreadystatechange=friendoptionsState
friendoptionsHttp.open("GET",url,true)
friendoptionsHttp.send(null)
}
function friendoptionsState() 
{
if (friendoptionsHttp.readyState==4 || friendoptionsHttp.readyState=="complete")
 {
 document.getElementById("friend-options").innerHTML=friendoptionsHttp.responseText
 document.getElementById("friend-options").style.background = "#FFFFFF"
 }
}

var photoinfoHttp
function loadPhotoInfo()
{
photoinfoHttp=GetXmlHttpObject()
if (photoinfoHttp==null) return
var url="/ajax/photo-info/"
photoinfoHttp.onreadystatechange=photoinfoState
photoinfoHttp.open("GET",url,true)
photoinfoHttp.send(null)
}
function photoinfoState() 
{
if (photoinfoHttp.readyState==4 || photoinfoHttp.readyState=="complete")
 {
 document.getElementById("photo-info-swap").innerHTML=photoinfoHttp.responseText
 document.getElementById("photo-info-swap").style.background = "#FFFFFF"
 }
}

var photowallHttp
function loadPhotoWall()
{
photowallHttp=GetXmlHttpObject()
if (photowallHttp==null) return
var url="/ajax/photo-wall/"
photowallHttp.onreadystatechange=photowallState
photowallHttp.open("GET",url,true)
photowallHttp.send(null)
}
function photowallState() 
{
if (photowallHttp.readyState==4 || photowallHttp.readyState=="complete")
 {
 document.getElementById("photo-wall").innerHTML=photowallHttp.responseText
 document.getElementById("photo-wall").style.background = "#FFFFFF"
 }
}

var messagesHttp
function loadMessages(show,getstart,toname,reply)
{
messagesHttp=GetXmlHttpObject()
if (messagesHttp==null) return
var url="/ajax/messages/" + show + "/" + getstart + "/"
messagesHttp.onreadystatechange=messagesState
messagesHttp.open("GET",url,true)
messagesHttp.send(null)
}
function messagesState() 
{
if (messagesHttp.readyState==4 || messagesHttp.readyState=="complete")
 {
 document.getElementById("private-messages").innerHTML=messagesHttp.responseText
 document.getElementById("private-messages").style.background = "#FFFFFF"
 }
}

var contactsHttp
function loadContacts(compose)
{
contactsHttp=GetXmlHttpObject()
if (contactsHttp==null) return
var url="/ajax/contacts/" + compose + "/"
contactsHttp.onreadystatechange=contactsState
contactsHttp.open("GET",url,true)
contactsHttp.send(null)
}
function contactsState() 
{
if (contactsHttp.readyState==4 || contactsHttp.readyState=="complete")
 {
 document.getElementById("contact-holder").innerHTML=contactsHttp.responseText
 }
}




// AJAX discount check
function checkDiscount(id) {
	discount = ajaxClean(document.getElementById("discount").value);
	discount = discount.split(" ");
	discount = discount.join("");
	discount = discount.split("@");
	discount = discount.join("");
	discount = discount.split(".");
	discount = discount.join("");
	discount = discount.split("-");
	discount = discount.join("");
	discount = discount.split("_");
	discount = discount.join("");
	discount = discount.split("+");
	discount = discount.join("");
	discount = discount.split("/");
	discount = discount.join("");
	discount = discount.split("'");
	discount = discount.join("");
	document.getElementById("discount").value = discount;
	if (discount == "") id = 0;
	if (id == 0) document.getElementById("discount-result").innerHTML = "";
	if (id == 1) document.getElementById("discount-result").innerHTML = "<img src='/images/loading.gif'>";
	if (id == 1) ajaxDiscount(discount);
}
var checkdiscHttp
function ajaxDiscount(discount) {
	checkdiscHttp=GetXmlHttpObject()
	if (checkdiscHttp==null) return
	var url="/ajax/discount/" + discount + "/"
	checkdiscHttp.onreadystatechange=checkdiscState
	checkdiscHttp.open("GET",url,true)
	checkdiscHttp.send(null)
}
function checkdiscState() {
	if (checkdiscHttp.readyState==4 || checkdiscHttp.readyState=="complete") {
		disctext = "";
		if (checkdiscHttp.responseText == "exp") disctext = "<span class='msg error'>Expired code</span>";
		if (checkdiscHttp.responseText == "inv") disctext = "<span class='msg error'>Invalid code</span>";
		if ((checkdiscHttp.responseText != "inv") && (checkdiscHttp.responseText != "exp") && (checkdiscHttp.responseText != "")) {
			disctext = "<span class='msg done'>OK</span>";
			document.getElementById("item-cost").value = checkdiscHttp.responseText;
		}
		document.getElementById("discount-result").innerHTML = disctext;
		
	} 
}
