var defaultzip = "Or enter your zip code";

function searchLocation() {
	var loc = getObj('state').value;
	var zip = getObj('zip').value;
	if (loc != "All") {
		onlinePop = false;
		//document.searchbox.submit();
		document.location.replace('university-of-phoenix/'+loc+'/index.php');
	} else {
		if (validateZip(zip)) {
			onlinePop = false;
			document.searchbox.submit();
			//document.location.replace('search-zip.php?zip='+zip);
		} else {
			alert("Please enter a valid 5-digit zip code.");
		}
	}
}

function validateZip(str) {
	var reg = /^\d{5}$/; 
	return reg.test(str);
}

function clickZip() {
	var zip = getObj('zip').value;
	if (zip == defaultzip) {
		getObj('zip').value = '';
		getObj('state').value = 'All';
	}
}

function selectState() {
	getObj('zip').value = defaultzip;
	var loc = getObj('state').value;
	document.location.replace('university-of-phoenix/'+loc+'/index.php');
}

var lastBoxID = 1;
var onlinePop = true;

function selectSchool(id) {
	layer = document.getElementById('school-'+lastBoxID);
	layer.style.border = 'none';
	layer = document.getElementById('school-'+id);
	layer.style.border = '1px solid #000000';

	layer = document.getElementById('school-blurb-'+lastBoxID);
	layer.style.display = 'none';
	layer = document.getElementById('school-blurb-'+id);
	layer.style.display = 'block';
	
	lastBoxID=id;	
}

function openOnline() {
	var loc = new String(document.location);
	if (loc.indexOf('university-of-phoenix')==-1 || onlinePop) {
	//	var newWindow = window.open('http://university-of-phoenix-campus.com/university-of-phoenix-online2.php', 'online', 'width=720,height=470,resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no'); 
	//	newWindow.blur();
	}
}

function clickLink() {
	onlinePop = false;
}

/////////////////////

function getObj(name)
{
	if (document.getElementById)
	{
		if (document.getElementById(name)!=null) {
			return document.getElementById(name);
			return;
		}
	}
	else if (document.all)
	{
		if (document.all[name]!=null) {
			return document.all[name];
		}
	}
	else if (document.layers)
	{
		if (document.layers[name]!=null) {
			return document.layers[name];
		}
	}
	return null;
}

function gotoSchool(id, type, position) {
        document.school.id.value = id;
        document.school.type.value = type;
        document.school.position.value = position;
        document.school.submit();
}

var nav_status = new Array(15);
var program_status = new Array(15);

function init() {
	for (i=0;i<15;i++) {
		nav_status[i] = 'none';
		program_status[i] = 'none';
	}
}

function setNav(id) {
	nav_status[id] = 'block';
}
	
function programAction(id) {
	if (id<program_status.length) {
		if (program_status[id]=='none') {
			program_status[id]='block';
			getObj('program-box-' + id).style.display = 'block';
			getObj('program-ctrl-' + id).innerHTML = 'Hide Programs';
		} else {
			program_status[id]='none';
			getObj('program-box-' + id).style.display = 'none';
			getObj('program-ctrl-' + id).innerHTML = 'Show Programs';
		}
	}
}

function programDisplay() {
	void(0);
}
	
function sectionAction(id) {
	if (id<nav_status.length) {
		if (nav_status[id]=='none') {
			nav_status[id]='block';			
			getObj('section-box-' + id).style.display = 'block';
			getObj('section-ctrl-' + id).innerHTML = '<img src="/images/arrow-down.gif" border="0" width="14" height="14" id="cursor">';
		} else {
			nav_status[id]='none';
			getObj('section-box-' + id).style.display = 'none';			
			getObj('section-ctrl-' + id).innerHTML = '<img src="/images/arrow-right.gif" border="0" width="14" height="14" id="cursor">';
		}
	}
}

function sectionDisplay() {
	void(0);
}

