
/*
	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 ---------*/

var startPoint = 1; // idea from Hassan Schroeder

var sep = "&nbsp;&#187;&nbsp;"

var startName = "DET Internet";

var uppercase = "yes";
var allUppercase = "no";

var replaceSpecialCharacters = "yes";
var specialCharactersUpper = "yes";
var charactersToReplace = new Array (								 
	[ "directorates","&#187;"],
	[ "vetinschools","Vet in Schools"],
	[ "jobsalive","Jobs Alive"],
	[ "ta_profiles","Transition Adviser Profiles"],
	[ "sbvet","School Delivered VET"],
	[ "teachbusiness","Teachers in Business"],
	[ "t-three","T&sup3;"],
	[ "tvet","TVET"],
	[ "parentscommunity","Parents &amp; Community"],
	[ "vet","HSC&nbsp;VET"],
	[ "TIBexperiences","Experiences"],
	[ "TIBemployers","Employers"],
	[ "teacherguide","Teacher's Guide"],
	[ "rssfeed","RSS Feed"],
	[ "worklearn","Workplace Learning"],
	[ "businessindustry","Business &amp; Industry"],
	[ "profdev","Professional Development"],
	[ "schooltowork","School to Work"],
	[ "traineeships","Apprenticeships &amp; Traineeships"],
	[ "sbt","School based Traineeships"],
	[ "vet_schools","VEiS Home"],
	[ "about","About Us"],
	[ "_" , "&nbsp;" ],
	[ "-" , "&nbsp;" ]);

var endPoint = "title";

var d=document;
var url = d.location.href;
var endChar = url.substr(url.length-1);


url=url.replace("//","/");


var urlText = url;
var urlLinkArray=url.split('/');


if(startName=="domain")
{
	var y;
	startName="";
	for(x=0;x<startPoint;x++)
	{
		y=x+1;
		if(y>=1&&y<startPoint)
		{
			startName = startName + urlLinkArray[y] + "/";
		}

		else
		{
			startName = startName + urlLinkArray[y];
		}
	}
}

if(replaceSpecialCharacters == "yes")
{
	for(x=0;x<charactersToReplace.length;x++)
	{
		var myRegExp = new RegExp(charactersToReplace[x][0], "g");
		urlText = urlText.replace(myRegExp,charactersToReplace[x][1]);
	}
}

var urlTextArray=urlText.split('/');

var urlL = urlLinkArray.length;
var uppercaseText;
var lowercaseText;
var lcase;
var linkName=new Array();


if(uppercase=="yes"&&allUppercase=="no")
{
	if(replaceSpecialCharacters=="yes"&&specialCharactersUpper=="yes")
	{
		for(x=0;x<charactersToReplace.length;x++)
		{
			var myRegExp = new RegExp(charactersToReplace[x][1]+"[a-z]", "g");
			for(y=2;y<urlL;y++)
			{
				if(urlTextArray[y].search(myRegExp)!=-1)
				{
					var regExpArray = new Array();
					regExpArray = urlTextArray[y].match(myRegExp);
					for(z=0;z<regExpArray.length;z++)
					{
						
						if(urlTextArray[y].search(myRegExp)!=-1)
						{
							
							var lastLetter = regExpArray[z].substr(regExpArray[z].length-1,regExpArray.length).toUpperCase();
							
							var newText = charactersToReplace[x][1]+lastLetter;
							urlTextArray[y] = urlTextArray[y].replace(regExpArray[z],newText);
						}
					}
				}
			}
		}
	}

	for(x=2;x<urlL;x++)
	{
		uppercaseText=urlTextArray[x].substr(0,1).toUpperCase();
		lowercaseText=urlTextArray[x].substr(1, urlTextArray[x].length);
		linkName[x]=uppercaseText+lowercaseText;
	}
}

else if(allUppercase=="yes"||uppercase=="yes"&&allUppercase=="yes")
{
	for(x=2;x<urlL;x++)
	{
		linkName[x]=urlTextArray[x].toUpperCase();
	}
}

else{linkName=urlTextArray;lcase="yes";}

var start=urlLinkArray[0]+"//";

if(startPoint<1){startPoint=1;}

for(y=1;y<=startPoint;y++)
{
	start=start+urlLinkArray[y]+"/";
}

function createBreadcrumbs()
{
	if(lcase!="yes")
	{
		d.write('<a class="breadcrumbJava" href="'+start+'">'+startName+'</a>');
	}

	else
	{
		startName = startName.toLowerCase();
		d.write('<a class="breadcrumbJava" href="'+start+'">'+startName+'</a>');
	}
	
	
	if(urlL>2)
	{	
		for(x=startPoint+1;x<urlL;x++)
		{			
			if(x<urlL-1)
			{
				if(x==urlL-2&&linkName[urlL-1]=="")
				{
					if(endPoint=="directory")
					{
						d.write(sep+linkName[x]);
						break;
					}
					
					else
					{
						if(lcase!="yes")
						{
							d.write(sep+d.title);
							break;
						}

						else
						{
							var ttl = d.title.toLowerCase();
							d.write(sep+ttl);
							break;
						}						
					}
				}
				
				else
				{
					start=start+urlLinkArray[x]+"/";
					d.write(sep+'<a class="breadcrumbJava" href="'+start+'">'+linkName[x]+'</a>');
				}
			}
			
			else
			{
				start=start+urlLinkArray[x];
				if(endChar=="/")
				{
					d.write(sep+linkName[x]);
				}
				
				else
				{
					d.write(sep+"Here");
				}
			}
		}
	}
}


/* ----------        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='../../images/sbtImages/traineeships2.jpg' />";
	//document.getElementById('hidetext').style.display = 'none';
	
}

/*
 * QTObject embed
 * http://blog.deconcept.com/2005/01/26/web-standards-compliant-javascript-quicktime-detect-and-embed/
 *
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 *
 * v1.0.2 - 02-16-2005
 *
 * Embeds a quicktime movie to the page, includes plugin detection
 *
 * Usage:
 *
 *	myQTObject = new QTObject("path/to/mov.mov", "movid", "width", "height");
 *	myQTObject.altTxt = "Upgrade your Quicktime Player!";    // optional
 
 *  myQTObject.addParam("controller", "false");              // optional
 *	myQTObject.write();
 *
 */

QTObject = function(mov, id, w, h) {
	this.mov = mov;
	this.id = id;
	this.width = w;
	this.height = h;
	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.altTxt = "This content requires the QuickTime Plugin. <a href='http://www.apple.com/quicktime/download/'>Download QuickTime Player</a>.";
	this.bypassTxt = "<p>Already have QuickTime Player? <a href='?detectqt=false&"+ this.sq +"'>Click here.</a></p>";
	this.params = new Object();
	this.doDetect = getQueryParamValue('detectqt');
}

QTObject.prototype.addParam = function(name, value) {
	this.params[name] = value;
}

QTObject.prototype.getParams = function() {
    return this.params;
}

QTObject.prototype.getParam = function(name) {
    return this.params[name];
}

QTObject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

QTObject.prototype.getHTML = function() {
    var qtHTML = "";
	if (navigator.plugins && navigator.plugins.length) { // not ie
        qtHTML += '<embed type="video/quicktime" src="' + this.mov + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '"';
        for (var param in this.getParams()) {
            qtHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        qtHTML += '></embed>';
    }
    else { // pc ie
        qtHTML += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '">';
        this.addParam("src", this.mov);
        if (this.getParamTags() != null) {
            qtHTML += this.getParamTags();
        }
        qtHTML += '</object>';
    }
    return qtHTML;
}


QTObject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}

QTObject.prototype.write = function(elementId) {
	if(isQTInstalled() || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}		
}

function isQTInstalled() {
	var qtInstalled = false;
	qtObj = false;
	if (navigator.plugins && navigator.plugins.length) {
		for (var i=0; i < navigator.plugins.length; i++ ) {
         var plugin = navigator.plugins[i];
         if (plugin.name.indexOf("QuickTime") > -1) {
			qtInstalled = true;
         }
      }
	} else {
		execScript('on error resume next: qtObj = IsObject(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1"))','VBScript');
		qtInstalled = qtObj;
	}
	return qtInstalled;
}

/* get value of querystring param */
function getQueryParamValue(param) {
	var q = document.location.search;
	var detectIndex = q.indexOf(param);
	var endIndex = (q.indexOf("&", detectIndex) != -1) ? q.indexOf("&", detectIndex) : q.length;
	if(q.length > 1 && detectIndex != -1) {
		return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
	} else {
		return "";
	}
}
