var zipdebug = false;
var rank = 2;

	function updateSchool()
	{
		document.getElementById("tschool").value = '<br>School: '+document.getElementById("sschool").value;	
	}

	function matchZip(docform){
		zip = document.getElementById('zipForm').value;
		var buysnd=document.payfrm
		//alert(ziparray[6][2]);
		//alert(arrlength);
		var uindex = "";
		for(i=0; i<arrlength; i++){
			if(ziparray[i][0] > zip){
				if(ziparray[i][0] - zip < zip - ziparray[i-1][0]){
					uindex = i;	
					break;
				}else{
					uindex = i-1;
					break;
				}
			}
		}
		if(zipdebug==true){
			alert(ziparray[uindex][2]);
		}
		if(uindex==""){
			uindex = arrlength-1;	
		}
		buysnd.school.value = ziparray[uindex][4];
		pricegrid(ziparray[uindex][1],docform);
	}
	


//***************************start*****************************
	function getElementsByClassName(strClass, strTag, objContElm) {
	/*
	usage:
	cont = container, element with id name ex:
	cont = document.getElementById('container')

	objClassArry = getElementsByClassName('one')	//array with all class 'one' objs
	getElementsByClassName('one', 'a', cont)		//class 'one' objs inside of <a>
	getElementsByClassName('one two', 'a', cont)	//'one' AND 'two' in <a>
	getElementsByClassName('one|two', 'span', cont)	//'one' OR 'two' in <a>

	for (i = 0; i < objClassArry.length; i++) 
	   // Do your thing here.
	   //ex: objClassArry[i].id
	}
	*/

	  strTag = strTag || "*";
	  objContElm = objContElm || document;
	  var objColl = (strTag == '*' && document.all) ? document.all : objContElm.getElementsByTagName(strTag);
	  var arr = new Array();
	  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
	  var arrClass = strClass.split(delim);
	  for (i = 0, j = objColl.length; i < j; i++) {
	    var arrObjClass = objColl[i].className.split(' ');
	    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
	    var c = 0;
	    comparisonLoop:
	    for (k = 0, l = arrObjClass.length; k < l; k++) {
	      for (m = 0, n = arrClass.length; m < n; m++) {
		if (arrClass[m] == arrObjClass[k]) c++;
		if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
		  arr.push(objColl[i]);
		  break comparisonLoop;
		}
	      }
	    }
	  }
	  return arr;
	}

	// To cover IE 5.0's lack of the push method
	Array.prototype.push = function(value) {
	  this[this.length] = value;
	}
	//*******************END*****************************




	 function getIndexByValue(selectlist, valfind) {
		//This functions returns the index number for a submitted option box value
		i=0;
		while (selectlist.options[i] != null) {
			if (selectlist.options[i].value == valfind) {
				return i
			}
			i++
		}
		return 0;
	 
	 }
 
	function showhidedropdown(state_max, docform) {
	//to get an option value:   document.form_name.select_id.options[option ID starts with 1].value
	//to get current option ID:   document.form_name.select_id.selectedIndex
	//to get current option value:  document.form_name.select_id.options[document.form_name.select_id.selectedIndex].value
	//pain in the ass, huh?
		
		
		new_id=document.getElementById(docform.thisstate.options[docform.thisstate.selectedIndex].value)
		//new_id=eval(thisstate.value)

		for(i=0;i < state_max+1; i++){

			allunv = document.getElementById("thisunv"+i)
			allunv.selectedIndex = 0


			cur_id = document.getElementById("university"+i)
			
			
			//cur_id=eval("university"+i)
			
			if (cur_id==new_id){
				cur_id.style.display = "inline"
			}
			else{
				cur_id.style.display = "none"
			} 
		} 
		docform.school.value = ""
	}

	function selectschool(curunv, docform) {

		docform.school.value = curunv.options[curunv.selectedIndex].value

		
		showstep3 = document.getElementById("step3")
		showstep3.style.display = "block";
		
	}
	
	function setschool(schoollist, unvfrm) { //a simple version of select school
		unvfrm.school.value = schoollist.options[schoollist.selectedIndex].value
	}
	
	
	function clickflipbar(the_id_name) {
		//version 2, changes img and div at same time
		//this will hide/show an element with name the_id_name
		//and it will switch the picture on an element with the_id_namei
		
		the_id = document.getElementById(the_id_name)
		the_img = document.getElementById(the_id_name + "i")
		
		if (the_id.style.display == "block") {
			if (the_id) the_id.style.display = "none"
			the_img.src = 'images/tutors-college-close.gif';
		}
		else {
			if (the_id) the_id.style.display = "block"
			the_img.src = 'images/tutors-college-open.gif';
		}
	}//*/

	function hoverflip1bar(the_img) {
		if (the_img.src.indexOf('close') > 0) { /*the_img.src = 'images/tutors-college-subjects.gif'; */ }
	}
	function hoverflip2bar(the_img) {
		if (the_img.src.indexOf('subjects') > 0) { the_img.src = 'images/tutors-college-close.gif';  }
	}
	
	function pricegrid(scale, docform) {
		

		
		//scale = parseInt(curunv.options[curunv.selectedIndex].getAttribute('value2'))
		
		
		for(row=1;row <= 3; row++){
			for(col=1;col <= 6; col++){
				cell = document.getElementById("g"+row+col);
				level = 3-1+scale;
				if (row == 2) {
					//level=10-1; //for megamind
					level=16-1+scale; //for megamind
				}
				if (row != 3) {
					cell.innerHTML = "$"+priceary[level][col];
				}else{
					cell.innerHTML = "$"+(priceary[level+3][col]+testprep);	
				}
				//cell.innerHTML = "$"+level+"]["+col;
			}
		}
		
	
	}
	
	function setRate(){
		//alert(rank);
		//alert(document.getElementById('planKey').value);
		hourbasis = document.getElementById('planKey').value * 1.0 + 1;
 		rate = document.getElementById('g'+rank+hourbasis).innerHTML;
		rate = rate.replace('$','');
		//alert(rate);
		document.getElementById('rate').value = rate;
	}