(function(a){if(typeof console==="undefined"){console=typeof window.console!=="undefined"?window.console:{}}console.log=console.log||function(){};console.debug=console.debug||console.log;console.warn=console.warn||console.log;console.error=console.error||function(){var b=[];for(var c=0;c<arguments.length;c++){b.push(arguments[c])}alert(b.join("\n"))};console.trace=console.trace||console.log;console.group=console.group||console.log;console.groupEnd=console.groupEnd||console.log;console.profile=console.profile||console.log;console.profileEnd=console.profileEnd||console.log;a.HistoryClass=function(){this.construct()};a.extend(a.HistoryClass.prototype,{hash:"",$window:null,$iframe:null,handlers:{generic:[],specific:{}},format:function(b){return b.replace(/^.+?#/g,"").replace(/^#?\/?|\/?$/g,"")},getState:function(){return a.History.format(a.History.hash)},setState:function(b){b=b||a.History.getHash();return(a.History.hash=a.History.format(b))},getHash:function(){var b=window.location.hash||location.hash;return a.History.format(b)},setHash:function(b){b=a.History.format(b);b=b.replace(/^\/?|\/?(\?)|\/?$/g,"/$1");if(typeof window.location.hash!=="undefined"){window.location.hash=b}else{location.hash=b}},go:function(b){if(a.browser.msie&&parseInt(a.browser.version,10)<8){a.History.$iframe.contentWindow.document.open();a.History.$iframe.contentWindow.document.close();a.History.$iframe.contentWindow.document.location.hash=b}b=b||"#";var c=a.History.getHash();if(c!==b){a.History.setHash(b)}a.History.$window.trigger("hashchange")},hashchange:function(d){var c=a.History.getHash();var b=a.History.getState();if((!a.History.$iframe&&b===c)||(a.History.$iframe&&a.History.hash===a.History.$iframe.contentWindow.document.location.hash)){return false}if(b===c){return false}a.History.setState(c);a.History.trigger();return true},bind:function(c,b){if(b){if(typeof a.History.handlers.specific[c]==="undefined"){a.History.handlers.specific[c]=[]}a.History.handlers.specific[c].push(b)}else{b=c;a.History.handlers.generic.push(b)}return true},trigger:function(e){if(typeof e==="undefined"){e=a.History.getState()}var b,f,c,d;if(typeof a.History.handlers.specific[e]!=="undefined"){d=a.History.handlers.specific[e];for(b=0,f=d.length;b<f;++b){c=d[b];c(e)}}d=a.History.handlers.generic;for(b=0,f=d.length;b<f;++b){c=d[b];c(e)}return true},construct:function(b){a(document).ready(function(){a.History.domReady()});return true},domReadied:false,domReady:function(){if(a.History.domRedied){return}a.History.domRedied=true;a.History.$window=a(window);a.History.$window.bind("hashchange",this.hashchange);setTimeout(a.History.hashchangeLoader,200);return true},hashchangeLoader:function(){if(!(a.browser.msie&&parseInt(a.browser.version)>=8)){var b;if(a.browser.msie){a.History.$iframe=a('<iframe id="jquery-history-iframe" style="display: none;"></$iframe>').prependTo(document.body)[0];a.History.$iframe.contentWindow.document.open();a.History.$iframe.contentWindow.document.close();var c=a.History.getHash();if(c){a.History.$iframe.contentWindow.document.location.hash=c}b=function(){var d=a.History.format(a.History.$iframe.contentWindow.document.location.hash);if(a.History.getState()!==d){a.History.setHash(a.History.$iframe.contentWindow.document.location.hash)}var e=a.History.getHash();if(a.History.getState()!==e){a.History.go(e)}}}else{b=function(){var d=a.History.getHash();if(a.History.getState()!==d){a.History.go(d)}}}setInterval(b,200)}else{var c=a.History.getHash();if(c){a.History.$window.trigger("hashchange")}}return true}});if(typeof a.History==="undefined"){a.History=new a.HistoryClass()}})(jQuery);

sharearray = new Object();
sharearray["http://myjeeves.ask.com/mysearch/BookmarkIt"]="?v=1.2&t=webpages&url={url}&title={title}";
sharearray["http://www.backflip.com/add_page_pop.ihtml"]="?url={url}&title={title}";
sharearray["http://ballhype.com/post/url/"]="?url={url}&title={title}";
sharearray["http://bebo.com/c/share"]="?Url={url}&Title={title}";
sharearray["http://www.blinklist.com/index.php"]="?Action=Blink/addblink.php&Url={url}&Title={title}";
sharearray["http://blogmarks.net/my/new.php"]="?mini=1&simple=1&url={url}&title={title}";
sharearray["http://del.icio.us/post"]="?v=4&partner=[partner]&noui&url={url}&title={title}";
sharearray["http://digg.com/submit"]="?phase=2&partner=[partner]&url={url}&title={title}";
sharearray["http://www.diigo.com/post"]="?url={url}&title={title}";
sharearray["http://www.facebook.com/sharer.php"]="?u={url}&t={title}";
sharearray["http://cgi.fark.com/cgi/fark/submit.pl"]="?new_url={url}&new_comment={title}";
sharearray["http://bluedot.us/Authoring.aspx"]="?u={url}&t={title}";
sharearray["http://feedmelinks.com/categorize"]="?from=toolbar&op=submit&url={url}&name={title}";
sharearray["http://friendfeed.com/share"]="?url={url}&title={title}";
sharearray["http://www.furl.net/savedialog.jsp"]="?p=1&u={url}&t={title}&r=&v=1&c=";
sharearray["http://www.google.com/bookmarks/mark"]="?op=add&bkmk={url}&title={title}";
sharearray["http://www.kaboodle.com/grab/addItemWithUrl"]="?url={url}&pidOrRid=pid=&redirectToKPage=true";
sharearray["http://www.linkagogo.com/go/AddNoPopup"]="?url={url}&title={title}";
sharearray["http://www.linkedin.com/shareArticle"]="?mini=true&url={url}&title={title}&ro=false&summary=&source=";
sharearray["https://favorites.live.com/quickadd.aspx"]="?marklet=1&mkt=en-us&url={url}&title={title}&top=1";
sharearray["http://www.mister-wong.com/index.php"]="?action=addurl&bm_url={url}&bm_description={title}";
sharearray["http://www.mixx.com/submit"]="?page_url={url}";
sharearray["http://multiply.com/gus/journal/compose/"]="?body=&url={url}&subject={title}";
sharearray["http://favorites.my.aol.com/ffclient/AddBookmark"]="?url={url}&title={title}&favelet=true";
sharearray["http://www.myspace.com/Modules/PostTo/Pages/"]="?u={url}&t={title}&c=%20";
sharearray["http://netvouz.com/action/submitBookmark"]="?url={url}&title={title}&popup=no";
sharearray["http://www.newsvine.com/_tools/seed&save"]="?u={url}&h={title}";
sharearray["http://www.propeller.com/submit/"]="?U={url}&T={title}";
sharearray["http://reddit.com/submit"]="?url={url}&title={title}";
sharearray["http://segnalo.com/post.html.php"]="?url={url}&title={title}";
sharearray["http://www.simpy.com/simpy/LinkAdd.do"]="?href={url}&title={title}";
sharearray["http://slashdot.org/bookmark.pl"]="?url={url}";
sharearray["http://www.spurl.net/spurl.php"]="?url={url}&title={title}";
sharearray["http://www.stumbleupon.com/submit"]="?url={url}&title={title}";
sharearray["http://tailrank.com/share/"]="?link_href={url}&title={title}";
sharearray["http://technorati.com/faves/"]="?add={url}";
sharearray["http://twitter.com/share"]="?url={url}&text={title}";
sharearray["http://bookmarks.yahoo.com/toolbar/savebm"]="?opener=tb&u={url}&t={title}";
sharearray["http://buzz.yahoo.com/submit"]="?submitUrl={url}&submitHeadline={title}";
sharearray["http://www.yardbarker.com/author/new/"]="?pUrl={url}";
function initShareLinks(){
	$(".share a:not(.email,.moreshare,.favorites,#shareclose)").bind("click", shareLink);
	$(".share a[class=favorites]").bind("click", bookmarkPage);
	$(".share .email").bind("click", function(){
		if($(this).parents(".news-article").length > 0){
 			lastshared= $(this).parents(".news-article").find("h3 a:first").attr("href");
		} else {
			lastshared = urlstring;
		}
	})
}
lastshared = "";
function shareLink(){
	if(typeof sharearray[$(this).attr("href")] == "undefined"){return;}
	var rel = $(this).attr("href")+sharearray[$(this).attr("href")];
	urlstring = self.location.href.split("#")[0]
	if($(this).parents(".news-article").length > 0){
		var url = encodeURIComponent($(this).parents(".news-article").find("h3 a:first").attr("href"));
	} else {
		var url = encodeURIComponent(urlstring);
	}
	var shorturl = url;
	$.get('/ajax/bitly.php?longurl='+url, function(data){
		var title = encodeURIComponent($("title:first").html());
		rel = rel.replace("{url}",data);
		rel = rel.replace("{title}",title);
		newwindow = window.open(rel,'lithiumsharepage');
		try{
		   newwindow.focus();
		} catch(e){}
		return false;
	});
	return false;
	
}
function bookmarkPage(){
	loc = document.location.href;
	title = document.title;
	try{
		window.external.AddFavorite(loc,title);
		return false;
	}
	catch(err){}
	try {
		window.sidebar.addPanel(title,loc,'');
		return false
	}
	catch(err){}
	alert("Sorry, your browser cannot add bookmarks from this link. Please save this page from your browser's bookmark menu.");
	return false;
}

/***************************************
  Columns
   @author Karl Swedberg
   @version 0.2 (08/19/2008)
   @requires jQuery v1.2.6+
  
***************************************/

;(function($) {
$.fn.columns = function(options) {
  var opts = $.extend(true, {}, $.fn.columns.defaults, options);


  return this.each(function(event) {
    var $container = $(this),
      nname = this.nodeName,
      $kids = $container.children(),
      col = 1,
      item = 1,
      items = [],
      cClass = opts.columnClass;
    
    if (opts.columnWrapper) {
      var cw = this.className ? this.className + ' ' + opts.columnWrapperClass : opts.columnWrapperClass;
      var $wrap = $(opts.columnWrapper)
        .addClass(cw + ' ' + cw + '-' + opts.columns)
        .attr('id', this.id)
        .insertBefore($container);
    }
    for (var i=0, klength = $kids.length; i < klength; i++) {
      items.push($kids[i]);
      var itemStart = (klength/opts.columns)*col;
      if (i+1 >= itemStart || i === klength-1) {
      item = Math.ceil(itemStart);  
        var $parent = $('<' + nname + ' class="' + cClass + ' ' + cClass + '-' + col + '"></' + nname + '>')
          .append($(items));
        if (i === klength-1) {
          $parent.addClass(cClass + '-last');
        }
        if (opts.columnWrapper) {
          $parent.appendTo($wrap);
        } else {
          $parent.insertBefore($container);
        }
        if ($parent[0].nodeName == 'OL' && col > 1) {
          $parent.attr('start', start);
        }
        col++;
        items = [];
      }
      var start = item+1;
    }
    
    $container.remove();


  });
};

})(jQuery);


$.fn.columns.defaults = {
  columns: 3,
  columnClass: 'floatcols',
  columnWrapper: '<div></div>', // set to null if you don't want a wrapper around all columns
  columnWrapperClass: 'column-wrapper'
};


jQuery.fn.revealers = function(){
	return this.each(function(){
		$(this).find("p").hide();
		$(this).find("h5").bind("click", function(){
			$(this).toggleClass("open");
			$(this).next("p").slideToggle(100);
		})
	})
}


jQuery.fn.overlayImage = function(){
	return this.each(function(){
		$(this).bind("click", function(){
			$("#overlayholder").html("<div class='overlaywrapper overlayphoto'><h5 class='close'><a href='#'>Close</a></h5></div>");
			$("#overlaybg").show();
			$("#overlayholder").show().css("visibility","hidden");
			$(".return a,.close a,.closelink").bind("click", jQuery.fn.overlay.closeEvent)
			var overlayimg = new Image()
			var overlaytitle = $(this).attr("title")
			overlayimg.src = $(this).attr("href");
			overlayimg.onload = function(){
				$("#overlayholder .overlaywrapper").append(overlayimg)
				if(overlaytitle != ""){
					$("#overlayholder .overlaywrapper").append("<p class='overlayimagetitle'>"+overlaytitle+"</p>")
				}
				setTimeout(function()
				{
		
					newtop = scrollTop + $(window).height()/2 - $(".overlaywrapper").height()/2;	
		
					$(".overlaywrapper").css("top",newtop);
					$(".overlaywrapper").css("left", $("#contentwrapper").width()/2-$(".overlaywrapper:first").width()/2+"px");
					$("#overlayholder").css("visibility","visible");
				}, 100)
			}
			
			return false;
		})
	});
}

var callbackreference;

jQuery.fn.overlay = function(addcallback){
	if(!jQuery.fn.overlay.hasrun){
		jQuery.fn.overlay.init();
	}
	var addcallback = addcallback;
	return this.each(function(){	
		$(this).bind("click", function(){
			
			var arr = $(this).attr("href").split("/");
			if(arr[0] == "http:"){
				arr.shift();
				arr.shift();
			}
			if(typeof addcallback == "function"){
				callbackreference = addcallback;
			} else {
				callbackreference = "";
			}
			if(typeof console != "undefined"){
				console.log(arr[arr.length-1]);
			}
			if(arr[1] == "overlays"){
				$.History.setHash("lithium/"+arr[arr.length-1]);
			} else {
				$.History.setHash(arr[arr.length-1]);
			}
			return false;
		})
	})
}

var scrollTop = "";
jQuery.fn.overlay.open = function(href){
	$("#overlayholder").empty().css("visibility","hidden").load(href+ " .overlaywrapper", function(responseText, textStatus, XMLHttpRequest){
		if(textStatus != "success"){	
			return false;
		}
		if(typeof pageTracker !="undefined"){
			pageTracker._trackPageview(href);
		}
		if(typeof mktoMunchkinFunction != "undefined"){
			mktoMunchkinFunction('visitWebPage', {url: href, params: ''});
		}
		$("#overlaybg").css("height", $(document).height()+"px");
		if(jQuery.browser.version == "6.0" && jQuery.browser.msie){
			$("#lithiumform-contactpage").hide();
			$(".cols241 li:first-child,.cols189 li:first-child").addClass("first-child");
		}
		$("#overlaybg").show();
		$("#overlayholder").show().css("visibility","hidden");

		scrollTop = $(window).scrollTop();

		$(".return a,.close a,.closelink").bind("click", jQuery.fn.overlay.closeEvent)
		if($("#parentname").length > 0){
			var arr = document.title.split(" - ");
			$("#parentname").text("to "+arr[arr.length-1]);
		}
		
		// Overlay to overlay link
		$("#overlayholder .overlink").overlay();
		
		$("#overlayholder .revealers").revealers();
		
		$("#overlayholder .scroller").rotatingSlider();
		
		if($("#overlayholder .imagerotator").length> 0){
			$.getScript("/javascripts/cycle.js");
		}
		
		setTimeout(function(){
			if($(".overlaywrapper:first").height() > $(window).height()){
				$(window).scrollTop(0);	
				newtop = "50px"
			} else {
				newtop = scrollTop + $(window).height()/2 - $(".overlaywrapper:first").height()/2;	
			}
			$(".overlaywrapper:first").css("top",newtop);
			$(".overlaywrapper:first").css("left", $("#contentwrapper").width()/2-$(".overlaywrapper:first").width()/2+"px");
			$("#overlayholder").css("visibility","visible");
			initShareLinks();
			
			if(typeof callbackreference == "function"){
					callbackreference.call();
			}
		}, 100)
	});
	return false;
}
jQuery.fn.overlay.init = function(){
	jQuery.fn.overlay.hasrun = true;
	$("#contentwrapper").after("<div id='overlaybg'></div>");
	$("#overlaybg").css("height", $(document).height()+"px");
	$("#overlaybg").after("<div id='overlayholder'></div>");
	$(document).keyup(function(event){
		if (event.keyCode == 27) {
			jQuery.fn.overlay.closeEvent()
		}
	});
}
jQuery.fn.overlay.closeEvent = function(e){
	if(typeof e != "undefined"){
		e.preventDefault();
	}
	if($(".overlayphoto").length > 0){
		jQuery.fn.overlay.close();
	} else {
		$.History.setHash("");
	}
	return false;
}
jQuery.fn.overlay.close = function(){
	$("#overlayholder iframe").attr("src", "");
	$("#overlayholder,#overlaybg").hide();
	if(jQuery.browser.version == "6.0" && jQuery.browser.msie){
		$("#lithiumform-contactpage").show();
	}
	if(scrollTop != ""){
		$(window).scrollTop(scrollTop);
	}
}
jQuery.fn.overlay.hasrun = false;


jQuery.fn.rotatingSlider = function(){
	return this.each(function(){
		var ul,width,viewportwidth;

		// we are assuming we're sliding a UL tag but it could be anything.
		
		ul = $(this).find(":first");

		// RESET first element margin		
		if(ul.css("margin-left") != "0px"){
			ul.find(":first").css("margin-left", "0px !important");
			ul.css("margin-left", "0px");
		}
		
		// Set length of UL exactly
		lastli = $(this).find(":first>:last");
		width = lastli.position()["left"] + lastli.outerWidth() - ul.position()["left"]+19;

		
		ul.css("width", width+"px");
		viewportwidth = $(this).width();
		
		// Don't show controls if there aren't extra images
		if(width-19 < viewportwidth){
			return;
		}

		
		// Generate Controller 
		cont = $(document.createElement("ul")).addClass("rcontroller");
		next = $(document.createElement("a")).addClass("next");
		prev = $(document.createElement("a")).addClass("prev disabled");
		cont.prepend("<li></li><li></li>");
		cont.find(":first").prepend(prev);
		cont.find(":last").prepend(next);
		$(this).before(cont);
		
		next.bind("click", function(){
			prev.removeClass("disabled")
			left = ul.css("margin-left").replace("px","")*1;
			if((left - viewportwidth) < (width-viewportwidth)*-1) {
				newleft =  (width-viewportwidth)*-1+"px";
			} else {
				newleft = left-viewportwidth+"px";
			}
			ul.animate({marginLeft: newleft})
			if(newleft == (width-viewportwidth)*-1+"px"){
				$(this).addClass("disabled");
			}
			return false;
		})
		
		prev.bind("click", function(){
			next.removeClass("disabled")
			left = ul.css("margin-left").replace("px","")*1;
			if(((left + viewportwidth) * 1) > 0) {
				newleft =  "0px";
			} else {
				newleft = left+viewportwidth+"px";
			}
			ul.animate({marginLeft: newleft})
			if(newleft == "0px"){
				$(this).addClass("disabled");
			}
			return false;
		})
			
	})
};


//jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	// swing: function (x, t, b, c, d) {
	// 	//alert(jQuery.easing.default);
	// 	return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	// },
	easeInCubic: function (x, t, b, c, d) {
			return c*(t/=d)*t*t + b;
		},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	}
});


function getBackgroundPosition(element){
	bgpos = element.css("backgroundPosition");
	if(typeof bgpos == "string"){
		return bgpos;
	} else {
		bgposx = element.css("background-position-x");
		bgposy = element.css("background-position-y");
		return bgposx + " " + bgposy;
	}
}
function setBackgroundPosition(element, newbg){
	bgpos = element.css("backgroundPosition");
	if(typeof bgpos == "string"){
		element.css("backgroundPosition", newbg)
	} else {
		bgarray = newbg.split(' ');
		element.css("background-position-x", bgarray[0]);
		element.css("background-position-y", bgarray[1]);
	}
}

function setWidth(){
	// sidebar pos
		var sidebarbg = getBackgroundPosition($('.sidebar:eq(0)'))
	//body class
	if($(window).width() < 1000){
		$("body").addClass("narrowlayout");
		setBackgroundPosition($('.sidebar:eq(0)'), sidebarbg.replace(/^40px/, "20px"))
	} else {
		$("body").removeClass("narrowlayout");
		setBackgroundPosition($('.sidebar:eq(0)'), sidebarbg.replace(/^20px/, "40px"))
	}
}

$(document).ready(function(){
	
	if ($("body.thankyou").length > 0){return false;}
	
	// set random BG
	if($("body.homepage").length == 0){
		bgcolors = ["da291c","6d2077","319b42","0085ca","ce0058"];
		randbg = Math.floor(Math.random()*4)+1;
		$("html,body").css("background", "#"+bgcolors[randbg-1]+" url(/images/int/backgrounds/bg"+randbg+".png) 39px 0 repeat fixed");
		$("#contentwrapper").css("background", "#FFF url(/images/int/backgrounds/flag"+randbg+".png) 100% 0 no-repeat");
		$("#logo a").css("background-position", -150*randbg+"px 0");		
		
		// check width
		$(window).bind('resize', function() { 
			if (widthTimer) clearTimeout(widthTimer); 
			widthTimer = setTimeout(setWidth, 10);
		});
		setWidth();
		var widthTimer = null;
	}
	
	$(".topli").bind("focusin mouseover", function(){$(this).addClass("active")});
	$(".topli").bind("focusout blur mouseout", function(){$(this).removeClass("active")});
	
	
	// set sidebar BG
	if($(".contentwside .content").length > 0){
		var sidebarheight = $($(".sidebar")[0]).height()
		var diff = $($(".contentwside .content")[0]).height() - sidebarheight;
		
		
		if(diff > 220){
			multiplier = Math.floor((diff-20) / 200);
			if(multiplier < 4){
				var paddingbottom = multiplier * 200 + 20;
			} else {
				var paddingbottom = 820;
			}
			$('.sidebar').css({"background-position": "0 "+Number(sidebarheight+20)+"px", "padding-bottom": paddingbottom+"px"});
			setWidth();
		}
		
	}
	
	if($(".grid").length > 0){
		$.getScript("/javascripts/jquery.masonry.min.js", function(){	
			$('.grid').masonry({
				itemSelector : '.tile',
				columnWidth : 280,
				gutterWidth: 20
			});
		});
	}
	
	$(".hoverinner").bind("click", function(e){
		var link = $(this).find("a:first");
		if(link.hasClass("overlink")){
			link.trigger("click");
		} else {
			if(link.data("target") == "current"){
				var newfriend = window.location = link.attr("href");
			}else{
				var newfriend = window.open(link.attr("href"));
			}
		}
	})
	$(".hoverinner a").bind("click", function(e){
		e.stopPropagation();
	})
	
	$(".story_controlbar a").bind("click", function(){
		var $this = $(this);
		
		if($this.hasClass("filterbutton")){
			return false;
		}
		
		if(!$this.hasClass("active")){
			$('.customer-list').hide();
			$($this.attr("href")).show();
			$('.story_controlbar .active').removeClass("active");
			$this.addClass('active');
			$this.parent('li').addClass('active');
			$('.story_controlbar h3').text($this.text());
		} 
		return false;
	});
	
	$(".overimg").overlayImage();
	
	$(".overlink").overlay();
	
	$(".overlink-withrotator").overlay();
	
	$.History.bind(function(state){
		
		if(state == ""){
			jQuery.fn.overlay.close();
			return;
		}
		arr = state.split("/");
		if(arr[0] == "http:"){
			arr.shift();
			arr.shift();
		}
		if(arr.length > 1){
			jQuery.fn.overlay.open("/overlays/"+state);
		} else {
			jQuery.fn.overlay.open("overlays/"+state);
		}
	});
	
	// Customer List
	
	
	
	// Customer fade in array
//	custfade =  [0, [1,6], [2,7], [3,8], [4,9], [5,10], 11];
	custfade = [0,6,1,7,2,8,3,9,4,5,10,11]
	
	function fadeNext(){
		if(typeof index == "undefined"){index = 0;}
		if(typeof custfade[index] == "undefined") { 
			$("#customerlist li:gt(5)").addClass("lower");
			$("#customerlist .overlay").bind("click", function(){
				$(this).find("h4 a").trigger("click");
				return false;
			})
			$("#customerlist li").hover(
				function(){$(this).find(".overlay").fadeIn(100)},
				function(){$(this).find(".overlay").fadeOut(100)}
			);	
		return; }
		var donext = function(){fadeNext(++index)};
		setTimeout(donext, 125)
		if(typeof custfade[index] == "object"){
			doFadeIn(custfade[index][0])
			doFadeIn(custfade[index][1])
		} else {
			doFadeIn(custfade[index])
		}
	}
	function doFadeIn(itemindex){
		$('#customerlist .item:eq('+itemindex+') .overlay').fadeOut(500, function(){$(this).find("h4").show()});
		//animateCustomerFlag($('#customerlist .item:eq('+itemindex+') .overlay'));
	}
	setTimeout(fadeNext, 1500);
	
	$("ul.partners .item").hover(
		function(){$(this).find(".overlay").fadeIn(100)},
		function(){$(this).find(".overlay").fadeOut(100)}
	);
		
	$("#site_search").bind("focus", function(){
		$("#globalsearch").css("visibility", "visible").hide().fadeIn(250)
	})
		
	$(".scroller").rotatingSlider();

	$(".morecontent").hide();
	
	$(".morelink").bind("click", function(){
		target = $($(this).attr("href")+":visible");
		if(target.length == 1){
			$(target).hide();
			$(this).text($(this).text().replace("Fewer ","More "));
		} else {
			$($(this).attr("href")).fadeIn()
			$(this).text($(this).text().replace("More ","Fewer "));
		}
		$(this).toggleClass("open").blur();
		return false;
	}).css("display", "block")
	
	if($("#fblike").length > 0){
		$("#fblike").html('<iframe src="http://www.facebook.com/plugins/like.php?href='+encodeURIComponent(window.location)+'&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:100px;" allowTransparency="true"></iframe>')
	}
	
	// if($("#awardsrotator, .imagerotator, .contentrotator").length > 0){
	// 	$.getScript("/javascripts/cycle.js");
	// }
	
	$("a[rel*=external]").attr("target","_blank");
	$(".clearfix .halfboxindent:nth-child(odd)").addClass("first");	
	$(".ppl li:nth-child(odd)").addClass("first");	
	$(".cols200 li:first-child").addClass("first-child");	

	$('.col3').columns({columns: 3, columnClass: 'll', columnWrapper: null});
	
   $('.simplepartnerslist').columns({columns: 4, columnClass: 'col', columnWrapper: null});

   $('.cols189 .ll').wrap('<li></li>');
initShareLinks();
});

/*
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2009 M. Alsup
 * Version: 2.66 (04-JUN-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.6 or later
 *
 * Originally based on the work of:
 *	1) Matt Oakes
 *	2) Torsten Baldes (http://medienfreunde.com/lab/innerfade/)
 *	3) Benjamin Sterling (http://www.benjaminsterling.com/experiments/jqShuffle/)
 */
(function(h){var k="2.66";if(h.support==undefined){h.support={opacity:!(h.browser.msie)}}function e(){if(window.console&&window.console.log){window.console.log("[cycle] "+Array.prototype.join.call(arguments," "))}}h.fn.cycle=function(r,q){var s={s:this.selector,c:this.context};if(this.length==0&&r!="stop"){if(!h.isReady&&s.s){e("DOM not ready, queuing slideshow");h(function(){h(s.s,s.c).cycle(r,q)});return this}e("terminating; zero elements found by selector"+(h.isReady?"":" (DOM not ready)"));return this}return this.each(function(){r=l(this,r,q);if(r===false){return}if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=this.cyclePause=0;var u=h(this);var v=r.slideExpr?h(r.slideExpr,this):u.children();var o=v.get();if(o.length<2){e("terminating; too few slides: "+o.length);return}var t=j(u,v,o,r,s);if(t===false){return}if(t.timeout||t.continuous){this.cycleTimeout=setTimeout(function(){d(o,t,0,!t.rev)},t.continuous?10:t.timeout+(t.delay||0))}})};function l(o,s,q){if(o.cycleStop==undefined){o.cycleStop=0}if(s===undefined||s===null){s={}}if(s.constructor==String){switch(s){case"stop":o.cycleStop++;if(o.cycleTimeout){clearTimeout(o.cycleTimeout)}o.cycleTimeout=0;h(o).removeData("cycle.opts");return false;case"pause":o.cyclePause=1;return false;case"resume":o.cyclePause=0;if(q===true){s=h(o).data("cycle.opts");if(!s){e("options not found, can not resume");return false}if(o.cycleTimeout){clearTimeout(o.cycleTimeout);o.cycleTimeout=0}d(s.elements,s,1,1)}return false;default:s={fx:s}}}else{if(s.constructor==Number){var r=s;s=h(o).data("cycle.opts");if(!s){e("options not found, can not advance slide");return false}if(r<0||r>=s.elements.length){e("invalid slide index: "+r);return false}s.nextSlide=r;if(o.cycleTimeout){clearTimeout(o.cycleTimeout);o.cycleTimeout=0}if(typeof q=="string"){s.oneTimeFx=q}d(s.elements,s,1,r>=s.currSlide);return false}}return s}function a(o,q){if(!h.support.opacity&&q.cleartype&&o.style.filter){try{o.style.removeAttribute("filter")}catch(r){}}}function j(y,I,u,t,E){var C=h.extend({},h.fn.cycle.defaults,t||{},h.metadata?y.metadata():h.meta?y.data():{});if(C.autostop){C.countdown=C.autostopCount||u.length}var r=y[0];y.data("cycle.opts",C);C.$cont=y;C.stopCount=r.cycleStop;C.elements=u;C.before=C.before?[C.before]:[];C.after=C.after?[C.after]:[];C.after.unshift(function(){C.busy=0});if(!h.support.opacity&&C.cleartype){C.after.push(function(){a(this,C)})}if(C.continuous){C.after.push(function(){d(u,C,0,!C.rev)})}m(C);if(!h.support.opacity&&C.cleartype&&!C.cleartypeNoBg){f(I)}if(y.css("position")=="static"){y.css("position","relative")}if(C.width){y.width(C.width)}if(C.height&&C.height!="auto"){y.height(C.height)}if(C.startingSlide){C.startingSlide=parseInt(C.startingSlide)}if(C.random){C.randomMap=[];for(var G=0;G<u.length;G++){C.randomMap.push(G)}C.randomMap.sort(function(w,o){return Math.random()-0.5});C.randomIndex=0;C.startingSlide=C.randomMap[0]}else{if(C.startingSlide>=u.length){C.startingSlide=0}}C.currSlide=C.startingSlide=C.startingSlide||0;var x=C.startingSlide;I.css({position:"absolute",top:0,left:0}).hide().each(function(o){var w=x?o>=x?u.length-(o-x):x-o:u.length-o;h(this).css("z-index",w)});h(u[x]).css("opacity",1).show();a(u[x],C);if(C.fit&&C.width){I.width(C.width)}if(C.fit&&C.height&&C.height!="auto"){I.height(C.height)}var D=C.containerResize&&!y.innerHeight();if(D){var v=0,B=0;for(var G=0;G<u.length;G++){var q=h(u[G]),J=q[0],A=q.outerWidth(),H=q.outerHeight();if(!A){A=J.offsetWidth}if(!H){H=J.offsetHeight}v=A>v?A:v;B=H>B?H:B}if(v>0&&B>0){y.css({width:v+"px",height:B+"px"})}}if(C.pause){y.hover(function(){this.cyclePause++},function(){this.cyclePause--})}if(b(C)===false){return false}if(!C.multiFx){var F=h.fn.cycle.transitions[C.fx];if(h.isFunction(F)){F(y,I,C)}else{if(C.fx!="custom"&&!C.multiFx){e("unknown transition: "+C.fx,"; slideshow terminating");return false}}}var s=false;t.requeueAttempts=t.requeueAttempts||0;I.each(function(){var L=h(this);this.cycleH=(C.fit&&C.height)?C.height:L.height();this.cycleW=(C.fit&&C.width)?C.width:L.width();if(L.is("img")){var w=(h.browser.msie&&this.cycleW==28&&this.cycleH==30&&!this.complete);var M=(h.browser.mozilla&&this.cycleW==34&&this.cycleH==19&&!this.complete);var K=(h.browser.opera&&this.cycleW==42&&this.cycleH==19&&!this.complete);var o=(this.cycleH==0&&this.cycleW==0&&!this.complete);if(w||M||K||o){if(E.s&&C.requeueOnImageNotLoaded&&++t.requeueAttempts<100){e(t.requeueAttempts," - img slide not loaded, requeuing slideshow: ",this.src,this.cycleW,this.cycleH);setTimeout(function(){h(E.s,E.c).cycle(t)},C.requeueTimeout);s=true;return false}else{e("could not determine size of image: "+this.src,this.cycleW,this.cycleH)}}}return true});if(s){return false}C.cssBefore=C.cssBefore||{};C.animIn=C.animIn||{};C.animOut=C.animOut||{};I.not(":eq("+x+")").css(C.cssBefore);if(C.cssFirst){h(I[x]).css(C.cssFirst)}if(C.timeout){C.timeout=parseInt(C.timeout);if(C.speed.constructor==String){C.speed=h.fx.speeds[C.speed]||parseInt(C.speed)}if(!C.sync){C.speed=C.speed/2}while((C.timeout-C.speed)<250){C.timeout+=C.speed}}if(C.easing){C.easeIn=C.easeOut=C.easing}if(!C.speedIn){C.speedIn=C.speed}if(!C.speedOut){C.speedOut=C.speed}C.slideCount=u.length;C.currSlide=C.lastSlide=x;if(C.random){C.nextSlide=C.currSlide;if(++C.randomIndex==u.length){C.randomIndex=0}C.nextSlide=C.randomMap[C.randomIndex]}else{C.nextSlide=C.startingSlide>=(u.length-1)?0:C.startingSlide+1}var z=I[x];if(C.before.length){C.before[0].apply(z,[z,z,C,true])}if(C.after.length>1){C.after[1].apply(z,[z,z,C,true])}if(C.next){h(C.next).click(function(){return n(C,C.rev?-1:1)})}if(C.prev){h(C.prev).click(function(){return n(C,C.rev?1:-1)})}if(C.pager){c(u,C)}i(C,u);return C}function m(o){o.original={before:[],after:[]};o.original.cssBefore=h.extend({},o.cssBefore);o.original.cssAfter=h.extend({},o.cssAfter);o.original.animIn=h.extend({},o.animIn);o.original.animOut=h.extend({},o.animOut);h.each(o.before,function(){o.original.before.push(this)});h.each(o.after,function(){o.original.after.push(this)})}function b(v){var r=h.fn.cycle.transitions;if(v.fx.indexOf(",")>0){v.multiFx=true;v.fxs=v.fx.replace(/\s*/g,"").split(",");for(var t=0;t<v.fxs.length;t++){var u=v.fxs[t];var q=r[u];if(!q||!r.hasOwnProperty(u)||!h.isFunction(q)){e("discarding unknown transition: ",u);v.fxs.splice(t,1);t--}}if(!v.fxs.length){e("No valid transitions named; slideshow terminating.");return false}}else{if(v.fx=="all"){v.multiFx=true;v.fxs=[];for(p in r){var q=r[p];if(r.hasOwnProperty(p)&&h.isFunction(q)){v.fxs.push(p)}}}}if(v.multiFx&&v.randomizeEffects){var s=Math.floor(Math.random()*20)+30;for(var t=0;t<s;t++){var o=Math.floor(Math.random()*v.fxs.length);v.fxs.push(v.fxs.splice(o,1)[0])}e("randomized fx sequence: ",v.fxs)}return true}function i(q,o){q.addSlide=function(t,u){var r=h(t),v=r[0];if(!q.autostopCount){q.countdown++}o[u?"unshift":"push"](v);if(q.els){q.els[u?"unshift":"push"](v)}q.slideCount=o.length;r.css("position","absolute");r[u?"prependTo":"appendTo"](q.$cont);if(u){q.currSlide++;q.nextSlide++}if(!h.support.opacity&&q.cleartype&&!q.cleartypeNoBg){f(r)}if(q.fit&&q.width){r.width(q.width)}if(q.fit&&q.height&&q.height!="auto"){$slides.height(q.height)}v.cycleH=(q.fit&&q.height)?q.height:r.height();v.cycleW=(q.fit&&q.width)?q.width:r.width();r.css(q.cssBefore);if(q.pager){h.fn.cycle.createPagerAnchor(o.length-1,v,h(q.pager),o,q)}if(h.isFunction(q.onAddSlide)){q.onAddSlide(r)}else{r.hide()}}}h.fn.cycle.resetState=function(q,o){o=o||q.fx;q.before=[];q.after=[];q.cssBefore=h.extend({},q.original.cssBefore);q.cssAfter=h.extend({},q.original.cssAfter);q.animIn=h.extend({},q.original.animIn);q.animOut=h.extend({},q.original.animOut);q.fxFn=null;h.each(q.original.before,function(){q.before.push(this)});h.each(q.original.after,function(){q.after.push(this)});var r=h.fn.cycle.transitions[o];if(h.isFunction(r)){r(q.$cont,h(q.elements),q)}};function d(w,o,v,x){if(v&&o.busy&&o.manualTrump){h(w).stop(true,true);o.busy=false}if(o.busy){return}var t=o.$cont[0],z=w[o.currSlide],y=w[o.nextSlide];if(t.cycleStop!=o.stopCount||t.cycleTimeout===0&&!v){return}if(!v&&!t.cyclePause&&((o.autostop&&(--o.countdown<=0))||(o.nowrap&&!o.random&&o.nextSlide<o.currSlide))){if(o.end){o.end(o)}return}if(v||!t.cyclePause){var u=o.fx;z.cycleH=z.cycleH||h(z).height();z.cycleW=z.cycleW||h(z).width();y.cycleH=y.cycleH||h(y).height();y.cycleW=y.cycleW||h(y).width();if(o.multiFx){if(o.lastFx==undefined||++o.lastFx>=o.fxs.length){o.lastFx=0}u=o.fxs[o.lastFx];o.currFx=u}if(o.oneTimeFx){u=o.oneTimeFx;o.oneTimeFx=null}h.fn.cycle.resetState(o,u);if(o.before.length){h.each(o.before,function(A,B){if(t.cycleStop!=o.stopCount){return}B.apply(y,[z,y,o,x])})}var r=function(){h.each(o.after,function(A,B){if(t.cycleStop!=o.stopCount){return}B.apply(y,[z,y,o,x])})};if(o.nextSlide!=o.currSlide){o.busy=1;if(o.fxFn){o.fxFn(z,y,o,r,x)}else{if(h.isFunction(h.fn.cycle[o.fx])){h.fn.cycle[o.fx](z,y,o,r)}else{h.fn.cycle.custom(z,y,o,r,v&&o.fastOnEvent)}}}o.lastSlide=o.currSlide;if(o.random){o.currSlide=o.nextSlide;if(++o.randomIndex==w.length){o.randomIndex=0}o.nextSlide=o.randomMap[o.randomIndex]}else{var s=(o.nextSlide+1)==w.length;o.nextSlide=s?0:o.nextSlide+1;o.currSlide=s?w.length-1:o.nextSlide-1}if(o.pager){h.fn.cycle.updateActivePagerLink(o.pager,o.currSlide)}}var q=0;if(o.timeout&&!o.continuous){q=g(z,y,o,x)}else{if(o.continuous&&t.cyclePause){q=10}}if(q>0){t.cycleTimeout=setTimeout(function(){d(w,o,0,!o.rev)},q)}}h.fn.cycle.updateActivePagerLink=function(o,q){h(o).find("a").removeClass("activeSlide").filter("a:eq("+q+")").addClass("activeSlide")};function g(u,r,s,q){if(s.timeoutFn){var o=s.timeoutFn(u,r,s,q);if(o!==false){return o}}return s.timeout}h.fn.cycle.next=function(o){n(o,o.rev?-1:1)};h.fn.cycle.prev=function(o){n(o,o.rev?1:-1)};function n(q,t){var o=q.elements;var s=q.$cont[0],r=s.cycleTimeout;if(r){clearTimeout(r);s.cycleTimeout=0}if(q.random&&t<0){q.randomIndex--;if(--q.randomIndex==-2){q.randomIndex=o.length-2}else{if(q.randomIndex==-1){q.randomIndex=o.length-1}}q.nextSlide=q.randomMap[q.randomIndex]}else{if(q.random){if(++q.randomIndex==o.length){q.randomIndex=0}q.nextSlide=q.randomMap[q.randomIndex]}else{q.nextSlide=q.currSlide+t;if(q.nextSlide<0){if(q.nowrap){return false}q.nextSlide=o.length-1}else{if(q.nextSlide>=o.length){if(q.nowrap){return false}q.nextSlide=0}}}}if(h.isFunction(q.prevNextClick)){q.prevNextClick(t>0,q.nextSlide,o[q.nextSlide])}d(o,q,1,t>=0);return false}function c(q,r){var o=h(r.pager);h.each(q,function(s,t){h.fn.cycle.createPagerAnchor(s,t,o,q,r)});h.fn.cycle.updateActivePagerLink(r.pager,r.startingSlide)}h.fn.cycle.createPagerAnchor=function(t,u,r,s,v){var q=(h.isFunction(v.pagerAnchorBuilder))?v.pagerAnchorBuilder(t,u):'<a href="#">'+(t+1)+"</a>";if(!q){return}var w=h(q);if(w.parents("body").length==0){var o=[];if(r.length>1){r.each(function(){var x=w.clone(true);h(this).append(x);o.push(x)});w=h(o)}else{w.appendTo(r)}}w.bind(v.pagerEvent,function(){v.nextSlide=t;var y=v.$cont[0],x=y.cycleTimeout;if(x){clearTimeout(x);y.cycleTimeout=0}if(h.isFunction(v.pagerClick)){v.pagerClick(v.nextSlide,s[v.nextSlide])}d(s,v,1,v.currSlide<t);return false});if(v.pauseOnPagerHover){w.hover(function(){v.$cont[0].cyclePause++},function(){v.$cont[0].cyclePause--})}};h.fn.cycle.hopsFromLast=function(s,r){var q,o=s.lastSlide,t=s.currSlide;if(r){q=t>o?t-o:s.slideCount-o}else{q=t<o?o-t:o+s.slideCount-t}return q};function f(r){function q(t){t=parseInt(t).toString(16);return t.length<2?"0"+t:t}function o(u){for(;u&&u.nodeName.toLowerCase()!="html";u=u.parentNode){var s=h.css(u,"background-color");if(s.indexOf("rgb")>=0){var t=s.match(/\d+/g);return"#"+q(t[0])+q(t[1])+q(t[2])}if(s&&s!="transparent"){return s}}return"#ffffff"}r.each(function(){h(this).css("background-color",o(this))})}h.fn.cycle.commonReset=function(u,s,t,q,r,o){h(t.elements).not(u).hide();t.cssBefore.opacity=1;t.cssBefore.display="block";if(q!==false&&s.cycleW>0){t.cssBefore.width=s.cycleW}if(r!==false&&s.cycleH>0){t.cssBefore.height=s.cycleH}t.cssAfter=t.cssAfter||{};t.cssAfter.display="none";h(u).css("zIndex",t.slideCount+(o===true?1:0));h(s).css("zIndex",t.slideCount+(o===true?0:1))};h.fn.cycle.custom=function(A,u,o,r,q){var z=h(A),v=h(u);var s=o.speedIn,y=o.speedOut,t=o.easeIn,x=o.easeOut;v.css(o.cssBefore);if(q){if(typeof q=="number"){s=y=q}else{s=y=1}t=x=null}var w=function(){v.animate(o.animIn,s,t,r)};z.animate(o.animOut,y,x,function(){if(o.cssAfter){z.css(o.cssAfter)}if(!o.sync){w()}});if(o.sync){w()}};h.fn.cycle.transitions={fade:function(q,r,o){r.not(":eq("+o.currSlide+")").css("opacity",0);o.before.push(function(u,s,t){h.fn.cycle.commonReset(u,s,t);t.cssBefore.opacity=0});o.animIn={opacity:1};o.animOut={opacity:0};o.cssBefore={top:0,left:0}}};h.fn.cycle.ver=function(){return k};h.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,prevNextClick:null,pager:null,pagerClick:null,pagerEvent:"click",pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!h.support.opacity,cleartypeNoBg:false,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250}})(jQuery);


startRotate(".imagerotator");

$("#awardsrotator").cycle();

if($(".contentrotator").length > 0) {
	rotatorelement = $(".contentrotator:first").offset()
	if((rotatorelement.top - $(window).height()) < 0){
		startRotate(".contentrotator");
	} else {
		$(window).scroll(function() {
			var y_scroll_pos = $(window).scrollTop();
			var scroll_pos_test = rotatorelement.top - $(window).height();
			if(y_scroll_pos > scroll_pos_test) {
				startRotate(".contentrotator");
				$(window).unbind("scroll");
			}
		})
	}
}

function startRotate(selector){
	$(selector).each(function(){
		$this = $(this);
		$this.after('<div class="rotatenav"><ul></ul></div>').cycle({
			fx: 'fade',
			timeout: 4000,
			speed: 'slow',
			cleartype: false,
			pager: $this.next(".rotatenav").find("ul"),
			pageAnchorBuilder: function(idx, slide){
				return '<li><a href="#">'+$(slide).attr("title")+'</a></li>'; 
			},
			after: function(isNext, currentSlide){
				var me = currentSlide
				var doFade  = function(){
					$(me).find('.custflag').fadeOut(500)
				}
				setTimeout(doFade, 750);
			}
		});
		$this.next(".rotatenav").bind("click", function(){
			$this.cycle("pause");
			return false;
		});
	});
}

