// ===========
// = rev 007 =
// ===========

/* ----------------------------------------------- REFACTORING START ----------------------------------------------- */

var Avid = function($) {

    var log = function(){ log.history = log.history || []; log.history.push(arguments); arguments.callee = arguments.callee.caller; if(this.console) console.log( Array.prototype.slice.call(arguments) ); };

    var _cache = {
        html : $('*')
    }
    /* ----------------------------------------------- private methods start ----------------------------------------------- */

    var _createCustomerStoriesCarousel = function() {
        log('_createCustomerStoriesCarousel()')
    }

    /* ----------------------------------------------- private methods end ----------------------------------------------- */


    /* ----------------------------------------------- public methods start ----------------------------------------------- */
    return {

        initialize : function() {

            if (_cache.html.index($('#csCarousel')[0]) != -1) { _createCustomerStoriesCarousel(); }

        }
    }
    /* ----------------------------------------------- public methods end ----------------------------------------------- */

}(jQuery);
/* ----------------------------------------------- REFACTORING END ----------------------------------------------- */


(function() {
    Avid.initialize();
})();








/* ******************* */
/* original code start */
/* ******************* */

if(typeof(STATIC_CONTENT_PATH) != "undefined"){
	//alert('STATIC_CONTENT_PATH='+STATIC_CONTENT_PATH);
} else {
	//alert('STATIC_CONTENT_PATH not defined');
	STATIC_CONTENT_PATH = 'http://na-webtmp/Static/';
}

var Eastwood = new EastwoodLib();

$(document).ready(function(){
	initAvid();
	
	// Clearing blank Lower Well:
	if ($('#LowerWellContent *').length == 1 && $('#LowerWellContent br').length == 1) {
		$('#LowerWellContent').next().remove();
		$('#LowerWellContent').remove();
	}
	// $.getScript('/Static/resources/common/js/clickmap_fix.js');
});


function initAvid() {

	var _html = $('*');

	if ( _html.index($('#tabs')[0]) != -1 ) 									{ Eastwood.tabs(); }
	if ( _html.index($('#csCarousel')[0]) != -1 ) 								{ Eastwood.carousel(); }
	if ( _html.index($('#mainwrap.home')[0]) != -1 ) 							{ Eastwood.initHome(); }
	if ( _html.index($('.cw_structTxt_accordians')[0]) != -1 ) 					{ Eastwood.accordian(); }
	if ( _html.index($('.tabTitle')[0]) != -1 ) 								{ Eastwood.inlineTabs();  }
	if ( _html.index($('a[rel="avidShadowbox"]')[0]) != -1 ) 					{ Eastwood.avidShadowbox();  }
	if ( _html.index($('a[rel="avidMaxShadowbox"]')[0]) != -1 ) 				{ Eastwood.avidMaxShadowbox();  }
	if ( _html.index($('a[rel="QTShadowbox"]')[0]) != -1 ) 						{ Eastwood.QTShadowbox();  }
	if ( _html.index($('a[rel^="genShadowbox"]')[0]) != -1 ) 					{ Eastwood.genShadowbox();  }
	if ( _html.index($('a[rel="videoShadowbox"]')[0]) != -1 ) 					{ Eastwood.videoShadowbox();  }
	if ( _html.index($('a[rel="videoShadowboxInline"]')[0]) != -1 ) 			{ Eastwood.videoShadowboxInline();  }
	if ( _html.index($('.cw_imgPromos_pod2x840')[0]) != -1 ) 					{ Eastwood.padpod2x840();  }
	if ( _html.index($('.cw_imgPromos_pod3x840')[0]) != -1 ) 					{ Eastwood.padpod3x840();  }
	if ( _html.index($('.cw_imgPromos_pod4x840')[0]) != -1 ) 					{ Eastwood.padpod4x840();  }
	if ( _html.index($('#LowerWellContent .cw_imgPromos_pod4x840')[0]) != -1 ) 	{ Eastwood.lowerwellPods();  }
	if ( _html.index($('.pod')[0]) != -1 ) 										{ Eastwood.biosPods();  }
	if ( _html.index($('#Display .content')[0]) != -1 ) 						{ Eastwood.displayPanel();  }
	if ( _html.index($('.cw_linkedImg_brandBox')[0]) != -1 ) 					{ Eastwood.brandBox();  }
	if ( _html.index($('.overlay')[0]) != -1 ) 									{ Eastwood.overlayShadowbox();  }
	if ( _html.index($('.heroPod3x3')[0]) != -1 ) 								{ Eastwood.productHome();  }
	if ( _html.index($('table.tablesorter')[0]) != -1 ) 						{ Eastwood.productTable();  }
	if ( _html.index($('a[href$="shadowbox"]')[0]) != -1 ) 						{ Eastwood.openShadowbox(); }
	if ( _html.index($('.box33Stories')[0]) != -1 ) 							{ Eastwood.box33Stories(); }
	if ( _html.index($('.blueActionButton2')[0]) != -1 ) 						{ Eastwood.setPricingBtns(); }
	if ( _html.index($('.cw_quote_fullWidth')[0]) != -1 ) 						{ Eastwood.chkQtImg(); }
	if ( _html.index($('.BCdiagram')[0]) != -1 ) 								{ Eastwood.BCdiagram(); }

	if ((_html.index($('.headerTabs')[0]) != -1 ) && (_html.index($('#hero')[0]) == -1 ))		{ Eastwood.tabsNoHero();  }

	if ( _html.index($('table.featurestbl')[0]) != -1 ) 						{ $("table.featurestbl tr:first th").css("background","#eaeaef"); }
	if ( _html.index($('.cw_linkList_FamilySolutions')[0]) != -1 ) 				{ $('<br class="clear" />').insertAfter(".cw_linkList_FamilySolutions ul"); }
	if ( _html.index($('.group_structTxt_width280')[0]) != -1 ) 				{ $('<br class="clear" />').insertAfter(".group_structTxt_width280"); }
	if ( _html.index($('#lowerHolderContent')[0]) != -1 ) 						{ $('#lowerHolderContent').append('<br class="clear" />'); }

	$("select#productsField").change(function() {
		var thisLoc = $('select#productsField option:selected').val();
		window.location = thisLoc;
	});

	$(document).pngFix();

	//industry solutions
	if ( _html.index($('.indNav li')[0]) != -1 ) 			{ Eastwood.indNavInit(); }
	if ( _html.index($('#BAMRegions')[0]) != -1 ) 			{ Eastwood.BAMLocator(); }
	if ( _html.index($('.inlineTabs li')[0]) != -1 ) 		{ Eastwood.indInlineTabs(); }

	if ( _html.index($('.relSol')[0]) != -1 ) 				{ $(".relSol a.selected").prepend('&raquo;&nbsp;'); }

	$('#navlist-tabs ul li').hover(function() {
		$('.submenu').css('display','none');
		$('#navlist-tabs ul li').removeClass('selected');
		// remove selected class to the main nav item
		var thisIdx = $('#navlist-tabs ul li').index(this);
		//$('.submenu:eq('+thisIdx+')').css('display','block');
		$('.submenu:eq('+thisIdx+')').css('display','block');
		$('#navlist-tabs ul li:eq('+thisIdx+')').addClass('selected');
		//$('#navlist-tabs li div.left').css('margin-bottom','-10px');
		// add a selected class to the main nav item
		var thisPos = $(this).position();
		//alert(thisPos.left);
		var thisWidth = $(this).width();
		var thisHalfWidth = (thisWidth/2);
		var newPos = (thisPos.left+thisHalfWidth-5)+'px';
		//alert(thisWidth);
		$('div.subTicker').css('left',newPos);
	}, function() {
		var thisIdx = $('#navlist-tabs ul li').index(this);
	});
	$('.submenu').hover(function() {
		// stuff on hover
	}, function() {
		$('.submenu').css('display','none');
		$('#navlist-tabs ul li').removeClass('selected');
		// remove selected class to the main nav item
	});

	//zIndexWorkaround();
}


function zIndexWorkaround()
{
    // If the browser is IE,
    //if(isIE7)
    //{
        $("div.ticker").parents().each(function() {
            var p = $(this);
            var pos = p.css("position");

            // If it's positioned,
            if(pos == "relative" ||
               pos == "absolute" ||
               pos == "fixed")
            {
                /*
                ** Add the "on-top" class name when the
                ** mouse is hovering over it, and remove
                ** it when the mouse leaves.
                */
                //p.hover(function() {
                        $(this).addClass("on-top");
                    //},
                   //function() {
                        //$('.left').removeClass("on-top");
                   // });
            }
        });
    //}
}

function SwitchMenu(obj){
   if(document.getElementById){
   var el = document.getElementById(obj);
      if(el.style.display != "block"){
         el.style.display = "block";
      }else{
         el.style.display = "none";
      }
   }
}

function popup( url, code, width, height ) {
	if( code == null )
	{
		code = "newPopup";
	}

	if( width == null )
	{
		width = 800;
	}

	if( height == null )
	{
		height = 600;
	}

	var popup = window.open( url, code, "width=" + width + ", height=" + height + ", left=50, top=50, toolbar=no, menubar=yes, scrollbars=yes, location=0, status=no" );
	popup.focus();
}



/**
 * URL Functions
 *------------------------------------------------------------------------------
 */
function urldecode(str) {
  return decodeURIComponent((str + '').replace('+', '%20'));
}

var URLVars;

function getURLVars() {
  if(URLVars == undefined) {
    URLVars = [];
    var hash, key;
    var hashes = window.location.search.substring(1).split('&');
    for(var i = 0; i < hashes.length; i++) {
      hash = hashes[i].split('=', 2);
      key = urldecode(hash[0]);
      if(key > '') {
        URLVars.push(key);
        URLVars[key] = hash.length == 2 ? urldecode(hash[1]) : '';
      }
    }
  }
  return URLVars;
}

function getURLVar(name){
  // var URLVars = getURLVars();
  // return typeof URLVars[name] == 'undefined' ? '' : URLVars[name];
  return getURLVars()[name] + '';
}
//------------------------------------------------------------------------------


function EastwoodLib() {

    this.tabs = function tabsFn() {
        //$("#tabs ul li:lt(1)").css("margin-left", "0px");
        //$("#tabs ul li:last").css("margin-right", "0px");
        var mLI = 0;
        var wFull = $("#tabs").innerWidth(); // full width of tab area
        var tCnt = $("#tabs ul li").length; // number of tabs
        var tmLI = mLI * (tCnt - 1); // will always be zero?
        //wFull = wFull - tmLI; // no change?
        wFull = wFull - 0; // no change?
        var wtLI = 0;
        $("#tabs ul li").each(function(i) {
            var thisW = $(this).innerWidth(); // individual width of tab
            wtLI = wtLI + thisW; // running total width of tab content
        });
        var wtFill = Math.floor((wFull - wtLI) / tCnt); // width per tab to fill
        var wtNewLI = 0;
        var tabFound = false;
        var wLastLI = 0;
        $("#tabs ul li").each(function(i) {
            if (tCnt < 2) {
                var thisTabWidth = ($(this).innerWidth() + $(this).innerWidth()); // new tab width
            } else {
                var thisTabWidth = ($(this).innerWidth() + wtFill); // new tab width
            }
            $(this).css("width", thisTabWidth + "px"); // assigns new tab width
            wtNewLI = wtNewLI + thisTabWidth; // running total of tab widths
            wLastLI = thisTabWidth; // the last tab's width
        });
        $("#tabs ul li a").each(function() {
            $(this).css("display", "block"); // TODO note - do we need this? why isn't this in the css?
        });
        $("#tabs ul li:last").css("width", (wLastLI + (wFull - wtNewLI)) + "px"); // sets last tab to be the remaining empty space
        //$("#tabs ul li:not(:first)").css("margin-left", mLI+"px");
        var tabPage = (window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1)).toLowerCase();
        $("#tabs ul li a").each(function(i) {
            var thisTab = (($(this).attr("href")).substring(($(this).attr("href")).lastIndexOf('/') + 1)).toLowerCase();
            if (thisTab == tabPage) {
                $(this).attr("className", "selected");
                tabFound = true;
            }
        });


        if (!tabFound) {
            // loop back up the path to find first match
            var path = window.location.pathname;
            var strPress = "press-releases"; // handle third level press release pages
            if (path.charAt(path.length - 1) == "/")
                path = path.substring(0, path.length - 1);

            var folders = path.split('/');
            var folderLevels = folders.length;
            if (folderLevels > 1) {
                //alert(folderLevels);
                for (level = folderLevels - 1; level > 0; level--) {
                    levelTab = folders[level];
                    $("#tabs ul li a").each(function(i) {
                        var thisTab = (($(this).attr("href")).substring(($(this).attr("href")).lastIndexOf('/') + 1)).toLowerCase();
                        //alert(thisTab);
                        if (thisTab == levelTab) {
                            $(this).attr("className", "selected");
                            tabFound = true;
                        }
                        //alert(level);
                        if (!tabFound && level == 1) {
                            if (thisTab == strPress) {
                                $(this).attr("className", "selected");
                                tabFound = true;
                               // alert(tabFound);
                            }
                        }

                    });

                    if (tabFound)
                        break;
                }

            }
        }


        $("#tabs ul li:last a").css("background-position", "-1px 0");
        $("#tabs ul li:last a.selected").css("background-position", "right top");
        $("#tabs ul li:last a").not(".selected").hover(
			function() {
			    $(this).css("background-position", "right top");
			},
			function() {
			    $(this).css("background-position", "-1px 0");
			}
		);
        $("#tabs ul li:lt(1) a.selected").css("background-position", "0 0");
        $("#tabs ul li:lt(1) a").not(".selected").hover(
			function() {
			    $(this).css("background-position", "left top");
			},
			function() {
			    $(this).css("background-position", "right top");
			}
		);
        $("#tabs ul li:last a").css("border-right", "0");
        $("#tabs ul li:last a.selected").css("border-right", "0");
        if ($("*").index($('.tabContent')[0]) != -1) { Eastwood.headerTabs(); }
    }  //tabs

	this.headerTabs = function headerTabsFn() {
		var tCnt = $("#tabs.headerTabs ul li").length;
		var hoverDiv;
		$("#tabs.headerTabs ul li").click(function () {
			Eastwood.closeResetTab();
			var index = $("#tabs.headerTabs ul li").index(this);
			hoverDiv = $("#hero div.tabContent").eq(index);
			$(hoverDiv).fadeIn(350);

			$(this).addClass("selected");
			return false;
		});
		$("#content,#footer").click(function() {
			Eastwood.closeResetTab();
		});
		$("#hero div.tabContent #closePanel").click(function() {
			Eastwood.closeResetTab();
			return false;
		});
	}//headerTabs

	this.inlineTabs = function inlineTabsFn() {
		$("span.tabTitle").css("cursor","pointer");
		$("span.tabTitle a").click(function() {
			$("span.tabTitle a").each(function() {
				$(this).removeAttr("className","selected");
			});
			$("div.description").each(function() {
				$(this).fadeOut(250);
			});
			$(this).attr("className","selected");
			$(this).closest("span").next().fadeIn(350);
			return false;
		});
		//alert($("span.tabTitle a").length);
		$("a.tbLink:eq(0)").trigger('click');
	} //inlineTabs

	this.closeResetTab = function closeResetTabFn() {
		$("#hero div.tabContent").each(function() {
			$(this).fadeOut(250);
		});
		$("#tabs.headerTabs ul li").wait().removeClass("selected");
	}//closeResetTab

	this.tabsNoHero = function tabsNoHeroFn() {
		//adjust header bg position to 0 0
		$("#header").addClass("ext");
	}//closeResetTab

	this.carousel = function carouselFn() {
		$("ul#csCarousel li").each(function (i) {
			$("div.jcarousel-control").append("<a href='#'></a>");
		}); // controller bar
		jQuery("#csCarousel").jcarousel({
			scroll:4,
			initCallback: csCarousel_initCallback,
			itemVisibleInCallback: {
				onAfterAnimation:  csCarousel_itemVisibleInCallbackAfterAnimation
			},
			itemVisibleOutCallback: {
				onAfterAnimation:  csCarousel_itemVisibleOutCallbackAfterAnimation
			}
		}); // carousel init and event callbacks
	}//carousel

	this.flashHero = function flashHeroFn(flashFile,divPlacement,flashWidth,flashHeight,flashBgColor) {
		var flashvars = {};
		var params = {};
		params.autostart = "true";
		params.play = "true";
		params.autoPlay = "true";
		params.menu = "true";
		params.wmode = "transparent";
		//params.bgcolor = flashBgColor;
		params.allowScriptAccess = "sameDomain";
		params.align = "middle";
		var attributes = {};
		attributes.id = "hero";
		swfobject.embedSWF(flashFile, divPlacement, flashWidth, flashHeight, "8.0.0", "expressInstall.swf", flashvars, params, attributes);
	} //flashHero

	this.inlineVideo = function inlineVideoFn(video,divPlacement,medType) {
		var imgPtrStr = "#"+divPlacement+" img";
		if (medType=='cw_media_audio') {
			var flashvars = {datasource:'/Static'+video};
			var pathToAudio = STATIC_CONTENT_PATH+"resources/flash/audioPlayer.swf";
            var params = {scale:"noscale", bgcolor:"#ffffff", align: "middle", allowScriptAccess: "always"};
            var attributes = {};
            attributes.id = "player";
            swfobject.embedSWF(pathToAudio, divPlacement, "100%", "100%", "9.0.0", false, flashvars, params, attributes);
		} else {
			var pathToVideo = STATIC_CONTENT_PATH+"resources/common/flash/flvPlayerSmall.swf?moviePath=http://media-cdn.avid.com/media/eastwood/"+video+"_512.flv";
			var newPathtoVideo = "http://media-cdn.avid.com/media/eastwood/"+video+"_512.flv";
			var newPathtoPlayer = STATIC_CONTENT_PATH+"resources/common/flash/flvPlayerSmall.swf";
			$(imgPtrStr).css("cursor","pointer");
			//$(imgPtrStr).click(function() {
			var flashvars = {};
				flashvars.videoPath = newPathtoVideo;
				flashvars.movieTitle = video;
				flashvars.playerName = "inlinePlayer";
				flashvars.autoplay = "on";
			var params = {};
				params.menu = "false";
				params.salign = "t";
				params.bgcolor = "#FFFFFF";
				params.allowfullscreen = "true";
				params.wmode = "opaque";
				params.allowScriptAccess = "sameDomain";

			var attributes = {};
				attributes.id = "site";
				attributes.align = "top";

			$(imgPtrStr).click(function() {
				swfobject.embedSWF(newPathtoPlayer, divPlacement, "522", "329", "8.0.0", "expressInstall.swf", flashvars, params, attributes);
			});
			// video autoplay
			var iVideo = $.query.get('iVideo'); // inline video token
			if (iVideo==video) {
				//alert('flashvars: '+flashvars);
				var divPlacementStr = '#'+divPlacement;
				$.scrollTo( $(divPlacementStr), 1600 );
				setTimeout(function() { swfobject.embedSWF(newPathtoPlayer, divPlacement, "522", "329", "8.0.0", "expressInstall.swf", flashvars, params, attributes); }, 1600);
			}
		}
	} //inlineVideo
	this.avidTV = function avidTVFn(video,divPlacement) {
			var pathToVideo = STATIC_CONTENT_PATH+"resources/common/flash/flvPlayer.swf?moviePath=http://media-cdn.avid.com/media/eastwood/"+video+"_768.flv";
			var newPathtoVideo = "http://media-cdn.avid.com/media/eastwood/"+video+"_768.flv";
			var newPathtoPlayer = STATIC_CONTENT_PATH+"resources/common/flash/flvPlayer.swf";
			var flashvars = {};
				flashvars.videoPath = newPathtoVideo;
				flashvars.movieTitle = video;
				flashvars.playerName = "AvidTVPlayer";
			var params = {};
				params.menu = "false";
				params.salign = "t";
				params.bgcolor = "#FFFFFF";
				params.allowfullscreen = "true";
				params.wmode = "opaque";
				params.allowScriptAccess = "sameDomain";

			var attributes = {};
				attributes.id = "site";
				attributes.align = "top";
			swfobject.embedSWF(newPathtoPlayer, divPlacement, "778", "473", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
		//});
	} //avidTV

	this.shadowboxVideo = function shadowboxVideoFn(video,divPlacement) {
			var pathToVideo = STATIC_CONTENT_PATH+"resources/common/flash/flvPlayer.swf?moviePath=http://media-cdn.avid.com/media/eastwood/"+video+"_768.flv";
			var newPathtoVideo = "http://media-cdn.avid.com/media/eastwood/"+video+"_768.flv";
			var newPathtoPlayer = STATIC_CONTENT_PATH+"resources/common/flash/flvPlayer.swf";
			var flashvars = {};
				flashvars.videoPath = newPathtoVideo;
				flashvars.movieTitle = video;
				flashvars.playerName = "shadowboxPlayer";
				flashvars.autoplay = "on"
			var params = {};
				params.menu = "false";
				params.salign = "t";
				params.bgcolor = "#000000";
				params.allowfullscreen = "true";
				params.wmode = "opaque";
				params.allowScriptAccess = "sameDomain";

			var attributes = {};
				attributes.id = "site";
				attributes.align = "top";
			swfobject.embedSWF(newPathtoPlayer, divPlacement, "778", "473", "8.0.0", "expressInstall.swf", flashvars, params, attributes);
	} //shadowboxVideo

	this.newsTicker = function() {
		var newsDelay = 7500;
		var newsCount = 0;
		var newsLength = $('.newsTicker span.headline').length;
		var newsContainer = $('.newsTicker span.current');
		var newsInitVal = newsContainer.html();

		function doNextNews(){
			newsContainer.fadeOut(250, function(){
				newsCount++;
				if(newsCount == newsLength){
					newsCount = 0;
						newsContainer.html(newsInitVal)
					} else {
						newsContainer.html($('.newsTicker span.headline').eq(newsCount).clone().html())
						}
				newsContainer.fadeIn(350);
			});
		}
		function doPrevNews(){
			newsContainer.fadeOut(250, function(){
				newsCount--;
				if(newsCount < 0) {
					newsCount = newsLength-1;
					newsContainer.html($('.newsTicker span.headline').eq(newsCount).clone().html());
				} else if (newsCount == 0){
					newsContainer.html(newsInitVal);
				} else {
					newsContainer.html($('.newsTicker span.headline').eq(newsCount).clone().html());
				}
				newsContainer.fadeIn(350);
			});
		}
		$('.newsTicker, .newsTicker .more, .newsTicker .prev').hover(
			function(){
				clearInterval(newsTimer);
				},
			function(){
				clearInterval(newsTimer);
				doAuto();
				}
		)
		$('.newsTicker .more').click(function(){
			clearInterval(newsTimer);
			doNextNews();
			return false;
		})
		$('.newsTicker .prev').click(function(){
			clearInterval(newsTimer);
			doPrevNews();
			return false;
		})
		var newsTimer = 0;
		function doAuto(){
			newsTimer = setInterval(function(){doNextNews(true);},newsDelay)
		}
		doAuto();
	} // newsTicker

	this.initHome = function initHomeFn() {
		$("#header").addClass("home");
		$("span.headline:first").addClass("current");
		Eastwood.newsTicker();
		$('#hero img').css('cursor','pointer').click(function(){
			//location.href = 'http://www.avid.com/US/products/family/Media-Composer?intcmp=AV-HP-S1';
			//location.href = 'http://www.avid.com/US/products/family/Media-Composer?intcmp=AV-HP-S1';
			//location.href = 'http://apps.avid.com/holiday/?intcmp=AV-HP-S1';
			location.href = "/about-avid/customer-stories/Avid-Stockholm";
		});
	} //initHome

	this.accordian = function accordianFn() {
		$(".cw_structTxt_accordians .preview a.accord").click(function() {
			$(this).closest("div").next().slideToggle("fast", function(){
			});
			return false;
		});
	} //accordian

	/*santiago*/
	/* last update */
	this.displayPanel = function displayPanelFn() {
    	// ie7 fix
    	var a = 0;
    	var sels = $('.content select');

    	$("#Display .content").hide();

        $("ul#Nav li").hover(function() {
            $(this).css("color","#333333")
        }, function() {
            if (!($(this).hasClass("selected"))) {
                $(this).css("color","#006BB6")
            }
        });

        var reqTab = (location.hash).slice(1);

        if (reqTab) {
            $("ul#Nav li").each(function(i) {
                if ( ($(this).attr("rel")) == reqTab ) {
                    var t = $("ul#Nav li").index(this);
                    $("#Display .content:eq("+t+")").show();
                    $(this).addClass("selected");
                }
            });
        } else {
            $("#Display .content:first").show();
            $("ul#Nav li:first").addClass("selected");
        }

		$('.content').find("div[id!='US']").filter("div[id!='']").hide()

		sels.change();

        $("ul#Nav li").click(function() {

            $('.content').hide();

            $("ul#Nav li").each(function (i) {
                if ($(this).hasClass("selected")) {
                    $(this).removeClass("selected").css("color","#006BB6");
                }
                $("select.locations option[selected]").removeAttr("selected");
                $("select.locations option[value='US']").attr("selected", "selected");
                $('.content').find("div[id!='US']").filter("div[id!='']").hide();
                $(".content #US").show(0);
            });

            $(this).addClass("selected");

            var n = $("ul#Nav li").index(this);

            a = n;

            $("#Display .content:eq("+n+")").animate({
                    opacity: "toggle"
            }, 250, "linear");

            sels.change();

            return false;
        });

    	var re = new RegExp('^[\/]*(AU|AP|CN|DK|FI|FR|DE|JP|KR|NL|NO|RU|ES|SE|UK|US)[\/]', 'i');
    	var showCountry = re.exec( location.pathname );

    	if(showCountry && showCountry[1]) {
      		showCountry = showCountry[1].toUpperCase();
    	} else {
      		showCountry = getURLVar('showCountry').toUpperCase();
      		if(!showCountry || !showCountry.match(new RegExp('^(AU|AP|CN|DK|FI|FR|DE|JP|KR|NL|NO|RU|ES|SE|UK|US)$'))) {
        		showCountry = 'US';
      		}
    	}

        $("select.locations option[selected]").removeAttr("selected");
        $("select.locations option[value='" + showCountry + "']").attr("selected", "selected");

        $('.locations').change(function() {

            $('.content').find("div[id!='']").hide();
            $('.content').eq(a).find("div[id=" + this.value + "]").fadeIn(500);

            if ((this.value.substr(0,7) == "http://") || (this.value.substr(0,5) == "mailto")) {
                location.href = this.value;
            }
        })
    } // displayPanel

	this.avidShadowbox = function avidShadowboxFn() {
		$('a[rel="avidShadowbox"]').click(function() {
			var thisURL = $(this).attr("href");
			Shadowbox.open({
			 content:    thisURL,
			 player:  "iframe",
			 height:     550,
			 width:      700
			});
			return false;
		});
	} //avidShadowbox

	this.avidMaxShadowbox = function avidMaxShadowboxFn() {
		$('a[rel="avidMaxShadowbox"]').click(function() {
			var thisURL = $(this).attr("href");
			var thisContent = $(thisURL).html();
			var brHt = $(window).height() - 100;
			var brWth = 1000;
			if ( $(window).width() < 1000  ) {
				brWth = $(window).width() -100;
			}
			Shadowbox.open({
			 content:    thisContent,
			 player:  "html",
			 height:     brHt ,
			 width:      brWth
			});
			var OmnPageName = s.pageName + thisURL
			callOmniture(OmnPageName);
			return false;
		});
	} //avidMaxShadowbox

	this.QTShadowbox = function QTShadowboxFn() {
		$('a[rel="QTShadowbox"]').click(function() {
			var thisURL = $(this).attr("href");
			Shadowbox.open({
			 content:    thisURL,
			 player:  "iframe",
			 height:     778,
			 width:      1034
			});
			return false;
		});
	} //avidShadowbox

	this.genShadowbox = function genShadowboxFn() {
		$('a[rel*="genShadowbox"]').click(function() {
			var thisURL = $(this).attr("href");
			var thisRel = $('a[rel*="genShadowbox"]').attr('rel');
			var theseAttribs = thisRel.split(";");
			Shadowbox.open({
			 content:    thisURL,
			 player:  "iframe",
			 height:     theseAttribs[2],
			 width:      theseAttribs[1]
			});
			return false;
		});
	} //genShadowbox

	this.videoShadowbox = function videoShadowboxFn() {
		$('a[rel="videoShadowbox"]').click(function() {
			var thisURL = $(this).attr("href");

			var pathToVideo = STATIC_CONTENT_PATH+"resources/common/flash/flvPlayer.swf?moviePath=http://media-cdn.avid.com/media/eastwood/"+thisURL;
			var newPathtoVideo = "http://media-cdn.avid.com/media/eastwood/"+thisURL;
			var newPathtoPlayer = STATIC_CONTENT_PATH+"resources/common/flash/flvPlayer.swf";
			var flashvars = {};
				flashvars.videoPath = newPathtoVideo;
				flashvars.movieTitle = video;
				flashvars.playerName = "shadowboxPlayer";
				flashvars.autoplay = "on"
			var params = {};
				params.menu = "false";
				params.salign = "t";
				params.bgcolor = "#000000";
				params.allowfullscreen = "true";
				params.wmode = "opaque";
				params.allowScriptAccess = "sameDomain";

			var attributes = {};
				attributes.id = "site";
				attributes.align = "top";
			var thisContent = swfobject.embedSWF(newPathtoPlayer, divPlacement, "778", "473", "8.0.0", "expressInstall.swf", flashvars, params, attributes);


			Shadowbox.open({
			 content:    thisContent,
			 player:  "iframe",
			 height:     472,
			 width:      778
			});
			return false;
		});
	} //videoShadowbox

	this.videoShadowboxInline = function videoShadowboxInlineFn() {
		//alert('inline');
		var contentHTML = "<div class='inner' style='width:778px;'><div style='margin:10px auto;'><div class='inlineVideo'><div id='flashVideo'></div></div></div></div>"
		$('a[rel="videoShadowboxInline"]').click(function() {
			//alert('click');
			var thisURL = $(this).attr("href");
			Shadowbox.open({
			 content:    "<div class='inner' style='width:778px;'><div style='margin:10px auto;'><div class='inlineVideo'><div id='flashVideo'></div></div></div></div>",
			 player:  "html",
			 height:     472,
			 width:      778
			});

			return false;
		});
	} //videoShadowboxInline

	this.overlayShadowbox = function overlayShadowboxFn() {
		$('div.pod').hover(
			function() {
				$(this).addClass('overBio');
			},
			function() {
				$(this).removeClass('overBio');
			}
		);
		$('div.pod').click(function() {
			var thisContent = $('.overlay',this).html();
			Shadowbox.open({
			 content:    thisContent,
			 player:  "html",
			 height:     550,
			 width:      700
			});
			//return false;
		});
	} //bios

	this.padpod3x840 = function padpod3x840Fn() {
		var podLength = $(".cw_imgPromos_pod3x840").length;
		$('<br class="clear" />').insertBefore(".cw_imgPromos_pod3x840:eq(0)");
		$('<br class="clear" />').insertAfter(".cw_imgPromos_pod3x840:eq(2),.cw_imgPromos_pod3x840:eq(5),.cw_imgPromos_pod3x840:eq(8),.cw_imgPromos_pod3x840:eq(11)");
		$(".cw_imgPromos_pod3x840:eq(1),.cw_imgPromos_pod3x840:eq(4),.cw_imgPromos_pod3x840:eq(7),.cw_imgPromos_pod3x840:eq(10)").addClass("middle");
		//$(".cw_imgPromos_pod3x840 .long_desc ul li:gt(0)").before('<li>&nbsp;&nbsp;|&nbsp;&nbsp;</li>');
	} // padpod3x840

	this.padpod4x840 = function padpod4x840Fn() {
		var podLength = $(".cw_imgPromos_pod4x840").length;
		//$(".cw_imgPromos_pod4x840 .long_desc ul li:gt(0)").before('<li>&nbsp;&nbsp;|&nbsp;&nbsp;</li>');
		$('<br class="clear" />').insertAfter(".cw_imgPromos_pod4x840:eq(3),.cw_imgPromos_pod4x840:eq(7),.cw_imgPromos_pod4x840:eq(11),.cw_imgPromos_pod4x840:eq(15),.cw_imgPromos_pod4x840:eq(19),.cw_imgPromos_pod4x840:eq(23),.cw_imgPromos_pod4x840:eq(27),.cw_imgPromos_pod4x840:eq(31),.cw_imgPromos_pod4x840:eq(35),.cw_imgPromos_pod4x840:eq(39),.cw_imgPromos_pod4x840:eq(43),.cw_imgPromos_pod4x840:eq(47)");
		$(".cw_imgPromos_pod4x840:eq(3),.cw_imgPromos_pod4x840:eq(7),.cw_imgPromos_pod4x840:eq(11),.cw_imgPromos_pod4x840:eq(15),.cw_imgPromos_pod4x840:eq(19),.cw_imgPromos_pod4x840:eq(23),.cw_imgPromos_pod4x840:eq(27),.cw_imgPromos_pod4x840:eq(31),.cw_imgPromos_pod4x840:eq(35),.cw_imgPromos_pod4x840:eq(39),.cw_imgPromos_pod4x840:eq(43),.cw_imgPromos_pod4x840:eq(47)").addClass("last");
	} // padpod4x840

	this.padpod2x840 = function padpod2x840Fn() {
		$('<br class="clear" />').insertBefore(".cw_imgPromos_pod2x840:eq(0)");
		$('<br class="clear" />').insertAfter(".cw_imgPromos_pod2x840:odd");
		$(".cw_imgPromos_pod2x840:odd").addClass("last");
		//$(".cw_imgPromos_pod2x840 .long_desc ul li:gt(0)").before('<li>&nbsp;&nbsp;|&nbsp;&nbsp;</li>');
	} // padpod2x840

	this.brandBox = function brandBoxFn() {
		$('<br class="clear" />').insertBefore(".cw_linkedImg_brandBox:eq(0)");
		$('<br class="clear" />').insertAfter(".cw_linkedImg_brandBox:eq(1),.cw_linkedImg_brandBox:eq(3)");
		$(".cw_linkedImg_brandBox:eq(0),.cw_linkedImg_brandBox:eq(2)").addClass("left");
	} // padpod2x840

	this.biosPods = function biosPodsFn() {
		$('<br class="clear" />').insertBefore(".pod:eq(0)");
		$('<br class="clear" />').insertAfter(".pod:eq(2),.pod:eq(5),.pod:eq(8),.pod:eq(11),.pod:eq(14)");
	} // padpod3x840

	this.lowerwellPods = function lowerwellPodsFn() {
			$("#LowerWellContent .cw_imgPromos_pod4x840:first").addClass("first");
			$("#LowerWellContent .cw_imgPromos_pod4x840:last").addClass("last");
	} //lowerwellPods

	this.productHome = function productHomeFn() {
		$(".heroPod3x3:eq(2),.heroPod3x3:eq(5)").addClass("last");
		$(".heroPod3x3 a").hover(
			function () {
				$(this).css("background-position", "0 -140px");
			}, function () {
    			$(this).css("background-position", "0 0");
  			}
		);
	} //productHome

	this.productTable = function productTableFn() {
		$("table.tablesorter tbody tr:odd").addClass("odd");
	} // productTable

	this.openShadowbox = function openShadowboxFn() {
		$('a[href$="shadowbox"]').click(function() {
			var thisURL = $(this).attr("href");
			Shadowbox.open({
			 content:    thisURL,
			 player:  "iframe",
			 height:     600,
			 width:      875
			});
			return false;
		});
	} // openShadowbox

	this.box33Stories = function box33StoriesFn() {
		$('<br class="clear" />').insertAfter(".box33Stories li:eq(2),.box33Stories li:eq(5),.box33Stories li:eq(8),.box33Stories li:eq(11),.box33Stories li:eq(14)");
	} // box33Stories

	this.setPricingBtns = function setPricingBtnsFn() {
		var thisClass = $('.blueActionButton2').attr('class');
		//alert(thisClass);
		var caseNo = 0;
		if (thisClass == 'blueActionButton2 rr_pricing_BuyNow') {
			$('a.rentNow').css('display','none');
		}
		if (thisClass == 'blueActionButton2 rr_pricing_NoLink') {
			  $('a.buyNow').css('display','none');
			  $('a.rentNow').css('display','none');
		}
		if (thisClass == 'blueActionButton2 rr_pricing_rentNow') {
			  $('a.buyNow').css('display','none');
		}
	} // setPricingBtns

	this.chkQtImg = function chkQtImgFn() {
		$(".cw_quote_fullWidth .holder blockquote").each(function () {
			if ($('.holder img').length) {
				//alert('img found');
			} else {
				//alert('not img found');
				$(this).css('padding-left','40px').css('width','535px');
				$(this).children('span').css('left','10px');
			}

		});
	} // chkQtImg

	this.indNavInit = function indNavInitFn() {
		$(".indNav li").click( function() {
			$(".pPanel").each(function (i) {
				$(".pPanel").stop(true, true);
				if (($(this).css('display'))=='block') {
					$(this).animate({
							opacity: "toggle"
						}, 100, "linear");
				}
			});
			$(".indNav li").each(function (i) {
				if ($(this).hasClass("selected")) {
					$(this).removeClass("selected");
				}
			});
			$(this).addClass("selected");
			var n = $(".indNav li").index(this);
			showIndPanel(n);
			return false;
		}//, function() {
			// mouse out action
			//}
		);
		$(".indNav li:eq(0)").click();
	} // indNavInit

	this.BAMLocator = function BAMLocatorFn() {
		$('#BAMRegions').change(function() {
	        $.getJSON('http://www.avid.com/US/common/howtobuy/bam/' + $('#BAMRegions option:selected').val(), function(json) {
	            $("#BAMNameSpan").text("");
	            $("#BAMTelSpan").text("");
	            $("#BAMEmailSpan").text("");
	            $("#BAMEmailSpan").text("");
	            if ((json.result)[0].value.toString() != 'nomatchesfound') {
	                $("#BAMNameSpan").text($(json.result)[0].value.toString());
	                $("#BAMEmailSpan").text('E-mail ' + $(json.result)[2].value.toString());
	                $("#BAMTelSpan").text('Tel ' + $(json.result)[1].value.toString());
					/* call Omniture with event param */
					//s.events=event19;
					//alert(s.events);
					//var s_code = s.t();
					//if (s_code) document.write(s_code);
	            } else {
	            }
	        });
			$('.results').slideDown(500, function(){
				$('*').bind('click', BAMhandler);
			});
			// *** custom link method
			var thisObj = $(this);
			s.linkTrackVars='events';
			s.linkTrackEvents='event19';
			//alert('firing');
			s.events='event19';
			//alert(s.events);
			var s_code = s.t();
			if (s_code) document.write(s_code);
			//alert('done');
		});
		var BAMhandler = function() {
	  		$('.results').fadeOut(250);
			$('*').unbind('click', BAMhandler);
		};
		$('#BAMRegions').click(function() {
			//s_objectID='SS1234';
		});
	} //BAMLocator

	this.indInlineTabs = function indInlineTabsFn() {
		$(".inlineTabs li").click( function() {
			$(".displayTab").stop(true, true).css('display','none');
			$(".displayTab").each(function (i) {
				$(".displayTab").stop(true, true);
				if (($(this).css('display'))=='block') {
					//$(this).animate({
							//opacity: "toggle"
						//}, 100, "linear");
					$(this).css('display','none');
				}
			});
			$(".inlineTabs li").each(function (i) {
				if ($(this).hasClass("selected")) {
					$(this).removeClass("selected");
				}
			});
			$(this).addClass("selected");
			var n = $(".inlineTabs li").index(this);
			showInlineTab(n);
			//s_objectID='SS'+n+'tab';
			//return false;
		}, function() {
			// mouse out action
			}
		);
		$(".inlineTabs li:eq(0)").click();
	} //indInlineTabs

	this.sVideo = function sVideoFn(token) {
		var thisURL = '/us/avid-tv/'+token+'/shadowbox';
		Shadowbox.init();
		setTimeout(function() { Shadowbox.open({
			 content:    thisURL,
			 player:  "iframe",
			 height:     600,
			 width:      875
		}); }, 500);
		//Shadowbox.open({
			// content:    thisURL,
			// player:  "iframe",
			// height:     600,
			// width:      875
		//});

	} // sVideo

		this.BCdiagram = function BCdiagramFn() {

				$('#mainwrap').append('<div class="hoverBox"></div>');
				$('.hoverBox').css('display','block').css('opacity','0').css('z-index','1');
				$('#rightSidebar').css('z-index','10');
				$('.mod').hover(
					function () {
						var thisIdx = $('.WFdiagram').index(this);
						var diaTopPos = $('.BCdiagram').position();
						$('.WFdiagram').addClass('WFdiagramHover');
						$('.WFdiagram:eq('+thisIdx+')').removeClass('WFdiagramHover');
						var hoverContent = $(this).children('.hoverBoxContent').html();
						var thisPosition = $(this).position();
						$('.hoverBox').stop(true,false).html(hoverContent);
						$('.hoverBox').css('z-index','9999');
						$('.hoverBox').animate({
							opacity:100,
							top:thisPosition.top+diaTopPos.top
						}, 1000, function() {
						});
					}, function () {
						$('.hoverBox').animate({
							opacity:0
						}, 250, function() {
							$('.hoverBox').css('z-index','1');
						});
						$('.WFdiagram').removeClass('WFdiagramHover');
					}
				);

				$('.WFdiagram .bd a').click(function() {
					var lowerBoxContent = $(this).next('.lowerBoxContent').html();
					var thisIdx = $('.WFdiagram .bd a').index(this);
					var thisMod = $(this).closest('.line');
					var thisModIdx = $('.line').index(thisMod);
					$('.line:eq('+thisModIdx+') .WFdiagram .bd a').removeClass('selected').removeClass('dblSelected');

					if (  $(this).hasClass('double') )  {
						$(this).addClass('dblSelected');
					} else {
						$(this).addClass('selected');
					}

					$('.lowerBox:eq('+thisModIdx+') .lowerBoxTarget').html(lowerBoxContent);
					$('.lowerBox:eq('+thisModIdx+')').slideDown(500);
					return false;
				});

				$('a.closeBtn').click(function() {
					var thisLine = $(this).closest('.line');
					var thisLineIdx = $('.line').index(thisLine);
					$('.lowerBox:eq('+thisLineIdx+')').slideUp(500);
					var thisHeader = $('.lowerBox:eq('+thisLineIdx+') h3').text();
					$('.line:eq('+thisLineIdx+') .WFdiagram .bd a').removeClass('selected').removeClass('dblSelected');
					return false;
				});

		} //BCdiagram

}//EastwoodLib

function csCarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
    	var scrollToIndex = $(".jcarousel-control a").index(this);
        carousel.scroll(jQuery.jcarousel.intval(scrollToIndex+1));
        return false;
    });
    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
}
function csCarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
    var thisID = idx-1;
    var URLStr = "url('"+STATIC_CONTENT_PATH+"resources/common/images/interface/carousel_dot_selected.png')"
    $(".jcarousel-control a").eq(thisID).css("background-image",URLStr);
}
function csCarousel_itemVisibleOutCallbackAfterAnimation(carousel, item, idx, state) {
    var thisID = idx-1;
    var URLStr = "url('"+STATIC_CONTENT_PATH+"resources/common/images/interface/carousel_dot_unselected.png')"
    $(".jcarousel-control a").eq(thisID).css("background-image",URLStr);
}

$.fn.wait = function(time, type) {
	//alert('fired');
	time = time || 5000;
	type = type || "fx";
	return this.queue(type, function() {
		var self = this;
		setTimeout(function() {
			$(self).dequeue();
		}, time);
	});
};

// audio functions
	function thisMovie(movieName){
	    if(navigator.appName.indexOf("Microsoft") != -1){return window[movieName]}
	    else{return document[movieName]}
	}
	jQuery(function() {
		$("#playerholder").bind("mouseleave",function(){
			// the "player" here is the swfobject "attributes.id"
			thisMovie("player").closeSlider();
	    });
	});
	function openPlaylist(what){
		jQuery(function() {
			if(what == 'open'){
				$('#playerholder').stop().animate({height: "130px"},300)
			}
			if(what == 'close'){
				$('#playerholder').stop().animate({height: "36px"},480)
			}
		});
	}

// functions in support of industry solutions pages
var eventTS, nowTS;
var isIE = (jQuery.browser.msie && jQuery.browser.version == 6); // non-optimal method to detect IE6
var isIE7 = (jQuery.browser.msie && jQuery.browser.version == 7); // non-optimal method to detect IE6
if (isIE) {
	//do IE6 stuff
	$('.flyout > li').hover(
		function () {
			$(this).addClass('ieHover');
		}, function () {
			$(this).removeClass('ieHover');
		}
	);
}
function showIndPanel(nPanel) {
	$(".pPanel:eq("+nPanel+")").stop(true, true).animate({
		opacity: "toggle"
		}, 500, "linear");
}

function showInlineTab(nPanel) {
	$(".displayTab:eq("+nPanel+")").stop(true, true).animate({
		opacity: "toggle"
		}, 500, "linear");
}

function callOmniture(p,retainPageName) { /* ONLY if needing to treat an event as a page view */
	var parentOmnPageName;
	if (retainPageName==undefined || retainPageName!=false) {
		parentOmnPageName = s.pageName;
	} else {
		parentOmnPageName = p;
	}
	if (p) { s.pageName=p; }
    /************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
	var s_code = s.t();
	if (s_code) document.write(s_code);
	s.pageName = parentOmnPageName;
}

//Content Panels for aplication support pages
$(function(){
    ContentPanel.initialize();
});

var ContentPanel = {
    initialize: function(){
		jQuery(".application-support-panel .right-panel").css("min-height", jQuery(".application-support-panel .left-panel").height() - 49);

        jQuery(".content-item").hide().eq(0).show();

        jQuery(".application-support-panel .left-panel a").live('click', function(){
            jQuery(".left-panel ul li").removeClass("selected");

            jQuery(this).parent().addClass("selected");

			jQuery(".content-item").hide();
            jQuery(".right-panel div").eq(jQuery(".left-panel a").index(this)).fadeIn(500);

			return false;
        })
    }
};


window.onload = function(){

	Shadowbox.init({
		onOpen : function(){ document.body.style.overflow = "hidden"; return true; },
   		onClose: function(){ document.body.style.overflow = "auto";   return true; }
	});


	if ( $.query.get('sVideo') ) { Eastwood.sVideo($.query.get('sVideo')); }
};

/* jQuery Query plug-in BEGIN */
new function(settings){var $separator=settings.separator||'&';var $spaces=settings.spaces===false?false:true;var $suffix=settings.suffix===false?'':'[]';var $prefix=settings.prefix===false?false:true;var $hash=$prefix?settings.hash===true?"#":"?":"";jQuery.query=new function(){var is=function(o,t){return o!=undefined&&o!==null&&(!!t?o.constructor==t:true);};var parse=function(path){var m,rx=/\[([^[]*)\]/g,match=/^(\S+?)(\[\S*\])?$/.exec(path),base=match[1],tokens=[];while(m=rx.exec(match[2]))tokens.push(m[1]);return[base,tokens];};var set=function(target,tokens,value){var o,token=tokens.shift();if(typeof target!='object')target=null;if(token===""){if(!target)target=[];if(is(target,Array)){target.push(tokens.length==0?value:set(null,tokens.slice(0),value));}else if(is(target,Object)){var i=0;while(target[i++]!=null);target[--i]=tokens.length==0?value:set(target[i],tokens.slice(0),value);}else{target=[];target.push(tokens.length==0?value:set(null,tokens.slice(0),value));}}else if(token&&token.match(/^\s*[0-9]+\s*$/)){var index=parseInt(token,10);if(!target)target=[];target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value);}else if(token){var index=token.replace(/^\s*|\s*$/g,"");if(!target)target={};if(is(target,Array)){var temp={};for(var i=0;i<target.length;++i){temp[i]=target[i];}
target=temp;}
target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value);}else{return value;}
return target;};var queryObject=function(a){var self=this;self.keys={};if(a.queryObject){jQuery.each(a.get(),function(key,val){self.SET(key,val);});}else{jQuery.each(arguments,function(){var q=""+this;q=q.replace(/^[?#]/,'');q=q.replace(/[;&]$/,'');if($spaces)q=q.replace(/[+]/g,' ');jQuery.each(q.split(/[&;]/),function(){var key=this.split('=')[0];var val=this.split('=')[1];if(!key)return;if(/^[+-]?[0-9]+\.[0-9]*$/.test(val))
val=parseFloat(val);else if(/^[+-]?[0-9]+$/.test(val))
val=parseInt(val,10);val=(!val&&val!==0)?true:val;if(val!==false&&val!==true&&typeof val!='number')
val=decodeURIComponent(val);self.SET(key,val);});});}
return self;};queryObject.prototype={queryObject:true,has:function(key,type){var value=this.get(key);return is(value,type);},GET:function(key){if(!is(key))return this.keys;var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];while(target!=null&&tokens.length!=0){target=target[tokens.shift()];}
return target||"";},get:function(key){var target=this.GET(key);if(is(target,Object))
return jQuery.extend(true,{},target);else if(is(target,Array))
return target.slice(0);return target;},SET:function(key,val){var value=!is(val)?null:val;var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];this.keys[base]=set(target,tokens.slice(0),value);return this;},set:function(key,val){return this.copy().SET(key,val);},REMOVE:function(key){return this.SET(key,null).COMPACT();},remove:function(key){return this.copy().REMOVE(key);},EMPTY:function(){var self=this;jQuery.each(self.keys,function(key,value){delete self.keys[key];});return self;},empty:function(){return this.copy().EMPTY();},copy:function(){return new queryObject(this);},COMPACT:function(){function build(orig){var obj=typeof orig=="object"?is(orig,Array)?[]:{}:orig;if(typeof orig=='object'){function add(o,key,value){if(is(o,Array))
o.push(value);else
o[key]=value;}
jQuery.each(orig,function(key,value){if(!is(value))return true;add(obj,key,build(value));});}
return obj;}
this.keys=build(this.keys);return this;},compact:function(){return this.copy().COMPACT();},toString:function(){var i=0,queryString=[],chunks=[],self=this;var addFields=function(arr,key,value){if(!is(value)||value===false)return;var o=[key];if(value!==true){o.push("=");o.push(encodeURIComponent(value));}
arr.push(o.join(""));};var build=function(obj,base){var newKey=function(key){return!base||base==""?[key].join(""):[base,"[",key,"]"].join("");};jQuery.each(obj,function(key,value){if(typeof value=='object')
build(value,newKey(key));else
addFields(chunks,newKey(key),value);});};build(this.keys);if(chunks.length>0)queryString.push($hash);queryString.push(chunks.join($separator));return queryString.join("");}};return new queryObject(location.search,location.hash);};}(jQuery.query||{});
/* jQuery Query plug-in END */

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

 // START Centerwell tabs - displays tab that's currently selected
$(function(){
    CwTabPanel.initialize();
});

var CwTabPanel = {
    initialize: function(){


        jQuery(".content-item").hide().eq(0).show();

        jQuery("#cwTabContainer a").click(function(){
            jQuery("#cwTabContainer ul li").removeClass("active");
            jQuery("#cwTabContainer ul li span").removeClass("active");
            jQuery(this).parent().addClass("active");

			jQuery(".content-item").hide();
            jQuery(".right-panel div").eq(jQuery("#cwTabContainer a").index(this)).fadeIn(500);

			return false;
        })
    }
};


// Fullwidth tabs
$(function(){
    CwTabPanelFullWidth.initialize();
});

var CwTabPanelFullWidth = {
    initialize: function(){


        jQuery(".content-item").hide().eq(0).show();

        jQuery("#cwTabContainerFullWidth a").click(function(){
            jQuery("#cwTabContainerFullWidth ul li").removeClass("active");
            jQuery("#cwTabContainerFullWidth ul li span").removeClass("active");
            jQuery(this).parent().addClass("active");

			jQuery(".content-item").hide();
            jQuery(".right-panel div").eq(jQuery("#cwTabContainerFullWidth a").index(this)).fadeIn(500);

			return false;
        })
    }
};
 // END Centerwell tabs - displays tab that's currently selected

/* ***************** */
/* original code end */
/* ***************** */


