// JavaScript Document
window.onerror = null;
var menuActive = 0;
var onLayer;
var timeOn = null;


// Shows a layer according to name
function showLayer(layerName) {
if (timeOn != null) {
clearTimeout(timeOn);
hideLayer(onLayer);
}

if (document.getElementById) {
document.getElementById(layerName).style.visibility = "visible";
}
else if (document.layers) {
document.layers[layerName].visibility = "show";
}
else if (document.all) {
document.all[layerName].style.visibility = "visible";
}
onLayer = layerName;
}


// Hides the layer
// This function isn't called in the HTML page but it's used below in the timeout function
function hideLayer(layerName) {
if (menuActive == 0) {
if (document.getElementById) {
document.getElementById(layerName).style.visibility = "hidden";
}
else if (document.layers) {
document.layers[layerName].visibility = "hidden";
}
else if (document.all) {
document.all[layerName].style.visibility = "hidden";
}
}
}

// Shows up when you roll the mouse over a menu item
function menuOver() {
clearTimeout(timeOn);
menuActive = 1;
}


// Hides after a brief pause when you roll the mouse off the menu
// Change the 400 to higher and lower numbers to affect this code
function menuOut() {
menuActive = 0;
timeOn = setTimeout("hideLayer(onLayer)", 0);
}
		
//Top Menu over and off states		
function navOver(divID) {
	if(navigator.userAgent.indexOf("MSIE 6.0") != -1 || navigator.userAgent.indexOf("MSIE 5.5") != -1){
		
	}else{
	document.getElementById(divID).style.paddingBottom = "8px";
	document.getElementById(divID).style.backgroundImage="url(/images/navBar_over.gif)";
	}

}
function navOut(divID) {
	document.getElementById(divID).style.backgroundColor = "transparent";
	document.getElementById(divID).style.backgroundImage = "url(/images/globalNav_seperator.jpg)";
	document.getElementById(divID).style.backgroundPosition = "0px 0px";
	document.getElementById(divID).style.backgroundPosition = "right";
	document.getElementById(divID).style.backgroundRepeat = "no-repeat";
	document.getElementById(divID).style.color = "#FFFFFF";
}

function overPosition(divID, leftPos, topPos){
	if(navigator.userAgent.indexOf("MSIE 7.0") != -1){
	
	document.getElementById(divID).style.backgroundPosition = leftPos + " " + topPos;
	
	} else if(navigator.userAgent.indexOf("MSIE 6.0") != -1 || navigator.userAgent.indexOf("MSIE 5.5") != -1){
	
		document.getElementById(divID).style.backgroundPosition = "right";	
	
	}else
	
	document.getElementById(divID).style.backgroundPosition = (leftPos-1) + "px " + (topPos-1) + "px";
}


function findAndReplace(stringRef, toFind, toReplace){
	var beginIndex = 0;
	var findIndex = 0;
	while(findIndex > -1){
		findIndex = stringRef.indexOf(toFind,beginIndex);
		if(findIndex != -1){
			var preSlice = stringRef.slice(0,beginIndex);
			var slice1 = stringRef.slice(beginIndex,findIndex);
			slice1 += toReplace;
			var beginSlice2 = findIndex + toFind.length;
			var slice2 = stringRef.slice(beginSlice2,stringRef.length);
			stringRef = preSlice + slice1 + slice2;
			beginIndex = findIndex + (toReplace.length); 
		}
	}
	return stringRef;
}

//BREADCRUMB SCRIPT
function breadcrumbs(){
  sURL = new String;
  bits = new Object;
  var x = 0;
  var stop = 0;
  var output = "&nbsp;&nbsp; <a href=\"/\">Home</a> &nbsp;>&nbsp; ";
  sURL = location.href;
  sURL = sURL.slice(8,sURL.length);
  chunkStart = sURL.indexOf("/");
  sURL = sURL.slice(chunkStart+1,sURL.length)
  while(!stop){
    chunkStart = sURL.indexOf("/");
    if (chunkStart != -1){
      bits[x] = sURL.slice(0,chunkStart)
      sURL = sURL.slice(chunkStart+1,sURL.length);
    }else{
      stop = 1;
    }
    x++;
  }
  for(var i in bits){
    output += "<a href=\"";
    for(y=1;y<x-i;y++){
      output += "../";
    }
    output += bits[i] + "/\">" + bits[i] + "</a> &nbsp;>&nbsp; ";
  }
  document.write(findAndReplace(output, "_", " ") + document.title);
}


  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-29083703-1']);
  _gaq.push(['_setDomainName', 'vibrantmedia.com']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

