﻿function checkdiv ()

{
var length = 9;	
  for (i = 0; i < length; i++)
  {
	document.getElementById("faq-"+i).className = "hide";
	
  }
}


function showhide(layer_ref)
{
  var mydiv = document.getElementById(layer_ref);
  
		if(mydiv.className == "hide")
		{
		  mydiv.className = "show";
		}
		else
		{
		 mydiv.className = "hide";	
		}

}



//swap the header image dependant on section
function swap()
 {
	if (image== "")
	{
      document['header-image'].src = "./images/headers/home.jpg";
	}
	else
	{
	    document['header-image'].src = "./images/headers/"+image+".jpg";	
    }
 }


function navigation(){

	//collapse/expand menus
	var sections = new Array("home","recruitment","what","how","benefits","why","testimonials", "contact");
	
	for(i=0; i<sections.length; i++){
		if(document.getElementById("sub-nav-" + sections[i])){
			if(window.main_nav && sections[i] != main_nav){
				document.getElementById("sub-nav-" + sections[i]).className = "hide";
			}else{
				document.getElementById("sub-nav-" + sections[i]).className = "show";
			}
		}
	}
	
	//highlight current location

    if(window.main_nav && document.getElementById("nav-" + main_nav)){
		document.getElementById("nav-" + main_nav).className = "on";
	}
	
	if(window.sub_nav && document.getElementById("nav-" + main_nav + "-" + sub_nav)){
		document.getElementById("nav-" + main_nav + "-" + sub_nav).className = "on";
	}

}




/*------------------------------------------------------------------------------
  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));
}