function checkEditProfileForm(){
	re = /([0-9a-zA-Z\.\-\_]+)@([0-9a-zA-Z\.\-\_]+)\.([0-9a-zA-Z\.\-\_]+)/;
	var user_name, email, check_email, pass, dataRight = true;
	message = "";
	
	user_name = document.EditProfileForm.user_name.value;
	email = document.EditProfileForm.email.value;
	check_email = document.EditProfileForm.check_email.value;
	pass = document.EditProfileForm.pass.value;
	
	if (user_name.length==0){
		message += "\n -  Name";
		dataRight=false;
	}	
	if (email.length==0){
	   message += "\n -  Please enter your E-mail address";
	   dataRight=false;
	}
	if (email.length!=0 && email.match(re)==null){
	   dataRight=false;
	   message += "\n -  Your E-Mail is Incorrect";
	}
	if (check_email.length==0){
	   message += "\n -  Please enter your Retype E-mail address";
	   dataRight=false;
	}
	if (check_email.length!=0 && check_email.match(re)==null){
	   dataRight=false;
	   message += "\n -  Your Retyped E-Mail is Incorrect";
	}
	if (email!=check_email){
	   dataRight=false;
	   message += "\n -  Your E-Mail and Retyped E-Mail does not match";
	}
	if (pass.length==0){
		message += "\n -  Password";
		dataRight=false;
	}	
	
	if (!dataRight){
		if (message != ""){
		   message ="\nYou failed to correctly fill in the form:\n" + message + "\n\nPlease re-enter and click the Send button again!";
	   }
	   alert(message);
	}
	return dataRight;
}

function checkSignUpForm(){
	re = /([0-9a-zA-Z\.\-\_]+)@([0-9a-zA-Z\.\-\_]+)\.([0-9a-zA-Z\.\-\_]+)/;
	var user_name, email, check_email, pass, vercode, dataRight = true;
	message = "";
	
	user_name = document.SignUpForm.user_name.value;
	email = document.SignUpForm.email.value;
	check_email = document.SignUpForm.check_email.value;
	pass = document.SignUpForm.pass.value;
	vercode = document.SignUpForm.vercode.value;
	
	if (user_name.length==0){
		message += "\n -  Name";
		dataRight=false;
	}	
	if (email.length==0){
	   message += "\n -  Please enter your E-mail address";
	   dataRight=false;
	}
	if (email.length!=0 && email.match(re)==null){
	   dataRight=false;
	   message += "\n -  Your E-Mail is Incorrect";
	}
	if (check_email.length==0){
	   message += "\n -  Please enter your Retype E-mail address";
	   dataRight=false;
	}
	if (check_email.length!=0 && check_email.match(re)==null){
	   dataRight=false;
	   message += "\n -  Your Retyped E-Mail is Incorrect";
	}
	if (email!=check_email){
	   dataRight=false;
	   message += "\n -  Your E-Mail and Retyped E-Mail does not match";
	}
	if (pass.length==0){
		message += "\n -  Password";
		dataRight=false;
	}	
	if (vercode.length==0){
		message += "\n -  Verification code";
		dataRight=false;
	}
	
	if (!dataRight){
		if (message != ""){
		   message ="\nYou failed to correctly fill in the form:\n" + message + "\n\nPlease re-enter and click the Send button again!";
	   }
	   alert(message);
	}
	return dataRight;
}

function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
alert("Right click disabled.\n\nTo download an incon click on the small D symbol below it\nand it will be added to your 'My Downloads' page. ");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;

function ShowIcon(srcvalue, id) {
	document.getElementById('icon'+id).src=srcvalue;
};

function ShowIconSet(srcvalue, id) {
	document.getElementById('set'+id).src=srcvalue;
};

function AddtoMyDownloads(id,background_id,symbol_id,iSize) {
	ajaxpage('addtomydownloads.php?background_id='+background_id+'&symbol_id='+symbol_id+'&iSize='+iSize,'none','get');
	var srcvalue = document.getElementById('icon'+id).src;
	document.getElementById('icon'+id).src='images/addedtomydownloads.gif';
	setTimeout(function () {ShowIcon(srcvalue,id)},1000);
};

function AddSetToMyDownloads(set_id,filename) {
	ajaxpage('addsettomydownloads.php?set_id='+set_id+'&filename='+filename,'none','get');
	var srcvalue = document.getElementById('set'+set_id).src;
	document.getElementById('set'+set_id).src='images/addedtomydownloads.gif';
	setTimeout(function () {ShowIconSet(srcvalue,set_id)},1000);
};

function AddToTempSet(background_id,symbol_id) {
	ajaxpage('add_to_set.php?background_id='+background_id+'&symbol_id='+symbol_id,'none','get');
	alert("Added to Icon Set");
};


function GetSuggested(tag) {
	if (tag=='') {
		document.getElementById('SuggestedTags').style.display='none';
	} else {
		ajaxpage('suggesttag.php?tag='+tag,'SuggestedTags','get')
		document.getElementById('SuggestedTags').style.display='block';
	};
};

function HideSuggestedTags(){
	document.getElementById('SuggestedTags').style.display='none';
};

function SelectSuggestedTag(tag) {
	document.frm.findtag.value = tag;
};

// JavaScript Document
var bustcachevar=1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
var bustcacheparameter="";

function ajaxpage(url, containerid, requesttype){
	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	} else	return false
	page_request.onreadystatechange=function(){
		loadpage(page_request, containerid)
	}
	
	if (requesttype=='get'){
		if (bustcachevar) bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
		page_request.open('GET', url+bustcacheparameter, true)
		page_request.send(null)
	} else if (requesttype=='post') {
		page_request.open('POST', url, true);
		page_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		page_request.setRequestHeader("Content-length", parameters.length);
		page_request.setRequestHeader("Connection", "close");
		page_request.send(parameters);
	};
}

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1) && containerid!=='none')
	document.getElementById(containerid).innerHTML=page_request.responseText
}