// JavaScript Document
/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"

}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

function fnClickDiv(){		
	document.getElementById('specialism_year_group').style.display="block";
	//document.getElementById('year_group_con').innerHTML="BAlaguru";
}
function fnCloseDiv(){
	document.getElementById('specialism_year_group').style.display="none";
}

function fnChangeText_search(obj,selVal){
	var display_text="";
	if(document.addsearchFrm.year_group.value=='Select Year Groups / Specialisms'){
		document.addsearchFrm.year_group.value = '';
	}
	
	var val=0;	
	if(document.addsearchFrm.elements['age_group[]'].length >0){
		for(iC=0;iC < document.addsearchFrm.elements['age_group[]'].length; iC++){
				if(document.addsearchFrm.elements['age_group[]'][iC].checked==true){
					val++;		
				}			
		}		
	} 
	
	if(val==0){	
		document.addsearchFrm.year_group.value='Select Year Groups / Specialisms';
	}else{
		document.addsearchFrm.year_group.value=val+' options selected';
	}	

}


//************************************** Add Search Area Functions *******************************************************************


function fnChangeText(obj,selVal){
	var display_text="";
	if(document.searchfrm.year_group.value=='Select Year Groups / Specialisms'){
		document.searchfrm.year_group.value = '';
	}
	
	var val=0;	
	if(document.searchfrm.elements['age_group[]'].length >0){
		for(iC=0;iC < document.searchfrm.elements['age_group[]'].length; iC++){
				if(document.searchfrm.elements['age_group[]'][iC].checked==true){
					val++;		
				}			
		}		
	} 
	
	if(val==0){	
		document.searchfrm.year_group.value='Select Year Groups / Specialisms';
	}else{
		document.searchfrm.year_group.value=val+' options selected';
	}	

}

function fnChangeText_client(obj,selVal){
	var display_text="";
	if(document.thisform_job_post.year_group.value=='Select Year Groups / Specialisms'){
		document.thisform_job_post.year_group.value = '';
	}
	
	var val=0;	
	if(document.thisform_job_post.elements['age_group[]'].length >0){
		for(iC=0;iC < document.thisform_job_post.elements['age_group[]'].length; iC++){
				if(document.thisform_job_post.elements['age_group[]'][iC].checked==true){
					val++;		
				}			
		}		
	} 
	
	if(val==0){	
		document.thisform_job_post.year_group.value='Select Year Groups / Specialisms';
	}else{
		document.thisform_job_post.year_group.value=val+' options selected';
	}	

}

function fnClickDiv_search(){
	document.getElementById('specialism_year_group_search').style.display="block";
	//document.getElementById('year_group_con').innerHTML="BAlaguru";
}
function fnCloseDiv_search(){
	document.getElementById('specialism_year_group_search').style.display="none";
}

function send_ajax_request_load_work_place(url){
	var response="", new_url="";
	var params ='&date='+(new Date().getTime());
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){		
		if (xmlhttp1.readyState==4){
		//if (xmlhttp.readyState==4 && xmlhttp.status==200){
			response=xmlhttp1.responseText;								
			document.searchfrm.workplace.options.length = 0; 			
			newOption1 = document.createElement("OPTION");					
			document.searchfrm.workplace.options.add(newOption1);
			newOption1.text = "All Workplaces";
			newOption1.value = "-1";
			if(response!=""){
				string1=response.split("|");
				for ( var i = 0; i < string1.length - 1; i++) {						
					string2 = string1[i].split("~");						
					newOption = document.createElement("OPTION");					
					document.searchfrm.workplace.options.add(newOption);
					newOption.text = string2[1];
					newOption.value = string2[0];				
				}						
			}
			if(document.searchfrm.category.value!='8'){
				document.getElementById("year_group_con").innerHTML='';								
			}
			
		}
	}
	new_url =url+""+params;
	xmlhttp1.open("GET",new_url,true);
	xmlhttp1.send();
}

function send_ajax_request_load_specialism(param_url){
	var response="",new_url="",table="";
	
	cmbval=document.searchfrm.workplace.value;
	url="ajax_common.php?id="+document.searchfrm.category.value+"&workid="+cmbval+"&table="+table+"&action=fill_specialism";
	//alert(url);
	
	var params ='&date='+(new Date().getTime());
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			response=xmlhttp.responseText;
			//alert(response);
			//document.getElementById("age_group_com").innerHTML = response;
			/*$(function(){
				//$("#age_group").multiselect();
				$("select").multiselect("setOption");
				setOption(function(){
					alert("Here");
					document.searchfrm.age_group.options.length = 0; 			
					newOption1 = document.createElement("OPTION");					
					document.searchfrm.age_group.options.add(newOption1);
					newOption1.text = "All Age Group";
					newOption1.value = "-1";
					if(response!=""){
						string1=response.split("|");
						for ( var i = 0; i < string1.length - 1; i++) {						
							string2 = string1[i].split("~");						
							newOption = document.createElement("OPTION");					
							document.searchfrm.age_group.options.add(newOption);
							newOption.text = string2[1];
							newOption.value = string2[0];				
						}
					}
				});
			});*/
			if(response!=''){
				document.getElementById("year_group_con").innerHTML = response;
				//document.getElementById("change_age_group").innerHTML = response;
			}
			if(response==''){
				document.getElementById("year_group_con").innerHTML='';				
			}
		}
	}
	new_url = param_url+url+""+params;	
	
	xmlhttp.open("GET",new_url,true);
	xmlhttp.send();	
	
}
function fnClickDiv_client(){
	document.getElementById('specialism_year_group_client').style.display="block";
	//document.getElementById('year_group_con').innerHTML="BAlaguru";
}
function fnCloseDiv_client(){
	document.getElementById('specialism_year_group_client').style.display="none";
}
function send_ajax_request_load_specialism_client(param_url){
	var response="",new_url="",table="";
	
	cmbval=document.thisform_job_post.workplace.value;
	url="ajax_common.php?id="+document.thisform_job_post.category.value+"&workid="+cmbval+"&table="+table+"&action=fill_specialism_client";
	//alert(url);
	
	var params ='&date='+(new Date().getTime());
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp4=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp4=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp4.onreadystatechange=function(){
		if (xmlhttp4.readyState==4 && xmlhttp4.status==200){
			response=xmlhttp4.responseText;
			//alert(response);
			if(response!=''){
				document.getElementById("year_group_con_client").innerHTML = response;
				//document.getElementById("change_age_group").innerHTML = response;
			}
			if(response==''){
				document.getElementById("year_group_con_client").innerHTML='';				
			}			
		}
	}
	new_url = param_url+url+""+params;	
	
	xmlhttp4.open("GET",new_url,true);
	xmlhttp4.send();		
}

function send_ajax_request_load_work_place_search(url){
	var response="", new_url="";
	var params ='&date='+(new Date().getTime());
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttpsrch=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttpsrch=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttpsrch.onreadystatechange=function(){		
		if (xmlhttpsrch.readyState==4){
		//if (xmlhttp.readyState==4 && xmlhttp.status==200){
			response=xmlhttpsrch.responseText;								
			document.addsearchFrm.workplace.options.length = 0; 			
			newOption1 = document.createElement("OPTION");					
			document.addsearchFrm.workplace.options.add(newOption1);
			newOption1.text = "All Workplaces";
			newOption1.value = "-1";
			if(response!=""){
				string1=response.split("|");
				for ( var i = 0; i < string1.length - 1; i++) {						
					string2 = string1[i].split("~");						
					newOption = document.createElement("OPTION");					
					document.addsearchFrm.workplace.options.add(newOption);
					newOption.text = string2[1];
					newOption.value = string2[0];				
				}						
			}
			if(document.addsearchFrm.category.value!='8'){
				document.getElementById("year_group_con_search").innerHTML='';								
			}
			
		}
	}
	new_url = url+""+params;
	xmlhttpsrch.open("GET",new_url,true);
	xmlhttpsrch.send();
}

function send_ajax_request_load_specialism_search(param_url){
	var response="",new_url="",table="";
	
	cmbval=document.addsearchFrm.workplace.value;
	url="ajax_common.php?id="+document.addsearchFrm.category.value+"&workid="+cmbval+"&table="+table+"&action=fill_specialism_search";
	//alert(url);
	
	var params ='&date='+(new Date().getTime());
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttpsrch1=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttpsrch1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttpsrch1.onreadystatechange=function(){
		if (xmlhttpsrch1.readyState==4 && xmlhttpsrch1.status==200){
			response=xmlhttpsrch1.responseText;
			//alert(response);
			if(response!=''){
				document.getElementById("year_group_con_search").innerHTML = response;
				//document.getElementById("change_age_group").innerHTML = response;
			}
			if(response==''){
				document.getElementById("year_group_con_search").innerHTML='';				
			}			
		}
	}
	new_url =param_url+url+""+params;		
	xmlhttpsrch1.open("GET",new_url,true);
	xmlhttpsrch1.send();	
	
}


function send_ajax_request_load_work_place_client(url){
	var response="", new_url="";
	var params ='&date='+(new Date().getTime());
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp3=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp3=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp3.onreadystatechange=function(){		
		if (xmlhttp3.readyState==4){
		//if (xmlhttp.readyState==4 && xmlhttp.status==200){
			response=xmlhttp3.responseText;								
			document.thisform_job_post.workplace.options.length = 0; 			
			newOption1 = document.createElement("OPTION");					
			document.thisform_job_post.workplace.options.add(newOption1);
			newOption1.text = "All Workplaces";
			newOption1.value = "-1";
			if(response!=""){
				string1=response.split("|");
				for ( var i = 0; i < string1.length - 1; i++) {						
					string2 = string1[i].split("~");						
					newOption = document.createElement("OPTION");					
					document.thisform_job_post.workplace.options.add(newOption);
					newOption.text = string2[1];
					newOption.value = string2[0];				
				}						
			}
			if(document.thisform_job_post.category.value!='8'){
				document.getElementById("year_group_con_client").innerHTML='';								
			}
			
		}
	}
	new_url = url+""+params;
	xmlhttp3.open("GET",new_url,true);
	xmlhttp3.send();
}

/*Balaguru Works starts here */
function fn_load_work_place(arg,table,rootpath){
	if(arg.value=="8"){
		document.getElementById("year_specialism").style.display='block';
	}else{
		document.getElementById("year_specialism").style.display='none';
		if(document.getElementById("specialism_year_group").style.display=="block"){
			$("#specialism_year_group").slideToggle("slow");
		}
	}
	var return_response="",url="";
	cmbval=arg.value;
	url="ajax_common.php?id="+cmbval+"&workid=&table="+table+"&action=fill_dropdown";
	//alert(url);
	var newURL;
	newURL = window.location.protocol + "//" + window.location.host;
	rootpath=newURL+"/";
	
	send_ajax_request_load_work_place(rootpath+url);
	url="";
	url="ajax_common.php?id="+cmbval+"&workid=&table="+table+"&action=fill_specialism";
	send_ajax_request_load_specialism(rootpath+url);			
}

function fn_load_specialism(arg,table,rootpath){
	cmbval=arg.value;
	if((document.searchfrm.category.value=="1")&&((arg.value=="2")||(arg.value=="3"))){
		document.getElementById("year_specialism").style.display='block';
	}else{
		document.getElementById("year_specialism").style.display='none';
		if(document.getElementById("specialism_year_group").style.display=="block"){
			$("#specialism_year_group").slideToggle("slow");
		}
	}
	
	if((document.searchfrm.category.value=="8")&&((arg.value!=""))){
		document.getElementById("year_specialism").style.display='block';
	}
		
	if((cmbval==3)||(cmbval==4)){
		cmbval = '';
	}
	//alert(cmbval);
	 //url="ajax_common.php?id="+cmbval+"&table="+table+"&action=fill_specialism";	
		url="ajax_common.php?id="+document.searchfrm.category.value+"&workid="+cmbval+"&table="+table+"&action=fill_specialism";
	//alert(url);
	var newURL;
	newURL = window.location.protocol + "//" + window.location.host;
	rootpath=newURL+"/";

	send_ajax_request_load_specialism(rootpath);
}


//************************************** Client Area Functions *******************************************************************

function fn_load_work_place_client(arg,table,rootpath){
	var return_response="",url="";
	cmbval=arg.value;
	url="ajax_common.php?id="+cmbval+"&workid=&table="+table+"&action=fill_dropdown";
	//alert(url);
	
	var newURL;
	newURL = window.location.protocol + "//" + window.location.host;
	rootpath=newURL+"/";

	
	
	send_ajax_request_load_work_place_client(rootpath+url);
	url="";
	url="ajax_common.php?id="+cmbval+"&workid=&table="+table+"&action=fill_specialism";
	
	
	
	send_ajax_request_load_specialism_client(rootpath);			
}


function fn_load_specialism_client(arg,table,rootpath){
	cmbval=arg.value;
	if((cmbval==3)||(cmbval==4)){
		cmbval = '';
	}
	//alert(cmbval);
	 //url="ajax_common.php?id="+cmbval+"&table="+table+"&action=fill_specialism";	
		url="ajax_common.php?id="+document.thisform_job_post.category.value+"&workid="+cmbval+"&table="+table+"&action=fill_specialism_client";
	//alert(url);
	
	var newURL;
	newURL = window.location.protocol + "//" + window.location.host;
	rootpath=newURL+"/";

	
	send_ajax_request_load_specialism_client(rootpath);
}
//************************************** Client Area Functions *******************************************************************

//************************************** Add Search Area Functions *******************************************************************

function fn_load_work_place_search(arg,table,rootpath){
	var return_response="",url="";
	cmbval=arg.value;
	url="ajax_common.php?id="+cmbval+"&workid=&table="+table+"&action=fill_dropdown";
	document.addsearchFrm.year_group.value='Select Year Groups / Specialisms';
	//alert(url);
	
	
	var newURL;
	newURL = window.location.protocol + "//" + window.location.host;
	rootpath=newURL+"/";

	
	send_ajax_request_load_work_place_search(rootpath+url);
	url="";
	url="ajax_common.php?id="+cmbval+"&workid=&table="+table+"&action=fill_specialism";
	send_ajax_request_load_specialism_search(rootpath);			
}

function fn_load_specialism_search(arg,table,rootpath){
	cmbval=arg.value;
	if((cmbval==3)||(cmbval==4)){
		cmbval = '';
	}
	
	var newURL;
	newURL = window.location.protocol + "//" + window.location.host;
	rootpath=newURL+"/";

	
	//alert(cmbval);
	 //url="ajax_common.php?id="+cmbval+"&table="+table+"&action=fill_specialism";	
		url="ajax_common.php?id="+document.addsearchFrm.category.value+"&workid="+cmbval+"&table="+table+"&action=fill_specialism_search";
	//alert(url);
	
	send_ajax_request_load_specialism_search(rootpath);
}

function fn_early_years_professional_yes(){
	
	fnshow_next_permission_qualification();
	
	if(document.getElementById("rj_early_year_profession_status")){
		document.getElementById("rj_early_year_profession_status").style.display="none";
	}
	
	document.getElementById('txt_early_year_profession_status').value="Y";	
	document.getElementById('div_early_year_profession_status').innerHTML="You have chosen Yes";
	document.getElementById('option_qualification').style.display="block";

	
		
	
}

function fn_early_years_professional_no(){
	
	document.getElementById('txt_early_year_profession_status').value="N";	
	document.getElementById('div_early_year_profession_status').innerHTML="You have chosen No";
	document.getElementById('option_qualification').style.display="none";
	
	if(document.getElementById("rj_early_year_profession_status")){
		document.getElementById("rj_early_year_profession_status").style.display="block";
	}
}

function fnshow_not_interested_early_year(){

	if(document.getElementById("rj_not_interested_early_year")){
		document.getElementById("rj_not_interested_early_year").style.display="block";
	}
	
	if(document.getElementById("option_qualification")){
		document.getElementById("option_qualification").style.display="none";
	}
	
	if(document.getElementById("option_nursary_nurse")){
		document.getElementById("option_nursary_nurse").style.display="none";
	}
	if(document.getElementById("option_education_support")){
		document.getElementById("option_education_support").style.display="none";
	}
	
	if(document.getElementById("option_country_training")){
		document.getElementById("option_country_training").style.display="none";
	}
	
	if(document.getElementById("div_button_next2")){
		document.getElementById("div_button_next2").style.display="none";
	}
	
	
	
}
