var xmlhttp = false;

function getXmlHttp() {
	try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function set_Opacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      set_Opacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

function start() {
	document.getElementById('fading_bg').style.backgroundImage = 'url(bg/' + img[i] + ')';
	fadeIn('fading_bg', 10);
	i = i + 1;
	window.setInterval("startImageShow('"+'fading_bg'+"',"+100+")", 15000);
}

function startImageShow(objId) {
	if (i == img.length) i = 0;
	document.getElementById(objId).style.backgroundImage = 'url(bg/' + img[i] + ')';
	fadeIn(objId, 10);
	i = i + 1;
	document.getElementById('img_loader').src = 'bg/' + img[i];
}

function linkOver(obj) {
	obj.style.cursor = 'pointer';
	obj.style.borderColor = '#F8C301';
}

function linkOut(obj) {
	if (obj.style.background == '') 
	obj.style.borderColor = '#000000';
}

function seriesOver(obj) {
	obj.style.cursor = 'pointer';
	obj.style.color = '#F8C301';
}

function seriesOut(obj) {
	if (series != obj.id)
		obj.style.color = '#fff';
}

function CheckForm(){

nullvalue = 0;
msg ="";

if(document.myForm.Name.value==""){
msg += "Your Name\n";
nullvalue = 1;
}

if(document.myForm.Email.value==""){
  msg += "Email Address\n";
  nullvalue = 1;
}

if(document.myForm.Subject.value==""){
 msg += "Subject\n";
nullvalue = 1;
}

if(document.myForm.Message.value==""){
 msg += "Message\n";
nullvalue = 1;
}
if(nullvalue==1){
 alert("The following fields are found to have no value:\n" + msg);
 return false;
}
var emailFilter= /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if (!(emailFilter.test(document.myForm.Email.value))) { 
	    alert(document.myForm.Email.value + " is not a valid email address.");
    return false;
	}

return true;
}

function adminConfirm(obj, id, value) {
	xmlhttp = getXmlHttp();
	var url = "../phpfiles/admin_confirm.php";
	
	parameters = "id=" + id + "&value=" + value;

	xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.open('POST', url, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-Length", parameters.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(parameters);
}

function deleteMembers(members) {
	xmlhttp = getXmlHttp();
	var url = "../phpfiles/delete_members.php";
	
	parameters = "members=" + members;
	
	xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4) {
			alert(xmlhttp.responseText);
			location.href = "";
		}
	}
	
	xmlhttp.open('POST', url, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-Length", parameters.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(parameters);
}

function changePassword(obj, username, password) {
	xmlhttp = getXmlHttp();
	var url = "../phpfiles/change_password.php";
	
	parameters = "password=" + password + "&username=" + username;
	
	xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.open('POST', url, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-Length", parameters.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(parameters);
}