var stateParm = "";
var majorsParm = "";
var studentbodysizeParm ="";
var citysizeParm = "";
var public_privateParm ="";
var two_four_yearParm = "";
var religiousaffilParm = "";
var studentbodytypeParm = "";
var ethnicmixParm = "";
var athleticsParm = "";
var specialservicesParm = "";
var disabilitiesParm =  "";

function setState( globalString){

stateParm =  globalString;

}
function getState(){
	if(stateParm != ""){
		return "&state=" + stateParm;
	}
	return "";
}
function convertState(){
	if(stateParm != ""){
		return "&state=" + stateParm;
	}
	return "";
}
function setMajors( globalString){

majorsParm =  globalString;

}
function getMajors(){
	if(majorsParm != ""){
		return "&major=" + majorsParm;
	}
	return "";
}
function convertMajors(){
	
	if(majorsParm != ""){
		return "&major=" + majorsParm;
	}
	return "";
}
function setStudentSize( globalString){

studentbodysizeParm =  globalString;

}
function getStudentSize(){

	if(studentbodysizeParm != ""){
		studentbodysizeParm = "&studentbodysize=" + studentbodysizeParm;
		return studentbodysizeParm;
	}
	return "";
}
function convertStudentSize(){
	if(studentbodysizeParm == 1){
		return "&studentbodymax=500";
	}
	if(studentbodysizeParm == 2){
		return "&studentbodymin=501&studentbodymax=2500";
	}
	if(studentbodysizeParm == 3){
		return "&studentbodymin=2501&studentbodymax=7500";
	}
	if(studentbodysizeParm == 4){
		return "&studentbodymin=7501&studentbodymax=15000";
	}
	if(studentbodysizeParm == 5){
		return "&studentbodymin=15000";
	}
	return "";
}
function setCitySize( globalString){

citysizeParm =  globalString;

}
function getCitySize(){

	if(citysizeParm != ""){
		return "&citysize=" + citysizeParm;
	}
	return "";
}
function convertCitySize(){

	if(citysizeParm != ""){
		return "&citySize=" + citysizeParm;
	}
	return "";
}
function setPublic( globalString){

public_privateParm =  globalString;

}
function getPublic(){

	if(public_privateParm != ""){
		return "&public_private=" + public_privateParm;
	}
	return "";
}
function convertPublic(){

	if(public_privateParm != ""){
		return "&institutionalControl=" + public_privateParm;
	}
	return "";
}
function setTwoYear( globalString){

two_four_yearParm =  globalString;

}
function getTwoYear(){

	if(two_four_yearParm != ""){
		return "&two_four_year=" + two_four_yearParm;
	}
	return "";
}
function convertTwoYear(){

	if(two_four_yearParm != ""){
		return "&institutionType=" + two_four_yearParm;
	}
	return "";
}
function setReligous( globalString){

religiousaffilParm =  globalString;

}
function getReligious(){

	if(religiousaffilParm != ""){
		return "&religiousaffil=" + religiousaffilParm;
	}
	return "";
}
function convertReligious(){

	if(religiousaffilParm != ""){
		return "&religiousAffiliation=" + religiousaffilParm;
	}
	return "";
}
function setStudentType( globalString){

studentbodytypeParm =  globalString;

}
function getStudentType(){

	if(studentbodytypeParm != ""){
		return "&studentbodytype=" + studentbodytypeParm;
	}
	return "";
}
function convertStudentType(){

	if(studentbodytypeParm == 1){
		return "&coedStatus=men+only";
	}
	if(studentbodytypeParm == 2){
		return "&coedStatus=men+and+women";
	}
	if(studentbodytypeParm == 3){
		return "&coedStatus=women+only";
	}
	return "";
}
function setEthnic( globalString){

ethnicmixParm =  globalString;

}
function getEthnic(){

	if(ethnicmixParm != ""){
		return "&ethnicmix=" + ethnicmixParm;
		
	}
	return "";
}
function convertEthnic(){

	if(ethnicmixParm == 1){
		return "&ethnicitytype=africanAmericanPercent&ethnicitypercentage=8&spiral=true&spiralField=ethnicitypercentage&steps=8,5,3";
		
	}
	if(ethnicmixParm == 2){
		return "&ethnicitytype=asianPercent&ethnicitypercentage=8&spiral=true&spiralField=ethnicitypercentage&steps=8,5,3";
		
	}
	if(ethnicmixParm == 3){
		return "&ethnicitytype=hispanicPercent&ethnicitypercentage=8&spiral=true&spiralField=ethnicitypercentage&steps=8,5,3";
		
	}
	if(ethnicmixParm == 4){
		return "&ethnicitytype=nativeAmericanPercent&ethnicitypercentage=8&spiral=true&spiralField=ethnicitypercentage&steps=8,5,3";
		
	}
	return "";
}

function setAthletics( globalString){

athleticsParm =  globalString;

}
function convertAthletics(){
	var maleString="";
	var femaleString="";
	var tempString = athleticsParm;
	
	if(athleticsParm != ""){
		
		
		while(tempString.indexOf(",") >= 0){
			var nextSport = tempString.substring(0,tempString.indexOf(","));
			
			if(nextSport.indexOf("M") != -1){
				maleString = maleString + tempString.substring(1,tempString.indexOf(",")) + ",";
			}
			if(nextSport.indexOf("W") != -1){
				femaleString = femaleString + tempString.substring(1,tempString.indexOf(",")) + ",";
			}
			
			tempString = tempString.substring(tempString.indexOf(",")+1);
			
		}

		if(maleString !=""){
			maleString = maleString.substring(0,maleString.length-1);
			maleString = "&maleSport=" + maleString;
		}
		if(femaleString !=""){
			femaleString = femaleString.substring(0,femaleString.length-1);
			femaleString = "&femaleSport=" + femaleString;
		}
		
		return maleString + femaleString;
		
	}
	return "";
}
function getAthletics(){

	if(athleticsParm != ""){
	
		return "&athletics=" + athleticsParm;
		
	}
	return "";
}
function setSpecial( globalString){

specialservicesParm =  globalString;

}
function getSpecial(){

	if(specialservicesParm != ""){
		return "&specialservices=" + specialservicesParm;
		
	}
	return "";
}
function convertSpecial(){

	if(specialservicesParm != ""){
		return "&service=" + specialservicesParm;
		
	}
	return "";
}
function setDisability( globalString){

disabilitiesParm =  globalString;

}
function getDisability(){

	if(disabilitiesParm != ""){
		return "&disabilities=" + disabilitiesParm;
		
	}
	return "";
}
function convertDisability(){

	if(disabilitiesParm != ""){
		return "&service=" + disabilitiesParm;
		
	}
	return "";
}
function convertBothSpecial(){
	var serviceString = "";
	
	if(disabilitiesParm != "" || specialservicesParm != ""){
		serviceString = "&service=";
		if(disabilitiesParm != ""){ 
			serviceString = serviceString + disabilitiesParm;
			if(specialservicesParm !=""){
				serviceString = serviceString + ",";
			}
			
		}
		if(specialservicesParm != ""){
			serviceString = serviceString + specialservicesParm
		}
		return serviceString;
	}
	return "";
}



function loadSubsearch(page){
	if(page == 'areaofstudy'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability();
	}
	if(page == 'locations'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getMajors() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability();
	}
	if(page == 'studentbodysize'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500"  + getMajors() + getState() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability();
	}
	if(page == 'citysize'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getMajors() + getState() + getStudentSize()+getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability();
	}
	if(page == 'public_private'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getMajors() + getState() + getStudentSize() +getCitySize()+ getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability();
	}
	if(page == 'two_four_year'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500"  + getMajors() + getState() + getStudentSize() +getCitySize() +getPublic() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability();
	}
	if(page == 'religiousaffiliation'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getMajors() + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability();
	}
	if(page == 'studentbodytype'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getMajors() + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious()+ getEthnic() + getAthletics() + getSpecial() + getDisability();
	}
	if(page == 'ethnicmix'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getMajors() + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getAthletics() + getSpecial() + getDisability();
	}
	if(page == 'athletics'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getMajors() + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getSpecial() + getDisability();
	}
	if(page == 'specialservices'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getMajors() + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getDisability();
	}
	if(page == 'disabilities'){
	window.location = "/collegesearch/" + page + ".jsp?location=1500" + getMajors() + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() ;
	}
	if(page == 'areaofstudyhead'){
	window.location = "/collegesearch/areaofstudy.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'locationshead'){
	window.location = "/collegesearch/locations.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'studentbodysizehead'){
	window.location = "/collegesearch/studentbodysize.jsp?location=1500"  + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'citysizehead'){
	window.location = "/collegesearch/citysize.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'public_privatehead'){
	window.location = "/collegesearch/public_private.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'two_four_yearhead'){
	window.location = "/collegesearch/two_four_year.jsp?location=1500"  + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'religiousaffiliationhead'){
	window.location = "/collegesearch/religiousaffiliation.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'studentbodytypehead'){
	window.location = "/collegesearch/studentbodytype.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'ethnicmixhead'){
	window.location = "/collegesearch/ethnicmix.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'athleticshead'){
	window.location = "/collegesearch/athletics.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'specialserviceshead'){
	window.location = "/collegesearch/specialservices.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
	if(page == 'disabilitieshead'){
	window.location = "/collegesearch/disabilities.jsp?location=1500" + getState() + getStudentSize() +getCitySize() +getPublic() + getTwoYear() + getReligious() + getStudentType() + getEthnic() + getAthletics() + getSpecial() + getDisability() + getMajors();
	}
}

function primarySearch(){
	
	window.location = "/SearchSchools.do?" + "state=" + stateParm +"&location=1500" + convertState() + convertMajors() + convertStudentSize() +convertCitySize() +convertPublic() + convertTwoYear() + convertReligious() + convertStudentType() + convertEthnic() + convertAthletics() + convertBothSpecial() ;;
		
}

function stateSearch(){
	var stateString ="&state=";

	for(i=0;i<document.csearch.locations.length;i++){
		if(document.csearch.locations[i].checked){
			stateString = stateString + document.csearch.locations[i].value + ",";
		}
	}
	stateString = stateString.substring(0,stateString.length-1);
	window.location = "/SearchSchools.do?location=1500" + stateString + convertMajors() + convertStudentSize() +convertCitySize() +convertPublic() + convertTwoYear() + convertReligious() + convertStudentType() + convertEthnic() + convertAthletics() + convertBothSpecial() ;
}

function majorsSearch(){
	var majorString ="&major=";
	for(i=0;i< document.csearch.majors.length;i++){
		majorString = majorString + document.csearch.majors[i].value + ","; 
	}
	majorString = majorString.substring(0,majorString.length-1);
	window.location = "/SearchSchools.do?location=1500" + majorString + convertState() + convertStudentSize() +convertCitySize() +convertPublic() + convertTwoYear() + convertReligious() + convertStudentType() + convertEthnic() + convertAthletics() + convertBothSpecial() ;

}

function studentsizeSearch(){
	var studentsize = "";
	var sizeString = "";
	for(i=0;i<document.csearch.studentbodysize.length;i++){
		if(document.csearch.studentbodysize[i].checked){
			studentsize = i;
		}
	}
	
	if(studentsize == 1){
		sizeString ="&studentbodymax=500";
	}
	if(studentsize == 2){
		sizeString ="&studentbodymin=501&studentbodymax=2500";
	}
	if(studentsize == 3){
		sizeString = "&studentbodymin=2501&studentbodymax=7500";
	}
	if(studentsize == 4){
		sizeString = "&studentbodymin=7501&studentbodymax=15000";
	}
	if(studentsize == 5){
		sizeString = "&studentbodymin=15000";
	}
	
	window.location = "/SearchSchools.do?location=1500" + sizeString + convertMajors() + convertState() +convertCitySize() +convertPublic() + convertTwoYear() + convertReligious() + convertStudentType() + convertEthnic() + convertAthletics() + convertBothSpecial() ;
}

function citysizeSearch(){
	
	var cityString ="&citySize=";
	
	for(i=0;i<document.csearch.citysize.length;i++){
		if(document.csearch.citysize[i].checked){
			cityString = cityString + document.csearch.citysize[i].value + ",";
		}
	}
	cityString = cityString.substring(0,cityString.length-1);
	
	
	window.location = "/SearchSchools.do?location=1500" + cityString + convertMajors() + convertState() + convertStudentSize()  +convertPublic() + convertTwoYear() + convertReligious() + convertStudentType() + convertEthnic() + convertAthletics() + convertBothSpecial() ;
}

function publicSearch(){

	var institutionString ="&institutionalControl=";
	
	for(i=0;i<document.csearch.public_private.length;i++){
		if(document.csearch.public_private[i].checked){
			institutionString = institutionString + document.csearch.public_private[i].value + ",";
		}
	}
	institutionString = institutionString.substring(0,institutionString.length-1);
	
	
	window.location = "/SearchSchools.do?location=1500" + institutionString + convertMajors() + convertState() + convertStudentSize() +convertCitySize()  + convertTwoYear() + convertReligious() + convertStudentType() + convertEthnic() + convertAthletics() + convertBothSpecial() ;


}

function schooltypeSearch(){

	
	var schooltypeString ="&institutionType=";
	
	for(i=0;i<document.csearch.two_four_year.length;i++){
		if(document.csearch.two_four_year[i].checked){
			schooltypeString = schooltypeString + document.csearch.two_four_year[i].value + ",";
		}
	}
	schooltypeString = schooltypeString.substring(0,schooltypeString.length-1);

	
	window.location = "/SearchSchools.do?location=1500" + schooltypeString + convertMajors() + convertState() + convertStudentSize() +convertCitySize() +convertPublic()  + convertReligious() + convertStudentType() + convertEthnic() + convertAthletics() +convertBothSpecial() ;
}

function religiousSearch(){
	
	var religionString ="&religiousAffiliation=";
	for(i=0;i< document.csearch.religiousaffil.length;i++){
		religionString = religionString + document.csearch.religiousaffil[i].value + ","; 
	}
	religionString = religionString.substring(0,religionString.length-1);
	window.location = "/SearchSchools.do?location=1500" + religionString + convertMajors() + convertState() + convertStudentSize() +convertCitySize() +convertPublic() + convertTwoYear()  + convertStudentType() + convertEthnic() + convertAthletics() + convertBothSpecial() ;
}

function ethnicSearch(){


	
	var ethnicString ="";
	
	for(i=0;i<document.csearch.ethnicmix.length;i++){
	if(document.csearch.ethnicmix[i].checked){
			
	if(document.csearch.ethnicmix[i].value == 1){
ethnicString= "&ethnicitytype=africanAmericanPercent&ethnicitypercentage=8&spiral=true&spiralField=ethnicitypercentage&steps=8,5,3";
		
	}
	if(document.csearch.ethnicmix[i].value == 2){
ethnicString= "&ethnicitytype=asianPercent&ethnicitypercentage=8&spiral=true&spiralField=ethnicitypercentage&steps=8,5,3";
		
	}
	if(document.csearch.ethnicmix[i].value == 3){
ethnicString= "&ethnicitytype=hispanicPercent&ethnicitypercentage=8&spiral=true&spiralField=ethnicitypercentage&steps=8,5,3";
		
	}
	if(document.csearch.ethnicmix[i].value == 4){
ethnicString= "&ethnicitytype=nativeAmericanPercent&ethnicitypercentage=8&spiral=true&spiralField=ethnicitypercentage&steps=8,5,3";
		
	}
			
		}
	}
	

	
	window.location = "/SearchSchools.do?location=1500" + ethnicString + convertMajors() + convertState() + convertStudentSize() +convertCitySize() +convertPublic() + convertTwoYear() + convertReligious() + convertStudentType() + convertAthletics() + convertBothSpecial() ;

}

function coedSearch(){

	
	var coedString ="&coedStatus=";
	
	for(i=0;i<document.csearch.studentbodytype.length;i++){
		if(document.csearch.studentbodytype[i].checked){
			if(document.csearch.studentbodytype[i].value == 1){
				coedString = coedString + "men+only";
			}
			if(document.csearch.studentbodytype[i].value == 2){
				coedString = coedString + "men+and+women";
			}
			if(document.csearch.studentbodytype[i].value == 3){
				coedString = coedString + "women+only";
			}
		}
	}
	

	
	window.location = "/SearchSchools.do?location=1500" + coedString + convertMajors() + convertState() + convertStudentSize() +convertCitySize() +convertPublic() + convertTwoYear() + convertReligious() + convertEthnic() + convertAthletics() + convertBothSpecial() ;
}

function athleticsSearch(){

	var athleticsString ="";
	for(i=0;i< document.csearch.athletics.length;i++){
		athleticsString = athleticsString + document.csearch.athletics[i].value + ","; 
	}
	
	
	var maleString="";
	var femaleString="";
	
	
	if(athleticsString != ""){
		
		
		while(athleticsString.indexOf(",") >= 0){
			var nextSport = athleticsString.substring(0,athleticsString.indexOf(","));
	
			if(nextSport.indexOf("M") != -1){
			
				maleString = maleString + athleticsString.substring(1,athleticsString.indexOf(",")) + ",";
			}
			if(nextSport.indexOf("W") != -1){
			
				femaleString = femaleString + athleticsString.substring(1,athleticsString.indexOf(",")) + ",";
			}
			
			athleticsString = athleticsString.substring(athleticsString.indexOf(",")+1);
			
		}
		if(maleString !=""){
			maleString = maleString.substring(0,maleString.length-1);
			maleString = "&maleSport=" + maleString;
		}
		if(femaleString !=""){
			femaleString = femaleString.substring(0,femaleString.length-1);
			femaleString = "&femaleSport=" + femaleString;
		}
		
		
	}

	window.location = "/SearchSchools.do?location=1500" + maleString + femaleString + convertMajors() + convertState() + convertStudentSize() +convertCitySize() +convertPublic() + convertTwoYear() + convertReligious() + convertStudentType() + convertEthnic() + convertBothSpecial() ;

}

function disabilitySearch(){

	var disabilityString = convertSpecial();
	if(disabilityString == ""){
		disabilityString =  "&service=";
	}
	else{
		disabilityString = disabilityString + ",";
	
	}
	
	for(i=0;i<document.csearch.disabilities.length;i++){
		if(document.csearch.disabilities[i].checked){
			disabilityString = disabilityString + document.csearch.disabilities[i].value + ",";
		}
	}
	disabilityString = disabilityString.substring(0,disabilityString.length-1);

	
	window.location = "/SearchSchools.do?location=1500" + disabilityString + convertMajors() + convertState() + convertStudentSize() +convertCitySize() +convertPublic() + convertTwoYear() + convertReligious() + convertStudentType() + convertEthnic() + convertAthletics() + convertSpecial();

}

function specialSearch(){

	
	var specialString = convertDisability();
	if(specialString == ""){
		specialString =  "&service=";
	}
	else{
		specialString = specialString + ",";
	
	}
	
	for(i=0;i<document.csearch.specialservices.length;i++){
		if(document.csearch.specialservices[i].checked){
			specialString = specialString + document.csearch.specialservices[i].value + ",";
		}
	}
	specialString = specialString.substring(0,specialString.length-1);

	
	window.location = "/SearchSchools.do?location=1500" + specialString + convertMajors() + convertState() + convertStudentSize() +convertCitySize() +convertPublic() + convertTwoYear() + convertReligious() + convertStudentType() + convertEthnic() + convertAthletics() + convertDisability();
}
