// Entire current URL as a string
var url = new String(window.location);

// Get current URL up to and including the first / (starts after http:// so those don't count)
var doc_root = url.substring(0,url.indexOf('/',9) + 1);

// start add to favorite code
function addFavorite(){
	if (window.sidebar){ // if using Mozilla
    	window.sidebar.addPanel('Schools.com', //Page title
								doc_root, //link target
								""); // empty parameter
  	}
  	else if( document.all ) {	//else if using IE
    	window.external.AddFavorite(doc_root, //target link
									'Schools.com'); //title that you want displayed on the list
  	}
  	else {	//if some other browser
   		return;
  	}
}

function string_replace(value) {
	temp = value.toLowerCase();
	temp = temp.replace(/ /g, "-");
	temp = temp.replace(/\./g, "");
	temp = temp.replace(/'/g, "");
	temp = temp.replace(/-&-/g, "-");
	temp = temp.replace(/\+\%26\+/g, "-and-");
	temp = temp.replace(/\,/g, "");
	temp = temp.replace(/\(/g, "");
	temp = temp.replace(/\)/g, "");
	return temp;
}
function submitForm() {
	var url = doc_root + 'online';
	
	var deg = string_replace(document.searchboxform.degree.value);
	if (deg != "all") {
		url += "/" + deg;
	}
	
	var subj = string_replace(document.searchboxform.subject.value);
	if (subj != "all") {
		url += "/" + subj;
	}
	
	var prog = string_replace(document.searchboxform.program.value);
	if (prog!="" && prog!="all" && prog!="0") {
		url += "/" + prog;
	}
	
	var concen = string_replace(document.searchboxform.concentration.value);
	if (concen!="" && concen!="all" && concen!="0") {
		url += "/" + concen;
	}
	
	if (url == doc_root + 'online')
		url += "/degrees/";
	else {
		url += ".html";
	}
	window.document.location = url;
}

function submitRotatingForm() {
	var url = doc_root + 'online';
	
	var deg = string_replace(document.rotating_box_searchboxform.degree.value);
	if (deg != "all") {
		url += "/" + deg;
	}
	
	var subj = string_replace(document.rotating_box_searchboxform.subject.value);
	if (subj != "all") {
		url += "/" + subj;
	}
	
	var prog = string_replace(document.rotating_box_searchboxform.program.value);
	if (prog!="" && prog!="all" && prog!="0") {
		url += "/" + prog;
	}
	
	if (url == doc_root + 'online')
		url += "/degrees/";
	else {
		url += ".html";
	}
	window.document.location = url;
}

function submitFormCampus() {
	var url = doc_root + 'campus-schools';
	
	var loc = string_replace(document.searchboxform.location.value);
	if (loc != "all") {
		url += "/" + loc;
	}
	
	var city = string_replace(document.searchboxform.city.value);
	if (city!="" && city!="all" && city!="0") {
		url += "/" + city;
	}
	
	var deg = string_replace(document.searchboxform.degree.value);
	if (deg != "all") {
		url += "/" + deg;
	}
	
	var subj = string_replace(document.searchboxform.subject.value);
	if (subj != "all") {
		url += "/" + subj;
	}
	
	var prog = string_replace(document.searchboxform.program.value);
	if (prog!="" && prog!="all" && prog!="0") {
		url += "/" + prog;
	}
	
	var concen = string_replace(document.searchboxform.concentration.value);
	if (concen!="" && concen!="all" && concen!="0") {
		url += "/" + concen;
	}
	
	if (url == doc_root + 'campus-schools')
		url += "/";
	else {
		url += ".html";
	}
	window.document.location = url;
}