function findObj(n){
var p,i,x,d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){
d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n];for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n);return x;
}

var mainMenuRolled=null,timeOn=null;

function showObj(o,v)
{
	if(o)o.style.visibility=(v==0)?'hidden':'visible';
}

function mainMenuHide()
{
	mainMenuRolled.onmouseout=null;
	mainMenuRolled.onmouseover=null;
	showObj(mainMenuRolled,0);
	mainMenuRolled=null;
}

function mainMenuTouch()
{
	clearTimeout(timeOn);
}

function mainMenuOut()
{
	timeOn=setTimeout("mainMenuHide()", 400);
}

function mainMenuHover(n)
{
	if(mainMenuRolled)
		mainMenuHide();

	if(!n)return;

	mainMenuTouch();

	mainMenuRolled=findObj(n);
	if(!mainMenuRolled)return;

	showObj(mainMenuRolled,1);
	mainMenuRolled.onmouseover=mainMenuTouch;
	mainMenuRolled.onmouseout=mainMenuOut;
}

function confirmAction(str)
{
	return confirm(str);
}

function limitInputLength(o,maxLength)
{
	if(o.value.length > maxLength)
		o.value=o.value.substring(0,maxLength);
}

function showDiv(id,style)
{
	if(document.getElementById)
		var s=document.getElementById(id).style;
	else if(document.all)
		var s=document.all[id].style;
	else if(document.layers)
		var s=document.layers[id].style;
	else
		return;

	if(style)
	{
		s.display=style;
		return;
	}

	if(s.display=='none' || s.display=='')
		s.display="block";
	else
		s.display="none";
}

function window_width()
{
	var w=500;
	if(typeof(window.innerWidth)=='number')
		w=window.innerWidth;
	else if(document.documentElement && document.documentElement.clientWidth)
		w=document.documentElement.clientWidth;
	else if(document.body && document.body.clientWidth)
		w=document.body.clientWidth;
	return w;
}

function window_height()
{
	var h=500;
	if(typeof(window.innerHeight)=='number')
		h=window.innerHeight;
	else if(document.documentElement && document.documentElement.clientHeight)
		h=document.documentElement.clientHeight;
	else if(document.body && document.body.clientHeight)
		h=document.body.clientHeight;
	return h;
}

function show_help(its_id,its_width,its_height)
{
	var req=getRequestObj();
	req.open('GET', '../help-get.php?id='+its_id, true);

	req.onreadystatechange=function()
	{
		if((req.readyState == 4) && (req.status == 200))
		{
			findObj('help_window_html').innerHTML=req.responseText;
			findObj('help_window').style.width=its_width+'px';
			showDiv('help_window','block');
		}
	}
	req.send(null);
}

function show_help_html(zhtml,its_width,its_height,obj,e)
{
	var p=get_mouse_pos(e);	
	findObj('help_window_html').innerHTML=zhtml;
	findObj('help_window').style.width=its_width+'px';
	findObj('help_window').style.position = "absolute";
	showDiv('help_window','block');
	//alert(p.px  - (screen.offsetLeft + obj.offsetWidth - findObj('help_window').style.width));
	//p.px = parseInt(parseInt(screen.width/2)+parseInt(findObj('help_window').offsetWidth/2)-parseInt(p.px));
	//alert(findObj('help_window').offsetWidth);
	//alert(p.px);
	findObj('help_window').style.top=p.py+'px';
	findObj('help_window').style.left=p.px+'px';
}


function getRequestObj()
{
	try
	{
		return(new XMLHttpRequest());
	}
	catch(error)
	{
		try
		{
			return(new ActiveXObject("Microsoft.XMLHTTP"));
		}
		catch(error)
		{
			return false;
		}
	}
}

function get_mouse_pos(e)
{
	if(!e) e=window.event;

	var p=new Object();

  if(e)
  {
    if(e.pageX || e.pageY)
    {
      p.px = e.pageX;
      p.py = e.pageY;
    }
    else if(e.clientX || e.clientY)
    {
      p.px = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
      p.py = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
    }
  }

  return p;
}

function find_div(id)
{
	if(document.getElementById)
		return document.getElementById(id);
	else if(document.all)
		return document.all[id];
	else if(document.layers)
		return document.layers[id];
	else
		return;
}


function focus_descriptive_text()
{
	var f = document.profile_form;
	if (f.descriptive_text.value == "Enter or cut and paste your resume, cover letter etc. or type directly in the text box" )
	{
		f.descriptive_text.value = "";
	}
}


function print_textarea(tarea,width,height) {

	var s = tarea;
	var regExp=/\n/gi;
	s = s.replace(regExp,'<br>');

	print_win=window.open('','Page_Title','scrollbars=yes,toolbar=no,resizable=yes,status=no,width='+width+',height='+height+',top='+((screen.availHeight/2)-(height/2))+',left='+((screen.availWidth/2)-(width/2))+',directores=no');
	print_win.document.open();
	print_win.document.write('<html><head></head><body>');
	print_win.document.write(s);
	print_win.document.write('</body></html>');
	print_win.document.close();
	print_win.focus();
	print_win.window.print();
	print_win.close();
}

function fill_provinces(selCountry)
{
   var pr_div=findObj('provinces_to_search');

   if(!selCountry)
   {
      if(iCountry.selectedIndex == 0)
      {
         pr_div.innerHTML='';
         return;
      }

      selCountry=iCountry.value;
   }

   var req=getRequestObj();

   req.open('GET', '../province-get.php?id='+selCountry, true);

   req.onreadystatechange = function()
   {
      if((req.readyState == 4) && (req.status == 200))
      {
         var items=eval( 'new Array('+req.responseXML.getElementsByTagName('result')[0].firstChild.data+')' );

         prov_lookup.length=0;

         var html='<ul class="prList">\n';

         for(var n=0; n<items.length; n+=2)
         {
            html += "<li><input type=\"checkbox\" name=\"pr"+n/2+"\" value=\"" + items[n] + "\" onclick=\"fill_cities(this,this.value)\" />"+items[n+1]+"</li>\n";
            prov_lookup[items[n]]=items[n+1];
         }

         html += '</ul>';

         pr_div.innerHTML=html;
      }
   }
   req.send(null);
}

function fill_cities(o,selProvince)
{
   var pr_div=findObj('cities_to_search');

   var selProvDiv=findObj(selProvince);

   if(!o.checked)
   {
      pr_div.removeChild(selProvDiv);
      return;
   }

   var req=getRequestObj();

   req.open('GET', '../city-get.php?id='+selProvince, true);

   req.onreadystatechange = function()
   {
      if((req.readyState == 4) && (req.status == 200))
      {
         var items=eval( 'new Array('+req.responseXML.getElementsByTagName('result')[0].firstChild.data+')' );

         var html='<div id="'+selProvince+'" class="prDiv"><strong>'+prov_lookup[selProvince]+'</strong><ul class="prList">\n';

         for(var n=0; n<items.length; n+=2)
         {
            html += "<li><input type=\"checkbox\" name=\"pr"+n/2+"\" value=\"" + items[n] + "\" />"+items[n+1]+"</li>\n";
         }

         html += "</ul></div>\n";

         if(selProvDiv)
            selProvDiv.innerHTML=html;
         else
            pr_div.innerHTML+=html;
      }
   }
   req.send(null);
}

function checkboxes(FormName, FieldName, CheckValue)
{
   if(!document.forms[FormName])
      return;

   var o;

   for(var i=0; i<999; i++)
   {
      if( (o = document.forms[FormName].elements[(FieldName + i)]) )
         o.checked = CheckValue;
      else
         return;
   }
}
function inputboxFocus(field_id){

	document.getElementById(field_id).focus();
}


function viewEmployer(url) {

	window.open(url,'Employer Profile','width=500,height=500,resizable=1,status=1,scrollbars=1');
}

function check_all(cur_obj) {
		
	var flag = false;
	if(cur_obj.checked == true)
		flag = true;
		
	var obj = document.getElementsByTagName("input");
	
	for(var i=0; i<obj.length; i++) {
	
		if(obj[i].type =="checkbox" && obj[i].name.search("job_app_id") != -1) {
			obj[i].checked = flag
		}//	endif
	}//	endfor
}

function inboxSltNoneAll(flag) {
	
	var obj = document.getElementsByTagName("input");
	
	for(var i=0; i<obj.length; i++) {
	
		if(obj[i].type =="checkbox" && (obj[i].name.search("r_msg") != -1 || obj[i].name.search("ur_msg") != -1))
			obj[i].checked = flag;
	}
}

function inboxSltAll() {
	
}