<!--
//************ Start Default Commands ************
var h = "hidden";
var v = "visible";
var db = "block";
var dn = "none";
var graphic = "";   
var isNS4 = 0; var isIE4 = 0; var isNS6 = 0; var isNew = 0;
var docObj, styleObj, currObj, cstyleObj;

var bVer = (parseInt(navigator.appVersion));
var bName = navigator.appName;
var brow = ((navigator.appName) + (parseInt(navigator.appVersion)));

if (bName == "Netscape" && bVer >= 3) version = "js";
else if (bName == "Microsoft Internet Explorer" && bVer >= 4) version = "js";
else if (bName == "Netscape" && bVer == 2) version = "no";
else if (bName == "Microsoft Internet Explorer" && bVer >= 2) version = "no";

if (parseInt(navigator.appVersion >= 5)){isNew = 1}
else if (brow == "Netscape4") {isNS4 = 1;}
else if (brow == "Netscape5") {isNS6 = 1;}
else if (brow == "Microsoft Internet Explorer4") {isIE4 = 1;}
				
if (isNS4||isNS6||isIE4||isNew) {
  if(isNS4){ docObj = "document."; }
  else if(isNS6){ docObj = "document.getElementById('"; }
  else { docObj = "document.all."; }

  if(isNS4){ styleObj = ""; }
  else if(isNS6){ styleObj = "').style"; }
  else { styleObj = ".style"; }
  
  if(isNS4){ cstyleObj = ""; }
  else if(isNS6){ cstyleObj = "').currentStyle"; }
  else { cstyleObj = ".currentStyle"; }
}

function getQuery(val){
  var querystring = location.search.substring(1,location.search.length);
  var o = "";
  var tSec = querystring.indexOf(val+"=");
  var tStr = querystring.substring( (tSec+(val.length+1)),querystring.length);
  
  if(tSec != -1){
    if(tStr.indexOf('&') != -1){
      o = tStr.substring(0,tStr.indexOf('&'));
    } else {
      o = tStr;
    }
  }
  return o;
}

function replaceSubstring(s,f,w){
  rtn = "";
  flg = 0;
  
  for(i = 0; i < s.length; i++){
    if(s.substr(i,f.length) == f){
      rtn += w;
      i += (f.length - 1);
    } else {
      rtn += s.charAt(i);
    }
  }
  
  return (rtn);
}

function openPopup(URL,id,width,height){
  window.open(URL, id, "toolbar=no,location=no,width="+width+",height="+height+",status=yes,scrollbars=yes,scrolling=yes,menubar=no,resizable=yes");
}

function openPopupLocked(URL,id,width,height){
  window.open(URL, id, "toolbar=no,location=no,width="+width+",height="+height+",status=yes,scrollbars=yes,scrolling=yes,menubar=no,resizable=no");
}

function goPage(u){
  location.href = u;
}

function layerChange(tmpLayer,tmpVisible) {
  if (isNS4||isNS6||isIE4||isNew) { eval(docObj + tmpLayer + styleObj + '.visibility = ' + tmpVisible) }
}

function displayChange(tmpLayer,tmpVisible) {
  if (isNS4||isNS6||isIE4||isNew) { eval(docObj + tmpLayer + styleObj + '.display = ' + tmpVisible) }
}

function rollover(graphic,state) {
  if(state==1){ if (version == "js") { document[graphic].src = "http://www.centurionsafety.net/graphics/" + graphic + "_dn.gif" } }
  if(state==0){ if (version == "js") { document[graphic].src = "http://www.centurionsafety.net/graphics/" + graphic + "_up.gif" } }
}

function imageover(graphic,filename) {
  if (version == "js") { document[graphic].src = "http://www.centurionsafety.net/graphics/" + filename }
}

function inputover(graphic,state) {
  if(state==1){ if (version == "js") { document.getElementById(graphic).src = "http://www.centurionsafety.net/graphics/" + graphic + "_dn.gif" } }
  if(state==0){ if (version == "js") { document.getElementById(graphic).src = "http://www.centurionsafety.net/graphics/" + graphic + "_up.gif" } }
}

function clearText(f,t,d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];
  var ele = doc.elements[f].value;

  if(ele == t){
    doc.elements[f].value = "";
  }
}
//************ End Default Commands ************

/********************************************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)  *
* This notice MUST stay intact for legal use                        *
* Visit http://www.dynamicdrive.com/ for this script and 100s more. *
*********************************************************************/

//************ Announcements Functions ************
var la_marqueespeed = 1;
var la_pauseit = 1;
var la_copyspeed = la_marqueespeed;
var la_pausespeed=(la_pauseit==0)? la_copyspeed: 0;
var la_actualheight='';

function scrollmarqueela(){
  if(parseInt(la_cross_marquee.style.top)>((la_actualheight*(-1)+8)/2)){ //if scroller hasn't reached the end of its height
    la_cross_marquee.style.top=parseInt(la_cross_marquee.style.top)-la_copyspeed+"px"; //move scroller upwards
  } else {
    la_cross_marquee.style.top="2px"; //else, reset to original position
  }
}

function initializemarqueela(){
  var scrollnow = (document.getElementById("announcement_list_num").value) * 1;
  var scrollnum = (document.getElementById("announcement_list_scrollnum").value) * 1;
  la_cross_marquee=document.getElementById("announcement_list")
  la_cross_marquee.style.top=0
  la_marqueeheight=document.getElementById("announcement_container").offsetHeight
  la_actualheight=la_cross_marquee.offsetHeight //height of marquee content (much of which is hidden from view)
  if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
    la_cross_marquee.style.height=marqueeheight+"px"
    la_cross_marquee.style.overflow="scroll"
    return
  }
  if(scrollnow >= scrollnum){
    setTimeout('lefttime=setInterval("scrollmarqueela()",50)', 2000)
  }
}

//************ Latest Updates Functions ************
var lu_marqueespeed = 1;
var lu_pauseit = 1;
var lu_copyspeed = lu_marqueespeed;
var lu_pausespeed=(lu_pauseit==0)? lu_copyspeed: 0;
var lu_actualheight='';

function scrollmarqueelu(){
  if(parseInt(lu_cross_marquee.style.top)>((lu_actualheight*(-1)+8)/2)){ //if scroller hasn't reached the end of its height
    lu_cross_marquee.style.top=parseInt(lu_cross_marquee.style.top)-lu_copyspeed+"px"; //move scroller upwards
  } else {
    lu_cross_marquee.style.top="2px"; //else, reset to original position
  }
}

function initializemarqueelu(){
  var scrollnow = (document.getElementById("latest_list_num").value) * 1;
  var scrollnum = (document.getElementById("latest_list_scrollnum").value) * 1;
  lu_cross_marquee=document.getElementById("latest_list")
  lu_cross_marquee.style.top=0
  lu_marqueeheight=document.getElementById("latest_container").offsetHeight
  lu_actualheight=lu_cross_marquee.offsetHeight //height of marquee content (much of which is hidden from view)
  if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
    lu_cross_marquee.style.height=marqueeheight+"px"
    lu_cross_marquee.style.overflow="scroll"
    return
  }
  if(scrollnow >= scrollnum){
    setTimeout('lefttime=setInterval("scrollmarqueelu()",50)', 2000)
  }
}

//************ Upcoming Courses Functions ************
var marqueespeed = 1;
var pauseit = 1;
var copyspeed = marqueespeed;
var pausespeed=(pauseit==0)? copyspeed: 0;
var actualheight='';

function scrollmarquee(){
  if(parseInt(cross_marquee.style.top)>((actualheight*(-1)+8)/2)){ //if scroller hasn't reached the end of its height
    cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"; //move scroller upwards
  } else {
    cross_marquee.style.top="2px"; //else, reset to original position
  }
}

function initializemarquee(){
  cross_marquee=document.getElementById("upcoming_list")
  cross_marquee.style.top=0
  marqueeheight=document.getElementById("upcoming_container").offsetHeight
  actualheight=cross_marquee.offsetHeight //height of marquee content (much of which is hidden from view)
  if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
    cross_marquee.style.height=marqueeheight+"px"
    cross_marquee.style.overflow="scroll"
    return
  }
  setTimeout('lefttime=setInterval("scrollmarquee()",50)', 2000)
}

//************ End Scroller Functions ************

//************ Start Validation Functions ************
function setFocus(f,d){
  document.forms[d].elements[f].focus();
}

function testEmail(f,d){
  var a = document.forms[d].elements[f].value;
  var at = a.indexOf("@")
  var name = a.substring(0, at)
  var isp = a.substring(at + 1, a.length)
  var dot = a.lastIndexOf(".")

  if (at == -1 || at == 0 || name == "" || isp == "" || dot == -1 || dot == (a.length - 1)) {
    alert('You must enter a valid email address');
    setFocus(f,d);
  } else {
    return true;
  }
}

function testText(f,t,c,d){
  if( (document.forms[d].elements[f].value != "") && (document.forms[d].elements[f].value != c) ){
    return true;
  } else {
    alert('You must enter ' + t);
    setFocus(f,d);
  }
}

function testSelect(f,t,d){
  var a = document.forms[d].elements[f];
  if( (a.selectedIndex >= 0) && (a.options[a.selectedIndex].value != "") ){
    return true;
  } else {
    alert('You must select a ' + t);
    setFocus(f,d);
  }
}

function testCheck(f,l,d){
  var a = document.forms[d].elements[f];
  var str = "";

  for(i = 0; i < a.length; i++){
    if(a[i].checked == true){
      str = "yes";
	break;
    } else {
      str = "no";
    }
  }

  if(str == "yes"){
    return true;
  } else {
    alert('You must select a ' + t);
  }
}

function getCheck(f,d){
  var a = document.forms[d].elements[f];
  var str = "";

  for(i = 0; i < a.length; i++){
    if(a[i].checked == true){
      return a[i].value;
    }
  }
}

function validate_booking(d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  if( testText('first_name','your First Name','',d) && testText('last_name','your Last Name','',d) && testText('organisation','your Organisation','',d) && testText('address1','your Address','',d) && testText('post_code','your Post code','',d) && testText('telephone','your Telephone number','',d) && testEmail('email_address',d) ){
    doc.action.value = "submit_booking";
    doc.submit();
  }
}

function validate_enquiry(d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  if( testText('places','an approximate number of required places','',d) && testText('first_name','your First Name','',d) && testText('last_name','your Last Name','',d) && testText('organisation','your Organisation','',d) && testText('address1','your Address','',d) && testText('post_code','your Post code','',d) && testText('telephone','your Telephone number','',d) && testEmail('email_address',d) ){
    if( (doc.location.selectedIndex == (doc.location.length-1)) && ((doc.ifother.value == "if other") || (doc.ifother.value == "")) ){
      alert('Please enter where would you like the course run');
      setFocus('ifother',d);
    } else {
      doc.action.value = "submit_booking";
      doc.submit();
    }
  }
}

function validate_comments(d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  if( testText('firstname','your first name','First name',d) && testText('lastname','your last name','Last name',d) && testEmail('emailaddress',d) && testText('telephone','your Telephone number','Telephone',d) && testText('company','your company name','Company',d) ){
    doc.action.value = "submitenquiry";
    doc.submit();
  }
}

function validate_contact(d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  if( testText('name','your name','',d) && testText('organisation','your organisation','',d) && testEmail('emailaddress',d) && testText('telephone','your Telephone number','Telephone',d) && testText('address1','your address','',d) && testText('postcode','your post code','',d) && testSelect('country','country',d) ){
    doc.action.value = "contactenquiry";
    doc.submit();
  }
}

//************ End Validation Functions ************

//************ Start General Functions ************

function submitSearch(d,s,t){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  if( testText(s,'a search query','',d) ){
    if(doc.elements[s].value == t){
      alert("Please enter a search query");
    } else {
      location.href = "/Search/" + replaceSubstring(doc.elements[s].value,' ','+');
    }
  }
}

function submitQuickSearch(d,s,t,u){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  if( testText(s,'a search query','',d) ){
    if(doc.elements[s].value == t){
      alert("Please enter a search query");
    } else {
      location.href = "/" + u + "/Search/" + replaceSubstring(doc.elements[s].value,' ','+');
    }
  }
}

function selectRiskAssessment(t){
  if(t.options[t.selectedIndex].value != ""){
    location.href = "/Countries/" + t.options[t.selectedIndex].value + ".html";
  }
}

function courseBookForm(d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];
  doc.submit();
}

function courseBookFormId(d,id,cid){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];
  doc.course_id.value = cid;
  doc.preferred_date.value = id;
  doc.second_date.value = id;
  doc.submit();
}

function courseEnquiry(d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  doc.course_id.value = document.forms['course_dates'].course_id.options[document.forms['course_dates'].course_id.selectedIndex].value;
  doc.submit();
}

function courseChosen(d,p){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  if(testText('course_choice','a chosen date','',d) ){
    doc.course_id.value = document.forms['course_dates'].course_id.options[document.forms['course_dates'].course_id.selectedIndex].value;
    doc.submit();
  }
}

function courseBook(d,p){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  doc.course_id.value = document.forms['course_dates'].course_id.options[document.forms['course_dates'].course_id.selectedIndex].value;
  doc.preferred_date.value = p;
  doc.submit();
}

function openCategory(n,tot){
  var obj = document.getElementById("cat_" + n);

  for(i=1; i<=tot; i++){
    if(i != n){ document.getElementById("cat_" + i).style.display = 'none'; }
  }

  if(obj.style.display == 'block'){
    obj.style.display = 'none';
  } else {
    obj.style.display = 'block';
  }
}

function checkBasket(){
  var doc = document.forms["basket"];
  var items = (doc.basket_items.value * 1);
  
  if(items > 0){
    doc.action.value = "confirm";
    doc.submit();
  } else {
    alert("There are currently no items in your basket");
  }
}

function update_product(d){
  var doc = document.forms[d];

  doc.submit();
}


function if_confirm(u){
  if(confirm('Are you sure?')){
    goPage(u);
  }
}

function checkoutStep(step,d){
  var doc = document.forms[d];

  if(step == "purchase"){
    if(confirm('Are you sure?')){
      doc.action.value = step;
      doc.submit();
    }
  } else if(step == "confirm_order"){
    if( testText('bil_name','your billing name','',d) && testText('bil_address1','your billing address','',d) && testText('bil_address2','your billing address','',d) && testText('bil_postcode','your billing postcode','',d) && testText('bil_telephone','your billing telephone number','',d) && testSelect('bil_country','your billing country',d) ){
      if(getCheck('same_delivery',d) == "yes"){
        doc.action.value = step;
        doc.submit();
      } else {
        if( testText('del_name','your delivery name','',d) && testText('del_address1','your delivery address','',d) && testText('del_address2','your delivery address','',d) && testText('del_postcode','your delivery postcode','',d) && testText('del_telephone','your delivery telephone number','',d) && testSelect('del_country','your delivery country',d) ){
          doc.action.value = step;
          doc.submit();
        }
      }
    }
  } else if(step == "order_success"){
    doc.action.value = step;
    doc.submit();
  } else {
    doc.action.value = step;
    doc.submit();
  }
}

function update_display(t){
  var doc = document.forms["checkout"];
  var trs = doc.getElementsByTagName('li');

  if(t == "show"){
    for(i = 0; i < trs.length; i++){
      if(trs[i].className == "hide"){
        trs[i].className = "show";
      }
    }
  } else {
    for(i = 0; i < trs.length; i++){
      if(trs[i].className == "show"){
        trs[i].className = "hide";
      }
    }    
  }
}

function doPreload(){
 preloadImages(imgArray);
}

function preloadImages(images) {
 for(i=0; i < images.length; i++) {
   var img = new Array();
   img[i] = new Image();
   img[i].src = images[i];
 }
}

function updateImage(value){
  var doc = document.forms['slideshow'];
  var count = (doc.fieldImage.value)*1;
  var imgStart = count + value;
  var arrLength = imgArray.length;
  
  for(var i=0; i<imgNum; i++){
    if(imgStart > (arrLength-1)){ imgStart = 0 } else if(imgStart == -1){ imgStart = (arrLength)+imgStart }
    var tmpStr = new String(imgStart-i);
    var tmpVal = "";
    if(tmpStr.indexOf('-') == ""){ tmpVal = imgArray.length + (imgStart-i) } else { tmpVal = imgStart-i }
    document.images["img"+[i]].src = imgArray[tmpVal];
  }
  doc.fieldImage.value = imgStart
}

function updateDelivery(d){
  var doc = document.forms[d];
  doc.submit();
}

//-->
