
function OpenSmallWindow(page) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  var left = myWidth/2 - 200;
  var top = myHeight/2 - 150;
    
  window.open(page, '', 'width=400,height=300,left='+left+',top='+top+',status=no,location=no,help=no');
}

function Recommend()
{
    OpenSmallWindow('/Popup/AddRecommend.aspx');
}
function EmployerPassword()
{
	OpenSmallWindow('/Popup/EmployerPassword.aspx');
}
function UserPassword()
{
	OpenSmallWindow('/Popup/UserPassword.aspx');
}

function SMSRules()
{
	OpenSmallWindow('/Popup/SMSRules.aspx');
}

function CheckPassword(sender, args)
{
	var ilen = args.Value.length;
			
	if (ilen>=6 && ilen<=10)
		args.IsValid = true;
	else
		args.IsValid = false;
}


function SendResume()
{
	window.location.href="/users/";
}

function SendToFriend(jobnum)
{
	OpenSmallWindow("/Popup/SendToFriend.aspx?ID="+jobnum);
}

function PrintSecondSelectMembers(firstSelectID,secondSelectID,secondArray,opnName)
{
		var firstSelectName = document.forms[0].elements[firstSelectID];
		var secondSelectName = document.forms[0].elements[secondSelectID];

		var selMakeIndex = firstSelectName.selectedIndex;
		var selMake = firstSelectName.options[selMakeIndex].value;

		secondSelectName.options.length = 0;
		secondSelectName.options[0] = new Option(opnName, "0");
		var secIndex = 1;

		for (var i=0;i<secondArray.length;i++)
		{
			if (selMake == secondArray[i][0])
			{
				secondSelectName.options[0] = new Option(opnName, "0");
				for (var j=1;j<secondArray[i].length;j=j+2)
				{
					secondSelectName.options[secIndex] =
						new Option (secondArray[i][j+1], secondArray[i][j]);
					secIndex++;
				} // for j
			}
		} // for i
			 
		secondSelectName.selectedIndex = 0;
		secondSelectName.disabled = false;
}


function SetSecondSelect(secondSelectID,selectedValues)
{
	var secondSelectName = document.forms[0].elements[secondSelectID];
	var sel_array = selectedValues.split(",");
	
	secondSelectName.options[0].selected = false;

	for (var j=0;j<sel_array.length;j++)
	{
		for (var i=0;i<secondSelectName.options.length;i++)
		{
			if (secondSelectName.options[i].value == sel_array[j])
			{
				secondSelectName.options[i].selected = true;
			}
		}

	}
	
}

function fnTrapKD(btnID, event){
btn = findObj(btnID);
if (document.all){
if (event.keyCode == 13){
event.returnValue=false;
event.cancel = true;
btn.click();
}
}
else if (document.getElementById){
if (event.which == 13){
event.returnValue=false;
event.cancel = true;
btn.focus();
btn.click();
}
}
else if(document.layers){
if(event.which == 13){
event.returnValue=false;
event.cancel = true;
btn.focus();
btn.click();
}
}
}

function findObj(n, d) { 
	var p,i,x;  
	if(!d) 
		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=findObj(n,d.layers[i].document);
	if(!x && d.getElementById) 
		x=d.getElementById(n); 
	return x;
}

function createCookie(name,value,days) 
{
	var expires = "";
	if(days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function createCookieForDomain(name,value,days,domain)
{	
	var expires = "";
	if(days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}	
	document.cookie = name+"="+value+expires+"; path=/; domain="+domain;
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function elementExists(arr,val) 
{
	var exists = false;
	
	for(var i=0;i<arr.length;i++)
	{
		if (arr[i] == val) 
		{
			exists = true;
			break;
		}
	}
	return exists;
}

function AddJobToCookie(jobID)
{
	var jobs = readCookie('slctjobs');
	
	if (jobs != null)
	{
		var arr = jobs.split(",");
		
		if (!elementExists(arr,jobID))
			jobs += ("," + jobID);
	}
	else
		jobs = jobID;	
	
	createCookie('slctjobs',jobs,10);
}

function DeleteJobFromCookie(jobID)
{
	var jobs = readCookie('slctjobs');
	
	if (jobs != null)
	{
		var newjobs="";
		var arr = jobs.split(",");

		for(var i=0;i<arr.length;i++)
		{
			if (arr[i]!=jobID)
			{
				if (newjobs!="")
					newjobs+=",";
				
				newjobs+=arr[i];
			}
		}

	    createCookie('slctjobs',newjobs,10);
	}
}

function chkJob(chkObj)
{
	var jobID = chkObj.name.substr(4);
	
	if(chkObj.checked)
		AddJobToCookie(jobID);
	else
		DeleteJobFromCookie(jobID);
}

function SelectMarkedJobs()
{
	var jobs = readCookie('slctjobs');
	if (jobs != null)
	{
		var arr = jobs.split(",");

		for(var i=0;i<arr.length;i++)
		{
			var chkObj = document.getElementById('job_'+arr[i]);

			if (chkObj != null)
				chkObj.checked=true;
		}
	}
}

function AddOneJob(jobID)
{
	AddJobToCookie(jobID);
	SendResume();
}

function DisplayFooterBanner() {
    var w;
    var divBan = document.getElementById('bannerLeft');
    if (divBan) {
        w=document.body.clientWidth/2-505;
        divBan.style.left=w+'px';
        divBan.style.display='block';
    }

    divBan = document.getElementById('bannerRight');
    if (divBan) {
        w = document.body.clientWidth / 2 + 385;
        divBan.style.left = w + 'px';
        divBan.style.display = 'block';
    }
   
    
}

window.onload=DisplayFooterBanner;
window.onresize=DisplayFooterBanner;

