/***************** AJAX ********************/
	<!--
	
	//Create a boolean variable to check for a valid Internet Explorer instance.
	var xmlhttp = false;
	
	
	//Check if we are using IE.
	try {
		//If the Javascript version is greater than 5.
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		//alert ("You are using Microsoft Internet Explorer.");
	} catch (e) {
		//If not, then use the older active x object.
		try {
			//If we are using Internet Explorer.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			//alert ("You are using Microsoft Internet Explorder");
		} catch (E) {
			//Else we must be using a non-IE browser.
			xmlhttp = false;
		}
	}
	
	//If we are using a non-IE browser, create a javascript instance of the object.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
		//alert ("You are not using Microsoft Internet Explorer");
	}
	
	function makerequest(serverPage, objID) {
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	//-->
	hex=255 // Initial color value.

	function fadetext(){ 
	if(hex>0) { //If color is not black yet
	hex-=11; // increase color darkness
	document.getElementById("ayala_projects").style.color="rgb("+hex+","+hex+","+hex+")";
	//document.getElementById("collapse_ayala").style.color="rgb("+hex+","+hex+","+hex+")";
	setTimeout("fadetext()",50); 
	}
	else
	hex=255 //reset hex value
	}
		function fadetext_partners(){ 
	if(hex>0) { //If color is not black yet
	hex-=11; // increase color darkness
	document.getElementById("partners").style.color="rgb("+hex+","+hex+","+hex+")";
	//document.getElementById("collapse_ayala").style.color="rgb("+hex+","+hex+","+hex+")";
	setTimeout("fadetext_partners()",50); 
	}
	else
	hex=255 //reset hex value
	}
	function fadeout(){ 
	if(hex>0) { //If color is not black yet
	hex-=11; // increase color darkness
	document.getElementById("collapse_ayala").style.color="rgb("+hex+","+hex+","+hex+")";
	//document.getElementById("collapse_ayala").style.color="rgb("+hex+","+hex+","+hex+")";
	setTimeout("fadeout()",50); 
	}
	else
	hex=255 //reset hex value
	}
	
/***************** FORM VALIDATIONS ********************/

function checkemail(str){
	var testresults
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=true
	else{
		testresults=false
	}
	return (testresults)
}

function validateSignUp(form){
	
	if (form.username.value == "") {
		alert('Please enter your Username');
		form.username.focus();
		return false ;
	  } 
	if (form.password.value == "") {
		alert('Please enter a Password');
		form.password.focus();
		return false ;
	  } 	  
	if (form.confirmpass.value == "") {
		alert('Please Re-confirm your password.');
		form.confirmpass.focus();
		return false ;
	  } 	  
	if (form.confirmpass.value != form.password.value) {
		alert('Passwords do not match. Please re-enter your password.');
		form.confirmpass.focus();
		return false ;
	  } 
	  if(form.email.value == '' || !checkemail(form.email.value)){
		alert('Please enter a valid email address!');
		form.email.focus();
		return false ;
	  } 
}

function validateContact(form){
	
	 if (form.visitor.value == "") {
		alert('Please enter your Name');
		form.visitor.focus();
		return false ;
	  } 
	 if(form.visitormail.value == '' || !checkemail(form.visitormail.value)){
		alert('Please enter a valid email address!');
		form.visitormail.focus();
		return false ;
	  } 
	   if (form.attn.value == "") {
		alert('Please enter your Subject');
		form.attn.focus();
		return false ;
	  } 
	   if (form.notes.value == "") {
		alert('Please enter your Message');
		form.notes.focus();
		return false ;
	  } 
}

function validateSearch(form){
	
	 if (form.sw.value == "") {
		alert('Please enter keyword to search.');
		form.sw.focus();
		return false ;
	  }
}

function validateSubject(form){
	
	if (form.subjcode.value == "") {
		alert('Please enter a Subject Code');
		form.subjcode.focus();
		return false ;
	}
	
	if (form.schedcode.value == "") {
		alert('Please enter a Schedule Code');
		form.schedcode.focus();
		return false ;
	} 
	
	if (form.description.value == "") {
		alert('Please enter a Description');
		form.description.focus();
		return false ;
	} 
	
	var x = 0;
	for(var i = 0;i < form.semester.length; i++){
		if(form.semester[i].checked)
			x = 1;
	}
	
	if(x==0){
		alert("Please select a semester");
		form.semester[0].focus();
		return false;
	}
	
	if (form.year.value == 0) {
		alert('Please select a School Year');
		form.year.focus();
		return false ;
	} 
	
	if (form.syllabus.value == 0) {
		alert('Please select a Syllabus');
		form.syllabus.focus();
		return false ;
	}	
}

function validateStud(form){
	if(form.subject.value == 0){
		alert("Please choose a subject");
		form.subject.focus();
		return false ;
	}
	
	if(form.student.value == ""){
		alert("Please select your student/s");
		form.subject.focus();
		return false;
	}
	var myArr = new Array();
	var x = 0;
	for(var i=0;i<form.student.options.length;i++){
		if(form.student.options[i].selected == true){
			myArr[i] = form.student.options[i].value;
			x++;
		}
	}
	
	if(x == 0){
		alert("Please select your student/s");
		form.subject.focus();
		return false;
	}
	
	form.studz.value = myArr.concat(",");
	//alert(form.studz.value);
	return true;
}

function promptMe(id,task,id2){
	var nxt = '';
	if(id2!=''){
		nxt = "&idno="+id2;
	}
	if(confirm("Are you sure you want to delete this record?")){
		location.href = "save.php?task=delete&id="+id+nxt;
	}
}

function chkLogin(form){
	if (form.username.value == "") {
		alert('Please enter your ID Number');
		form.username.focus();
		return false ;
	} 
	if (form.password.value == "") {
		alert('Please enter a Password');
		form.password.focus();
		return false ;
	} 	
}

function chkAnnouncement(form){
	if(form.announce.value.length < 1){
		form.announce.focus();
		alert("Please enter an announcement");
		return false;
	}	
}

function chkFilter(form){
	if(form.subject.value == 0){
		alert("Please choose a subject");
		form.subject.focus();
		return false;
	}
}

function chkUpload(form){
	if(form.file.value == 0){
		alert("Please select a file to upload");
		form.file.focus();
		return false;
	}
	
	if(form.caption.value == 0){
		alert("Please put a caption");
		form.caption.focus();
		return false;
	}
}

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function mailto(domain,user) 
    { 
        document.location.href = "mailto:" + user + "@" + domain; 
    }
