var previousClicked='videoscoutLanding';
$(document).ready(function(){
		showVideoscutContent();	
		$(".first").css('background-image', 'url(../pics/videonav/firstnave-mouse.jpg)');
});
/***************************** Begin Change the videoscout page conent navigation click *********************/
function showVideoscutContent(){
	$(".first").css('background-image', 'url(../pics/videonav/firstnave-mouse.jpg)');
	$("#video-menu a").click(function(){
		var clickedNavigation=this.rel;
		
		if(previousClicked!='')
			$("#"+previousClicked).hide();
			
		previousClicked=clickedNavigation;
		
		setActivelink();	
		if(this.className=='first'){
			$("#video-menu .last").css('background-image', 'url(../pics/videonav/lastnav.jpg)');		
			$(this).css('background-image', 'url(../pics/videonav/firstnave-mouse.jpg)');
		}
		else if(this.className=='last'){
			$(".first").css('background-image', 'url(../pics/videonav/firstnav.jpg)');
			$(this).css('background-image', 'url(../pics/videonav/lastnav-mousae.jpg)');
		}
		else{ 
			$(".first").css('background-image', 'url(../pics/videonav/firstnav.jpg)');
			$("#video-menu .last").css('background-image', 'url(../pics/videonav/lastnav.jpg)');
			$(this).css('background-image', 'url(../pics/videonav/middle-moseover.jpg)');
		}
		$("#"+clickedNavigation).show();
		
		
	});
}
function setActivelink(){
	$("#video-menu a").css('background-image', 'url(../pics/videonav/videoscout_middle.gif)');
	if($("#video-menu a").className=='first')
		$(this).css('background-image', 'url(../pics/videonav/firstnav.jpg)');
	if($("#video-menu a").className=='last')
		$(this).css('background-image', 'url(../pics/videonav/lastnav.jpg)');	
		
}
/***************************** Ends Change the videoscout page conent navigation click *********************/
/*****************************Begin Tell to friend ***************************************************************/
	function telltofriend(){
		window.open ("telltofriend.php","BCTech","toolbar=0,resizable=1,top=100,left=100,location=0,status=1,scrollbars=0,width=400,height=500"); 
	}
/*****************************End Tell to friend ***************************************************************/
/* ***********************Begin Get current Month*********************** */
function getCurrentMonth(spanId){
	var d=new Date();

	var month=new Array(12);
	month[0]="january";
	month[1]="february";
	month[2]="march";
	month[3]="april";
	month[4]="may";
	month[5]="june";
	month[6]="july";
	month[7]="august";
	month[8]="september";
	month[9]="october";
	month[10]="november";
	month[11]="december";	
	document.getElementById(spanId).innerHTML=month[d.getMonth()];
	//alert(document.getElementById(spanId).innerHTML);
}
/* ***********************End Get current Month*********************** */

/* ***********************Begin Open Blank Window*********************** */
function BlankWin (url) {
     blankWin = window.open(url,'_blank');
  }
/* ***********************End Open Blank Window*********************** */


/* ***********************begin toggle div tags***********************  */
function toggledivs() {
  var inc, endInc=arguments.length;
  for (inc=0; inc<endInc; inc+=2) {
    var id = arguments[inc];
    if (arguments[inc+1] == 'none') param = "none";
    else if(arguments[inc+1]=='block') param = "block";
    if (document.layers) document.layers['container'].layers[id].visibility = param;
    else if (document.all) eval("document.all." + id + ".style.display = \"" + param + "\"");
    else if (document.getElementById) eval("document.getElementById(id).style.display = \"" + param + "\"");
  }
}


function togglevisibility() {
  var inc, endInc=arguments.length;
  for (inc=0; inc<endInc; inc+=2) {
    var id = arguments[inc];
    if (arguments[inc+1] == 'hidden') param = "hidden";
    else if(arguments[inc+1]=='visible') param = "visible";
    if (document.layers) document.layers['container'].layers[id].visibility = param;
    else if (document.all) eval("document.all." + id + ".style.visibility = \"" + param + "\"");
    else if (document.getElementById) eval("document.getElementById(id).style.visibility = \"" + param + "\"");
  }
}


// new code for swapping divs without the hack of adding all the div layers in the onclick event
function getElementsByClass(searchClass,node,tag) {
  // This function gets the elements that all share a class name
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function an_toggleDisplay(theid) {
	// This function toggles between the tabs and the corresponding content for the tabs.  The tabs <li> must correspond 1-1 with the order of the content UL content elements.
	// if your 3rd tab is "tab for content z" then ensure that your UL for the content is placed as the 3rd element.
	// we could give the tabs an id in order to match the id of the actual content, but it was kept this way in order to save on logic processing time and added code to the HTML (yet more id's to keep track of).
  
	var contentelmt = getElementsByClass('tab_contents');
	var tabelmt = getElementsByClass('litab');
	var match = false;
		for (i = 0; i < contentelmt.length; i++) {
			if (theid == contentelmt[i].id) {
				match = true;
				contentelmt[i].style.display = "block";
				tabelmt[i].className ="litab active";
				urchinTracker(document.location.pathname + "->" + theid);//google analytics call
			}
			else {
				contentelmt[i].style.display = "none";
				tabelmt[i].className = "litab";			
			}		
		}
		if (match == false) {
			contentelmt[0].style.display = "block";
			tabelmt[0].className="litab active";
		}
}

function an_toggleDisplay2(theid) {
	// This function toggles between the tabs and the corresponding content for the tabs.  The tabs <li> must correspond 1-1 with the order of the content UL content elements.
	// if your 3rd tab is "tab for content z" then ensure that your UL for the content is placed as the 3rd element.
	// we could give the tabs an id in order to match the id of the actual content, but it was kept this way in order to save on logic processing time and added code to the HTML (yet more id's to keep track of).
  
	var contentelmt = getElementsByClass('tab_contents');
	var tabelmt = getElementsByClass('litab');
	var match = false;
		for (i = 0; i < contentelmt.length; i++) {
			if (theid == contentelmt[i].id) {
				match = true;
				contentelmt[i].style.display = "block";
				tabelmt[i].className ="litab active";
			}
			else {
				contentelmt[i].style.display = "none";
				tabelmt[i].className = "litab";			
			}		
		}
		if (match == false) {
			contentelmt[0].style.display = "block";
			tabelmt[0].className="litab active";
		}
}

function an_togglePortfolio(requested) {
	// This will display the body content and summary block of the chosen item, 
	// as well as making the thumbnail active
	// it also sets the variable used by google analytics to track page views
	
	var thumbs = getElementsByClass('portfoliothumb');
	var summaries = getElementsByClass('portfoliosummary');
	var bodies = getElementsByClass('portfoliobody');
	var viewed = ""; //this is to pass to google analytics
	var matched = false;
	var origDisplayed = 0;
	
	for (var i=0; i<thumbs.length; i++){
		var productname = thumbs[i].getAttribute("name");
		//check for query string from calling url
		if (requested == productname) { 
			matched = true;
			bodies[i].style.display = "block";
			origDisplayed = i;
			summaries[i].style.display = "block";
			thumbs[i].className ="portfoliothumb active";
			document.title = thumbs[i].getAttribute("title");
			viewed = productname; 
		}
		// set event handlers
		thumbs[i].onmouseover = function(){
			this.setAttribute("origClass",this.className);
			this.className="portfoliothumb active"; 
			for (j = 0; j<thumbs.length; j++) {
				if (j == this.getAttribute("index")) { 
					summaries[j].style.display = "block";
				}
				else {
					if (summaries[j].style.display == "block"){ //if we find the currently active summary
						origDisplayed = j;
					}
					summaries[j].style.display = "none";		
				}		
			};
		}
		thumbs[i].onmouseout = function(){
			this.className=this.getAttribute("origClass");
			summaries[this.getAttribute("index")].style.display = "none";
			summaries[origDisplayed].style.display="block";
		}
		thumbs[i].onclick = function(){
			this.setAttribute("origClass",this.className);
			this.className ="portfoliothumb active";
			for (j = 0; j<thumbs.length; j++) {
				if (j == this.getAttribute("index")) { 
					bodies[j].style.display = "block";
					summaries[j].style.display = "block";
					origDisplayed = j;
					document.title = this.getAttribute("title");					
					viewed = this.getAttribute("name");
					urchinTracker(document.location.pathname + "->" + viewed);//google analytics call
				}
				else {
					bodies[j].style.display = "none";
					summaries[j].style.display = "none";
					thumbs[j].className = "portfoliothumb";		
				}		
			}
		}
		
		thumbs[i].setAttribute("index",i);
	}
	
	if (matched == false){ //no particular product was requested in url
		bodies[0].style.display = "block";
		summaries[0].style.display = "block";
		thumbs[0].className ="portfoliothumb active";
	}
	
	return viewed;
}


//returns a query value corresponding to specified key, else returns nothing
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  return;
}

/* ***********************end toggle div tags*********************** */


/********** open privacy policy pop-up **********/
function openPrivacyPolicy(url){
	window.open (url,"privacy","location=0,status=0,menu=0,scrollbars=1,width=500");
}
/********** end open privacy policy pop-up **********/

/********** open job listing pop-up **********/
function openJobListing(url){
	window.open (url,"joblisting","location=0,status=0,menu=0,scrollbars=1,width=800");
}
/********** end open job listing pop-up **********/
/********** Begin open email pop-up **********/
function emailpopup(url,name) {
  popupwin = window.open(url, name, 'width=350,height=280');
}
/********** end open email pop-up **********/
/********** contact us form **********/
function showSendInfo(){
	if (document.forms[0].sendme.checked) {
		document.getElementById('contact-info').style.display = 'block';
	}
	else{
		document.getElementById('contact-info').style.display = 'none';
	}
}
/********** end contact us form **********/

/*********** main nav mouseover ************/

// This is the implementation of SimpleSwap
// by Jehiah Czebotar
// Version 1.1 - June 10, 2005
// Distributed under Creative Commons
//
// Include this script on your page
// then make image rollovers simple like:
// <img src="/images/ss_img.gif" oversrc="/images/ss_img_over.gif">
//
// http://jehiah.com/archive/simple-swap
// 

function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
//window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}
//moved previous line to body onload attribute
/*********** end main nav mouseover ************/
