
var menu1=new Array()
//menu1[1]='<a href="'+ root_dir +'recruiter/addrecruiterquestion.php">Create New Questions</a>'
menu1[1]='<a href="'+ root_dir +'recruiter/questions/addqcategory.php">Create New Questions</a>'
menu1[2]='<a href="'+ root_dir +'recruiter/questions/viewqcategories.php">Modify Existing</a>'

//Contents for menu 2, and so on
var menu2=new Array()
//menu2[1]='<a href="'+ root_dir +'recruiter/postjob.php">Create Job</a>'
//menu2[2]='<a href="'+ root_dir +'recruiter/joblist.php">Job List</a>'
menu2[1]='<a href="'+ root_dir +'recruiter/job/post.php">Create Job</a>'
menu2[2]='<a href="'+ root_dir +'recruiter/job/list.php">Job List</a>'
//menu2[3]='<a href="'+ root_dir +'recruiter/interviewlist.php">Received Interviews</a>'

var menu3=new Array()
//menu3[1]='<a href="'+ root_dir +'recruiter/recruiterfavourite.php">Summary</a>'
menu3[1]='<a href="'+ root_dir +'recruiter/saveList.php">Detail</a>'

var menu4=new Array()
menu4[1]='<a href="'+ root_dir +'recruiter/invite_jobseeker.php">Invite Candidate</a>'
menu4[2]='<a href="'+ root_dir +'recruiter/janerecruiterinterview.php">Sent Interviews</a>'
//menu4[3]='<a href="'+ root_dir +'recruiter/janerecruiterinterviewlist.php">Received Interviews</a>'

var menu5=new Array()
menu5[1]='<a href="'+ root_dir +'calendar/calendar.php">Calendar</a>'
/*menu5[2]='<a href="">Send to Outlook link above the calendar</a>'*/

var menu6=new Array()
/*menu6[1]='<a href="'+ root_dir +'calendar/calendar.php">Overview</a>'*/
menu6[2]='<a href="'+ root_dir +'recruiter/EditInfo.php">Edit Info</a>'
menu6[3]='<a href="'+ root_dir +'recruiter/pay1.php">Update Plan</a>'


var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var horizontaloffset=2 //horizontal offset of menu from default location. (0-5 is a good value)

/////No further editting needed


var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width: 160px" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move menu up?
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
edgeoffset=dropmenuobj.y
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}



/////////////////////////////////////////

function other_win(url) {
	window.open(url, "MyWin", "toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=yes,width=600,height=400,left = 100,top = 50");
}

function image_over(image_name) {
	var a = document.all(image_name);
	a.src = img_dir + image_name + "_a.gif"
}

function image_out(image_name) {
	var a = document.all(image_name);
	a.src = img_dir + image_name + ".gif"
}

function cdel(w) {
	if(confirm('Are you sure you want to delete this '+w+'?')) {
		return true;
	}
	else {
		return false;
	}
}



//new

function showMenu(a) {
	var elem = document.getElementById(a);
		elem.style.visibility="visible";
}

function hideMenu(a) {
	var elem = document.getElementById(a);
		elem.style.visibility="hidden";
}


var c=0;
var s;

function changePhoto()
{
if (c%3==0){
document.getElementById('topPhotoFirst').style.backgroundImage = "url(images/new_photos/new1.jpg)";
}
if (c%3==1){
document.getElementById('topPhotoFirst').style.backgroundImage = "url(images/new_photos/new2.jpg)";
}
if (c%3==2){
document.getElementById('topPhotoFirst').style.backgroundImage = "url(images/new_photos/new3.jpg)";
}

c=c+1;
s=setTimeout("changePhoto()",5000);
}



function restoreValue(event) {
	
	
	var target;
	if (!event)
		var event = window.event;
	if (event.target)
		target = event.target;
	else if (event.srcElement) 
		target = event.srcElement;
	if (target.nodeType == 3) // defeat Safari bug
		target = targ.parentNode;
 
	  if( target.value == "") {
		  target.value = target.title;
		  
		  target.style.color = "silver";
	      target.style.paddingLeft = "20px";
	      target.style.textTransform = "uppercase";
	      	  
	  }
           
}

function restorePasswordValue(event) {
	
	
	
	var target;
	if (!event)
		var event = window.event;
	if (event.target)
		target = event.target;
	else if (event.srcElement) 
		target = event.srcElement;
	if (target.nodeType == 3) // defeat Safari bug
		target = targ.parentNode;
	
	
	
 
	  if(target.value == "") {
		  var newO=document.createElement('input');
			newO.setAttribute('type','text');
			newO.setAttribute('title',target.getAttribute('title'));
			newO.setAttribute('name',target.getAttribute('name'));
			newO.setAttribute('value',target.getAttribute('title'));
			newO.setAttribute('onClick','enterPassword(event)');
			target.parentNode.replaceChild(newO,target);
			newO.focus();
			setTimeout(newO.focus(), 10);
			
			newO.setAttribute("class", "newTextInput"); 
			newO.setAttribute("className", "newTextInput");
		  target.value = target.title;
    	  
	  }
           
}

function restorePasswordValue2(event) {
	
	
	
	var target;
	if (!event)
		var event = window.event;
	if (event.target)
		target = event.target;
	else if (event.srcElement) 
		target = event.srcElement;
	if (target.nodeType == 3) // defeat Safari bug
		target = targ.parentNode;
	
	
	
 
	  if(target.value == "") {
		  var newO=document.createElement('input');
			newO.setAttribute('type','text');
			newO.setAttribute('title',target.getAttribute('title'));
			newO.setAttribute('name',target.getAttribute('name'));
			newO.setAttribute('value',target.getAttribute('title'));
			newO.setAttribute('onClick','enterPassword2(event)');
			target.parentNode.replaceChild(newO,target);
			newO.focus();
			setTimeout(newO.focus(), 10);
			
			newO.setAttribute("class", "newTextInput silverInput"); 
			newO.setAttribute("className", "newTextInput silverInput");
		  target.value = target.title;
    	  
	  }
           
}

function enterText(event) {
	
	
	var target;
	if (!event)
		var event = window.event;
	if (event.target)
		target = event.target;
	else if (event.srcElement) 
		target = event.srcElement;
	if (target.nodeType == 3) // defeat Safari bug
		target = targ.parentNode;
	//var f = document.getElementById('ff');
	
	target.setAttribute('title',target.getAttribute('value'));
	target.setAttribute("onblur", "restoreValue(event);" );
	 if(target.title == '') {
		  target.style.color = "black";
	      target.style.paddingLeft = "0px";
	      target.style.textTransform = "none";
	      target.value = "";  
	      target.onfocus = null;  
	  }
	
	 
	 else if(target.title == target.value) {
		  target.style.color = "black";
	      target.style.paddingLeft = "0px";
	      target.style.textTransform = "none";
	      target.value = "";  
	  }
	 
	  
      
      //target.onfocus = null;
     // target.addEventListener("onFocus", enterTextTwice(event));   
     
         
}


function textareaHint(event) {
	
	
	var target;
	if (!event)
		var event = window.event;
	if (event.target)
		target = event.target;
	else if (event.srcElement) 
		target = event.srcElement;
	if (target.nodeType == 3) // defeat Safari bug
		target = targ.parentNode;
	//var f = document.getElementById('ff');
	
	target.innerHTML = '';
       
}





function enterPassword(event) {
	
	var target;
	if (!event)
		var event = window.event;
	if (event.target)
		target = event.target;
	else if (event.srcElement) 
		target = event.srcElement;
	if (target.nodeType == 3) // defeat Safari bug
		target = targ.parentNode;
	target.value = "";
	
	//target.style.textTransform = "none";
	//target.style.paddingLeft = "0px";
	//target.style.color = "black";
	//target.type = "password";
	
	var newO=document.createElement('input');
	newO.setAttribute('type','password');
	newO.setAttribute('title',target.getAttribute('value'));
	newO.setAttribute('name',target.getAttribute('name'));
	target.parentNode.replaceChild(newO,target);
	newO.focus();
	setTimeout(newO.focus(), 10);
	newO.setAttribute("class", "newTextInputFocused"); 
	newO.setAttribute("className", "newTextInputFocused");
	newO.setAttribute("onblur", "restorePasswordValue(event);");
	
	
	
	//newO.addEventListener("onBlur", restorePasswordValue(event))
	
}

function enterPassword2(event) {
	
	var target;
	if (!event)
		var event = window.event;
	if (event.target)
		target = event.target;
	else if (event.srcElement) 
		target = event.srcElement;
	if (target.nodeType == 3) // defeat Safari bug
		target = targ.parentNode;
	target.value = "";
	
	//target.style.textTransform = "none";
	//target.style.paddingLeft = "0px";
	//target.style.color = "black";
	//target.type = "password";
	
	var newO=document.createElement('input');
	newO.setAttribute('type','password');
	newO.setAttribute('title',target.getAttribute('value'));
	newO.setAttribute('name',target.getAttribute('name'));
	target.parentNode.replaceChild(newO,target);
	newO.focus();
	setTimeout(newO.focus(), 10);
	newO.setAttribute("class", "newTextInputFocused2"); 
	newO.setAttribute("className", "newTextInputFocused2");
	newO.setAttribute("onBlur", "restorePasswordValue2(event);");
	
}


function loadMore(user, order, id)
{
var xmlhttp;
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)
    {
    document.getElementById("myDiv").innerHTML += xmlhttp.responseText;
    
    }
  }
xmlhttp.open("GET","ajax2.php?lastmsg="+id+"&user="+user,true);
xmlhttp.send();
}

function changeTab(tabId, buttonId) {
	var tab = document.getElementById(tabId);
	var button = document.getElementById(buttonId);
	
	var tab0 = document.getElementById('tab0');
	var tab1 = document.getElementById('tab1');
	var tab2 = document.getElementById('tab2');
	var tab3 = document.getElementById('tab3');
	var tab4 = document.getElementById('tab4');
	var tab5 = document.getElementById('subtab1');
	var tab6 = document.getElementById('subtab2');
	var tab7 = document.getElementById('subtab3');
	var button0 = document.getElementById('but0');
	var button1 = document.getElementById('but1');
	var button2 = document.getElementById('but2');
	var button3 = document.getElementById('but3');
	var button4 = document.getElementById('but4');
	
	tab0.style.visibility = 'hidden'; 
	tab1.style.visibility = 'hidden'; 
	tab2.style.visibility = 'hidden'; 
	tab3.style.visibility = 'hidden'; 
	tab4.style.visibility = 'hidden'; 
	tab5.style.visibility = 'hidden'; 
	tab6.style.visibility = 'hidden'; 
	tab7.style.visibility = 'hidden'; 
	tab0.style.position = 'absolute'; 
	tab1.style.position = 'absolute'; 
	tab2.style.position = 'absolute'; 
	tab3.style.position = 'absolute'; 
	tab4.style.position = 'absolute'; 
	tab5.style.position = 'absolute'; 
	tab6.style.position = 'absolute'; 
	tab7.style.position = 'absolute'; 
	
	if(tabId == 'tab3') {
		tab5.style.position = 'static';
		tab5.style.visibility = 'visible'; 
		var obj = document.getElementById('step');
		obj.innerHTML = 1;
	}
	button0.style.backgroundColor = '#BFBFBF';
	button1.style.backgroundColor = '#BFBFBF';
	button2.style.backgroundColor = '#BFBFBF';
	button3.style.backgroundColor = '#BFBFBF';
	button4.style.backgroundColor = '#BFBFBF';
	
	tab.style.position = 'static';
	tab.style.visibility = 'visible'; 
	
	button.style.backgroundColor = '#4F91CD';
	
	
	
}

function changeSubTab(id, tabId, butId) {
	var alertBox = document.getElementById('alert_job');
	alertBox.style.visibility = "hidden";
	if(id == 3) {
		var del = document.getElementById('next');
		del.style.display = "none";
		
	}
	else {
		var del = document.getElementById('next');
		del.style.display = "none";
	}
	
	if(id == 1) {
		var del = document.getElementById('prev');
		del.style.display = "none";
		
	}
	else {
		var del = document.getElementById('prev');
		del.style.display = "none";
	}
	var tab = document.getElementById(tabId);
	var obj = document.getElementById('step');
	var but = document.getElementById(butId);
	obj.innerHTML = id;
	
	var tab1 = document.getElementById('subtab1');
	var tab2 = document.getElementById('subtab2');
	var tab3 = document.getElementById('subtab3');
	
	
	var but1 = document.getElementById('subBut1');
	var but2 = document.getElementById('subBut2');
	var but3 = document.getElementById('subBut3');
	
	but1.style.backgroundColor = '#4F91CD';
	but2.style.backgroundColor = '#4F91CD';
	but3.style.backgroundColor = '#4F91CD';
	but1.style.color = 'white';
	but2.style.color = 'white';
	but3.style.color = 'white';
	
	but.style.backgroundColor = 'white';
	but.style.color = 'black';
	tab1.style.display = 'none';
	tab2.style.display = 'none';
	tab3.style.display = 'none';
	
	
	
	tab.style.display = 'block';
	
}

function changeButtonColor(id) {
	
	var button = document.getElementById(id);
	
	var button0 = document.getElementById('but0');
	var button1 = document.getElementById('but1');
	var button2 = document.getElementById('but2');
	var button3 = document.getElementById('but3');
	var button4 = document.getElementById('but4');
	button0.style.backgroundColor = '#BFBFBF';
	button1.style.backgroundColor = '#BFBFBF';
	button2.style.backgroundColor = '#BFBFBF';
	button3.style.backgroundColor = '#BFBFBF';
	button4.style.backgroundColor = '#BFBFBF';
	
	button.style.backgroundColor = '#4F91CD';
}

function deleteObject(id) {
	 var element = document.getElementById(id);
	 element.parentNode.removeChild(element);
}

function addQuestion(divId, id, moveId) {
	var elDivId = document.getElementById(divId);
	var elId = document.getElementById(id);
	var elMoveId = document.getElementById(moveId);
	var text = elId.innerHTML;
	elMoveId.value = text;
	elDivId.parentNode.removeChild(elDivId);
}


function preview() {
	var obj;
	var p;
	var answeredQuestions = 0;
	var missedQuestion = false;
	var missedQuestionNumber;
	var error = false;
	var inputValue = new Array();
	var questionId = new Array();
	var divId = new Array();
	var defaultQuestion = "TYPE YOUR CUSTOM QUESTION HERE OR CLICK THE CHECK MARK FROM THE LIST OF QUESTIONS TO THE RIGHT.";
	
	inputValue[1] = post_job.q1.value;
	inputValue[2] = post_job.q2.value;
	inputValue[3] = post_job.q3.value;
	inputValue[4] = post_job.q4.value;
	inputValue[5] = post_job.q5.value;
	inputValue[6] = post_job.q6.value;
	inputValue[7] = post_job.q7.value;
	inputValue[8] = post_job.q8.value;
	inputValue[9] = post_job.q9.value;
	inputValue[10] = post_job.q10.value;
	
	questionId[1] = "preview_q1";
	questionId[2] = "preview_q2";
	questionId[3] = "preview_q3";
	questionId[4] = "preview_q4";
	questionId[5] = "preview_q5";
	questionId[6] = "preview_q6";
	questionId[7] = "preview_q7";
	questionId[8] = "preview_q8";
	questionId[9] = "preview_q9";
	questionId[10] = "preview_q10";
	
	divId[1] = "preview_quest1";
	divId[2] = "preview_quest2";
	divId[3] = "preview_quest3";
	divId[4] = "preview_quest4";
	divId[5] = "preview_quest5";
	divId[6] = "preview_quest6";
	divId[7] = "preview_quest7";
	divId[8] = "preview_quest8";
	divId[9] = "preview_quest9";
	divId[10] = "preview_quest10";
	
	for(p=1; p<=10; p++) {
		if(inputValue[p] != '' && inputValue[p] != defaultQuestion) {
			if(missedQuestion == true) {
				error = true;
			}
			document.getElementById(questionId[p]).innerHTML = inputValue[p];
			answeredQuestions++;
		}
		else if (missedQuestion == false) {
			missedQuestion = true;
			missedQuestionNumber = p;
		}
		
	}
	
	if(answeredQuestions == 0) {
		 alert('Error: You have to have at least one question to create an interview. Please type in or select a question to use, then save');
		 previousTab();
		 return false;
	 }
	
	if(error) {
		alert('Please fill the questions in right order. You have missed the question number '+missedQuestionNumber);
		previousTab();
		return false;
	}
	
	
	
	
	
	
	
	
	
	document.getElementById('txt_jobname').innerHTML =  post_job.txt_jobname.value;
	document.getElementById('position').innerHTML =  post_job.position.value;
	var country =  post_job.CompanyCountry[post_job.CompanyCountry.selectedIndex].text;
	var state   =  post_job.txtState[post_job.txtState.selectedIndex].text;
	document.getElementById('CompanyCountry').innerHTML =  country + ', ' + state;
	document.getElementById('txt_experience').innerHTML =  post_job.txt_experience.value;
	document.getElementById('jobtype').innerHTML =  post_job.jobtype.value;
	document.getElementById('job_category').innerHTML =  post_job.job_category_id.value;
	document.getElementById('txt_companyname').innerHTML =  post_job.txt_companyname.value;
	document.getElementById('description').innerHTML =  post_job.description.value;
	document.getElementById('aboutjob').innerHTML =  post_job.aboutjob.value;
	document.getElementById('salary').innerHTML =  post_job.salary.value;
	document.getElementById('salary').innerHTML += '/' + post_job.s_period.value;
	document.getElementById('posting_valid').innerHTML =  post_job.offer.value + ' days';
	
	
	
	
	
}

function nextTab() {
	var obj = document.getElementById('step');
	var curTab = obj.innerHTML;
	if(curTab == 1) {
		changeSubTab('2','subtab2','subBut2')
	}
	else if(curTab == 2) {
		changeSubTab('3','subtab3','subBut3')
		preview();
	}
}

function previousTab() {
	var obj = document.getElementById('step');
	var curTab = obj.innerHTML;
	if(curTab == 2) {
		changeSubTab('1','subtab1','subBut1');
	}
	else if(curTab == 3) {
		changeSubTab('2','subtab2','subBut2');
	}
}




function confirmPost() {
	
	var error = '';
	var legalCharsCompanyName = /^[A-z]+[\s]*[A-z]*[\s]*[A-z]*$/;
	if(post_job.txt_jobname.value == '' || post_job.txt_jobname.value == 'This is your Posting title' || post_job.txt_jobname.value.length == 1 || legalCharsCompanyName.test(post_job.txt_jobname.value) == false ) {
		
		error += 'Incorrect Job Title\n';
	}


	if(post_job.position.value == '' || post_job.position.value == 'Job Position') {
		error += 'Incorrect Job Position\n';
	}
	
	if(post_job.CompanyCountry[post_job.CompanyCountry.selectedIndex].text == 'Please Select') {
		error += 'Please, Select the Country\n';
	}
	
	if(post_job.txtState[post_job.txtState.selectedIndex].text == 'State') {
		error += 'Please, Select the State\n';
	}
		
	if(post_job.txt_experience.value == 'Select') {
		error += 'Incorrect Level of Experience Required\n';
	}
	if(post_job.txt_companyname.value == '' || post_job.txt_companyname.value == 'Company Name') {
		error += 'Incorrect Company Name\n';
	}
	if(post_job.description.value == '' || post_job.description.value == 'Description') {
		error += 'Incorrect Company Description\n';
	}
	if(post_job.aboutjob.value == '' || post_job.aboutjob.value == 'Description') {
		error += 'Incorrect Additional Job Description\n';
	}
	if(post_job.salary.value == '' || post_job.salary.value == 'Salary' || !(post_job.salary.value >= 1 && post_job.salary.value <= 999999999)) {
		error += 'Incorrect Salary\n';
	}
	
	
	if(error != '') {
		alert(error);
	}
	else {
	
	var alertBox = document.getElementById('alert_job');
	alertBox.style.visibility = "visible";
	window.scrollTo(0,0);
	}
}

function validatePost() {
	
	var error = '';
	var legalCharsCompanyName = /^[A-z]+[\s]*[A-z]*[\s]*[A-z]*$/;
	if(post_job.txt_jobname.value == '' || post_job.txt_jobname.value == 'This is your Posting title' || post_job.txt_jobname.value.length == 1 || legalCharsCompanyName.test(post_job.txt_jobname.value) == false ) {
		
		error += 'Incorrect Job Title\n';
	}


	if(post_job.position.value == '' || post_job.position.value == 'Job Position') {
		error += 'Incorrect Job Position\n';
	}
	
	if(post_job.CompanyCountry[post_job.CompanyCountry.selectedIndex].text == 'Please Select') {
		error += 'Please, Select the Country\n';
	}
	
	if(post_job.txtState[post_job.txtState.selectedIndex].text == 'State') {
		error += 'Please, Select the State\n';
	}
		
	if(post_job.txt_experience.value == 'Select') {
		error += 'Incorrect Level of Experience Required\n';
	}
	if(post_job.txt_companyname.value == '' || post_job.txt_companyname.value == 'Company Name') {
		error += 'Incorrect Company Name\n';
	}
	if(post_job.description.value == '' || post_job.description.value == 'Description') {
		error += 'Incorrect Company Description\n';
	}
	if(post_job.aboutjob.value == '' || post_job.aboutjob.value == 'Description') {
		error += 'Incorrect Additional Job Description\n';
	}
	if(post_job.salary.value == '' || post_job.salary.value == 'Salary' || !(post_job.salary.value >= 1 && post_job.salary.value <= 999999999)) {
		error += 'Incorrect Salary\n';
	}
	
	if(error != '') {
		changeSubTab('1', 'subtab1', 'subBut1');
		alert(error);
	}
	else {
	

	}
}



function hideAlert() {
	var alertBox = document.getElementById('alert_job');
	alertBox.style.visibility = "hidden";
}

function showBlock(id) {
	var obj = document.getElementById(id);
	obj.style.display = "block";
}

function hideBlock(id) {
	var obj = document.getElementById(id);
	obj.style.display = "none";
}

function showObject(id) {
	var obj = document.getElementById(id);
	obj.style.visibility = "visible";
}

function hideObject(id) {
	var obj = document.getElementById(id);
	obj.style.visibility = "hidden";
}

function selectSubTab(id) {
	var obj = document.getElementById(id);
	obj.style.color = "black";
}

function printText(objectId, text) {
	var obj = document.getElementById(objectId);
	obj.innerHTML = text;
}

function changeQuestionSet(id) {
	
	var content = document.getElementById('readyQuestions');
	content.innerHTML = '<br />';
	
	var question=new Array(12);
	for (i=0; i <12; i++) {
		question[i]=new Array(12);
	}
	
	
	//The position

	question[0][0] = "Assuming you read the job description, which parts of the description appeal to you and why?";
	question[0][1] = "What personal traits do you consider valuable given this job description and requirements?";
	question[0][2] = "How important was the salary for the position to you in considering this opportunity?";
	question[0][3] = "When you decided to interview for this position, which part of the position appealed to you the most?";


	//Strengths

	question[1][0] = "Why do you feel you're qualified for this position?"
	question[1][1] = "If you don't feel you're qualified or interested in this position, would feel comfortable passing to a friend? Why?";
	question[1][2] = "What do you bring to the table that the company will not be able to do without?";
	question[1][3] = "What would you have included or excluded from the job description if you were the one writing?";
	question[1][4] = "How do you deal with adversity?";



	//Experience




	question[2][0] = "How much relevant experience do you have to this industry described in the job description?";
	question[2][1] = "What type of training gives you the qualifications you need for this position?";
	question[2][2] = "How much research have you done within this industry?";
	question[2][3] = "Do you know what companies are number 1, 2 and 3 in this industry?";
	question[2][4] = "How do you define success?";
	question[2][5] = "Talk about your first job and what you liked or disliked about it?";




	//Goals


	question[3][0] = "Please talk about some of your goals and how you feel this position will help you get closer to them?";
	question[3][1] = "Do you prefer working with others or are you more productive working alone? ";
	question[3][2] = "What objectives have you set for your career? What kind of plan do you have to achieve it?";
	question[3][3] = "Do you plan on being in a management position or would you rather just work with less responsibility?";
	question[3][4] = "Which do you feel are more important? Long term goals or short term ones? Why?";


	//Personal

	question[4][0] = "How do you spend your spare time?";
	question[4][1] = "Tell me about a hobby you have that would help in some way with this type of position.";
	question[4][2] = "How much are you involved in helping family and friends?";
	question[4][3] = "Do you like hearing about competitors in your spare time?";

	//Situation Management

	question[5][0] = "Talk about a situation when a customer was rude and how did you diffuse the situation.";
	question[5][1] = "Talk about a time when a co-worker was rude towards you or another co-worker and how did you diffused the situation.";
	question[5][2] = "What was the reason you left the last 2 jobs that you had prior to considering this one?";
	question[5][3] = "What position or industry would be your dream position be if you had the opportunity to get anything you wanted?";

	//Planning & Organization

	question[6][0] = "Give an example of a situation where you predicted a problem and influenced a new direction.";
	question[6][1] = "Do you often find that you need more hours in the day to work and get more done?";
	question[6][2] = "How do you plan and execute when you have multiple tasks that need to be done simultaneously?";
	question[6][3] = "Why did you decide this was the right job to apply for?";
	question[6][4] = "When you check your email, do you just go down the line or do you first delete the junk mail and then get to the real emails?";
	question[6][5] = "If a co-worker that reports to you is not very organized, but gets the job done, would this bother you?";
	question[6][6] = "When you write a document do you work on the index first or do you just start writing and then come back and edit and paste?";
	question[6][7] = "Some people work better under pressure. How do you work better, when under pressure or the exact opposite?";

	//Values

	question[7][0] = "Assuming everyone is punctual, would you be? ";
	question[7][1] = "How do you feel about receiving cell phone calls during work?";
	question[7][2] = "Do you feel texting and SMS are best replied to immediately or during breaks and after work?";
	question[7][3] = "If you feel a co-worker is lying, do you confront him or her?";
	question[7][4] = "What would you do if a co-worker is falsifying records?";

	//Technology

	question[8][0] = "How many social networking or social media sites do you have accounts in?";
	question[8][1] = "Do you consider yourself a social media expert?";
	question[8][2] = "Do you like reading about new trends in technology?";
	question[8][3] = "Are you usually a 'First Mover' when it comes to trying new sites?";

	//Sales

	question[9][0] = "When you make a sales call and are not able to convert the sale, do you feel the customer has rejected you?";
	question[9][1] = "When going on a sales call, do you feel it is more important to take more time to be prepared or speed to the sale is more important?";
	question[9][2] = "Is it hard to let the customer take charge of the conversation or do you find it easy to just wait and listen before showing solutions?";
	question[9][3] = "Have you ever been told 'You can sell ice to Eskimos'? When was this and why?";
	question[9][4] = "If you can get to a decision maker in a company, will you settle for any employee in the organization with the hopes that you can convince him/her to get to the decision maker?";

	//Motivation

	question[10][0] = "How do you motivate others to work with you an a project that you have the most vested interest in?";
	question[10][1] = "Do you feel a manager is more successful motivating to achieve a goal than to penalize missing it?";
	question[10][2] = "What factors does a company need to consider when establishing a reward structure?";
	question[10][3] = "What part does a salary play in motivating the employee base?";
	question[10][4] = "What role does the promise of a better position, or more power play in achieving excellence in the workplace?";
	question[10][5] = "Sometimes you need to get information from co-workers that are not willing to do it on your own time. How do you motivate them to do it?";

	//Managing risk

	question[11][0] = "Everyone is a risk taker, some take very little some very much. Where are you on a scale of 1 to 10, 1 being the smallest risk taker. Give an example.";
	question[11][1] = "Do people think you take too long or too short to make a decision? Give an example.";
	question[11][2] = "Do you feel you can make decisions with incomplete data or would you be uncomfortable making the decision and taking responsibility?";
	question[11][3] = "Do you feel that with the Internet, email and fax that you are pressured to make decisions too quickly sometimes?";
	question[11][4] = "Have you seen companies implement projects that you had thought of well before them?";
	question[11][5] = "What do you think is the biggest reason that startups fail?";
	question[11][6] = "Do you feel that the company needs to give you a certain amount of latitude to implement ideas that come to you at any given time?";
		
		var i =0;
		while( i<=3) {
			content.innerHTML += '<div class="readyQuestion" onClick=selectText("quest'+i+'") id="quest'+i+'"/>' + question[id][i] + '</div>';
			i++;
		}
			

}

function selectAll(id) //for form inputs
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function selectText(id) // for other html tags
{ 
    if (document.selection) {
    var range = document.body.createTextRange();
        range.moveToElementText(document.getElementById(id));
    range.select();
    }
    else if (window.getSelection) {
    var range = document.createRange();
    range.selectNode(document.getElementById(id));
    window.getSelection().addRange(range);
    }
}


function determinePosition() {
	
	if(document.post_job.position2.value == 'select from list') {
		document.post_job.position.value = document.post_job.position1.value;
		
	}
	else {
		document.post_job.position.value = document.post_job.position2.value;
	}
}

function calculateChecks(event) {
	var target;
	if (!event)
		var event = window.event;
	if (event.target)
		target = event.target;
	else if (event.srcElement) 
		target = event.srcElement;
	if (target.nodeType == 3) // defeat Safari bug
		target = targ.parentNode;
	
	var obj = document.getElementById('checked_n');
	
	
	if(target.value == 'on')
		obj.value = parseInt(obj.value) + 1;
	else 
		obj.value = parseInt(obj.value) - 1;
	
	
	
}

function deleteChecked() {
	var obj = document.getElementById('checked_n');
	if(obj.value != '0') {
		showObject('confirm_delete');	
	}
	else {
		alert('You have not selected any postings to delete. Please select one or multiple postings to delete');
	}
	
}
var xmlhttp;
function validateInterviewCode() {
	
	var error;
	var form = document.interview_code_form.interview_code;
	var legalChars = /^[0-9]{4}-[0-9]{4}$/;
	if(legalChars.test(form.value) == false ) {
		
	alert('Please enter a valid Interview code in the following format:\n(XXXX-XXXX)\n Where X are only numbers');
	return false;
	}
	else {
		
		if (window.XMLHttpRequest) {
		  xmlhttp=new XMLHttpRequest();
		  }
		else {
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		
	 	
	 	
		xmlhttp=GetXmlHttpObject(validateInterviewCodeAjax);
		xmlhttp.open("GET","validate_interview_code.php?code="+form.value,true);
		xmlhttp.send();
	
			
		 return false;	
	}
	
	
	
	
	 
}

function validateInterviewCodeAjax() {
	 var form = document.interview_code_form;
	 if(xmlhttp.readyState==4) {
		   	 if(xmlhttp.responseText == '')
		   	 {
		   		 form.submit();
		   	 }
		   	 else {
			  alert(xmlhttp.responseText);
		   	 }
	 }
	

}

function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null;
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
			var strName="Msxml2.XMLHTTP";
			objXmlHttp=new ActiveXObject(strName);
			objXmlHttp.onreadystatechange=handler ;
			return objXmlHttp;
		
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler ;
		return objXmlHttp;
	}
} 

function getTimeZone() {

	var d = new Date()
	var gmtHours = -d.getTimezoneOffset()/60;
	return gmtHours;

}

function interviewExit() {
	var answer = confirm("Are you sure you want to leave this page")
	if (answer){
		
		javascript:history.go(-1);
	}
	else{
		
	}
}

function fixEmptyDate(id) {
	var el = document.getElementById(id);
	var d = new Date();
	var curr_date = d.getDate();
	var curr_month = d.getMonth() + 1; //months are zero based
	if(curr_month<9) {
		curr_month = '0' + curr_month;
	}
	var curr_year = d.getFullYear();
	
	if(el.value == 'Select Date') {
		
		el.value = curr_month + "/" + curr_date + "/" + curr_year;
		//el.value = "12/11/2011";
	}
	
}

	
