function initTinyMCE(){
	
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		plugins : "ibrowser,paste" ,
		editor_selector : "mceEditor",
		theme_advanced_buttons1_add : "ibrowser",
		//theme_advanced_path_location : "bottom",
		document_base_url : "http://www.cadjobs.nl/",
		//convert_urls : true,
		relative_urls : false,
		remove_script_host : false,
		content_css : "/templates/images/tinymce.css",
		cleanup : false
	});
}

function doShowHide(rowname) { 

	if(document.getElementById(rowname).style.display=='none'){
		document.getElementById(rowname).style.display = "";
	} else {
		document.getElementById(rowname).style.display = "none";
	}

}

function doCollapse(rowname) { 
	document.getElementById(rowname).style.display = 'none' ;
	//rowname.style.display = 'none' ;
}

function doExpand(rowname) { 
	document.getElementById(rowname).style.display = '' ;
	//rowname.style.display = '' ;
}






var isExistingCompany = false;

function searchform_check(){
	if(document.forms[0].keepinformed.checked==true && document.forms[0].sEmail.value == ""){
		alert('Als u op de hoogte wilt worden gehouden, vul a.u.b. ook een email adres in.');
		return false;	
	} else {
		return true;
	}
	
}


function checkAll(field){
	for (i = 0; i < field.length; i++)
		field[i].checked = true ;
}

function uncheckAll(field){
	for (i = 0; i < field.length; i++)
		field[i].checked = false ;
}

function PopUpCv(PersonId) {
	URL = 'CvDetailController.php?iPersonId=' + PersonId;
	var load = window.open(URL,'','scrollbars=yes,menubar=no,height=300,width=500,resizable=yes,toolbar=no,location=no,status=no');
	if (window.focus) {load.focus()}
}

function PopUpPrintProfile(iPkPrintId) {
	URL = 'ProfileListController.php?iPkPrintId=' + iPkPrintId; 
	var load = window.open(URL,'','scrollbars=yes,menubar=no,height=600,width=790,left=100,top=100,resizable=yes,toolbar=no,location=no,status=no');
	if (window.focus) {load.focus()}
}

function PopUpPrintVacancy(iPkPrintId) {
	URL = 'VacancyListController.php?iPkPrintId=' + iPkPrintId;
	var load = window.open(URL,'','scrollbars=yes,menubar=no,height=600,width=790,left=100,top=100,resizable=yes,toolbar=no,location=no,status=no');
	if (window.focus) {load.focus()}
}

function resetCompany(selectedOption){
	if(selectedOption.selectedIndex == 00){
		document.forms[0].sCompanyName.disabled = false;
		document.forms[0].sContactPerson.disabled = false;
		document.forms[0].sContactPerson2.disabled = false;
		document.forms[0].sContactPerson2Email.disabled = false;	
		document.forms[0].sContactPerson2Telephone.disabled = false;	
		document.forms[0].sContactTelephone.disabled = false;
		document.forms[0].sEmail.disabled = false;
		document.forms[0].sUrl.disabled = false;
		document.forms[0].sAddress.disabled = false;
		document.forms[0].sZipcode.disabled = false;
		document.forms[0].sCity.disabled = false;
		document.forms[0].sPostAddress.disabled = false;
		document.forms[0].sPostZipcode.disabled = false;
		document.forms[0].sPostCity.disabled = false;
		document.forms[0].sCompanyTelephone.disabled = false;
		
		document.forms[0].sCompanyName.className = 'textinput';
		document.forms[0].sContactPerson.className = 'textinput';
		document.forms[0].sContactPerson2.className = 'textinput';
		document.forms[0].sContactPerson2Email.className = 'textinput';
		document.forms[0].sContactPerson2Telephone.className = 'textinput';
		document.forms[0].sContactTelephone.className = 'textinput';
		document.forms[0].sEmail.className = 'textinput';
		document.forms[0].sUrl.className = 'textinput';
		document.forms[0].sAddress.className = 'textinput';
		document.forms[0].sZipcode.className = 'textinput';
		document.forms[0].sCity.className = 'textinput';
		document.forms[0].sPostAddress.className = 'textinput';
		document.forms[0].sPostZipcode.className = 'textinput';
		document.forms[0].sPostCity.className ='textinput';
		document.forms[0].sCompanyTelephone.className = 'textinput';
	} else {
		document.forms[0].sCompanyName.disabled = true;			
		document.forms[0].sContactPerson.disabled = true;
		document.forms[0].sContactPerson2.disabled = true;
		document.forms[0].sContactPerson2Email.disabled = true;
		document.forms[0].sContactPerson2Telephone.disabled = true;
		document.forms[0].sContactTelephone.disabled = true;
		document.forms[0].sEmail.disabled = true;
		document.forms[0].sUrl.disabled = true;
		document.forms[0].sAddress.disabled = true;
		document.forms[0].sZipcode.disabled = true;
		document.forms[0].sCity.disabled = true;
		document.forms[0].sPostAddress.disabled = true;
		document.forms[0].sPostZipcode.disabled = true;
		document.forms[0].sPostCity.disabled = true;
		document.forms[0].sCompanyTelephone.disabled = true;
		
		document.forms[0].sCompanyName.className = 'textinput_off';
		document.forms[0].sContactPerson.className = 'textinput_off';
		document.forms[0].sContactPerson2.className = 'textinput_off';
		document.forms[0].sContactPerson2Email.className = 'textinput_off';
		document.forms[0].sContactPerson2Telephone.className = 'textinput_off';
		document.forms[0].sContactTelephone.className = 'textinput_off';
		document.forms[0].sEmail.className = 'textinput_off';
		document.forms[0].sUrl.className = 'textinput_off';
		document.forms[0].sAddress.className = 'textinput_off';
		document.forms[0].sZipcode.className = 'textinput_off';
		document.forms[0].sCity.className = 'textinput_off';
		document.forms[0].sPostAddress.className = 'textinput_off';
		document.forms[0].sPostZipcode.className ='textinput_off';
		document.forms[0].sPostCity.className = 'textinput_off';
		document.forms[0].sCompanyTelephone.className = 'textinput_off';
		
		isExistingCompany = true;
	}
}

// Check browser version
var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "/";
// If you are using any Java validation on the back side you will want to use the / because
// Java date validations do not recognize the dash as a valid date separator.
var vDateType = 3; // Global value for type of date format
//                1 = mm/dd/yyyy
//                2 = yyyy/dd/mm  (Unable to do date check at this time)
//                3 = dd/mm/yyyy
var vYearType = 2; //Set to 2 or 4 for number of digits in the year for Netscape
var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.
var err = 0; // Set the error code to a default of zero
if(navigator.appName == "Netscape") {
	if (navigator.appVersion < "5") {
		isNav4 = true;
		isNav5 = false;
	}
	else
	if (navigator.appVersion > "4") {
		isNav4 = false;
		isNav5 = true;
	}
}
else {
	isIE4 = true;
}



// Zorgen dat de geen voorkeur checkbox niet tegelijkertijd kan worden geselecteerd met haar childs.
function handle_geen_voorkeur_checkboxes(selectornot,loopid) {
	/*
	alert("boe");	
	alert(selectornot.checked + " " + loopid);
	*/
	if (selectornot) {
		temp = document.forms[0].elements.length  ;
		for (i=0; i < temp; i++) {   
			if ( (document.forms[0].elements[i].id.substring(0,7) == "loop"+loopid) && (document.forms[0].elements[i].id.substring(0,8) == "loop"+loopid+"_") ) {
				document.forms[0].elements[i].checked =false;			
			}
		}
	} 

	return;	
	
}

function validate_criteria(loops){
	
	checkset = Array();
	alert(loops);
	loopid = "00"+loops;
	
	//for(z=0, z < loops; z++;){
	//	loopid = "00"+z;
	//	alert("z "+z);
	//	alert("boe");
		temp = document.forms[0].elements.length  ;
		
		for (i=0; i < temp; i++) {   
			if ( (document.forms[0].elements[i].id.substring(0,7) == "loop"+loopid) ) {
				
				if(document.forms[0].elements[i].checked){
					checkset[loopid] = true;	
				}
					
			}
		}
	//}
	
	for(a=0, a < loops; a++;){	
		alert("loopid: "+checkset[loopid]);
	}
	
	//if(checkset){		
	//	return true;
	//} else {
		alert('U moet voor alle criteria een optie aanvinken (geen voorkeur mag ook)');
		return false;
	//}
	
}

function submitVacancyAdd() {
	//form naam = addvacancy
	
	sError = "";
	
	if(isExistingCompany == false){
		if (document.forms[0].sCompanyName.value == "") {
			sError += "-U dient een Bedrijfsnaam in te vullen \n\r";
		}
		
		if (document.forms[0].sContactPerson.value == "") {
			sError += "-U dient een Contactpersoon in te vullen \n\r";
		}
		
		if (document.forms[0].sContactTelephone.value == "") {
			sError += "-U dient een Telefoonnummer in te vullen \n\r";
		}
		
		if (document.forms[0].sEmail.value == "") {
			sError += "-U dient een Email-adres in te vullen \n\r";
		}
	} 
	
	if (sError != "") {
		alert(sError);
			
	}
	else {
		document.forms[0].submit();
	}

}



function submitProfileAdd() {
	//form naam = addvacancy
	
	sError = "";
	
	if (document.forms[0].sFirstName.value == "") {
		sError += "-U dient uw voornaam in te vullen \n\r";
	}
	
	if (document.forms[0].sLastName.value == "") {
		sError += "-U dient uw achternaam in te vullen \n\r";
	}
	
	if ((document.forms[0].sEmail.value == "") && (document.forms[0].sTelephoneDay.value == "") && (document.forms[0].sTelephoneNight.value == "") ) {
		sError += "-U dient uw emailadres of een telefoonnummer in te vullen \n\r";
	}

	
	if (sError != "") {
		alert(sError);
			
	}
	else {
		document.forms[0].submit();
	}

}


function submitProfileReaction() {
	//form naam = addvacancy
	
	sError = "";
		
	
	if (document.forms[0].sContactPerson.value == "") {
		sError += "-U dient uw naam in te vullen \n\r";
	}
	
	if ((document.forms[0].sEmail.value == "") && (document.forms[0].sContactTelephone.value == "") ) {
		sError += "-U dient uw emailadres of een telefoonnummer in te vullen \n\r";
	}

	
	if (sError != "") {
		alert(sError);
	}

	else {
		document.forms[0].submit();
	}

}


function submitInschrijvingAdd() {
	sError = "";
	
	
	if (document.forms[0].Naam_voorletters.value == "") {
		sError += "-U dient uw naam in te vullen \n\r";
	}
	
	//if (document.forms[0].Bedrijfsnaam.value == "") {
//		sError += "-U dient uw naam in te vullen \n\r";
//	}
	
	
	if (document.forms[0].Straat.value == "") {
		sError += "-U dient uw straatnaam in te vullen \n\r";
	}
	if (document.forms[0].Postcode.value == "") {
		sError += "-U dient uw postcode in te vullen \n\r";
	}
	
	if (document.forms[0].Plaats.value == "") {
		sError += "-U dient uw plaats in te vullen \n\r";
	}
	
	if ((document.forms[0].Email.value == "") && (document.forms[0].Telefoon.value == "") ) {
		sError += "-U dient uw emailadres of een telefoonnummer in te vullen \n\r";
	}

	//if (document.forms[0].Opmerking.value == "") {
//		sError += "-U dient uw Plaats in te vullen \n\r";
//	}

	if (sError != "") {
		alert(sError);
	}

	else {
		document.forms[0].submit();
	}

	
}


function submitVacancyReaction() {
	//form naam = addvacancy
	
	sError = "";
	
	if (document.forms[0].sFirstName.value == "") {
		sError += "-U dient uw voornaam in te vullen \n\r";
	}
	
	if (document.forms[0].sLastName.value == "") {
		sError += "-U dient uw achternaam in te vullen \n\r";
	}
	
	if ((document.forms[0].sEmail.value == "") && (document.forms[0].sTelephoneDay.value == "") && (document.forms[0].sTelephoneNight.value == "") ) {
		sError += "-U dient uw emailadres of een telefoonnummer in te vullen \n\r";
	}

	
	if (sError != "") {
		alert(sError);
	}
	else {
		document.forms[0].submit();
	}

}



function submitSearchForm() {
	document.forms[0].submit();
	/*
	temp = document.forms[0].elements.length  ;
    for (i=0; i < temp; i++) {   
		//alert("hoi " + document.forms[0].elements[i].id.substring(0,5));
  		//alert(document.forms[0].elements[i].id.substring(0,5) + "equals"  + );
		// hoofdgroep opzoeken
  		if ( (document.forms[0].elements[i].id.substring(0,4) == "loop")  ) {
        	catName = document.forms[0].elements[i].id.substring(0,7)
  			temp = document.forms[0].elements.length  ;
    		for (j=0; j < temp; j++) {   
  				// Controleren of er een child geselecteerd is.
    			if ( (document.forms[0].elements[i].id.substring(0,7) == "loop"+loopid+"_") && (document.forms[0].elements[i].id.substring(0,8) == "loop"+loopid+"_") )
  					
    			document.forms[0].elements[i].checked =false;
        	}
		}
	
} */
}

function submitHomeSearchVacancy() {
	if (document.toonvacancy.iPkVacancyId.value == '') {
		document.toonvacancy.iPkVacancyId.value = 'alle';	
	}
	document.toonvacancy.submit();
}

function submitHomeSearchProfile() {
	if (document.toonprofile.iPkProfileId.value == '') {
		document.toonprofile.iPkProfileId.value = 'alle';	
	}
	
	document.toonprofile.submit();
}



// ***** JANUARI 2008 ****/
function changeTab(fieldId) {

	// eerst alles weer uitzetten
	document.getElementById('tab_category').className = 'one';
	document.getElementById('tab_region').className = 'two';
	document.getElementById('tab_company').className = 'three';
	
	document.getElementById('panel_category').style.display = 'none';
	document.getElementById('panel_region').style.display = 'none';
	document.getElementById('panel_company').style.display = 'none';
	
	switch(fieldId){
		case 'category':
			document.getElementById('tab_category').className = 'one_active'; // dan de juist tab op aan zetten
			document.getElementById('panel_category').style.display = '';// en de juiste panel showen
			break    
		case 'region':
			document.getElementById('tab_region').className = 'two_active'; // dan de juist tab op aan zetten
			document.getElementById('panel_region').style.display = '';// en de juiste panel showen
			break
		case 'company':
			document.getElementById('tab_company').className = 'three_active'; // dan de juist tab op aan zetten
			document.getElementById('panel_company').style.display = '';// en de juiste panel showen
			break
	}	
	
}
/*
var currentThumb;
var currentTip;

function showTip(st) {
  closeTips();

  currentThumb = "thumb"+st;
  currentTip   = currentThumb+"Tip";

  //document.getElementById(currentThumb).style.border="2px solid #f00";
  $(currentThumb).style.border="2px solid #f00";
  document.getElementById(currentTip).style.display = '';
  Element.show(currentTip);
}

function hideTip() {
  if (currentThumb) {
	//var style = document.getElementById(currentThumb).style;
    var style = $(currentThumb).style;
    style.borderBottom = "2px solid #fff";
    style.borderTop    = "2px solid #fff";
    style.borderLeft   = "2px solid #fff";
    style.borderRight  = "2px solid #fff";
  }
  closeTips();
}

function closeTips() {
  if (currentTip) {
	//document.getElementById(currentTip).style.display = 'none';
    $(currentTip).style.display = 'none';
  }
}
*/

