$(document).ready(function(){
	
	/* define regex for MAIN NAVIGATION tabs */
	function isSolutionsTab(strValue)
	{
		return /^(.)+(index.php\?x=)+(21|22|23|35|42|43|44|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73)/.test(strValue);	
	}
	function isServicesTab(strValue)
	{
		return /^(.)+(index.php\?x=)+(25|26|27|28|29|41)/.test(strValue);	
	}
	function isOurWorkTab(strValue)
	{
		return /^(.)+(index.php\?x=)+(30|31)/.test(strValue);	
	}
	function isContactTab(strValue)
	{
		return /^(.)+(index.php\?x=)+(32|33|34|39)/.test(strValue);	
	}
	function isWhoWeAreTab(strValue)
	{
		return /^(.)+(index.php\?x=)+(36|37|38|40|41)/.test(strValue);	
	}
	function isInteriorFeaturesTab(strValue)
	{
		return /^(.)+(index.php\?x=)+(55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73)/.test(strValue);	
	}
	
	/* change tab backgrounds based on page */
	var currentUrl = location.href;
	if (isSolutionsTab(currentUrl)) {
		$("#headerGuts ul li:nth-child(1) a").css("background-image","url(themes/bluehue/images/bg-nav-item-selected-firstchild.gif)");
	}
	if (isServicesTab(currentUrl)) {
		$("#headerGuts ul li:nth-child(2) a").css("background-image","url(themes/bluehue/images/bg-nav-item-selected.gif)");
	}
	if (isOurWorkTab(currentUrl)) {
		$("#headerGuts ul li:nth-child(3) a").css("background-image","url(themes/bluehue/images/bg-nav-item-selected.gif)");
	}
	if (isContactTab(currentUrl)) {
		$("#headerGuts ul li:nth-child(4) a").css("background-image","url(themes/bluehue/images/bg-nav-item-selected.gif)");
	}
	if (isWhoWeAreTab(currentUrl)) {
		$("#headerGuts ul li:nth-child(5) a").css("background-image","url(themes/bluehue/images/bg-nav-item-selected.gif)");
	}
	if (isInteriorFeaturesTab(currentUrl)) {
		$("ul#ec_tabs li:nth-child(3) a").css("background","none");
		$("ul#ec_tabs li:nth-child(3) a").css("border-bottom","1px solid #ffffff");
		$("ul#ec_tabs li:nth-child(3) a").css("color","#198ac8");
	}
	
	
	function gup(name)
	{
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp( regexS );
	  var tmpURL = window.location.href;
	  var results = regex.exec( tmpURL );
	  if( results == null )
	    return "";
	  else
	    return results[1];
	}
	var currentTab = gup("x");

	/* change interior tabs based on page */
	$("#t-"+currentTab).addClass("currentTab");
	
	/* force browsers to be friends */
	if ($.browser.name == "msie" && $.os.name == "win") {
		$("#headerGuts ul li:nth-child(1) ul").css("left","-83px");
		$("#headerGuts ul li:nth-child(2) ul").css("left","-88px");
		$("#headerGuts ul li:nth-child(3) ul").css("left","-84px");
		$("#headerGuts ul li:nth-child(4) ul").css("left","-88px");
		$("#headerGuts ul li:nth-child(5) ul").css("left","-79px");
	} else if ($.browser.name =="firefox" && $.os.name == "win") {
		$("#headerGuts ul li:nth-child(1) ul").css("left","-83px");
		$("#headerGuts ul li:nth-child(2) ul").css("left","-88px");
		$("#headerGuts ul li:nth-child(3) ul").css("left","-84px");
		$("#headerGuts ul li:nth-child(4) ul").css("left","-88px");
		$("#headerGuts ul li:nth-child(5) ul").css("left","-79px");
	} else {
		$("#headerGuts ul li:nth-child(1) ul").css("left","-80px");
		$("#headerGuts ul li:nth-child(2) ul").css("left","-85px");
		$("#headerGuts ul li:nth-child(3) ul").css("left","-81px");
		$("#headerGuts ul li:nth-child(4) ul").css("left","-86px");
		$("#headerGuts ul li:nth-child(5) ul").css("left","-76px");
	}
	
	/* sifr to the rescue! */
	$.sifr({path:'themes/bluehue/flash/sifrFonts'});
	$('h2.sifr').sifr({
		font:'ArialRounded',
		textAlign:'left'
	});
	$('h5.sifr').sifr({
		font:'ArialRounded',
		textAlign:'left'
	});
	$('span.sifr').sifr({
		font:'ArialRounded',
		textAlign:'left'
	});
	
	/* play me a song on the accordion... research and insights */
	$('#accordionBlock').accordion({
		autoheight: false,
		header: '.accordionHead'
	});
	
	/* play me a song on the accordion.. mmm archive */
	$('#mmm_archive').accordion({
		autoheight: false,
		active: false,
		alwaysOpen: false,
		header: '.accordionHead'
	});
	
	/* play me a song on the accordion.. sales careers */
	$('#accordionSalesCareer').accordion({
		autoheight: false,
		active: false,
		alwaysOpen: false,
		header: '.accordionSalesCareerHead'
	});
	
	/* play me a song on the accordion.. creative careers */
	$('#accordionCreativeCareer').accordion({
		autoheight: false,
		active: false,
		alwaysOpen: false,
		header: '.accordionCreativeCareerHead'
	});
	
	/* play me a song on the accordion.. operations careers */
	$('#accordionOperationsCareer').accordion({
		autoheight: false,
		active: false,
		alwaysOpen: false,
		header: '.accordionOperationsCareerHead'
	});
	
	/* flashy goodness */
	$('#casestudies').flash({
    src: 'themes/bluehue/flash/case_studies.swf',
    width: 772,
    height: 705
	});
	
	/* flashy goodness.. deux */
	$('#im_dd_marketing').flash({
    src: 'themes/bluehue/flash/int_marketing_scroll.swf',
    width: 445,
    height: 400
	});
	
	/* flashy goodness.. trois */
	$('#im_video_flash').flash({
    src: 'themes/bluehue/flash/video.swf',
    width: 750,
    height: 439
	});
	
	/* flashy goodness.. quatre */
	$('#ec_overview_flash').flash({
    src: 'themes/bluehue/flash/overview.swf',
    width: 478,
    height: 316
	});
	
	/* flashy goodness.. cinq */
	$('#ec_modules_flash').flash({
    src: 'themes/bluehue/flash/modules_flash.swf',
    width: 467,
    height: 1200
	});
	
	/* flashy goodness.. six */
	$('#con_careers_flash').flash({
    src: 'themes/bluehue/flash/BlueHuevid_recruit.swf',
    width: 320,
    height: 199
	});
	
	/* flashy goodness.. sept */
	$('#portfolio_flash').flash({
    src: 'themes/bluehue/flash/JTportfolio.swf',
    width: 965,
    height: 580,
		wmode: 'transparent'
	});
	
	/* flashy goodness.. huit */
	$('#home_flash').flash({
    src: 'themes/bluehue/flash/blueHue_home.swf',
    width: 788,
    height: 291
	});
	
	/* size up those columns */
	$('#contentWrapper').equalHeights();
	
});

function popUp(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=570,height=720,left = 675,top = 240');");
	}