// JavaScript Document
        function open_popup(html){
                document.getElementById("popup_content").innerHTML = "<a href='javascript:close_popup()' class='xbox'></a>"+html;
                document.getElementById("popup").style.display = "block";
                document.getElementById("screen").style.display = "block";
                window.scrollTo(0,0);
        }
		function set_popup_html(html){
                document.getElementById("popup_content").innerHTML = "<a href='javascript:close_popup()' class='xbox'></a>"+html;
		}
        function close_popup(){
                document.getElementById("popup").style.display = "none";
                document.getElementById("screen").style.display = "none";
        }
		
//Drop Downs
var the_open_element="";

function dropDown(o,theClickable){
        if(the_open_element == o){
                closeDown(the_open_element);return;//just close the drop down
        }
        closeDown(the_open_element);
        try{
                the_open_element=o;
                var ele = document.getElementById(o);
                var c = getCoords(theClickable);

                ele.style.display = "block";
                ele.style.width = c.w+"px";
                ele.style.top = (c.y+c.h)+"px";
                ele.style.left = c.x+"px";
        }
        catch(err){}
}
function closeDown(o){
        try{
                document.getElementById(o).style.display = "none";
                the_open_element="";
        }
        catch(err){}
}
function select_option(o, display_id, display_value, data_id, data_value){
        closeDown(o);
        document.getElementById(display_id).value = display_value;
        document.getElementById(data_id).value = data_value;
}

function getCoords(element) {
        var coords = { x:0, y:0, w:0, h:0};

        //alert(element.style.width +" 1 "+ element.width +" 2 "+ document.getElementById('popup_content').style.width +" 3 "+ document.getElementById('popup_content').width);

        coords.w = parseInt(element.style.width) || element.width || 250;
        coords.h = parseInt(element.style.height) || element.height || 18;
        while (element) {
                coords.x += element.offsetLeft;
                coords.y += element.offsetTop;
                element = element.offsetParent;
        }
        return coords;
}

function getPos(e) {
        if(!e) e = window.event;
        var pos = { x:0, y:0};
        if(e.pageX || e.pageY){
                pos.x = e.pageX;
                pos.y = e.pageY;
        }else if(e.clientX || e.clientY){
                pos.x = e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
                pos.y = e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
        }
        return pos;
}

function setValue(id,value){
        document.getElementById(id).innerHTML = value;
}

function add_other_school(school){
	document.getElementById('campus_name').value = school;
	document.getElementById('campus_id').value = -1;
	
	closeDown('campuses');
	close_popup();
}



	function print_object(obj){
			var str=""; 
			for(prop in obj){
				str+=prop + " value :"+ obj[prop]+"\n";//Concate prop and its value from object
			}
			return str; //Show all properties and its value
	}

	function hide(id){
		try{
		document.getElementById(id).style.display = 'none';
		
		}catch(e){
			alert(e);
		}
	}
	function show(id){
		document.getElementById(id).style.display = 'block';
	}

//Author: Nate Good 
//This is a dev tool used created for easy instantiation of Ajax objs called "Jax" objects
//I dig open source and code sharing just give props where props are due if used

//Jax Object
//url:Url of Server Script
//feedback: Function while loading and upon on completion
function Jax(url, feedback){
	var that = this;
	this.url = url;
	this.xmlHttp = getXmlHttpObject();
	if(this.xmlHttp == null) error("Browser Lacks Support");
	this.feedback = feedback;
	this.output = false;
	this.method = "POST";
	this.send = function(sendData){
		try{
			this.sendData = sendData;
			this.xmlHttp.onreadystatechange = that.stateChanged;
			this.xmlHttp.open(that.method,that.url,true);
			this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			this.xmlHttp.send(that.sendData);
		}catch(e){
			error(e);
		}
	}
	this.stateChanged = function(){ 
		var msg, complete, status;
		if(that.xmlHttp.readyState == 4){
			complete = true;
			status = that.xmlHttp.status;
			if(that.xmlHttp.status == 200) msg = that.xmlHttp.responseText;
			else msg = "Error : "+that.xmlHttp.status+" "+that.xmlHttp.statusText;
		}else{
			complete = false;
			status = 0;
			msg = "Loading";
		}
		var str = that.feedback(complete, status, msg);
		if(that.output != false)
		  that.output.innerHTML = str;
	}
}
function getXmlHttpObject(handler){ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

function error(err){
	alert(err);
}
