function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}

function populateSector(myIndex) {
  mySectors = specificSector[myIndex];
  sectorField = document.searchForm.specificSector;
  sectorField.options.length = 0;
  for (x=0; x<mySectors.length; x++) {
      sectorField.options[sectorField.options.length] = new Option (mySectors[x], mySectors[x]);
  }
  sectorField.options[0].selected = true;
  if (sectorField.options[0].value == "(select a general career area first)") {
    sectorField.disabled = true;
  } else {
    sectorField.disabled = false;
  }
}

function populateGeneral() {
  generalField = document.searchForm.genCareer;
  generalField.options.length = 0;
  for (x=0; x<genCareer.length; x++) {
    generalField.options[generalField.options.length] = new Option (genCareer[x], genCareer[x]);
  }
  generalField.options.selectedIndex = 0;
}

function setMenus(f) {
  if (navigator.SCgenCareer && f.genCareer) { 
    f.genCareer.options.selectedIndex = navigator.SCgenCareer;
    populateSector(navigator.SCgenCareer);
  }
  if (navigator.SCspecificSector && f.specificSector)
    f.specificSector.options.selectedIndex = navigator.SCspecificSector;
  if (navigator.SCinstitution && f.institution)
    f.institution.options.selectedIndex = navigator.SCinstitution;
  if (navigator.SCqualification && f.qualification)
    f.qualification.options.selectedIndex = navigator.SCqualification;
  if (navigator.SCtype && f.type)
    f.type.options.selectedIndex = navigator.SCtype;
}

function setGlobalVar(theVar,theValue) {
  if (theVar == 'genCareer') {
    navigator.SCgenCareer = theValue;
    navigator.SCspecificSector = null;
  }
  if (theVar == 'specificSector')
    navigator.SCspecificSector = theValue;
  if (theVar == 'institution')
    navigator.SCinstitution = theValue;
  if (theVar == 'qualification')
    navigator.SCqualification = theValue;
  if (theVar == 'type')
    navigator.SCtype = theValue;
}

// scottish clearing cookies

function setCookie(name, value, path, expires, 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 dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1)
  {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
  if (getCookie(name))
  {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function get_page_ad_source()
{
    var source = '';
	var doc = document;
    
    if ( doc.location == null ) { return 's1clearing-global' }

    if ( doc.location.hostname.indexOf('clearing') != -1 && doc.location.pathname.indexOf('search') == -1 )
	{
	    source = 's1clearing-';
	    var testRE = new RegExp ( "(/[^/]*/?)", "i" );
	    switch ( doc.location.pathname.match(testRE)[0] )
		{
		    case "/" :  source += 'home'; break;
			case "/index.shtml" :  source += 'home'; break;
			case "/2005.shtml" :  source += 'home'; break;
			case "/2006.shtml" :  source += 'home'; break;
			default: source += 'global'; break;
		}
    }		
	
	
    if ( doc.location.pathname.indexOf('search') != -1 )
	{
	   source = 's1clearing-';
	   var thisURL = doc.location.search;
	   var thisURL = thisURL.replace(/^.*genCareer=([^&;]+).*$/, "$1");
	    if (thisURL && thisURL != "")
        thisURL = thisURL.replace(/[^a-z0-9]+/ig, "_");
		if (thisURL && thisURL != "")
        thisURL = thisURL.toLowerCase();
	    source +=  thisURL;
	}	
	
    if(source == '') { source = 's1clearing-global'; }
	
    return source;

}

//==================================




// new OAS stuff - July 08

	OAS_url = 'http://oas.newsquestdigital.co.uk/RealMedia/ads/';
	//var source = 's1homes-global';
	//source = get_page_ad_source();
    OAS_sitepage = 'www.scottishclearing.org/';

	if(OAS_sitepage.charAt(OAS_sitepage.length - 1) == '/')
	OAS_sitepage += 'index.php';
	OAS_listpos = 'Top,Right,x01,x02,x03,x04,x05,x06,x07,x08';
	//end of configuration
	OAS_version = 10;
	OAS_rn = new String (Math.random()); 
	OAS_rns = OAS_rn.substring (2, 11);

	function OAS_NORMAL(pos) {
		document.write('<a href="' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '">');
		document.write('<img src="' + OAS_url + 'adstream_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '" border="0" alt="Advert" /></a>');
	}

	
	
	
	OAS_version = 11;
	if (navigator.userAgent.indexOf('Mozilla/3') != -1 || navigator.userAgent.indexOf('Mozilla/4.0 WebTV') != -1)
	OAS_version = 10;
	if (OAS_version >= 11)
	document.write('<SCR' + 'IPT LANGUAGE=JavaScript1.1 SRC="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '"><\/SCR' + 'IPT>');
	//  document.write('"' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '"');

	
	
	function OAS_AD(pos) {
		if (OAS_version >= 11)
		OAS_RICH(pos);
		else
		OAS_NORMAL(pos);
	}
	
// END















