/**
 *
 * @author Christopher Piekarski
 * @author Leonard Cross
 * @copyright 2010 Greenberg, Inc.
 * @filesource gb-scripts.js
 * @version 1.0
 *
 **/

	//Adds click to load and remove demo content on Work Page
	function loadDemo() {
		$('#client-list > li > .demo-click').each(function(index) {
			$(this).click(function() {
				$('#client-list > li > .demo-click + .client-demo').removeClass('load-demo');
				$(this).parent().children('.client-demo').addClass('load-demo');
				$('#client-list > li > .demo-click').removeClass('link-active');
				$(this).parent().children('.demo-click').addClass('link-active');
			});										   
		});
		$('#client-list > li > span[title="Visa"] + .client-demo').addClass('load-demo');
		$('#client-list > li > span[title="Visa"]').addClass('link-active');
	};
	
	//Enables hover state of span for loadDemo
	function clientListHover() {
		$(".demo-click").hover(function () { 
			$(this).addClass('link-hover');
		}, function() {
			$(this).removeClass('link-hover');
			}
		);
	};
	
	//Enables hover state of Coming Soon in IE6
	function comingSoonHover() {
		$("#nav-blog a").hover(function () {
			$(this).addClass('ie-link-hover');
		}, function() {
			$(this).removeClass('ie-link-hover');
			}
		);
	};

	//Enables href to open link in new window
	function bindNewWindows() {
		$(".newWindow")
			.click(function() {window.open(this.getAttribute("href"),"",""); return false;} )
			.keypress(function(event) {
				if (key_ability(event)) {
					window.open(this.getAttribute("href"),"","");
					event.preventDefault();
				};
			});
	};
	
	// google analytics tracking code
	function googleAnalytics($) {
	  var gaTrackCode = "UA-12824487-2";
	  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	
	  jQuery.getScript(gaJsHost + "google-analytics.com/ga.js", function(){
		var pageTracker = _gat._getTracker(gaTrackCode);
		pageTracker._initData();
		pageTracker._trackPageview();
	  });
	};

//DOMReady
$(document).ready(function() {
	clientListHover();
	comingSoonHover();
	loadDemo();	
	bindNewWindows();
	googleAnalytics();
});
