// Get base url
url = document.location.href;
xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);

/***********************************************
* 
*  Handle startup data 
* 
***********************************************/

function start_EPSengine (inContent,inStates,inCategories) {
				var searchstr = '';
				var url = '';
		   
			 
			 //document.getElementById("appBody").innerHTML = '<br><h3><image src="images/indicator1.gif" border=0 > Loading please wait...</h3>';

				if(inContent=="C")
				{
				 document.getElementById("contentdiv").innerHTML = '<br><h3><image src="images/indicator1.gif" border=0 > Loading please wait...</h3>';
					url="get_candidates.phtml";
					//searchstr = form_do();
  	      if (url.substring(0, 4) != 'http') {
                url = base_url + url + searchstr;
    	    }

        // Create new JS element
	        var jsel = document.createElement('SCRIPT');
  	      jsel.type = 'text/javascript';
    	    jsel.src = url;
				//alert (url);
        // Append JS element (therefore executing the 'AJAX' call)
      	  document.body.appendChild (jsel);
				}
				else if(inContent=="R")
				{
				 document.getElementById("contentdiv").innerHTML = '<br><h3><image src="images/indicator1.gif" border=0 > Loading please wait...</h3>';
					url="get_resumes.phtml";
					//searchstr = form_do();
  	      if (url.substring(0, 4) != 'http') {
                url = base_url + url + searchstr;
    	    }

        // Create new JS element
	        var jsel = document.createElement('SCRIPT');
  	      jsel.type = 'text/javascript';
    	    jsel.src = url;
				//alert (url);
        // Append JS element (therefore executing the 'AJAX' call)
      	  document.body.appendChild (jsel);
				}


				if(inStates=="S")
				{
					url="get_countries.phtml";
					//searchstr = '';
  	      if (url.substring(0, 4) != 'http') {
                url = base_url + url + searchstr;
    	    }

        // Create new JS element
	        var jsel = document.createElement('SCRIPT');
  	      jsel.type = 'text/javascript';
    	    jsel.src = url;
					//alert (jsel);
        // Append JS element (therefore executing the 'AJAX' call)
      	  document.body.appendChild (jsel);

					url="get_states.phtml";
					//searchstr = '';
  	      if (url.substring(0, 4) != 'http') {
                url = base_url + url + searchstr;
    	    }

        // Create new JS element
	        var jsel = document.createElement('SCRIPT');
  	      jsel.type = 'text/javascript';
    	    jsel.src = url;
					//alert (url);
        // Append JS element (therefore executing the 'AJAX' call)
      	  document.body.appendChild (jsel);

					url="get_cities.phtml";
					//searchstr = '';
  	      if (url.substring(0, 4) != 'http') {
                url = base_url + url + searchstr;
    	    }

        // Create new JS element
	        var jsel = document.createElement('SCRIPT');
  	      jsel.type = 'text/javascript';
    	    jsel.src = url;
					//alert (url);
        // Append JS element (therefore executing the 'AJAX' call)
      	  document.body.appendChild (jsel);


				}

				if(inCategories=="C")
				{
					url="get_categories.phtml";
					//searchstr = '';
  	      if (url.substring(0, 4) != 'http') {
                url = base_url + url + searchstr;
    	    }

        // Create new JS element
	        var jsel = document.createElement('SCRIPT');
  	      jsel.type = 'text/javascript';
    	    jsel.src = url;
				//alert (url);
        // Append JS element (therefore executing the 'AJAX' call)
      	  document.body.appendChild (jsel);


					url="get_subcategories.phtml";
					//searchstr = '';
  	      if (url.substring(0, 4) != 'http') {
                url = base_url + url + searchstr;
    	    }

        // Create new JS element
	        var jsel = document.createElement('SCRIPT');
  	      jsel.type = 'text/javascript';
    	    jsel.src = url;
				//alert (url);
        // Append JS element (therefore executing the 'AJAX' call)
      	  document.body.appendChild (jsel);

				}


}

/***********************************************
* 
*  Handle data 
* 
***********************************************/

function run_EPSengine (url,passForm) {
        // Does URL begin with http?
				//var country = '';
				//var city = '';
				//var state = '';
				
				var searchstr = '';
				//var country = document.getElementById('country').value;
				//var region = document.getElementById('region').value;
				//var city = document.getElementById('city').value;
				if(passForm == "true")
					searchstr = form_do();
				else if(passForm == "form1")
					searchstr = form1_do();
				else if(passForm == "form2")
					searchstr = form2_do();
				else if(passForm == "form3")
					searchstr = form3_do();
				else if(passForm == "form4")
					searchstr = form4_do();
				else if(passForm == "form5")
					searchstr = form5_do();
				else if(passForm == "form6")
					searchstr = form6_do();
				//if(searchstr == "")
					//searchstr = '';
				//alert(country);
        if (url.substring(0, 4) != 'http') {
                url = base_url + url + searchstr;
        }

        // Create new JS element
        var jsel = document.createElement('SCRIPT');
        jsel.type = 'text/javascript';
        jsel.src = url;
        // Append JS element (therefore executing the 'AJAX' call)
        document.body.appendChild (jsel);
				
				//alert (url);
}

/***********************************************
* 
*  create urls str from form values
* 
***********************************************/

function form_do () {

	var str = "?results=true"; 
	//var theForm = "document."+theFrm+".elements[]";
		
	frmLength = document.form1.length;

	isEmpty = false;

	for (i=0; i<frmLength;i++){
					
    if(document.form1[i].value != "" && document.form1[i].value != "Filter List")
		{
	    //if(document.form1[i].value != "Filter List")
  	    str +=  "&" + document.form1[i].name + "=" + escape(document.form1[i].value); 
			//alert('value: ' + document.form1[i].name + '!\n');
		}
	}
			return str;

}

function form1_do () {

	var str = "?results=true"; 
	//var theForm = "document."+theFrm+".elements[]";
		
	frmLength = document.form1.length;

	isEmpty = false;

	for (i=0; i<frmLength;i++){
					
    if((document.form1[i].value != "" && document.form1[i].value != "Go") )
		{
			if(document.form1[i].type == "checkbox")
			{
		    if(document.form1[i].checked==true )
	  	    str +=  "&" + document.form1[i].name + "=" + escape(document.form1[i].value); 
			
			}
			else
			{
	    //if(document.form1[i].value != "Filter List")
  	    str +=  "&" + document.form1[i].name + "=" + escape(document.form1[i].value); 
			//alert('value: ' + document.form1[i].name + '!\n');
			}
		}
	}
			return str;

}
function form2_do () {

	var str = "?results=true"; 
	//var theForm = "document."+theFrm+".elements[]";
		
	frmLength = document.form2.length;

	isEmpty = false;

	for (i=0; i<frmLength;i++){
					
    if((document.form2[i].value != "" && document.form2[i].value != "Go") )
		{
			if(document.form2[i].type == "checkbox")
			{
		    if(document.form2[i].checked==true )
	  	    str +=  "&" + document.form2[i].name + "=" + escape(document.form2[i].value); 
			
			}
			else
			{
	    //if(document.form2[i].value != "Filter List")
  	    str +=  "&" + document.form2[i].name + "=" + escape(document.form2[i].value); 
			//alert('value: ' + document.form2[i].name + '!\n');
			}
		}
	}
			return str;

}
function form3_do () {

	var str = "?results=true"; 
	//var theForm = "document."+theFrm+".elements[]";
		
	frmLength = document.form3.length;

	isEmpty = false;

	for (i=0; i<frmLength;i++){
					
    if((document.form3[i].value != "" && document.form3[i].value != "Go") )
		{
			if(document.form3[i].type == "checkbox")
			{
		    if(document.form3[i].checked==true )
	  	    str +=  "&" + document.form3[i].name + "=" + escape(document.form3[i].value); 
			
			}
			else
			{
	    //if(document.form3[i].value != "Filter List")
  	    str +=  "&" + document.form3[i].name + "=" + escape(document.form3[i].value); 
			//alert('value: ' + document.form3[i].name + '!\n');
			}
		}
	}
			return str;

}
function form4_do () {

	var str = "?results=true"; 
	//var theForm = "document."+theFrm+".elements[]";
		
	frmLength = document.form4.length;

	isEmpty = false;

	for (i=0; i<frmLength;i++){
					
    if((document.form4[i].value != "" && document.form4[i].value != "Go") )
		{
			if(document.form4[i].type == "checkbox")
			{
		    if(document.form4[i].checked==true )
	  	    str +=  "&" + document.form4[i].name + "=" + escape(document.form4[i].value); 
			
			}
			else
			{
	    //if(document.form3[i].value != "Filter List")
  	    str +=  "&" + document.form4[i].name + "=" + escape(document.form4[i].value); 
			//alert('value: ' + document.form3[i].name + '!\n');
			}
		}
	}
			return str;

}
function form5_do () {

	var str = "?results=true"; 
	//var theForm = "document."+theFrm+".elements[]";
		
	frmLength = document.form5.length;

	isEmpty = false;

	for (i=0; i<frmLength;i++){
					
    if((document.form5[i].value != "" && document.form5[i].value != "Go") )
		{
			if(document.form5[i].type == "checkbox")
			{
		    if(document.form5[i].checked==true )
	  	    str +=  "&" + document.form5[i].name + "=" + escape(document.form5[i].value); 
			
			}
			else
			{
	    //if(document.form3[i].value != "Filter List")
  	    str +=  "&" + document.form5[i].name + "=" + escape(document.form5[i].value); 
			//alert('value: ' + document.form3[i].name + '!\n');
			}
		}
	}
			return str;

}
function form6_do () {

	var str = "?results=true"; 
	//var theForm = "document."+theFrm+".elements[]";
		
	frmLength = document.form6.length;

	isEmpty = false;

	for (i=0; i<frmLength;i++){
					
    if(document.form6[i].value != "" && document.form6[i].value != "Go")
		{
	    //if(document.form6[i].value != "Filter List")
  	    str +=  "&" + document.form6[i].name + "=" + escape(document.form6[i].value); 
			//alert('value: ' + document.form6[i].name + '!\n');
		}
	}
			return str;

}


/***********************************************
* 
*  Handle spans
* 
***********************************************/

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var memoryduration="7" //persistence in # of days

var contractsymbol='images/minus.gif' //Path to image to represent contract state.
var expandsymbol='images/plus.gif' //Path to image to represent expand state.

/////No need to edit beyond here //////////////////////////

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}


function expandrow(curobj, cid){
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : ""
curobj.src=(document.getElementById(cid).style.display=="none")? expandsymbol : contractsymbol
}


/***********************************************
* 
* Bubble Code
* 
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="images/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

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

function ddrivetip(thetext, thewidth, thecolor){
//alert(thetext);
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip




//  Handle folder mouseovers
if (document.images) {
 img_on =new Image();  img_on.src ="images/1.gif"; 
 img_off=new Image();  img_off.src="images/2.gif"; 

 img1_on =new Image(); img1_on.src ="images/111.gif"; 
 img1_off=new Image(); img1_off.src="images/112.gif"; 

 img2_on =new Image(); img2_on.src ="images/121.gif"; 
 img2_off=new Image(); img2_off.src="images/122.gif"; 

 img3_on =new Image(); img3_on.src ="images/131.gif"; 
 img3_off=new Image(); img3_off.src="images/132.gif"; 

 img4_on =new Image(); img4_on.src ="images/141.gif"; 
 img4_off=new Image(); img4_off.src="images/142.gif"; 

 img5_on =new Image(); img5_on.src ="images/151.gif"; 
 img5_off=new Image(); img5_off.src="images/152.gif"; 

 img6_on =new Image(); img6_on.src ="images/161.gif"; 
 img6_off=new Image(); img6_off.src="images/162.gif"; 
}

function movr(k) {
 if (document.images) 
  eval('document.img'+k+'.src=img'+k+'_on.src');
}

function mout(k) {
 if (document.images) 
  eval('document.img'+k+'.src=img'+k+'_off.src');
}

function handleOver() {
 if (document.images) 
  document.imgName.src=img_on.src;
}

function handleOut() {
 if (document.images) 
  document.imgName.src=img_off.src;
}



/***********************************************
* 
* Rollover Checkbox
* 
***********************************************/
//var thebox=document.form

function rollcheck(whichbox){
document.getElementById(whichbox).checked=true
//alert(whichbox);
}
function rolluncheck(whichbox){
document.getElementById(whichbox).checked=false
}

function rollovercheck(whichbox){
thebox.ACTIONBOX[whichbox].checked=true
}

function rolloutcheck(whichbox){
thebox.ACTIONBOX[whichbox].checked=false
}

/***********************************************
* 
*  Next Prev code
* 
***********************************************/

function GoNext(whichform){
	document[whichform].thispage.value=document[whichform].nextpage.value;
}
function GoPrev(whichform){
	document[whichform].thispage.value=document[whichform].prevpage.value;
}



/***********************************************
* 
*  Add Remove from queue
* 
***********************************************/
var addQsymbol='images/open_folder.gif' //Path to image to represent contract state.
var removeQsymbol='images/closed_folder.gif' //Path to image to represent expand state.


function changeQRem(curobj){
//document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : ""
//curobj.src=(document.getElementById(cid).style.display=="none")? addQsymbol : removeQsymbol
document[curobj].src="images/closed_folder.gif";
document[curobj].alt="Remove from Queue";
alert("Added to Queue!");
//document.getElementById(swaplnk).href = '<?echo $escqlink?>';
//curobj.src=removeQsymbol
}
function changeQAdd(curobj,linkname){
//document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : ""
//curobj.src=(document.getElementById(cid).style.display=="none")? addQsymbol : removeQsymbol
document[curobj].src="images/open_folder.gif";
document[curobj].alt="Add to Queue";
//document.getElementById(swaplnk).href = '<?echo $escqlink?>';
//curobj.src=removeQsymbol
}
function AddQueue(img_name,img_src) {
document[img_name].src=img_src;
//document.rollover.src=='';
}


/***********************************************
* 
*  trigger action box 
* 
***********************************************/
function goAction(whichform)
{
	//alert(whichform);
	box=document[whichform].actionID;
	//box = document.forms[1].actionID;
	destination = box.options[box.selectedIndex].value;
	if (destination)
	{
	run_EPSengine(destination,whichform);
	 //alert(destination);
	}
	//if (destination) location.href = destination;
}
