/******************************************************
SLIDER START + DREAMWEAVER SCRIPTS
******************************************************/
$(document).ready(function(){	
			$("#slider").easySlider({
				auto: true, 
				continuous: true
			});
		});
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/******************************************************
SNEAKY SCRIPT
******************************************************/
function codify (thisguy) {
	str = "";
	for (i=0; i<thisguy.length; i++) {
		str += "&#" + thisguy.charCodeAt(i) + ";";
	}	
	return str;
}

function buildaddress (one, two, three) {
	str = "";
	str += codify(three);
	str += "&#" + "064" + ";";
	str += codify(two);
	str += "&#" + "046" + ";";
	str += codify(one);
	return str;
}

// Our most popular function -- creates mailto link with email address as link text
function sneaky (one, two, three, four) {
	str = buildaddress(one, two, three);
	if (four != "") four = "class=" + four + " ";
	document.write("<a " + four + "hre" + "f=mai" + "lto:" + str +">" + str + "</" + "a>");
}

// Creates mailto link with fourth parameter as the link text
function sneaky2 (one, two, three, four, five) {
	str = buildaddress(one, two, three);
	if (four != "") five = "class=" + four + " ";
	document.write("<a " + five + "hre" + "f=mai" + "lto:" + str +">" + four + "</" + "a>");
}

// Simply prints the email address (great for forms!)
function sneaky3 (one, two, three) {
	document.write(buildaddress(one, two, three));
}

/******************************************************
FORM VALIDATOR
******************************************************/
function isMailAddress(m) {
   if ((m == '') || (m == ' ')) { return false; }

    var a = 1;
    var ml = m.length;

    while ((ml>a) && (m.charAt(a) != "@")) { a++ }
    if ((a >= ml) || (m.charAt(a) != "@")) {
	return false;
    } else {
	a = a + 2;
    }
    while ((ml > a) && (m.charAt(a) != ".")) { a++ }
    if ((a >= ml - 1) || (m.charAt(a) != ".")) {
	return false;
    } else {
    return true;
    }
}

// For Contact Form
function validate(obj) {

	var valid = true;
	var msg = "";

	if (obj.elements["name"].value == "") {
		msg += "Please enter your name.\n";
		valid = false;
		obj.elements["name"].focus();

	}
	
		// Check for white space
		reWhiteSpace = new RegExp(/^\s+$/);
		
			if (reWhiteSpace.test(obj.elements["name"].value)) {
				msg += "Please enter your name.\n";
				valid = false;
				obj.elements["name"].focus();
			}

	if (!isMailAddress(obj.elements["email"].value)) {
		msg += "Please enter a valid email address.\n";
		if (valid) {
			valid = false;
		    obj.elements["email"].focus();
		}
	}

	if (!valid) alert(msg);
	return valid;
}

// For Online Admission Application
function validate2(obj) {

	var valid = true;
	var msg = "";

	if (obj.elements["name"].value == "") {
		msg += "Please enter your name.\n";
		valid = false;
		obj.elements["name"].focus();

	}
	
		// Check for white space
		reWhiteSpace = new RegExp(/^\s+$/);
		
			if (reWhiteSpace.test(obj.elements["name"].value)) {
				msg += "Please enter your name.\n";
				valid = false;
				obj.elements["name"].focus();
			}
			
	if (obj.elements["telephone"].value == "") {
		msg += "Please enter your telephone number.\n";
		valid = false;
		obj.elements["telephone"].focus();

	}

	if (!isMailAddress(obj.elements["email"].value)) {
		msg += "Please enter a valid email address.\n";
		if (valid) {
			valid = false;
		    obj.elements["email"].focus();
		}
	}

	if (!valid) alert(msg);
	return valid;
}

/******************************************************
FOOTER POPUP
******************************************************/
var gcookie;
window.onscroll = chkScroll;
readCookie();

function createCookie() {
	var name = "fpucookie";
	var value = 1;
	var days;

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	document.getElementById("footerfix").style.display = "none";
	gcookie = 1;
}

function readCookie() {
	var name = "fpucookie";
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) gcookie = c.substring(nameEQ.length,c.length);
	}
	return null;
}

function chkScroll(){
	if (gcookie != 1) {
		var ScrollTop = document.body.scrollTop;
		if (ScrollTop == 0) {
			if (window.pageYOffset){
				ScrollTop = window.pageYOffset;
				} else {
					ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
					}
		}
		if (ScrollTop >= 120) {
			document.getElementById("footerfix").style.display = "block";
			} else {
				document.getElementById("footerfix").style.display = "none";
		}
	}
}

/******************************************************
SIDEBAR LOCATIONS
******************************************************/
function showbox1(){	
	var check;
	check = document.getElementById("drop1").value;
	if (check == "0"){ // Small
		document.getElementById("content1").style.display = 'none';
		document.getElementById("drop1").value = '1';
		}
	if (check == "1"){ // Big
		document.getElementById("content1").style.display = 'block';
		document.getElementById("drop1").value = '0';
		}
	}
function showbox2(){	
	var check;
	check = document.getElementById("drop2").value;
	if (check == "0"){ // Small
		document.getElementById("content2").style.display = 'none';
		document.getElementById("drop2").value = '1';
		}
	if (check == "1"){ // Big
		document.getElementById("content2").style.display = 'block';
		document.getElementById("drop2").value = '0';
		}
	}
