window.onload = initPage;

function initPage() {
  externalLinks();
  if(document.getElementById('qcenquiry')) {
    document.getElementById('qcenquiry').onfocus = clearfield;
    document.getElementById('qcenquiry').onblur = reinstatefield;
  }
  
  if(document.getElementById('flash')) {
    insertFlashObject('flash', 'flash/banner.swf', 978, 192);
  }
  
  if(document.getElementById('bottom_flash')) {
    insertFlashObject('bottom_flash', 'flash/bottom_logos.swf', 418, 69);
  }
   
  if(document.getElementById('menu_right')) {
    $a = 1;
    for(var x=0;document.getElementById('menu_right').childNodes[x];x++) {
      if(document.getElementById('menu_right').childNodes[x].tagName == 'UL') {
        for(var y=0;document.getElementById('menu_right').childNodes[x].childNodes[y];y++) {
          if(document.getElementById('menu_right').childNodes[x].childNodes[y].tagName == 'LI') {
            for(var z=0;document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[z];z++) {
              if(document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[z].tagName == 'UL') {
                for(var i=0;document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[i];i++) {
                  if(document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[i].tagName == 'A') {
                    document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[i].id = 'a' + $a;
                    $a++;
                    var xmlhttp = false;
                    try {
                      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                    } catch(e) {
                      try {
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                      } catch(e) {
                        xmlhttp = false;
                      }
                    }
                    if(!xmlhttp && typeof(XMLHttpRequest != 'undefined')) {
                      document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[i].onmouseover = addBackground;
                      document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[i].onmouseout = removeBackground;
                      document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[z].onmouseover = addBackground;
                      document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[z].onmouseout = removeBackground;
                    } else {
                      document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[i].onmouseenter = addBackground;
                      document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[i].onmouseleave = removeBackground;
                      document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[z].onmouseenter = addBackground;
                      document.getElementById('menu_right').childNodes[x].childNodes[y].childNodes[z].onmouseleave = removeBackground;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

function addBackground() {
  anchorID = 'a' + this.id.substring(1);
  document.getElementById(anchorID).style.backgroundImage = 'url("images/template/menu-selected.jpg")';
  document.getElementById(anchorID).style.backgroundRepeat = 'repeat-x';
  document.getElementById(anchorID).style.backgroundPosition = 'bottom';
  document.getElementById(anchorID).style.color = '#002CD0';
}

function removeBackground() {
  anchorID = 'a' + this.id.substring(1);
  document.getElementById(anchorID).style.backgroundImage = "";
  document.getElementById(anchorID).style.color = '#000000';
}

function externalLinks() { 
  if(!document.getElementsByTagName) {
    return;
  }
  var anchors = document.getElementsByTagName("a");
  for(var i=0;i<anchors.length;i++) {
    var anchor = anchors[i];
    if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external" || anchor.getAttribute("rel") == "external nofollow" ) {
      anchor.target = "_blank";
    }
  }
}

function trim(str, chars) {
  var replaceLeft, replaceRight;
  chars = chars || "\\s";
  replaceLeft = str.replace(new RegExp("^[" + chars + "]+", "g"), "");
  replaceRight = replaceLeft.replace(new RegExp("[" + chars + "]+$", "g"), "");
  return replaceRight;
}

function clearfield() {
  switch(this.id) {
    case 'qcenquiry':
      trimValue = trim(this.value);
      if(trimValue == 'Enquiry') {
        this.value = '';
      }
    break;
  }
}

function reinstatefield() {
  switch(this.id) {
    case 'qcenquiry':
      trimValue = trim(this.value);
      if(trimValue == '') {
        this.value = 'Enquiry';
      }
    break;
  }
}

function insertFlashObject(objID, flashLocation, width, height, flashString) {
  var flashObject;
  flashObject = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + width + "' height='" + height + "'>";
  flashObject = flashObject + "<param name='wmode' value='transparent'>";
  flashObject = flashObject + "<param name='movie' value='" + flashLocation + "' />";
  flashObject = flashObject + "<param name='quality' value='high' />";
  if(typeof(flashString) == "undefined") {
    flashObject = flashObject + "<embed src='" + flashLocation + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + width + "' height='" + height + "' wmode='transparent'>";
  } else {
    flashObject = flashObject + "<param name='FlashVars' value='" + flashString + "'>";
    flashObject = flashObject + "<embed src='" + flashLocation + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + width + "' height='" + height + "' wmode='transparent' ";
    flashObject = flashObject + "FlashVars='" + flashString + "'>";
  }
  flashObject = flashObject + "</embed></object>";
  if(document.getElementById(objID)) {
    document.getElementById(objID).innerHTML = flashObject;
  }
}

function display_overlay(url) {
  var objLink = document.createElement('a');
  objLink.setAttribute('href', url);
  objLink.setAttribute('rel', 'overlay');
  jQuery.prototype.start(objLink);
}

if(typeof(jQuery) != "undefined") {
(function($) { $.fn.lightBox = function(settings) {
settings = jQuery.extend({
overlayBgColor: '#000000',
overlayOpacity: 0.6,
fixedNavigation: false,
imageLoading: 'images/icons/loading.jpg',
imageBtnClose: 'images/buttons/close.jpg',
imageBlank: 'images/icons/blank.gif',
containerBorderSize: 10,
containerResizeSpeed: 400,
imageArray: [],
activeImage: 0
},settings);
var jQueryMatchedObj = this;function _initialize(){_start(this,jQueryMatchedObj);return false;}function _start(objClicked,jQueryMatchedObj) {
$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;
if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{
for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}
while(settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href')){settings.activeImage++;} _set_image_to_view();}function _set_interface() {
$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');
var arrPageSizes = ___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll = ___getPageScroll();
$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();
$('#jquery-overlay,#jquery-lightbox').click(function(){ _finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){ _finish();return false;});
$(window).resize(function(){var arrPageSizes = ___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});
var arrPageScroll = ___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}function _set_image_to_view(){$('#lightbox-loading').show();
if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{
$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}
var objImagePreloader = new Image();objImagePreloader.onload = function(){
$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
objImagePreloader.onload=function(){};};objImagePreloader.src = settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){
var intCurrentWidth = $('#lightbox-container-image-box').width();var intCurrentHeight = $('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));
var intDiffW = intCurrentWidth-intWidth;var intDiffH = intCurrentHeight-intHeight;
$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){ _show_image();});
if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}$('#lightbox-container-image-data-box').css({width:intImageWidth});
$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize * 2)});};
function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();});};
function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}}
function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
function ___getPageSize() {var xScroll, yScroll;
if(window.innerHeight && window.scrollMaxY){xScroll = window.innerWidth+window.scrollMaxX;yScroll = window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight > document.body.offsetHeight){
xScroll = document.body.scrollWidth;yScroll = document.body.scrollHeight;}else{xScroll = document.body.offsetWidth;yScroll = document.body.offsetHeight;}var windowWidth, windowHeight;
if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth = document.documentElement.clientWidth;}else{windowWidth = self.innerWidth;}windowHeight = self.innerHeight;}else if(document.documentElement && document.documentElement.clientHeight){windowWidth = document.documentElement.clientWidth;windowHeight = document.documentElement.clientHeight;}else if(document.body){windowWidth = document.body.clientWidth;windowHeight = document.body.clientHeight;}
if(yScroll < windowHeight){pageHeight = windowHeight;}else{pageHeight = yScroll;}if(xScroll < windowWidth){pageWidth = xScroll;}else{pageWidth = windowWidth;}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};
function ___getPageScroll(){var xScroll, yScroll;if(self.pageYOffset){yScroll = self.pageYOffset; xScroll = self.pageXOffset;
}else if(document.documentElement && document.documentElement.scrollTop){yScroll = document.documentElement.scrollTop; xScroll = document.documentElement.scrollLeft;
}else if(document.body){yScroll = document.body.scrollTop;xScroll = document.body.scrollLeft;}arrayPageScroll = new Array(xScroll,yScroll);
return arrayPageScroll;};function ___pause(ms) { var date = new Date();curDate = null;do { var curDate = new Date();} while(curDate - date < ms);};
return this.unbind('click').click(_initialize);};$(function(){ $('a[@rel*=overlay]').lightBox();});})(jQuery);}