//Browser Support Code
var updaterID = 0;
var chatupdaterID = 0;
var useractive=true;
function showpodcast(podcastid)
{
	document.getElementById('podcastepisodes' + podcastid).style.display='block';
	var visiblepodcast = document.getElementById('visiblepodcast').value;
	document.getElementById('visiblepodcast').value=podcastid;
	document.getElementById('viewlink' + podcastid).innerHTML="Hide";
	//alert(visiblepodcast);
	if ((visiblepodcast) && visiblepodcast != podcastid && document.getElementById('podcastepisodes' + visiblepodcast))
	{
		document.getElementById('podcastepisodes' + visiblepodcast).style.display='none';
	}
	if (visiblepodcast === podcastid)
	{
		document.getElementById('podcastepisodes' + podcastid).style.display='none';
		document.getElementById('visiblepodcast').value ="0";
		document.getElementById('viewlink' + podcastid).innerHTML="View";
	}
}
function showloader(div)
{
	document.getElementById(div).innerHTML="Loading...<BR><img src='http://www.purehousemusic.net/contentimages/loading.gif' width='126' height='22'>";
}
function clickcounter(id)
{
	processAjaxRequest('ajaxprocessor.php','?action=countclicks&id=' + id,'nodiv');
}

function validatemixsubmission()
{
		var allok=true;
		var errormsg="Your mix submission has not been completed correctly;\n";
		if (!document.getElementById("title").value)
		{
				allok=false;
				errormsg+="You need to add a title for your mix\n";
		}
		if (document.getElementById("urlok").value==="0")
		{
				allok=false;
				errormsg+="The URL you have used is not a valid MP3 file\n";
		}
		if (!document.getElementById("tracks").value)
		{
				allok=false;
				errormsg+="You need to add a tracklisting for the mix\n";
		}
		if (!document.getElementById("mixdescription").value)
		{
				allok=false;
				errormsg+="Please tell us a little bit about your mix\n";
		}
		if (document.getElementById("style1").value===document.getElementById("style2").value || document.getElementById("style2").value===document.getElementById("style3").value || document.getElementById("style1").value===document.getElementById("style3").value)
		{
				allok=false;
				errormsg+="Please tag your mix with 3 different styles\n";
		}
		if (allok==true)
		{
			return true;
		}
		else
		{
			alert(errormsg);
			return false;
		}
}
		
function validatenewuser()
{
		var allok=true;
		var errormsg="You need to fill in the sign up form correctly!\n";
		var login=document.getElementById("newusername").value;
		if (login=="")
		{
			allok=false;
			errormsg+="You need to specify a username\n";
		}
		var pword=document.getElementById("supassword").value;
		if (pword=="")
		{
			allok=false;
			errormsg+="You need to specify a password\n";
		}
		var cfmpword=document.getElementById("sucfmpassword").value;
		if (cfmpword=="")
		{
			allok=false;
			errormsg+="You need to confirm your password\n";
		}
		if (cfmpword!=pword)
		{
				errormsg+="Your password and confirmed password aren't the same!\n";
		}
		var isadj=document.getElementById("isadj").value;
		var email=document.getElementById("email").value;
		var emailcfm=document.getElementById("emailcfm").value;
		if (email=="")
		{
			allok=false;
			errormsg+="You need to specify a valid email address\n";
		}
		if (email!=emailcfm)
		{
				if (email!="")
				{
					allok=false;
					errormsg+="Your email address doesn't match your confirmation email address\n";
				}
		}
		if (allok==true)
		{
			return true;
		}
		else
		{
			alert(errormsg);
			return false;
		}
}

function logIn()
{
		var userName=document.getElementById("userName").value;
		var password=document.getElementById("password").value;
		if (userName!="" && password!="")
		{
			var queryString="?action=login&userName=" + escape(userName) + "&password=" + escape(password);
			var ajaxRequest = makeajaxobject();
			var date=new Date();
			queryString+="&randdate=" + date;
			ajaxRequest.open("GET", "v3onlineusers.php" + queryString, true);
			ajaxRequest.onreadystatechange = function()
			{
				if(ajaxRequest.readyState == 4)
				{
					var detail = ajaxRequest.responseText;
					//alert(detail);
					if (detail=="1")
					{
							//alert("You have succesfully logged in...");
							window.parent.location.href='http://www.purehousemusic.net';
					}
					else
					{
							alert("We were unable to log you in, make sure you specificed the correct username and password!");
					}
				}
			}
			ajaxRequest.send(null);
		}
		else
		{
				alert("You should probably enter and username and password to log in!");
		}
}
function validateurl(url){
	if (url=="reciprocal")
	{
		var pagetosearch = document.getElementById("reciprocal").value;
		if (pagetosearch!="")
		{
			var statusplace= document.getElementById("statusplace");
			statusplace.innerHTML = "checking url...";
			var queryString = "?action=checkreciprocal&url=" + escape(pagetosearch);
			var ajaxRequest=makeajaxobject();
			ajaxRequest.open("GET", "v3checkurl.php" + queryString, true);
			
			ajaxRequest.onreadystatechange = function()
			{
				if(ajaxRequest.readyState == 4)
				{
					var linkstatus = ajaxRequest.responseText;
					if (linkstatus=="Link found")
					{
							document.getElementById("reciprocated").value= escape(pagetosearch);
					}
					statusplace.innerHTML = linkstatus;
				}
			}
			ajaxRequest.send(null); 
			var queryString2 = "?action=gettld&url=" + escape(pagetosearch);
			var ajaxRequest2=makeajaxobject();
			ajaxRequest2.open("GET", "v3checkurl.php" + queryString2, true);
			ajaxRequest2.send(null); 
			ajaxRequest2.onreadystatechange = function()
			{
				if(ajaxRequest2.readyState == 4)
				{
					var tld = ajaxRequest2.responseText;
					//window.parent.document.getElementById("url").value = tld;
					var queryString3 = "?action=gettitle&url=" + escape(tld);
					var ajaxRequest3=makeajaxobject();
					ajaxRequest3.open("GET", "v3checkurl.php" + queryString3, true);
					ajaxRequest3.send(null); 
					ajaxRequest3.onreadystatechange = function()
					{
						if(ajaxRequest3.readyState == 4)
						{
							var title = ajaxRequest3.responseText;
						}
					}
				}
			}
		}
	}
	else if (url!="")
	{
		var response="";
		var mixurl= document.getElementById("url").value;
		if (mixurl!="")
		{
			var ajaxRequest = makeajaxobject();
			var queryString = "?action=checkurl&url=" + escape(mixurl);
			ajaxRequest.open("GET", "v3checkurl.php" + queryString, true);
			ajaxRequest.send(null); 
			ajaxRequest.onreadystatechange = function()
			{
				if(ajaxRequest.readyState == 4)
				{
					var response = ajaxRequest.responseText;
					//alert("Response is " + response);
					if (response=="FOUND")
					{
							document.getElementById("urlok").value='true';
							document.getElementById("urlvalidation").innerHTML="<span style='background-color: rgb(255, 255, 255); color: rgb(255, 0, 0); font-size: 12px; font-weight: bold;'>All good :)</span>";
							return false;
					}
					if (response=="NOTFOUND")
					{
							//alert("The URL you used for your mix wasn't found, please check and try again");
							document.getElementById("urlok").value='false';
							document.getElementById("urlvalidation").innerHTML="<span style='background-color: rgb(255, 255, 255); color: rgb(255, 0, 0); font-size: 12px; font-weight: bold;'>MP3 not found at the location you entered, please check it and try again...</span>";
							return false;
					}
					if (response=="NOMP3")
					{
							//alert("The URL you used for your mix isn't an MP3");
							document.getElementById("urlok").value='false';
							document.getElementById("urlvalidation").innerHTML="<span style='background-color: rgb(255, 255, 255); color: rgb(255, 0, 0); font-size: 12px; font-weight: bold;'>The location of the mix you have entered is not an MP3.  You must use a direct link to the mp3 file.  File sharing sites like DivShare, MegaUpload and YouSendit are not usable I'm afraid!</span>";
							return false;
					}
				}
			}
		}
	}
}

function processVideo(action,videoID)
{
	var errorMessage="GO";
	if (action=="show")
	{
		var queryString="?action=show&videoID=" + videoID;
	}
	else
	{
		queryString="?action=" + action + "&first=" + videoID;
		if (action=="Add")
		{
				var queryString="?action=Add&first=" + videoID;
				var title=document.getElementById("title").value;
				if (title=="")
				{
					errorMessage="You need to include a title!\n";
				}
				queryString+="&title=" + escape(title);
				var videoLink=escape(document.getElementById("videoLink").value);
				if (videoLink=="")
				{
					errorMessage+="You need to include a link to the clip on YouTube!\n";
				}
				queryString+="&videoLink=" + videoLink;
				var description=document.getElementById("videodescription").value;
				queryString+="&description=" + escape(description);
				if (description=="")
				{
					errorMessage+="You need to include a description!\n";
				}
				var type=document.getElementById("type").value;
				queryString+="&type=" + type;
				if (type=="")
				{
					errorMessage+="You need to select a type!\n";
				}
				var djname=document.getElementById("djname").value;
				queryString+="&djname=" + escape(djname);
		}
	}
	if (errorMessage=="GO")
	{
		var URL="v3videos.php";
		processAjaxRequest(URL,queryString,'mainDiv');
	}
	else
	{
			alert(errorMessage);
	}
}

function openlink(linkid)
{
	processAjaxRequest("v3moderate.php","?action=goto&linkid=" + linkid,"nodiv");
}

function addlink()
{
		var ajaxRequest = makeajaxobject();
		var url=document.getElementById("url").value;
		var title=document.getElementById("title").value;
		//alert("Adding Link");
		var typeoflink=document.getElementById("type").value;
		//alert("Type is " + typeoflink);
		var isreciprocated = document.getElementById("isreciprocated").value;
		
		var querystring="?action=addlink&url=" + escape(url) + "&title=" + escape(title) + "&type=" + typeoflink + "&reciprocated=" + isreciprocated;
		
		ajaxRequest.open("GET","v3links.php" + querystring,true);
		ajaxRequest.send(null);
		ajaxRequest.onreadystatechange= function()
		{
				if (ajaxRequest.readyState==4)
				{
						var addedstatus=ajaxRequest.responseText;
						alert(addedstatus);
				}
		}
}

function modlink(action,linkid)
{
		var querystring = "?action=" + action + "&linkid=" + linkid;
		processAjaxRequest("v3links.php",querystring,"links");
}

function showlinkscategory(categoryid)
{
		var querystring = "?action=showcat&categoryid=" + categoryid;
		processAjaxRequest("v3links.php",querystring,"links");
}

function editpost(action,postnumber,type,hash)
{
	if (action=="edit")
	{
		var queryString="?page=forum&action=editpost&postid=" + postnumber + "&type=" + type + "&hash=" + hash;
		document.getElementById("post" + postnumber).innerHTML="";
		processAjaxRequest('v3forumfunctions.php',queryString,'post' + postnumber);
	}
	if (action=="quote")
	{
		var currentTime = new Date();
		var ajaxRequest = makeajaxobject();
		var queryString="?page=forum&action=quotepost&postid=" + postnumber + "&type=" + type + "&time=" + currentTime + "&hash=" + hash;
		processAjaxRequest('v3forumfunctions.php',queryString,'forumreply');
		window.location.href="#forumreply";
	}
	if (action=="save")
	{
		var updatedpost=document.getElementById(postnumber + "changed").value;
		var queryString="?page=forum&action=savechanges&postid=" + postnumber + "&post=" + updatedpost + "&type=" + type + "&hash=" + hash;
		document.getElementById("post" + postnumber).innerHTML="";
		processAjaxRequest('v3forumfunctions.php',queryString,'post' + postnumber);
	}
	if (action=="delete")
	{
		var queryString="?page=forum&action=deletepost&postid=" + postnumber + "&type=" + type + "&hash=" + hash;
		processAjaxRequest('v3forumfunctions.php',queryString,'mainDiv');
	}
	if (action=="lockthread")
	{
		var queryString="?page=forum&action=lockthread&threadid=" + postnumber + "&type=" + type + "&hash=" + hash;
		processAjaxRequest('v3forumfunctions.php',queryString,'noDiv');
	}
}

function fanboi(action,id,type)
{
	var queryString="?action=" + action + "&id=" + id + "&type=" + type;
	processAjaxRequest('v3fans.php',queryString,action);
}

function profilebrowser(type,id,div)
{
	showloader(div);
	var queryString="?page=" + type + "&id=" + id;
	if (id!="")
	{
		processAjaxRequest('v3profilefunctions.php',queryString,div);
	}
}

function addtochangelog()
{
		var itemtoadd = window.prompt("What have you just done?","");
		var queryString="?action=addchange&item=" + escape(itemtoadd);
		if (itemtoadd!=null)
		{
			processAjaxRequest('v3changelog.php',queryString);
		}
}

function moderateitem(id,type,action)
{
		if (action==="delete")
		{
				var confirmed = window.confirm("Are you sure you want to delete this item?");
				if (confirmed==true)
				{
						var queryString = "?action=delete&id=" + id + "&type=" + type;
				}
		}
		if (action=="approve")
		{
				var queryString = "?action=approve&id=" + id + "&type=" + type;
		}
		processAjaxRequest('v3moderate.php',queryString,'approvalDiv' + id);
		//alert(queryString);
		//ajaxFunction('home');
}

function addtoptrack(userid,trackid)
{
	var queryString="?page=tracks&action=newtoptrack&userid=" + userid + "&trackid=" + trackid;
	var confirmed=window.confirm("Are you sure you want to change your top track?");
	if (confirmed==true)
	{
		processAjaxRequest('index.php',queryString,'nodiv');
		ajaxFunctionratetrack(trackid,5.5);
	}
}

function ajaxplaylist(playlistlocation)
{
	winContent = window.open( "v3musicplayer.php?playlist=" + playlistlocation, "musicplayer","status = 0, height = 350, width = 270, resizable = 1" );
}

function listening(id,type,dj)
{
	var queryString="?action=listening&id=" + id + "&type=" + type + "&dj=" + dj;
	if (queryString!="")
	{
			processAjaxRequest('v3getmix.php',queryString,'nodiv');
	}
}

function CommentMaker(action,id,type)
{
	var queryString = "?page=comments&action=" + action + "&id=" + id + "&type=" + type;
	if (action=='savechanges')
	{
		var comment=document.getElementById("comment").value;
		queryString += "&message=" + escape(comment);
	}
	if (action=='save' || action ==='saveajaxcomment')
	{
		var type= document.getElementById("commenttype").value;
		var id=document.getElementById("subject").value;
		var comment=document.getElementById("comment").value;
		queryString += "&message=" + escape(comment);
	}
	if (action=='delete')
	{
		var confirmed=window.confirm("Are you sure you wish to delete this comment?");
		if (confirmed==false)
		{
			queryString="";
		}
	}
	if (queryString!="")
	{
		if (action==='saveajaxcomment')
		{
				var URL = "v3commentmaker.php";
		}
		else
		{	
				var URL="index.php";
		}
		if (document.getElementById('ratingamounttrack' + id))
		{
			processAjaxRequest(URL,queryString,"ratingamount" + type + id);
		}
		else if (document.getElementById('commentspace'))
		{
			processAjaxRequest(URL,queryString,"commentspace");
		}
	}
}

function ajaxFunctionratetrack(id,rating,type)
{
	if (window.parent.document.getElementById('ratingamount' + type + id))
	{
		window.parent.document.getElementById('ratingamount' + type + id).innerHTML ="Saving...";
	}
	var msgcurrentTime = new Date();
	var ajaxRequest = makeajaxobject();
	if (!type)
	{
		var type = "track";
	}
	var queryString = "?page=ratings&id=" + id + "&type=" + type + "&rating=" + rating + "&action=ratetrack&rand=" + msgcurrentTime;
	if (type==="track")
	{
		ajaxRequest.open("GET", "v3rateme.php" + queryString, true);
	}
	else
	{
		ajaxRequest.open("GET", "index.php" + queryString, true);
	}
	ajaxRequest.send(null);
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState === 4)
		{
			var ajaxResponse = ajaxRequest.responseText;
			if (rating!=6)
			{
				if (document.getElementById('ratingamounttrack' + id))
				{
					var ajaxRatingDisplay = document.getElementById('ratingamounttrack' + id);
					ajaxRatingDisplay.innerHTML = ajaxResponse;
				}
				else
				{
					document.getElementById('ratingamount' + type + id).innerHTML = "Thanks! You just rated this " + rating;
					thoughtCapture(id,type,rating);
				}
				
				if (type==="mix")
				{
					if (window.parent.document.getElementById("mixrating"))
					{
						window.parent.document.getElementById("mixrating").innerHTML="Thanks!!!";
					}
					if (rating>=1)
					{
						thoughtCapture(id,type,rating);		
					}
				}				
			}
		}
	}
}

function thoughtCapture(trackID,type,rating)
{
	{
		if (document.getElementById("ratingamount" + type + trackID))
		{
			processAjaxRequest('v3commentmaker.php','?action=givemeacommentbox&id=' + trackID + '&type=' + type + '&isajax=TRUE','ratingamount' + type + trackID);
		}
	}
}

function changetracktag(trackid,stylenumber,style)
{
		var queryString="?page=tracks&action=updatetag&trackid=" + trackid + "&stylenumber=" + stylenumber + "&style=" + style;
		processAjaxRequest('index.php',queryString,'nodiv');
}

function showsmilies(hideorshow)
{
	if (hideorshow=="hide")
	{
		document.getElementById("smilies").innerHTML="<a href=\"javascript:void(0)\" onclick=\"showsmilies('show')\">Show Extras</a>";
	}
	else
	{
		var ajaxRequest = makeajaxobject();
		var currentTime = new Date();
		ajaxRequest.open("GET", "v3chat_mini.php?action=showsmilies&rand=" + currentTime, true);
		ajaxRequest.send(null);
		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4)
			{
				document.getElementById("smilies").innerHTML = ajaxRequest.responseText;
			}
		}
	}
}

function initiateChat()
{
	document.cookie='chatting=yes';
	UpdateMiniChat();
	processAjaxRequest('v3onlineusers.php','?action=newonline','nodiv');
	checkim('Chat engaged...');
}
	
function UpdateMiniChat()
{
	//alert('Update...');
	if(chatupdaterID)
	{
		clearTimeout(chatupdaterID);
		chatupdaterID  = 0;
	}
	var userawaystatus="HERE";
	if (document.getElementById("userawaystatus"))
	{
		userawaystatus = document.getElementById("userawaystatus").value;
	}
	if (document.getElementById('message').value!="Click here to start chat updates" && userawaystatus!="AWAY")
	{
		//alert('Update...');
		updatechat();
	}
	chatupdaterID = setTimeout("UpdateMiniChat()", 3500);
}
function updatechat()
{
	//alert('Update');
	if (document.getElementById('alerts') && userawaystatus!="AWAY")
	{
		if (!document.getElementById('newim'))
		{
			//checkim();
		}
	}
	var ajaxRequest = makeajaxobject();
	var currentTime = new Date();
	var latestmessagetime=document.getElementById("latestmessagetime").value;
	var latestmessageID=document.getElementById("latestmessageID").value;
	var userid=document.getElementById("userid").value;
	var userawaystatus="AWAY";
	if (document.getElementById("userawaystatus"))
	{
		userawaystatus = document.getElementById("userawaystatus").value;
	}
	{
		var chatType="mini";
		var querystring = "?action=checknewmessages&userawaystatus=" + userawaystatus + "&userid=" + userid + "&type=" + chatType + "&latestmessagetime=" + currentTime + "&latestmessageID=" + latestmessageID;
		ajaxRequest.open("GET", "http://titan.host1.com.au/~pur17409/v3chat_mini.php" + querystring, true);
		//alert (querystring);
		
		
		
		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4)
			{
				//var newMessages = http://www.ajax-cross-domain.com/cgi-bin/ACD/ACD.js?uri=(http://titan.host1.com.au/~pur17409/v3chat_mini.php"+ querystring;
				//alert (newMessages);
				//ajaxRequest.responseText;
				//alert ('Result = ' + ajaxRequest.responseText);
				if (chatType=="mini")
				{
					if (newMessages!="")
					{
						var splitmessages = newMessages.split("||");
						var latestMessage = splitmessages[1];
						var messages = splitmessages[0];
						var latestmessageID = splitmessages[2];
						var isValid = splitmessages[3];
						if (splitmessages[2])
						{
							document.getElementById("latestmessageID").value = latestmessageID;
							var existingMessages = document.getElementById("chatlet").innerHTML;
							var splitExistingMessages=existingMessages.split("<br>");
							var splitNewMessage=messages.split("<br>");
							if(splitNewMessage[0]!=splitExistingMessages[0])
							{
								var chatcache = addslashes(messages +  existingMessages);
								chatcache = stripslashes(messages +  existingMessages);
								document.getElementById("chatlet").innerHTML = chatcache;
								if (latestMessage!="")
								{
									window.parent.document.title = latestMessage;
								}
							}
						}
					}
				}
			}
		}
		ajaxRequest.send(null);
	}
}

function updateonlineusers()
{
	var showawayusers;
	var radiologo;
	var livemixviewer;
	var livemixdj;
	if (document.getElementById('showawayusers'))
	{
		showawayusers = document.getElementById('showawayusers').checked;
	}
	if (document.getElementById('livemixviewer'))
	{
		livemixviewer=document.getElementById('livemixviewer').value;
	}
	if (document.getElementById('livemixdj'))
	{
		livemixdj=document.getElementById('livemixdj').value;
	}
	var queryString="?action=showonlinesuers&showawayusers=" + showawayusers + "&radiologo=" + radiologo + "&livemixdj=" + livemixdj + "&livemixviewer=" + livemixviewer;
	//alert(queryString);
	processAjaxRequest('v3onlineusers.php',queryString,'onlineusers');
}

function UpdateUsers()
{
  if(updaterID) {
      clearTimeout(updaterID);
      updaterID  = 0;
   }
  // checkim();
   updateonlineusers();
   updaterID = setTimeout("UpdateUsers()", 20000);
   
}

function checkim(message)
{
	//if (!(document.getElementById('alerts').style.visibility='visible') && !(document.getElementById("newim")))
	//{
		if (!message)
		{
			if (document.getElementById('alerts').style.visibility!="visible" || !(document.getElementById("newim")))
			{
				var queryString="?action=checkim";
				var date=new Date();
				queryString+="&randdate=" + date;
				var ajaxRequest = makeajaxobject();
				ajaxRequest.open("GET", "v4pms.php" + queryString, true);
				ajaxRequest.onreadystatechange = function()
				{
					if(ajaxRequest.readyState == 4)
					{
						var newMessage = ajaxRequest.responseText;
						if (newMessage!="")
						{
							var splitmessage = newMessage.split("|");
							var message = splitmessage[0];
							var isim = splitmessage[1];
							if (isim==="IM")
							{				
								document.getElementById('alertcontents').innerHTML=message;
								document.getElementById('alerts').style.visibility='visible';
								if (window.parent.document.title!="NEW IM!!!")
								{
									window.parent.document.title = "NEW IM!!!";
								}
								else
								{
									window.parent.document.title = "HEY!";
								}
							}
						}
					}
				}
			ajaxRequest.send(null);
			}
		}
		else
		{
			document.getElementById('alertcontents').innerHTML=message;
			document.getElementById('alerts').style.visibility='visible';
		}
	//}
}

function newsendim()
{
	if (document.getElementById('newim'))
	{
		var message=document.getElementById('newim').value;
	}
	var recipient=document.getElementById('recipient').value;
	var queryString="?action=sendim&recipient=" + recipient + "&message=" + escape(message);
	processAjaxRequest('v4pms.php',queryString,'alertcontents');
	HideAlerts();
}
function HideAlerts()
{
	setTimeout("HideOpenAlerts()",2000);
}

function HideOpenAlerts()
{
	document.getElementById('alerts').style.visibility = 'hidden';
	window.parent.document.title="Pure House Music .net - House Music DJ Mixes, Free Mix Hosting, Reviews, Interviews, Forum, live chat...";
}

function sendmessage() 
{
	var message = document.getElementById('message').value;
	if ((message!="Say Hello!"))
	{
		document.getElementById('message').value = "";
		var ajaxRequest = makeajaxobject();
		var querystring = "?action=sendmessage&message=" + escape(message);
		ajaxRequest.open("GET", "http://titan.host1.com.au/~pur17409/v3chat_mini.php" + querystring, true);
		ajaxRequest.send(null);
		alert(querystring);
	}
}

function setCookie(c_name,value)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function StartUpdate()
{
   UpdateUsers();
}

function checkusername(type)
{
	var username = document.getElementById(type).value;
	var queryString = '?action=check' + type + '&type=' + username; 
	processAjaxRequest("v3profilemanager.php",queryString, type+"check");
}

function processAjaxRequest(URL,queryString,DivForOutput)
{
	var ajaxRequest = makeajaxobject();
	var date=new Date();
	queryString+="&randdate=" + date;
	if (DivForOutput === "mainDiv")
	{
		if (window.opener)
		{
				window.opener.location.href = URL + queryString;
		}
		else
		{	
			window.location.href = URL + queryString;
		}
	}
	else
	{
		ajaxRequest.open("GET", URL + queryString, true);
		ajaxRequest.onreadystatechange = function()
		{
			if ( ajaxRequest.readyState == 4 )
			{  // 4 is "complete" 
				{
					var detail = ajaxRequest.responseText;
					if (detail!="")
					{
						if (!DivForOutput)
						{
							alert(detail);
							if (detail=="Deleted!")
							{
								window.location.reload();
							}
						}
						else
						{
							if (DivForOutput!='nodiv')
							{
								if (document.getElementById(DivForOutput))
								{
									document.getElementById(DivForOutput).innerHTML = detail;
								}
								else
								{
									if (document.getElementById(DivForOutput))
									{
										document.getElementById(DivForOutput).innerHTML = detail;
									}
								}
							}
							else
							{
									return detail;
							}
						}
					}
				}
			}
		}
		ajaxRequest.send(null);
	}
}

function makeajaxobject()
{
	var ajaxRequest;
	try
	{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e)
	{
		// Internet Explorer Browsers
		try
		{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e)
		{
			try
			{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e)
			{
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}

function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}

// ----------------------------------------------------------------
// INITIALIZATION
// ----------------------------------------------------------------
var ACD = new Object();


// ----------------------------------------------------------------
// ACD.request - FULL REQUEST THAT WAS SENT
// ----------------------------------------------------------------
ACD.request = '';
ACD.request += 'AJAX Cross Domain discovered that you cannot perform the remote request. The query-string after ACD.js must be set as an allowed query-string in the configuration area of ACD.js.\r\n';


// ----------------------------------------------------------------
// ACD.status - HTTP RESPONSE STATUS CODE
// ----------------------------------------------------------------
ACD.status = 'AJAX Cross Domain discovered that you cannot perform the remote request. The query-string after ACD.js must be set as an allowed query-string in the configuration area of ACD.js.';


// ----------------------------------------------------------------
// ACD.getAllResponseHeaders - FULL HEADERS OF RESPONSE
// ----------------------------------------------------------------
ACD.getAllResponseHeaders = '';
ACD.getAllResponseHeaders += 'AJAX Cross Domain discovered that you cannot perform the remote request. The query-string after ACD.js must be set as an allowed query-string in the configuration area of ACD.js.\r\n';


// ----------------------------------------------------------------
// ACD.getResponseHeader - METHOD WITH EVERY KEY/VALUE HEADER
// ----------------------------------------------------------------
ACD.getResponseHeader = {};


// ----------------------------------------------------------------
// ACD.responseText - BODY OF RESPONSE
// ----------------------------------------------------------------
ACD.responseText = '';
ACD.responseText += 'AJAX Cross Domain discovered that you cannot perform the remote request. The query-string after ACD.js must be set as an allowed query-string in the configuration area of ACD.js.\r\n';


// ----------------------------------------------------------------
// ACD.error - ERRORS
// ----------------------------------------------------------------
ACD.error = 'AJAX Cross Domain discovered that you cannot perform the remote request. The query-string after ACD.js must be set as an allowed query-string in the configuration area of ACD.js.';

