/* ALL JS $Revision: 1.6 $  Copyright 2007 Adobe Systems Incorporated */
var CS3Products={XNavMenuList:[{xMap:"designPremium",productFamily:"Design Premium",menuID:"xNavMenu-DesignPremium",subMenuID:"xNavMenu-subMenu-DesignPremium"},{xMap:"designStandard",productFamily:"Design Standard",menuID:"xNavMenu-DesignStandard",subMenuID:"xNavMenu-subMenu-DesignStandard"},{xMap:"webPremium",productFamily:"Web Premium",menuID:"xNavMenu-WebPremium",subMenuID:"xNavMenu-subMenu-WebPremium"},{xMap:"webStandard",productFamily:"Web Standard",menuID:"xNavMenu-WebStandard",subMenuID:"xNavMenu-subMenu-WebStandard"},{xMap:"productionPremium",productFamily:"Production Premium",menuID:"xNavMenu-ProductionPremium",subMenuID:"xNavMenu-subMenu-ProductionPremium"},{xMap:"masterCollection",productFamily:"Master Collection",menuID:"xNavMenu-MasterCollection",subMenuID:"xNavMenu-subMenu-MasterCollection"}],ProductFamilies:{"Photoshop CS3 Extended":{designPremium:"1",designStandard:"0",webPremium:"1",webStandard:"0",productionPremium:"1",masterCollection:"1"},"Photoshop CS3":{designPremium:"0",designStandard:"1",webPremium:"0",webStandard:"0",productionPremium:"0",masterCollection:"0"},"Illustrator CS3":{designPremium:"1",designStandard:"1",webPremium:"1",webStandard:"0",productionPremium:"1",masterCollection:"1"},"InDesign CS3":{designPremium:"1",designStandard:"1",webPremium:"0",webStandard:"0",productionPremium:"0",masterCollection:"1"},"Acrobat 8 Professional":{designPremium:"1",designStandard:"1",webPremium:"1",webStandard:"0",productionPremium:"0",masterCollection:"1"},"Flash CS3 Professional":{designPremium:"1",designStandard:"0",webPremium:"1",webStandard:"1",productionPremium:"1",masterCollection:"1"},"Dreamweaver CS3":{designPremium:"1",designStandard:"0",webPremium:"1",webStandard:"1",productionPremium:"0",masterCollection:"1"},"Contribute CS3":{designPremium:"0",designStandard:"0",webPremium:"1",webStandard:"1",productionPremium:"0",masterCollection:"1"},"Fireworks CS3":{designPremium:"0",designStandard:"0",webPremium:"1",webStandard:"1",productionPremium:"0",masterCollection:"1"},"After Effects CS3 Professional":{designPremium:"0",designStandard:"0",webPremium:"0",webStandard:"0",productionPremium:"1",masterCollection:"1"},"Adobe Premiere Pro CS3":{designPremium:"0",designStandard:"0",webPremium:"0",webStandard:"0",productionPremium:"1",masterCollection:"1"},"Soundbooth CS3":{designPremium:"0",designStandard:"0",webPremium:"0",webStandard:"0",productionPremium:"1",masterCollection:"1"},"Encore CS3":{designPremium:"0",designStandard:"0",webPremium:"0",webStandard:"0",productionPremium:"1",masterCollection:"1"},"Adobe Bridge CS3":{designPremium:"1",designStandard:"1",webPremium:"1",webStandard:"1",productionPremium:"1",masterCollection:"1"},"Version Cue CS3":{designPremium:"1",designStandard:"1",webPremium:"1",webStandard:"1",productionPremium:"0",masterCollection:"1"},"Adobe Device Central CS3":{designPremium:"1",designStandard:"1",webPremium:"1",webStandard:"1",productionPremium:"1",masterCollection:"1"},"Adobe Stock Photos":{designPremium:"1",designStandard:"1",webPremium:"1",webStandard:"1",productionPremium:"0",masterCollection:"1"},"Acrobat Connect":{designPremium:"1",designStandard:"1",webPremium:"1",webStandard:"1",productionPremium:"1",masterCollection:"1"},"Dynamic Link":{designPremium:"0",designStandard:"0",webPremium:"0",webStandard:"0",productionPremium:"1",masterCollection:"1"},"Adobe OnLocation CS3":{designPremium:"0",designStandard:"0",webPremium:"0",webStandard:"0",productionPremium:"1",masterCollection:"1"},"Ultra CS3":{designPremium:"0",designStandard:"0",webPremium:"0",webStandard:"0",productionPremium:"1",masterCollection:"1"}}};xNav=Class.create();xNav.prototype={initialize:function(){},disableLink:function(){return false;},parseFamilies:function(_1){var _2=CS3Products.ProductFamilies[_1];if(!_2){return;}$H(_2).each(function(_3){if(_3.value==1){xNavType=CS3Products.XNavMenuList.findAll(function(_4){return _4.xMap==_3.key;});subMenuNodes=$A($(xNavType[0].subMenuID).childNodes);subMenuNodes.each(function(_5){if(_5.nodeType==1){tag=_5.childNodes[0];if(tag.nodeName=="A"){linkTextNode=tag.childNodes[0];linkText=linkTextNode.nodeValue;if(_1==linkText){tag.parentNode.className="selected";Event.observe(tag,"click",Event.stop);tag.href="";}}}});}});},localizeTemplate:function(_6){var _7={es:"Adem&aacute;s",it:"Pl&ugrave;",jp:"\u540c\u68b1\u88fd\u54c1",kr:"\ucd94\uac00",tw:"\u52a0\u4e0a"};var _8=_7[_6];if(_8){noteNodes=adobe.Element.getElementsByClassName($("xNav"),"DD","note");noteNodes.each(function(_9){_9.innerHTML=_8;});}},getTemplate:function(el,_b,_c){function handleResponse(_d){var _e=new adobe.ContentTemplate(_d.responseText);_b=_b.replace("Adobe ","");var _f=["Bridge","Premiere","Device","OnLocation","Stock"];_f.each(function(_10){if(_b.indexOf(_10)>-1){_b="Adobe "+_b;}});if(_c){_c=_c.replace("/","");}else{_c="en";}this.localizeTemplate(_c);this.parseFamilies(_b);}var _11=new Ajax.Request("/lib/com.adobe/module/xnav/xnav.html",{method:"get",parameters:"",onComplete:handleResponse.bindAsEventListener(this)});}};
initXLoc=function(){var _1=new adobe.YouAreHere("sideNav");};registerOnReady(initXLoc);adobe.YouAreHere=Class.create();adobe.YouAreHere.prototype={initialize:function(id){if(!$(id)){return;}this.links=$A($(id).getElementsByTagName("a")).collect(this.createLink);this.handlePageLoad();},highlightLink:function(_3){var _4=_3.toString();_4=(_4.indexOf("/WORKAREA/cs3")>-1)?_4.replace("/WORKAREA/cs3",""):_4;_4=(_4.indexOf("?")!=-1)?_4.substring(0,_4.lastIndexOf("?")):_4;_4=_4.substring(0,_4.lastIndexOf("/")+1);var _5=_4;var _6=["engineering","graphicdesign","prophotographer","medical","manufacturing","motiondesign","science"];if(_4.indexOf("/reviews/")>-1){_5=_4.substring(0,_4.indexOf("reviews/"));}if(_4.indexOf("/awards/")>-1){_5=_4.substring(0,_4.indexOf("/awards"))+"/";}if(_4.indexOf("allfeatures")>-1){_5=_4.substring(0,_4.indexOf("allfeatures"));}if(_4.indexOf("/ultra/")>-1){_5=_4.substring(0,_4.indexOf("ultra/"))+"features/";}if(_4.indexOf("gettingstarted")>-1){_5=(_4.replace("gettingstarted","bridge"));}if(_4.indexOf("/plugins/photoshop/")>-1){_5=_4.substring(0,_4.indexOf("/products/plugins/photoshop/"))+"/go/more_ps_resources/";}if(_4.indexOf("products/photoshop")>-1){_6.each(function(_7){if(_4.indexOf(_7+"/features")>-1){_5=_4.substring(0,_4.indexOf("features"));}});}this.links.each(function(a){a.parent.className=(a.pathname==_5)?"selected":"";}.bind(this));},handlePageLoad:function(_9){var _a=window.location.pathname;this.highlightLink(_a);},createLink:function(a){menuLink=(a.pathname.charAt(0)!="/")?("/"+a.pathname):a.pathname;menuLink=(menuLink.charAt(menuLink.length-1)!="/"&&menuLink.charAt(menuLink.length-1)!="m"&&menuLink.charAt(menuLink.length-1)!="l")?(menuLink+"/"):menuLink;return {parent:a.parentNode,element:a,pathname:menuLink};}};
/* 
	IFRAME TAB NAVIGATION 
	$Id: framenav.js,v 1.16 2008/01/11 07:52:06 btapley Exp $
	* keeps track of all the tab highlights and associated iframe
*/

adobe.FrameNavigation = Class.create();

Object.extend(adobe.FrameNavigation, new adobe.StateManager("adobe.omniture.save",0));
adobe.Cookie.set("adobe.omniture.save", "initialLoad");	
// define object
adobe.FrameNavigation.prototype = {
	
	// required using prototype library (needs to have this method)
	initialize : function(navId,frameId,height) {

		this.id = navId;
		this.frameId = $(frameId);
		this.queryParam = adobe.FrameNavigation.getQueryParam('tab') || '';
		
		// * loops through all LI's and A's and create tabs for them
		this.tabs = $A($(navId).getElementsByTagName('li')).collect(this.createTab);
		
		var assignTabClickHander = (function(tab) {
			Event.observe(tab.control, "click", this.handleTabClick.bindAsEventListener(this));
		}).bind(this);

		// adding an "handleTabClick" method to each tab		
		this.tabs.each(assignTabClickHander);
		
		// observe the iframe to control tab highlight
		Event.observe(this.frameId, "load", this.handleFrameEvent.bindAsEventListener(this));
			
		this.loadSelectedTab();
		
	},
	
	// watches the mouse event and gets the href of the link 
	handleTabClick: function(event) {
		var tabLocation = event.element().href;
		this.highlightTab(tabLocation);
		this.setSelectedTab(tabLocation);
		this.setOmnitureCookie(tabLocation);		
	},
	
	// highlight a tab if the target href of link matches the location of the iframe html file
	highlightTab : 	function (tabLocation) {
		
		tabLocation = tabLocation.toString();
		
		/*
		if(tabLocation.indexOf('/WORKAREA/') != -1) {
			tabLocation = tabLocation.replace(/\/WORKAREA\/[^\/]+/,'');
		}
		*/
		
		var highlight = (function(tab){
			tab.element.className = (tab.location == tabLocation)? 'on' : 'off';
		}).bind(this);
		
		this.tabs.each(highlight);
	},
	
	// sets the currentTabTarget of the tab to the target of the current highlighted tab
	setSelectedTab :	function(tabLocation) {
		return (this.currentTabTarget = tabLocation);
	},
	
	loadSelectedTab :	function() {		
		// if query param (with "!") set default state of tabs (whatever HREF is set to in iframe include)
		if(this.queryParam && this.queryParam.indexOf('!') > -1) {
			return;
		} else 
		// if query param (with no "!")
		if(this.queryParam) {
			this.setTabFromQuery(this.queryParam);
		} 
		//get whatever frameLocation and highlight matching tab
		else {		
			selectedLoc = this.getFrameLocation();
			this.highlightTab(selectedLoc);
		}
	},
	
	// if url query
	setTabFromQuery : function(query) {
		/* if query matches the ID of a tab, set the tab highlight to matching tab id */
		var notab = this.tabs.detect(function(tab) {
			currentTabTarget =  tab.location;
			return tab.elementID == query;					
		});
		
		/* if tab query doesn't match anything */
		if(!notab) { return; }
		
		// set highlighted tab to match the tab location
		this.highlightTab(currentTabTarget);	
				
		this.setFrameLocation(currentTabTarget);
	},
		

	// set omniture cookie to frame URL if tab is clicked
	setOmnitureCookie :	function(tabLocation) {
		function save () {
			adobe.Cookie.set("adobe.omniture.save", "");
			adobe.FrameNavigation.setCookieParam(this.id, tabLocation);
		}
		Event.observe(window.document, "click", save.bindAsEventListener(this));
		
	},
	
	// get current frame location
	getFrameLocation : function() {
		return this.frameId.contentWindow.location;
	},
	
	// set current frame loc to current tab target
	setFrameLocation : function (currentTabTarget) {
		this.frameId.contentWindow.location = currentTabTarget; 
	},
	
	// watches frame load event
	handleFrameEvent: function(event) {
		
		// setting the pathname location of the iframe window
		var iframeLoc = this.getFrameLocation();	
		// highlight the tab with matching frame location href
		this.highlightTab(iframeLoc);		
		
		// set href of current href if set from cookie or not
		var iframeHref = this.frameId.contentWindow.location.href;	
		this.frameLocation = iframeHref || '';
						
	},
	
	// keep track of list elements and their links
	createTab : function (li) {
		var a = li.getElementsByTagName('a')[0];
		return { 
			element 	: 	li,
			elementID	:	li.id,
			control		: 	a,
			location 	: 	a.href
		};
	}
};
