



function showOnlineOptions4(par,field) {
	if ((par == 1) || (par == 2)) {
        showField(field);
    } else {
        hideField(field);
    }
}

function showField(par) {
	document.getElementById(par).style.visibility = "visible";
}

function hideField(par) {
	document.getElementById(par).style.visibility = "hidden";
}

function displayBlock(par) {
	document.getElementById(par).style.display = "block";
}

function displayNone(par) {
	document.getElementById(par).style.display = "none";
}

function clearField(par) {
    document.getElementById(par).value = "";
}

/*===========================================================
Show Region Index
=============================================================*/
function defineregion(){
	var oCountry = document.getElementById("country");
	var oRegion = document.getElementById("region");
    var oLocation = document.getElementById("location");
    if (oCountry.options[oCountry.selectedIndex].value=='United Kingdom') {
		oRegion.style.display = "block";
    } else {
		oRegion.style.display = "none";
        oLocation.selectedIndex = 0;
    }
}

/*===========================================================
Show Other Discipline
=============================================================*/
function defineDisciplineText() {
    var oDiscipline = document.getElementById("disciplineopt");
	var dDisciplineText = document.getElementById("disciplinetext");
    var iDisciplineText = document.getElementById("idisciplinetext");
    if (oDiscipline.options[oDiscipline.selectedIndex].text == 'Other') {
		dDisciplineText.style.display = "block";
    } else {
        dDisciplineText.style.display = "none";
        iDisciplineText.value = "";
    }
}
	
/*===========================================================
Show Region
=============================================================*/
function define(){
	var oCountryOpt = document.getElementById("icountryopt");
	var oCountyOpt = document.getElementById("icountyopt");
	var oBoroughOpt = document.getElementById("iboroughopt");

	var oCounty = document.getElementById("icounty");
	var oBorough = document.getElementById("iborough");
    var i, j, k;

    if (oCountryOpt.selectedIndex != '-1') {
        for (i = 0; i < oCountryOpt.options.length; i++) {
            if (oCountryOpt.options[i].selected && oCountryOpt.options[i].text == 'United Kingdom') {
                oCounty.style.display = "block";

                for (j = 0; j < oCountyOpt.options.length; j++) {
                    if (oCountyOpt.options[j].selected && oCountyOpt.options[j].text == 'London') {
                        oBorough.style.display = "block";
                        break;
                    }
                }
                if (j == oCountyOpt.options.length) {
                    oBorough.style.display = "none";
                    for (k = 0; k < oBoroughOpt.options.length; k++) {
                        if (oBoroughOpt.options[k].selected) {
                            oBoroughOpt.options[k].selected = false;
                        }
                    }
                }
                break;
            }
        }
        if (i == oCountryOpt.options.length) {
            oCounty.style.display = "none";
            for (k = 0; k < oCountyOpt.options.length; k++) {
                if (oCountyOpt.options[k].selected) {
                    oCountyOpt.options[k].selected = false;
                }
            }

            oBorough.style.display = "none";
            for (k = 0; k < oBoroughOpt.options.length; k++) {
                if (oBoroughOpt.options[k].selected) {
                    oBoroughOpt.options[k].selected = false;
                }
            }
        }
    } else {
        oCounty.style.display = "none";
        oBorough.style.display = "none";
    }
}

/*===========================================================
Show qualification
=============================================================*/
function defineQualification() {
    var oQualificationOpt = document.getElementById("iqualificationopt");
    var oQualificationText = document.getElementById("iqualificationtext");
    var oQualificationTextArea = document.getElementById("iqualificationtextarea");

    if (oQualificationOpt.selectedIndex != '-1'
            && oQualificationOpt.options[oQualificationOpt.selectedIndex].text == 'Other') {
        oQualificationText.style.display = "block";
    } else {
        oQualificationText.style.display = "none";
        oQualificationTextArea.value = "";
    }
}


/*===========================================================
Show language
=============================================================*/
var langIndex = 2;

function showLanguage() {
    document.getElementById('langMenu' + langIndex).style.display = 'block';
    if (langIndex < 5) {
        langIndex++;
    }
}

/*===========================================================
Choose Subject on Sector
=============================================================*/

var aValues = new Array(
"Please Select..." ,
"All Keystages;No classroom Commitment;Kindergarten/Pre-school/Nursery;Early years/ Foundation;Reception;Year/grade 1;Year/grade 2;Year/grade 3;Year/grade 4;Year/grade 5;Year/grade 6;Year 8 Elementary;TEFL;All year groups",
"All Keystages;No classroom Commitment;Year/grade 7;Year/grade 8",
"All Keystages;No classroom Commitment;English;Media Studies;Maths;Science Biology;Science Chemistry;Science Physics;Science Combined;Art;DT Electronics;DT Food Technology;DT Textiles;DT Metal;DT Resistant Materials;DT Wood;MFL French;MFL German;MFL Spanish;MFL Other;Geography;History;RE;Citizenship;PE (Male);PE (Female);PSHE;Music;ICT;Business Studies;Economics;Drama;Dance/Performing Arts;Psychology;Sociology;Other;Graphics;TEFL",
"All Keystages;No classroom Commitment;ADD;ADHD;ASD;ASP;BESD;CB;CP;DOW;DYC;DYP;DYS;EPI;HEA;HI;IM;MLD;PMLD;SLD;SP&amp;LD;TOU;VI;WU;Various",
"All Keystages;No classroom Commitment;Accountancy;Administration;Aeronautics;Agriculture;Animal Care;Arboriculture;Archaeology;Architecture, Housing and Planning;Art;Art History;Automobile Engineering/Vehicle Service and Repair;Banking;Beauty and Hairdressing;Bookkeeping;Bricklaying;Building Maintenance;CAD;Car Maintenance;Caring;Carpentry;Catering;Ceramics;Childcare;Civil Engineering;Clerical and Office Studies;Communication Skills;Complementary/Holistic Therapies;Computers;Conservation;Construction/Building Crafts;Cooking;Counselling Skills;Countryside Management;Crafts;Dance;Decoration and Design;Dentistry and Dental Technology;Design/CAD;Desktop Publishing/Graphic Design;DIY;Drama;Dressmaking;DTP;Education;EFL/ESOL/ESL;Electrical;Electronics;Embroidery;Engineering;English as a Foreign or Second Language;Environmental Studies;Equine Science;Estate Management;European/International Studies;Facilities Management;Fashion;Finance;Fine Art;First Aid and Safety;Floristry;Food Technology;Foreign Languages;Forestry and Arboriculture;Furniture;Gardening;Geology;Government and Politics;Graphic Design;Hairdressing;Health and Care;Heritage Studies/Management;Holistic Therapies;Home Economics;Horticulture and Gardening;Hospitality;Hotel Management;Housing and Publishing;Human Resources;Hydraulics;Information Technology;Institutional Management;Insurance;Interior Decoration and Design;International Studies;IT;Joinery;Journalism;Land Management;Landscape and Garden Design;Languages;Law;Legal Studies;Leisure and Tourism;Librarianship;Maintenance;Management;Manufacturing;Maritime Operations and Studies;Marketing;Mechanical Engineering ;Media Studies;Medical Physics;Metrology;Motor Vehicle Studies;Multimedia Arts;Music;Naval Studies;Oenology;Office Studies;Performing Arts;Personnel/Human Resources;Photography;Physical Education;Planning;Pneumatics;Police Work;Politics;Pottery and Ceramics;Printing and Publishing;Programming;Project Management;Property Investment;Public/Uniformed Services;Publishing;Quality Assurance and Control;Receptionists;Recreation Studies;Repair and Maintenance;Restoration;Retail;Robotics;Safety;Secretarial/Administration;Services;Sports Studies;Stage Management/Technical Theatre/Directing/Design;Supervisory Management;Surveying;Teacher Training;Textiles;Theatre;Therapy;Tourism;Trade Union Studies;Training;Transport Studies;Travel;Uniformed Services;Vehicle Studies;Veterinary Studies/Animal Care;Viticulture;Welding;Wine Production;Woodworking;Word Processing",
"All Keystages;No classroom Commitment;NNEB;BTEC Diploma;Cache;NVQ 3;Montessori;Other",
"",
"");

function getValuesBySelect(index){
    var sValues = aValues[index];
    if (sValues.length==0) {
        return new Array();
    } else {
        return sValues.split(";");
    }
}

function MkValues(index, selectedSubj){
	if(index!=0) {
		var aCurrValues = getValuesBySelect(index);
	    var nCurrValuesCnt = aCurrValues.length;
	    var oList = document.getElementById("iSubjectOpt");
	    var oListOptionsCnt = oList.options.length;

		oList.length = 0;
		
	    for (i = 0; i < nCurrValuesCnt; i++){
	        if (document.createElement){
	            var newListOption = document.createElement("OPTION");
				
	            newListOption.text = aCurrValues[i];
	            newListOption.value = aCurrValues[i];

	            (oList.options.add) ? oList.options.add(newListOption) : oList.add(newListOption, null);
				
				if (selectedSubj == aCurrValues[i]) {
	                newListOption.selected = true;
	            }
	        }
	    }
		if (document.getElementById("iSubjectDiv") && nCurrValuesCnt > 0) {
			document.getElementById("iSubjectDiv").style.display = "block";
		} else
		if (document.getElementById("iSubjectDiv") && nCurrValuesCnt <= 0) {
			document.getElementById("iSubjectDiv").style.display = "none";
		}
	} else if(index==0) {
		if(document.getElementById("iSubjectDiv")) {
			document.getElementById("iSubjectDiv").style.display = "none";
		}
}
}

/*===========================================================
Choose Discipline on Sector
=============================================================*/
function showValues(par) {
	if (par == "Primary") {
		displayBlock('iYear'); displayNone('iSubject'); displayNone('iSpecialNeeds');
	} else if (par == "Secondary") {
		displayBlock('iSubject'); displayNone('iYear'); displayNone('iSpecialNeeds');
	} else if (par == "Special Education Needs") {
		displayBlock('iSpecialNeeds'); displayNone('iYear'); displayNone('iSubject');
	} else {
		displayNone('iYear'); displayNone('iSubject'); displayNone('iSpecialNeeds');
	}
}

/*===========================================================
Show Contract Length field
=============================================================*/
function typeLength(par) {
	if(par.selectedIndex == 1) showField('iContractLength')
	else hideField('iContractLength');
}

/*===========================================================
Choose Apply Online Options & Format
=============================================================*/
function detectOnline() {
	if(document.forms["post_job"].elements["applyOnline"]) {
		var oRadioElements = document.forms["post_job"].elements["applyOnline"];
		if(oRadioElements.checked!=false){
			if(oRadioElements[0].checked!=false) displayBlock('iApplyOnline');
			if(oRadioElements[1].checked!=false) displayNone('iApplyOnline');
		}else{
			displayNone('iApplyOnline');
		}
	}
}

function showOnlineOptions(par,field) {
	if(par==1) showField(field)
	else hideField(field)
}

function showOnlineOptions2() {
	if(document.forms["post_job"].elements["autoResponse"] && document.forms["post_job"].elements["responseFormat"]) {
		var oResponseOptions = document.forms["post_job"].elements["autoResponse"];
		var oResponseFormat = document.forms["post_job"].elements["responseFormat"];

		if(oResponseOptions.selectedIndex==1) showField('iListOptions');
		else hideField('iListOptions');
		
		if(oResponseFormat.selectedIndex==1) showField('iListQuestions');
		else hideField('iListQuestions');
	}
}
function loadOnline() {
	detectOnline();
	showOnlineOptions2();
}

/*===========================================================
Show OFCCP Information
=============================================================*/
function detectTracking(par) {
	var obj = document.getElementById(par);
	if(obj) {
		if(obj.checked!=false){
			displayBlock('iOFCCP');
		}else{
			displayNone('iOFCCP');
		}
	}
}

/*===========================================================
Converter 
=============================================================*/
function convertSalary(){
	var oSrc=document.getElementById("isalary");
	var oDest=document.getElementById("iresult");
	oDest.innerHTML=format(oSrc.value);
	oSrc.focus();
}

function format(value){
	var currentValue, intPart, floatPart, arr;

	intPart=floatPart='';
	currentValue = value;
	re = /[^0-9\.]/gi;
	currentValue = parseFloat(currentValue.replace(re, ""))*2080;
	
	re = /(\d{1,})\.(\d{1,})/ig;
	arr = re.exec(currentValue);
	if (RegExp.$1&&RegExp.$2){
		intPart=RegExp.$1;
		floatPart=RegExp.$2;
	}else{
		re = /(\d{1,})/ig;
		arr = re.exec(currentValue);
		intPart=RegExp.$1;
	}

	result='';
	j=0;
	for (var i=intPart.length-1; i>=0; i--){
		j++;
		result=intPart.charAt(i) + result;
		
		if(((j/3)==Math.ceil(j/3))&&(i!=0)){
			result = ","+result;	
		}
	}
	
	if(floatPart){
		currentValue=result + "." + floatPart;
	}else{
		currentValue=result;
	}

	return currentValue;
}

var pressed=false;

function validate(box){
	if(pressed){
		var texttyped=1;
		var MaxLen = 15;
		var inputStr = box.value;
		var strlength= inputStr.length;
		if (strlength > MaxLen ){
			box.value=inputStr.substring(0,MaxLen);
		}
		if (!isIntegerCorrect(box.value)){
			if(box.value.length!=0){
				box.value=inputStr.substring(0,box.value.length-1);
			}
		}
    }
    pressed=false;
}

function remove(box){
	if(!pressed){
		pressed=true;
	}
}

function isIntegerCorrect(data) {
	var numStr="0123456789.";
	var thisChar;
	var counter = 0;
	
	for (var i=0; i < data.length; i++) {
		thisChar = data.substring(i, i+1);
		
		if (numStr.indexOf(thisChar) != -1)
		counter++ ;
	}
	
	if (counter != data.length) {
		return false ;
	}
	return true ;
}

/*===========================================================
Do Blink for new message
=============================================================*/
function doblink() {
    for (var i = 0; i < document.all.length; i++) {
        if (document.all[i].className == "Blink") {
            if ((document.all[i].style.visibility == "visible") ||
(document.all[i].style.visibility == "")) {
                document.all[i].style.visibility = "hidden";
            }
            else {
                document.all[i].style.visibility = "visible";
            }
        }
    }
}
function loadDoBlink(){
	setInterval('doblink()', 300);
}







