
	var req = createXMLHttpRequest();

	//block hour function --- shailesh kumar singh
	function blockhourfunc(btype,tId)
	{//alert(tId);
	
		if(document.frm.grd.value != '' && document.frm.subj.value != '' && document.frm.spec_sub.value != '')
		{
			var subid = document.frm.spec_sub.value;
			//alert(subid);
			req.open('get', 'function.php?do=blockhrs&id='+subid+'&btype='+btype+'&tId='+tId);
			req.onreadystatechange = checkSaveStatus;
			req.send(null);
			
		}
		
	}
	
	function checkSaveStatus()
	{
		if(req.readyState == 4)
		 {
			if(req.status == 200)
			{
				resp = req.responseText;
				respArr = resp.split("|"); 
				alert(respArr[3]);
document.frm.action = 'block-hour-package.php?event=purchase&btype='+respArr[1]+'&rdoSessionType='+respArr[2]+'&tId='+respArr[3];
				document.frm.event.value = 'purchase';
				document.frm.submit();
				return true;
			}
		}	
	}
	
	function chkTuts()
	{
		tutIds = document.getElementById("tutIds").value;
		url = 'functions.php?do=chkTutStatus&tutIds='+tutIds;
		req.open('get', url);
		req.onreadystatechange = chkTutStatus;
		req.send(null);	
	}

	function chkTutStatus()
	{
		var tids = '';
		if(req.readyState == 4)
		{
			var resp = req.responseText;
			var subList = resp.split(',');
			var j = 0;
			var k = 0;
			var isenble = 0;
			for(i=0; i < subList.length; i++)
			 {
				if(subList[i] != "")
				{
					idnamearr = subList[i].split('|'); 
					if(idnamearr[0] == 1)
					{
						if(j == 0)
						{
							document.getElementById("divtip_"+idnamearr[1]).innerHTML = '<img src="images/help_off.gif" style="border-width: 0px;"  onmouseover="show_tip(\'tip44\', \'img44\');" onmouseout="hide_tip(\'tip44\', \'img44\');" id="img44" alt="Help" /><div id="tip44" style="display:none; width:250px; margin-left:-278px; margin-top:-23px;" class="ToolTipNS2"><div>Tutor is busy and taking session with another student.This button will automatically change to Contact Live once tutor is free!</div></div>'; 
							j++;
						}
						document.getElementById("div_"+idnamearr[1]).style.display = 'none';
						document.getElementById("div1_"+idnamearr[1]).style.display = 'inline';
					}
					else if(idnamearr[0] == 2)
					{
						document.getElementById("div_"+idnamearr[1]).style.display = 'none';
						document.getElementById("div1_"+idnamearr[1]).style.display = 'none';
					}
					else
					{ 
						
						if((k == 0 || k == 1) && idnamearr[2] == 0)
						{
							document.getElementById("divtip_"+idnamearr[1]).innerHTML = '<img src="images/help_off.gif" style="border-width: 0px;"  onmouseover="show_tip(\'tip4\', \'img4\');" onmouseout="hide_tip(\'tip4\', \'img4\');" id="img4" alt="Help" /><div id="tip4" style="display:none; width:250px; margin-left:-278px; margin-top:-23px;" class="ToolTipNS2"><div>Click here to take an Instant (On-Demand) session right away with the tutor. Session starts Free, Payment starts only after you click Hire!.</div></div>'; 
							k++;
						}
						else if((k == 0 || k == 1) && idnamearr[2] == 1)
						{
							document.getElementById("divtip_"+idnamearr[1]).innerHTML = '<img src="images/help_off.gif" style="border-width: 0px;" onmouseover="show_tip(\'tip444\', \'img444\');" onmouseout="hide_tip(\'tip444\', \'img444\');" id="img444" alt="Help" /><div id="tip444" style="display:none; width:250px; margin-left:-278px; margin-top:-23px;" class="ToolTipNS2"><div>Click here to take an Instant (On-Demand) session right away with the tutor. Session starts Free, Payment starts only after you click Hire!.<br />This tutor also offers 20 min Instant Free Trials. Free-trials are a way for you to try new and different tutors and find the right tutor. You should not request repeat free trials from the same tutor; most tutors will decline such requests.</div></div>'; 
							k++;
						}
					
						
						if(j == 1 && k == 1)
						{
							document.getElementById("divtip_"+idnamearr[1]).style.display = 'inline';
						}
						else if((j == 1 || j == 0) && k == 2 && (isenble == idnamearr[2]))
						{
							document.getElementById("divtip_"+idnamearr[1]).style.display = 'none';
						}
						document.getElementById("div_"+idnamearr[1]).style.display = 'inline';
						document.getElementById("div1_"+idnamearr[1]).style.display = 'none';
						
						isenble = idnamearr[2];
					}
				}
			}
			
				setTimeout('chkTuts();', 60000);	 
		}	
	
	}
	
	function rtrim(str, chars)
	{
		chars = chars || "\\s";
		return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	}
	
	
	function changePage(page) {
		document.frm.page.value = page;
		document.frm.submit();
	}
	function sortResult(val)
	{
		if(val == 1)
		{
			document.frm.sortingResult2.value = '';
			document.frm.sortingResult_final.value = document.frm.sortingResult.value;
		}
		else
		{
			document.frm.sortingResult.value = '';
			document.frm.sortingResult_final.value = document.frm.sortingResult2.value;
		}
		document.frm.page.value = 1;
		document.frm.submit();
	}
	
	function locationResult(val)
	{
		document.frm.page.value = 1;
		document.frm.submit();
	}
	
	function gotoStep3() {
			
			validate = false;
			for (i = 0;i < document.frm.elements.length;i++)	{
				var e = document.frm.elements[i];
				if (e.checked){
					document.frm.tId.value = e.value;
					validate = true;
					break;
				}
			}
			if(!validate) {
				alert('Please select a tutor');
				return false;
			} else {
				document.frm.action = 'student-session-request.php';
				document.getElementById('event').value = 'step3';
				document.frm.method = 'get';
				document.frm.submit();
			}
	}	
	
	function goBack() {
		document.frm.action = "adv_tutor_search.php";
		document.frm.method = 'get';
		document.frm.event.value = '';
		document.frm.submit();
	}	
	/*
	function tutorDetail(tId) {
		//alert(tId);
		document.frm.action = 'tutor-search.php?event=td';
		document.frm.tId.value = tId;
		document.frm.submit();
	}  */
	function show_tip(tip, img){
		document.getElementById(tip).style.display = 'block';
		document.getElementById(img).src = 'images/help_on.gif';
	}
	
	function hide_tip(tip, img){
		document.getElementById(tip).style.display = 'none';
		document.getElementById(img).src = 'images/help_off.gif';
	}	
	
	function show_tip_text(tip, img){
		document.getElementById(tip).style.display = 'block';
		//document.getElementById(img).src = 'images/help_on.gif';
	}
	
	function hide_tip_text(tip, img){
		document.getElementById(tip).style.display = 'none';
		//document.getElementById(img).src = 'images/help_off.gif';
	}	
function MM_openBrWindow(theURL,winName,features)
{ //v2.0
	var newWin = window.open(theURL,winName,features);
	newWin.focus(); 
}
