
/*
	These functions are used for the print version to provide additional information
*/
//declare variables:
var date, pageRef, curYear;

function getCurrentDate(){
	var now = new Date();
	date = now.toLocaleDateString();
	return date;
}
function getPage(){
	pageRef = document.location.href;
	return pageRef;
}
function getCurYear(){
	var now = new Date();
	return now.getFullYear();
}

/*--------- This is the start of the Breadcrumb script ---------*/

function breadCrumbs(base, delStr, defp, cStyle, tStyle, dStyle, nl) {
    loc = window.location.toString();
    subs = loc.substr(loc.indexOf(base) + base.length + 1).split("/");
    document.write("<a href=\"" + getLoc(subs.length - 1) + defp + "\" class=\"" + cStyle + "\">Home</a>  " + "<span class=\"" + dStyle + "\">" + delStr + "</span> ");
    a = (loc.indexOf(defp) == -1) ? 1 : 2;
    for (i = 0; i < (subs.length - a); i++) {
        subs[i] = makeCaps(unescape(subs[i]));
        document.write("<a href=\"" + getLoc(subs.length - i - 2) + defp + "\" class=\"" + cStyle + "\">" + subs[i] + "</a>  " + "<span class=\"" + dStyle + "\">" + delStr + "</span> ");
    }
    if (nl == 1) {
        document.write("<br>");
    }
    document.write("<span class=\"" + tStyle + "\">" + document.title + "</span>");
}

function makeCaps(a) {
    g = a.split(" ");
    for (l = 0; l < g.length; l++) {
        g[l] = g[l].toUpperCase().slice(0, 1) + g[l].slice(1);
    }
    return g.join(" ");
}
 
function getLoc(c) {
    var d = "";
    if (c > 0) {
        for (k = 0; k < c; k++) {
            d = d + "../";
        }
    }
    return d;
}


/* ----------        Date last modified script   ---------- */

function date_ddmmmyy(date)
{
  var d = date.getDate();
  var m = date.getMonth() + 1;
  var y = date.getYear();


  if(y >= 2000)
  {
    y -= 2000;
  }
  if(y >= 100)
  {
    y -= 100;
  }

  // could use splitString() here 
  // but the following method is 
  // more compatible
  var mmm = 
    ( 1==m)?'Jan':( 2==m)?'Feb':(3==m)?'Mar':
    ( 4==m)?'Apr':( 5==m)?'May':(6==m)?'Jun':
    ( 7==m)?'Jul':( 8==m)?'Aug':(9==m)?'Sep':
    (10==m)?'Oct':(11==m)?'Nov':'Dec';

  return "" +
    (d<10?"0"+d:d) + "-" +
    mmm + "-" +
    (y<10?"0"+y:y);
}


function date_lastmodified()
{
  var lmd = document.lastModified;
  var s   = "Unknown";
  var d1;

  // check if we have a valid date
  // before proceeding
  if(0 != (d1=Date.parse(lmd)))
  {
    s = "" + date_ddmmmyy(new Date(d1));
  }

  return s;
}

function displayDate()
{
document.write( '<span class="modified">This page was updated on ' + 
  date_lastmodified() + '</span>' );
}


/* ---------- Javascript to switch the style sheets ---------- */

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

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;
}

window.onload = function(e) {
  var cookie = readCookie("veisstyle");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("veisstyle", title, 365);
}

var cookie = readCookie("veisstyle");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


/* This js shows or hides any div using an id and this script*/

function hidediv(id) {
	//safe function to hide an element with a specified id
		document.getElementById(id).style.display = 'none';
		window.location.href = "#header";
}
								 

function showdiv(id) {
	//safe function to hide an element with a specified id

		document.getElementById(id).style.display = 'block';


		if((id) != "aeroskills" && (id) != "animal" && (id) != "auto" && (id) != "business" && (id) != "caravan" && (id) != "careSupport" && (id) != "community" && (id) != "conservation" && (id) != "electro" && (id) != "engineering" && (id) != "entertainment" && (id) != "food" && (id) != "horticulture" && (id) != "hospitality" && (id) != "infotech" && (id) != "meat" && (id) != "processManufaturing" && (id) != "printing" && (id) != "property" && (id) != "retail" && (id) != "rural" && (id) != "sportandrec" && (id) != "tourism" && (id) != "transport" && (id) != "pharmacy" && (id) != "beauty"&& (id) != "pharmacy" && (id) != "beauty" && (id) != "furnishing" && (id) != "lab" && (id) != "tele")
		{	
		document.getElementById(id).style.backgroundColor = '#FFFFE5';
		}

		var link = "#" + id
		window.location.href = link;
		

}



function hovershow(id) {
	
	document.getElementById(id).style.visibility = 'visible';
	document.getElementById(id).style.backgroundColor = '#FF9900';

}
	
function hoverclose(id) {
	
	document.getElementById(id).style.visibility = 'hidden';
	document.getElementById(id).style.backgroundColor = '#ffffff';

}


var idjobsAlive=new Array('a', 'b', 'd', 'f', 'g', 'h', 'j', 'o', 'q', 's', 't', 'x');


function hideallids(array){
	//loop through the array and hide each element by id
	for (var i=0;i<(array).length;i++){
		hidediv((array)[i]);
	}		  
}

function showallids(array){
	//loop through the array and hide each element by id
	for (var i=0;i<(array).length;i++){
		document.getElementById((array)[i]).style.display = 'block';
		
	}		  
}

function imageswap(id) {
	document.getElementById(id).style.display = 'block';
}
function imagereturn(id) {
	document.getElementById(id).style.display = 'none';
}
function traineeshipimage() {

	var e = document.getElementById('testjavascript'); 
	e.innerHTML = "<img src='file:///F|/web/pmri/images/sbtImages/traineeships2.jpg' />";
	//document.getElementById('hidetext').style.display = 'none';
	
}
