//define animation

function mainMenu(){

//collapse/expand menus
	var sections = new Array("home","about-us","job-search","clients","candidates","join-freedom","contact-us");
	var expansion = 0;
	var items = 0;
	var itemCount = 0;
	
	//loop through sections
	for(i=0; i<sections.length; i++){
		c_section = sections[i];	
		if(document.getElementById(c_section)){
			if(sections[i] != section){
				//if its not the right section set to hide class
				document.getElementById(c_section).className = "hide";
			}else{
				//if it is then set to show class
				document.getElementById(c_section).className = "show";
				items = document.getElementById(c_section).childNodes;
				//count the number of sub links
				for(n=0; n<items.length; n++){
					//alert(items[n].nodeName);
					if(items[n].nodeName == "LI"){
						itemCount++;	
					}
				}
			}
		}
	}
	
	//use the sub link count to push the menu up into the right place
	//note the height difference between browsers
	if(BrowserDetect.browser == "Explorer"){
		expansion = 18 * itemCount;
		document.getElementById('latest-jobs').style.marginBottom = (73 - expansion) + 'px';
	} else {
		expansion = 17 * itemCount;
		document.getElementById('latest-jobs').style.marginBottom = (69 - expansion) + 'px';
	}
	
	//highlight current section
	if(window.section && document.getElementById("nav-" + section)){
		document.getElementById("nav-" + section).className = "on";
	}
	
	//highlight current sub section
	if(window.sub_section && document.getElementById("nav-" + sub_section)){
		document.getElementById("nav-" + sub_section).className = "on";
	}

}

function showDate(){
		
		dateDayHolder = document.getElementById ? document.getElementById("date-day") : document.all.date-day;
		dateTimeHolder = document.getElementById ? document.getElementById("date-time") : document.all.date-time;
		
		var myDate=new Date()
		var day = myDate.getDay();
		var date = myDate.getDate();
		var month = myDate.getMonth();
		var year = myDate.getFullYear();
		var hours = myDate.getHours();
		var minutes = myDate.getMinutes();
		var seconds = myDate.getSeconds();
		
		var month_names = new Array ( );
		month_names[month_names.length] = "Jan";
		month_names[month_names.length] = "Feb";
		month_names[month_names.length] = "Mar";
		month_names[month_names.length] = "Apr";
		month_names[month_names.length] = "May";
		month_names[month_names.length] = "Jun";
		month_names[month_names.length] = "Jul";
		month_names[month_names.length] = "Aug";
		month_names[month_names.length] = "Sep";
		month_names[month_names.length] = "Oct";
		month_names[month_names.length] = "Nov";
		month_names[month_names.length] = "Dec";
		
		var day_names = new Array ( );
		day_names[day_names.length] = "Sun";
		day_names[day_names.length] = "Mon";
		day_names[day_names.length] = "Tue";
		day_names[day_names.length] = "Wed";
		day_names[day_names.length] = "Thu";
		day_names[day_names.length] = "Fri";
		day_names[day_names.length] = "Sat";
		
		if (minutes <= 9){
			minutes = "0" + minutes;
		}
		if (seconds <= 9){
			seconds = "0" + seconds;
		}
		var myTime = hours + "." + minutes + "." + seconds;
		var myDay = day_names[day] + " " + date + " " + month_names[month] + " " + year;

		dateDayHolder.innerHTML = myDay;
		
		if(BrowserDetect.browser == "Explorer"){
			dateTimeHolder.innerHTML = myTime;
			setTimeout("showDate()",1000);
		}
}
window.onload = showDate;

function goAnimate(){
   //alert("loaded");
   //animates elements - only run first three on home page
	if(section == ""){
		animate_tagline.animate();
		animate_decor.animate();
		animate_cloud.animate();
	}
	if(executive != true){
		animate_person.animate();
	}
	animate_grass.animate();

}

window.onload = goAnimate;


function testimonials(text,pos,action){
	//make the pointer react to the users movement and clicking	on the logos
	
	document.getElementById("testimonial").className = action;
	document.getElementById("pointer").className = action;
	document.getElementById("pointer").style.backgroundPosition = pos + "%";
	
	
	document.getElementById("text-" + text).className = action;
	
	if(action == "show"){
	document.getElementById("text-" + text).style.visibility = "visible";
	} else {
	document.getElementById("text-" + text).style.visibility = "hidden";
	}
	
}

function popup( targetURL, winWidth, winHeight,target ) {

	var winName = target;
	//var winWidth = "";
	//var winHeight = "";
	var	winScroll = "yes";
	var winCenter = "";
	
	
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (winCenter)){
        xposition = (screen.width - winWidth) / 2;
        yposition = (screen.height - winHeight) / 2;
    }
    args = "width=" + winWidth + ","
    + "height=" + winHeight + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=1,"
    + "scrollbars=" + winScroll + ","
    + "status=0,"
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only
	
	var myWin = window.open( targetURL, winName, args);
	myWin.focus();
	
}

function spawn(url)	{
  
 
  
var features = "width=750px,height=440px,resizable=yes,scrollbars=yes,toolbar=no,menubar=no";
 
var windowName = "editWindow";
 
 
var detailsWin = window.open(url,windowName,features);
 
  
  
  
}
  
  
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


/*------------------------------------------------------------------------------
  cookie functions
------------------------------------------------------------------------------*/

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return null;
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}



function getJobId(string,parm) {
    // returns value of parm from string
	
		 
var string = location.pathname;
	 
	//alert(job_id);
	 
	 //alert(string);
	//alert(document.form.autoapply.value);
	
	
    var startPos = string.indexOf("=");
	var job_id;
    if (startPos > -1) {
        startPos = startPos +  1;
		 
        var endPos = string.indexOf("&",startPos);
        if (endPos == -1)
            endPos = string.length;
      job_id =  unescape(string.substring(startPos,endPos));
    }
  //  return '';
  
 
	//alert(job_id);
	document.f1.job_id.value = job_id;
	 
  
}

 function disableButton(div)
 {
 
  document.getElementById(div).style.display= "none";
  
  //alert(document.getElementById(div).style.display);
 
 
 }


 

 

	 

