var intervalWG="";

function changeWG()
{
	clearInterval(intervalWG);
	try
	{wkgid=document.getElementById("workgroupid").value;}
	catch(err)
	{wkgid="";}	
	document.getElementById("wglbl").innerHTML = "Workgroup:";
	document.getElementById("wgip").innerHTML = "&nbsp;"+ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=wgchange&companyid="+document.getElementById("companyid").value+"&workgroupid="+wkgid, "");
}

function jobAppDel(id)
{
	var ret=confirm("Do you want to remove this application?");
	if(ret==true)
	{
		ajaxrun('includes/ajaxpgs/humanresourcesAJAX.php?Page=jobAppDel&applicationid='+id, '');
		document.getElementById('proempData').innerHTML=ajaxrun('includes/ajaxpgs/humanresourcesAJAX.php?Page=returnJobs', document.getElementById('jobs'));
		greenComplete("Applicant Removed");		
	}
}

function jobClose(id, jobnum)
{
	var ret=confirm("Do you want to close job number - "+jobnum+"?");
	if(ret==true)
	{
		var	value = ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=closeJob&jobid="+id+"&jobnumber="+jobnum, "");
		if(value!="")
		{redComplete(value);}
		else
		{
			document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=manageOpenings", "");
			document.getElementById("manageopenings").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=openingsList", document.getElementById("jobs"));
			greenComplete("Job Closed");		
		}
	}
}

function jobDelete(id, jobnum)
{
	var ret=confirm("Do you want to delete job number - "+jobnum+"?");
	if(ret==true)
	{
		var	value = ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=deleteJob&jobid="+id+"&jobnumber="+jobnum, "");
		if(value!="")
		{redComplete(value);}
		else
		{
			document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=manageOpenings", "");
			document.getElementById("manageopenings").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=openingsList", document.getElementById("jobs"));
			greenComplete("Job Removed");		
		}
	}
}

function jobEdit(id, jobnum)
{
	document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=postnew&jobid="+id+"&jobnumber="+jobnum, "");
	document.getElementById("cmdJob").onclick=jobUpdate;
	document.getElementById("cmdJob").value="Update Job";
	intervalWG=setInterval("changeWG();", 500);
}

function jobFilter()
{document.getElementById("manageopenings").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=openingsList", document.getElementById("jobs"));}

function jobOpen(id, jobnum)
{
	ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=openJob&jobid="+id+"&jobnumber="+jobnum, "");
	document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=manageOpenings", "");
	document.getElementById("manageopenings").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=openingsList", document.getElementById("jobs"));
}

function jobUpdate()
{
	var	value = ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=updateJob", document.getElementById("jobs"));
	//alert(value);
	if(value!="")
	{redComplete(validate(value));}
	else
	{
		document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=manageOpenings", "");
		document.getElementById("manageopenings").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=openingsList", document.getElementById("jobs"));
		greenComplete("Job Updated");		
	}
}

function jobView(jobnum)
{
	pgContent=obj("ajaxcontentarea");
	pgContent.innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=viewJob&jobnumber="+jobnum, "");

	setTimeout("jobView_sub1()",500);	
}

function jobView_sub1()
{	
	//JQuery Tooltip
	$("td.tooltip1 a.links2").tooltip({
		position: "bottom right"
		,onBeforeShow: function() 
		{
			var tooltipInfo=this.getTip()[0];
			var lookup=this.getTrigger()[0].rev;
			tooltipInfo.innerHTML=ajaxrun(lookup,"");
		}
	}).dynamic({ bottom: { direction: 'down', bounce: true } });
	//End JQuery Tooltip
}

function hrReview(jobnum,applID)
{
	/*var temp=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=setReviewed&applID="+applID+"&hrscreenid="+userID(), obj("comments"));
	if(temp=="")
	{jobView(jobnum);ajax_hideTooltip();}*/
	
	var temp=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=hrReviewInfoset&applID="+applID+"&hrscreenid="+userID(), obj("comments"));
	if(temp=="")
	{jobView(jobnum);ajax_hideTooltip();}
}

function jobViewReviewReq(applID,jobnum)
{
	if(confirm("I have reviewed this application")==true)
	{
		var temp=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=setReviewedReq&applID="+applID+"&reqscreenid="+userID(), "");
		if(temp==""){jobView(jobnum);}
	}	
}

function positionCreate()
{
	var	value = ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=createPos", document.getElementById("formJobs"));
	if(value!="")
	{redComplete(validate(value));}
	else
	{
		document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=managePos", "");
		greenComplete("Position Saved");		
	}
}

function positionDelete(id)
{
	ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=deletePos&id="+id, "");
	document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=managePos", "");
	greenComplete("Position Removed");
}

function positionEdit(id)
{
	document.getElementById("ajaxcontentarea").innerHTML= ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=managePos&id="+id, "");
	document.getElementById("posButton").value="Update";
}

function positionUpdate()
{
	var	value = ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=updatePos", document.getElementById("formJobs"));
	if(value!="")
	{redComplete(validate(value));}
	else
	{
		document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=managePos", "");
		greenComplete("Position Saved");		
	}
}


function onlineSubmit(website)
{
	if(website=="kljengInternship")
	{info="includes/ajaxpgs/humanresourcesAJAX.php?Page=jobSubmittal&empl_type=Internship&website="+website;}
	else
	{info="includes/ajaxpgs/humanresourcesAJAX.php?Page=jobSubmittal&website="+website;}
	
	var	value = ajaxrun(info,obj("formJobs"));
	//alert(value+" "+website);
	var ret=splitRetText(value);
	if(ret!="")
	{
		if(ret=="enrolled")
		{
			document.getElementById('retmess').innerHTML="<span style=\"color:#FF0000;\">Our records indicate you have previously applied for this position.  As it is possible that someone with the same name has applied, please enter in the first letter of, or your entire, middle name.</span>";
		}
		else{validateNew(ret);}
	}
	else
	{
		if(website=="kljeng")
		{
			window.close();
			//location.replace("jobs.asp");
		}
		else if(website=="kljengInternship")
		{location.replace("jobs.asp?Page=Internships");}
		else if(website!="")
		{location.replace("jobs.asp?site="+website);}
		else
		{location.replace("humanresources.asp?Page=Jobs");}
	}
}

function checkUploads()
{
	if(document.getElementById("filecoverid1").value=="")
	{
		document.getElementById("resumeid").innerHTML="To attach a RESUME, you must attach/submit a COVER LETTER.";
		document.getElementById("butSubmit").disabled=true;
		document.getElementById("butSubmit").style.display = "none";
	}
	else
	{
		try{test=document.getElementById("fileresumeid1").value;}
		catch(err)
		{formupload("resumeid", 1, "formJobs");}				
		try
		{
			test=document.getElementById("fileresumeid1").value;
			if(test != "")
			{
				document.getElementById("butSubmit").disabled=false;
				document.getElementById("butSubmit").style.display = "";
			}
			else
			{
				document.getElementById("butSubmit").disabled=true;
				document.getElementById("butSubmit").style.display = "none";
			}
		}
		catch(err)
		{
			document.getElementById("butSubmit").disabled=true;
			document.getElementById("butSubmit").style.display = "none";
		}
	}
}

function onlineSubmitChange()
{
	if(document.getElementById("source").value=="Other")
	{document.getElementById("sourceposition").innerHTML="<input class=\"input3\" id=\"source\" name=\"source\" value=\"\" type=\"text\" />";}
}

function sourceCreate()
{
	var	value = ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=createSource", document.getElementById("formJobs"));
	if(value!="")
	{redComplete(validate(value));}
	else
	{
		document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=manageSources", "");
		greenComplete("Source Saved");		
	}
}

function sourceDelete(id)
{
	ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=deletePos&id="+id, "");
	document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=manageSources", "");
	greenComplete("Source Removed");
}

function sourceEdit(id)
{
	document.getElementById("ajaxcontentarea").innerHTML= ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=manageSources&id="+id, "");
	document.getElementById("posButton").value="Update";
}

function sourceUpdate()
{
	var	value = ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=updateSource", document.getElementById("formJobs"));
	if(value!="")
	{redComplete(validate(value));}
	else
	{
		document.getElementById("ajaxcontentarea").innerHTML=ajaxrun("includes/ajaxpgs/humanresourcesAJAX.php?Page=manageSources", "");
		greenComplete("Source Saved");		
	}
}

function redComplete(value)
{document.getElementById('returnmess').innerHTML="<span style=\"color:#FF0000;\">"+value+"</span>";document.getElementById("returnmess").focus();}

function greenComplete(value)
{document.getElementById('returnmess').innerHTML="<span style=\"color:#009900;\">"+value+"</span>";document.getElementById("returnmess").focus();}


function genSystemInfo()
{
	document.getElementById("systemInfo").innerHTML= ajaxrun("includes/systemInfo.php?Page=","");	
}

