int_obj = '';

function loadField(id) {

	if($(id)) {

		attachTooltip(id);
		Highlight(id);
		clearInterval(int_obj);
	}
}

//Baloon functions

function attachTooltip(elementId){
	if($(elementId)){
		Event.observe(elementId, 'focus', onfocusEle, false);
		Event.observe(elementId, 'blur', onblurEle, false);
		//	   Event.observe(elementId, 'mouseover', onfocusEle, false);
		//	   Event.observe(elementId, 'mouseout', onblurEle, false);
	}
};



//only for home page tool-tip

function onblurEle(e){
	var id = Event.element(e).id;
	$(id).className = "inputstyle" ;
	$("h-" + id).className = "field-hint-inactive" ;
};

function onfocusEle(e){

	if($(selected_field)) {
		$("h-" + selected_field).className = "field-hint-inactive" ;
		$(selected_field).className = "inputstyle" ;
	}
	var id = Event.element(e).id;
	$(id).className = "inputstyle-focus" ;
	$("h-" + id).className = "field-hint" ;
};

selected_field = '';

function Highlight(id){
	selected_field = id;
	$(id).focus();
};

clearField = function(eleM, compString){
	var fieldValue = eleM.value;
	if(fieldValue.toLowerCase() == compString.toLowerCase()){
		eleM.value = '';
	}
}

fillField = function(eleM, compString){
	var fieldValue = eleM.value;
	if(fieldValue.toLowerCase() == ''){
		eleM.value = compString;
	}
}
function displayAlert(msg_div,msg)
{
	
	if(msg) $(msg_div).innerHTML = msg;
	$(msg_div).className = 'errorDiv';
}
function selectCity(state){
	
	var schid = $('dispcityDiv').style.display;
	
	if(state==''){
			$('dispcityDiv').style.display = 'none';
		}
		
	if(schid!='none'){
		
		showAjaxloader(1,'ctDiv');
		$('school').disabled = true;
		$('city').disabled = true;
		var level = $F('videolevel');
		
		var url =  'advanceSearch.php';
		var pars = "state="+state+"&level="+level+"&mode=selectCity";
		
		//	displayAlert(msg);
		var myAjax = new Ajax.Request(
		url,
		{
			method: 'POST',
			parameters: pars,
			onComplete:showcity_Response
		});	
	}
	else{
		var level = $F('videolevel');
		
		if(state==''){
			
			$('dispcityDiv').style.display = 'none';
			$('selSchoolDiv').style.display = 'none';
		}
		else
		{
			
			//showAjaxloader(1,'scDiv');
			if(level==76){
				
				$('dispcityDiv').style.display = '';
				$('selSchoolDiv').style.display = '';
				showAjaxloader(1,'ctDiv');
				var url =  'advanceSearch.php';
				var pars = "state="+state+"&level="+level+"&mode=selectCity";
				
				//	displayAlert(msg);
				var myAjax = new Ajax.Request(
				url,
				{
					method: 'POST',
					parameters: pars,
					onComplete:showcity_Response
				});
				
			}
			else if(level==77){
				$('dispcityDiv').style.display = 'none';
				$('selSchoolDiv').style.display = '';
				
			$('school').style.display = '';
			$('school').disabled = true;
			var url =  'advanceSearch.php';
			var pars = "state="+state+"&mode=selectcollege";
			//	displayAlert(msg);
			var myAjax = new Ajax.Request(
			url,
			{
				method: 'POST',
				parameters: pars,
				onComplete:showcollege_Response
			});
			
			}
			else{
				
				$('selSchoolDiv').style.display = 'none';
				$('dispcityDiv').style.display = '';
				showAjaxloader(1,'ctDiv');
				var url =  'advanceSearch.php';
				var pars = "state="+state+"&level="+level+"&mode=selectCity";
			
				//	displayAlert(msg);
				var myAjax = new Ajax.Request(
				url,
				{
					method: 'POST',
					parameters: pars,
					onComplete:showcity_Response
				});
			}
			
		}
		
	}
	
	

}
function showcity_Response(originalRequest)
{
	
	response  = originalRequest.responseText;
	$('cityDiv').style.display = '';
	$('cityDiv').innerHTML = response;
	showAjaxloader(0,'ctDiv');
	//selectSchool('');
}
function showcollege_Response(originalRequest)
{
	
	response  = originalRequest.responseText;
	
	$('schoolDiv').innerHTML = response;
	showAjaxloader(0,'scDiv');
}
function selectSchool(city){
	showAjaxloader(1,'scDiv');
	var url =  'advanceSearch.php';
	var pars = 'city='+city+"&mode=selectSchool";
	//	displayAlert(msg);
	var myAjax = new Ajax.Request(
	url,
	{
		method: 'POST',
		parameters: pars,
		onComplete:showschool_Response
	});

}
function showschool_Response(originalRequest)
{
	response  = originalRequest.responseText;
	$('schoolDiv').innerHTML = response;
	showAjaxloader(0,'scDiv');
}
function doAdvanceSearch(){
	document.advSearch.submit();
}
/*
function doAdvanceSearch(){
	
	$('e_tag').style.display = 'none';
	if(alltrim($F('userName')) == '') {

		//$('e_user').innerHTML = "Username is blank!";
		$('e_tag').style.display = '';
		displayAlert('e_tag','Please enter a username or keyword(s) to search for videos.');
		//showLoader(0);
		return false;
	}
	else{
		document.advSearch.submit();
		return true;
	}
			
}
*/
function displaySchool(level){
	
	$('city').disabled=true;
	var country = $F('country');
	if(level==78){
		$('teamDiv').style.display = '';
		$('dispCountryDiv').style.display = 'none';
		$('dispstateDiv').style.display = 'none';
		$('dispcityDiv').style.display = 'none';
		$('selSchoolDiv').style.display = 'none';
		$('videoteam').disabled = false;
	}
	else if(country==209 && level==77){
		$('dispCountryDiv').style.display = '';
		$('dispstateDiv').style.display = '';
		var state  = $F('state');
		
		if(state==""){
			$('selSchoolDiv').style.display = 'none';
		}
		else{
			$('selSchoolDiv').style.display = '';
		}
		$('schoollebel').innerHTML = '';
		$('schoolDiv').innerHTML = '';
		$('schoollebel').innerHTML = "College:";
		$('schoolDiv').innerHTML = "<select class='medium' id='school' disabled><option>Select College</option></select>";
		//selectcollege();
		$('dispcityDiv').style.display = 'none';
		$('teamDiv').style.display = 'none';
		//$('selSchoolDiv').style.display = '';
		//$('teamDiv').style.display = 'none';
		//$('videoteam').disabled = true;
	}
	else if(country==209 && level==76){
		$('dispCountryDiv').style.display = '';
		$('dispstateDiv').style.display = '';
		var state  = $F('state');
		
		if(state==""){
			$('dispcityDiv').style.display = 'none';
		}
		else{
			$('dispcityDiv').style.display = '';
		}
		
		if(state==""){
			$('selSchoolDiv').style.display = 'none';
		}
		else{
			$('selSchoolDiv').style.display = '';
		}
		
		$('schoollebel').innerHTML = '';
		$('schoolDiv').innerHTML = '';
		$('schoollebel').innerHTML = "School:";
		$('schoolDiv').innerHTML = "<select name='school' id='school' class='medium' disabled><option>Select School</option></select>";
		$('teamDiv').style.display = 'none';
		//$('selSchoolDiv').style.display = '';
		//$('teamDiv').style.display = 'none';
		//$('videoteam').disabled = true;
	}
	else if(country==209 && level==74){
		$('dispCountryDiv').style.display = '';
		$('dispstateDiv').style.display = '';
		var state  = $F('state');
		if(state==""){
			$('dispcityDiv').style.display = 'none';
		}
		else{
			$('dispcityDiv').style.display = '';
		}
		$('selSchoolDiv').style.display = 'none';
		$('teamDiv').style.display = 'none';
		//$('selSchoolDiv').style.display = '';
		//$('teamDiv').style.display = 'none';
		$('videoteam').disabled = true;
	}
	else if(country==209 && level==75){
		$('dispCountryDiv').style.display = '';
		$('dispstateDiv').style.display = '';
		var state  = $F('state');
		if(state==""){
			$('dispcityDiv').style.display = 'none';
		}
		else{
			$('dispcityDiv').style.display = '';
		}
		$('selSchoolDiv').style.display = 'none';
		$('teamDiv').style.display = 'none';
		//$('selSchoolDiv').style.display = '';
		//$('teamDiv').style.display = 'none';
		$('videoteam').disabled = true;
	}
	/*
	else if(level==76){
		$('selSchoolDiv').style.display = '';
		$('teamDiv').style.display = 'none';
		$('videoteam').disabled = true;
	}
	
	else if(level==77 && country==209){
		$('selSchoolDiv').style.display = '';
		$('teamDiv').style.display = 'none';
		$('videoteam').disabled = true;
	}
	* */
	else{
		$('dispCountryDiv').style.display = '';
		$('selSchoolDiv').style.display = 'none';
		$('teamDiv').style.display = 'none';
		$('videoteam').disabled = true;
	}
	
	
}

function selectStateValue(countryName){
	var level = $F('videolevel');
	/*
	if(countryName=='209' && level!=77){
		$('dispstateDiv').style.display = '';
		$('dispcityDiv').style.display = '';
		$('selSchoolDiv').style.display = 'none';
		$('state').disabled=false;
	}
	else if(countryName=='209' && level!=76){
		
		$('dispstateDiv').style.display = '';
		$('dispcityDiv').style.display = '';
		$('selSchoolDiv').style.display = 'none';
		$('state').disabled=false;
	}
	*/
	if(countryName==209){
		
		if(level==77){
		$('schoollebel').innerHTML = "College:";
		$('schoolDiv').innerHTML = "<select class='medium' id='school' disabled><option>Select College</option></select>";
		//selectcollege();
			$('dispstateDiv').style.display = '';
			$('dispcityDiv').style.display = 'none';
			$('selSchoolDiv').style.display = '';
			$('state').disabled=false;
		}
		else if(level==76){
		$('schoollebel').innerHTML = "School:";
		$('schoolDiv').innerHTML = "<select name='school' id='school' class='medium' disabled><option>Select School</option></select>";
			$('dispstateDiv').style.display = '';
			$('dispcityDiv').style.display = 'none';
			$('selSchoolDiv').style.display = 'none';
			$('state').disabled=false;
		}
		else{
			$('dispstateDiv').style.display = '';
			$('dispcityDiv').style.display = 'none';
			$('selSchoolDiv').style.display = 'none';
			$('state').disabled=false;
		}
	}
	else{
		$('dispstateDiv').style.display = 'none';
		$('dispcityDiv').style.display = 'none';
		$('selSchoolDiv').style.display = 'none';
		$('state').disabled=true;
	}
}
/*
function selectcollege(){

	var url =  'advanceSearch.php';
	var pars = "mode=selectcollege";
	//	displayAlert(msg);
	var myAjax = new Ajax.Request(
	url,
	{
		method: 'POST',
		parameters: pars,
		onComplete:showcollege_Response
	});

}
function showcollege_Response(originalRequest)
{
	response  = originalRequest.responseText;
	$('schoolDiv').innerHTML = response;
}
*/
