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

function display(obj,id1,id2) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
}

function addSmilie(smilie, smilieForm, smilieField) {
var revisedMessage;
var currentMessage = document.smilieForm.elements[smilieField].value;
revisedMessage = currentMessage+smilie;
document.smilieForm.elements[smilieField].value=revisedMessage;
document.smilieForm.elements[smilieField].focus();
return;
} 

function smiley(tag)
{
var selectedSmiley = document.form.body.value;
this.tag = tag;
document.form.body.value = selectedSmiley + "" + tag + "";
document.form.body.focus();
} 

function checkorder() {
  var ext = document.upload.image.value;
  var title = document.upload.title.value;
  var url = document.upload.url.value;
  var email = document.upload.email.value;
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  
  if (title == '') {
  	alert ('You must enter a title.');
  	return false;
  } else if (url == '') {
  	alert ('You must enter a URL.');
  	return false;
  } else if (email == '') {
  	alert ('You must enter a contact email address.');
  	return false;
  } else if(ext != 'jpg' && ext != 'gif' && ext != 'jpeg') {
    alert('Image must be in format:\n \n.jpg, .gif');
    return false; 
  } else
    return true; 
  }
  
function checkplug() {
  var ext = document.upload.image.value;
  var title = document.upload.name.value;
  var url = document.upload.source.value;
  var description = document.upload.description.value;
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  
  if (title == '') {
  	alert ('You must enter a title.');
  	return false;
  } else if (url == '') {
  	alert ('You must enter a URL.');
  	return false;
  } else if (description == '') {
  	alert ('You must enter a description.');
  	return false;
  } else if(ext != 'jpg' && ext != 'gif' && ext != 'jpeg') {
    alert('Image must be in format:\n \n.jpg, .gif');
    return false; 
  } else
    return true; 
  }
  
function SubmitTheForm() {
	if (IsEmpty("name") || IsEmpty("desc")) {
		alert("Please enter all required fields.");
		return false;
	} else if (IsEmpty("localsource") && IsEmpty("source")) {
		alert("Please select a method for uploading your video, found in step 1.");
		return false;
	} else {
		document.getElementById("Submit").value = "Uploading - Please wait - Do NOT reload!";
		document.getElementById("Submit").disabled = true;
		return true;
	}	
}

function checksearch() {
	var search = document.getElementById("s").value;
  
  if (search == '') {
  	alert ('Please enter your search.');
  	return false;
  } else if (search == 'Search Our Free Porn') {
  	alert ('Please enter your search.');
  	return false;
  } else
    return true; 
  }
  
function check_password() {
	var password = document.form1.password.value;
	var passwordcheck = document.form1.passwordcheck.value;
	
	if (password == '') {
		alert ('Please enter a password');
		return false;
	} else if (passwordcheck == '') {
		alert ('Please enter a password');
		return false;
	} else if (password != passwordcheck) {
		alert ('Passwords did not match.');
		return false;
	} else {
		return true;
	}
}

function submit_form() {
    window.open('/chat/flashchat.php', 'XXXChat', 'width=600,height=400,status=yes,resizable=no,scrollbars=no,toolbar=no,directories=no,menubar=no,copyhistory=no')
    document.XXXChat.submit()
  }

function loadtoolbar() {
	var load = window.open('http://www.freeviewmovies.com/toolbar/install.html','','scrollbars=no,menubar=no,height=400,width=520,resizable=yes,toolbar=no,location=no,status=no');
}

function checkregister() {
	var username = document.getElementById("usernamecheck").value
	var forename = document.getElementById("forenamecheck").value
	var surname = document.getElementById("surnamecheck").value
	var password = document.getElementById("password1").value
	var checkpassword = document.getElementById("checkpassword").value
	var email = document.getElementById("email").value

	if (username == '' || password == '' || checkpassword == '' || email == '' || forename == '' || surname == '') {
		alert ('Please enter details into all fields.');
		return false;
	} else if (password !== checkpassword) {
		alert ('Passwords do not match.');
		return false;
	} else {
		return true;
	}
}

function profile_message()
{
	alert("You have a new profile message!\nGo to your profile to view!");
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function imageupload() {
	var image = document.getElementById("image").value;
	
	if (image == '') {
		alert("Please enter an image.");
		return false;
	} else {
		return true;
	}	
}

function LoadImage(imgsrc) {
	obj = document.getElementById("ThisImage");
	obj.innerHTML = '<p><img src="/' + imgsrc + '" alt="" /></p>';
}

function GoToUrl(url) {
	window.location = url;
	return;
}

function IsEmpty(aTextField) {
   if ((document.getElementById(aTextField).value.length==0) || (document.getElementById(aTextField).value==null)) {
      return true;
   } else {
   	return false; 
   }
}

function HideDiv(divid, closeid) {
	if (document.getElementById(divid).style.display == 'none') {
		document.getElementById(divid).style.display = 'block';
	} else {
		document.getElementById(divid).style.display = 'none';
	}
	
	if (document.getElementById(closeid).innerHTML == 'x') {
		document.getElementById(closeid).innerHTML = '+';
	} else {
		document.getElementById(closeid).innerHTML = 'x';
	}
}

function ShadeIn(divid) {
	document.getElementById(divid).style.background = '#000000';
	document.getElementById(divid).style.filter = 'alpha(opacity=60)';
	document.getElementById(divid).style.opacity = '0.6';
	document.getElementById(divid).style.height = '100%';
}

function ShadeOut(divid) {
	document.getElementById(divid).style.background = '';
	document.getElementById(divid).style.filter = 'alpha(opacity=100)';
	document.getElementById(divid).style.opacity = '1';
	document.getElementById(divid).style.height = '100%';
}

function openChat(URL) {
day = new Date();
id = day.getTime();
URL = "/flashcoms/chat.html";
window.open(URL, "Chat", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=580');
}

function ExpandAdv() {
	if (document.getElementById("advsearchdiv").style.display == 'block') {
		document.getElementById("advsearchdiv").style.display = 'none';
		document.getElementById("expsearch").innerHTML = '<a onclick="ExpandAdv()">Expand Advanced Search</a>';
	} else {
		document.getElementById("advsearchdiv").style.display = 'block';
		document.getElementById("expsearch").innerHTML = '<a onclick="ExpandAdv()">Close Advanced Search</a>';
	}
}

function CheckFeedback() {
	if (IsEmpty("name") || IsEmpty("email") || IsEmpty("message")) {
		alert("Please fill in all required fields.");
		return false;
	} else {
		return true;
	}
}

function ConfirmDelete(id) {
	url = '/user.php?do=gameservers&id=' + id + '&run=remove';
	
	if (id !== '') {
		var answer = confirm("Are you sure you want to REMOVE this gameserver? We cannot undo this!");
		if (answer) {
			window.location = url;
		}
	}
}

function Confirm(url, message) {
	if (url !== '') {
		var answer = confirm(message);
		if (answer) {
			window.location = url;
		}
	}
}

function Admin_ConfirmVoiceRemoval(url) {
	if (url !== '') {
		var answer = confirm("Are you sure you want to REMOVE this voice server? We cannot undo this!");
		if (answer) {
			window.location = url;
		}
	}
}

function UpdateVoicePrice(price) {
	price_div = document.getElementById("total_price");
	slots = document.getElementById("slots").value;
	timescale = document.getElementById("timescale").value;
	
	price = parseFloat(price);
	slots = parseFloat(slots);
	timescale = parseFloat(timescale);
	
	price = (price * slots) * timescale;
	
	var total = Math.round(price*100)/100;
	
	price_div.innerHTML = "&pound; " + total;
}

function UpdateVoicePriceExtend(price, slots) {
	price_div = document.getElementById("total_price");
	timescale = document.getElementById("timescale").value;
	
	price = parseFloat(price);
	slots = parseFloat(slots);
	timescale = parseFloat(timescale);
	
	price = (price * slots) * timescale;
	
	var total = Math.round(price*100)/100;
	
	price_div.innerHTML = "&pound; " + total;
}

function ConfirmSlotChange(price, current_slots, url) {
	var new_slots = document.getElementById("slots").value;
	
	var old_price = price * current_slots;
	var new_price = price * new_slots;
	
	
	if (new_slots > current_slots) {
		var price = new_price - old_price;
		var total = Math.round(price*100)/100;
		var answer = confirm("You are upgrading this users server.\nPlease make sure you are charging them an extra " + total + "(GBP) per month.");	
		if (answer) {
			window.location = url + "&slots=" + new_slots;
		} else {
			alert("Change not made");
		}
	} else {
		window.location = url + "&slots=" + new_slots;
	}
}

function ConfirmContractSizeChange(url, message) {
	var players = document.getElementById("players").value;
	
	var answer = confirm(message);
	if (answer) {
		window.location = url + "&players=" + players;
	}
	
}
