	try { document.execCommand("BackgroundImageCache", false, true); } catch(e) {}

	$j = jQuery.noConflict(true);
	
	$j.Avaya = {
		global : {}
	};
	
	/* 
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
		DEBUG
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	*/
	(document.location.href.search("debug=true") != -1) ? $j.Avaya.global.debug = true : $j.Avaya.global.debug = false;

	/* 
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
		EVENT: DOM READY
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	*/
	$j(function() {		
	
		$j.Avaya.Page.Sizing.init();
		$j.Avaya.Page.MastNav.init();
		$j.Avaya.global.CustomSelects = [];
		
		if(!$j.browser.msie && $j.browser.version.substr(0,3)!="7.0"){
			new $j.Avaya.CustomSelect($j('#mastheadCountrySelect select'), {maxHeight:350}); 
		 } else {
			$j('#mastheadCountrySelect select').css('position','static');
		 }
			

	});	
	
	/* 
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
		EXTENSION: delegate
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	*/
	$j.fn.delegate = function(eventType, rules) {
	  return this.bind(eventType, function(e) {
		var target = $j(e.target);
		for(var selector in rules)
		  if(target.is(selector)) {
			return rules[selector].apply(this, arguments)
		  }
	  })
	}
	
	$j(window).resize(function(){
		$j.Avaya.Page.Sizing.resize();
	});
	
	
	$j.Avaya.Page = {
		region: 'United States',
		minHeight: 700,
		
		Section: {
			id : 'aboutus'
		}
	};

	if(typeof PAGETYPE != "undefined") {
		$j.Avaya.Page.Section.id = PAGETYPE;	
	}

	$j.Avaya.Page.Sizing = {
		
		init: function(){
			this.page = $j('#page');
			this.wrapper = $j('#wrapper');
			this.footer = $j("#footer");
			this.resize();
			this.timeout;
		},
		
		resize: function(){
			if (!this.page || !this.page.get(0) || $j.Avaya.Page.Sizing.dontResize) return;
			var windowHeight = $j(window).height();
			var wrapperHeight = this.wrapper.height();

			if (wrapperHeight<$j.Avaya.Page.minHeight && windowHeight<$j.Avaya.Page.minHeight){
				this.page.css({height:$j.Avaya.Page.minHeight});
				this.footer.css({position:'absolute', bottom:0});
			}
			else if (wrapperHeight+64>windowHeight){
				this.page.css({height:'auto'});
				this.footer.css({position:'static'});
			} 
			else {
				this.page.css({height:windowHeight});
				this.footer.css({position:'absolute', bottom:0});
			}

			var windowWidth = $j(window).width();
		    var pageWidth = windowWidth < $j.Avaya.Page.minWidth ? $j.Avaya.Page.minWidth : windowWidth;
		    this.page.width(pageWidth);
		}
	}

	$j.Avaya.Page.MastNav = {

		init: function(){
			var self = this;
			this.nav = $j('#mastheadNav');
			this.pointer = $j('#mastheadNavPointer');
			this.mainNavs = this.nav.find('li.mainNavs');
			this.subNavs = this.nav.find('li.subNavs');
			this.activeClass = 'active';
			this.liPadding = 15;
			this.showTimer = 300;
			this.hideTimer = 500;
			this.activeMain = this.activeSub = -1;
			this.showMainTimeout,this.showSubTimeout,this.hideMainTimeout,this.hideSubTimeout;
			this.sifr();
			this.navIndicator();
			
		/*****Bind Events*****/
			
			this.nav.bind('mouseleave',function(e){
				self.hideMain(self.nav.find('.'+self.activeClass).eq(0));
			});
			
			this.mainNavs.each(function(index){
				var $this = $j(this);
				$this.hover(function(e){
					self.showMain($this, index);
				},function(e){
					self.hideMain($this);
				});
			});
			
			this.subNavs.each(function(index){
				var $this = $j(this);
				$this.hover(function(e){
					self.showSub($this, index);
				},function(e){
					self.hideSub($this);
				});
			});
		},
		
		sifr : function(){
			var swf = $j.Avaya.SifrConfig.gothamBook;
			var options = {
				selector : '#mastheadNav ul p',
				css : [
					'.sIFR-root { text-align: center; font-weight: normal; }',
					'a { text-decoration: none; }',
					'a:link { color: #333333; }',
					'a:hover { color: #CC0000; }'
				]
			}
			$j.Avaya.SifrConfig.masterReplace(swf,options);
		},
		
		navOrder: ['solutions','products','support','community','aboutus','myavaya'], //Lowercase no spaces
		
		navIndicator: function(){
			var page = $j.Avaya.Page.Section.id.replace(/\s/g,'').toLowerCase();
			
			if (page){
				var li;
				
				for (var i=0;i<this.navOrder.length;i++){
					if (page==this.navOrder[i]){
						li = this.mainNavs[i];
						break;
					}
				}
				
				var left = $j(li).position().left+this.liPadding+this.nav.find('ul').eq(0).position().left;
				this.pointer.css({left:left});
				
			} else {
				this.pointer.hide();
			}
		},
		
		showMain:function(tar, index){
			var self = this;
			clearTimeout(this.hideMainTimeout);
			clearTimeout(this.showMainTimeout);
			
			this.showMainTimeout = setTimeout(function(){
				if (!tar.hasClass(self.activeClass)){
					self.mainNavs.eq(self.activeMain).removeClass(self.activeClass);
					self.subNavs.eq(self.activeSub).removeClass(self.activeClass);
					tar.addClass(self.activeClass);
					self.activeMain = index;
					self.pointer.hide();
				}
			}, self.showTimer);
		},
		
		hideMain:function(tar){
			var self = this;
			clearTimeout(this.hideMainTimeout);
			clearTimeout(this.showMainTimeout);
			
			this.hideMainTimeout = setTimeout(function(){
				tar.removeClass(self.activeClass);
				self.pointer.show();
			}, self.hideTimer);
		},
		
		showSub:function(tar, index){
			var self = this;
			clearTimeout(this.hideSubTimeout);
			clearTimeout(this.showSubTimeout);
			
			this.showSubTimeout = setTimeout(function(){
				if(!tar.hasClass(self.activeClass)){
					self.subNavs.eq(self.activeSub).removeClass(self.activeClass);
					tar.addClass(self.activeClass);
					self.activeSub = index;
				}
			}, self.showTimer);
		},
		
		hideSub:function(tar){
			var self = this;
			clearTimeout(this.showSubTimeout);
			
			this.hideSubTimeout = setTimeout(function(){
				tar.removeClass(self.activeClass);
			}, self.hideTimer);
		},
		
		hideAll:function(){
			this.mainNavs.eq(this.activeMain).removeClass(this.activeClass);
			this.subNavs.eq(this.activeSub).removeClass(this.activeClass);
		}
	}

	$j.Avaya.SifrConfig = {

		init: function(){
			sIFR.activate(this.gothamLight);
			sIFR.activate(this.gothamBook);
		},
		
		gothamLight: {
			src: '/_assets/swf/gothamLight.swf',
			ratios : [9, 1.27, 13, 1.18, 18, 1.14, 26, 1.13, 32, 1.11, 37, 1.1, 64, 1.09, 105, 1.08, 107, 1.07, 119, 1.08, 122, 1.07, 1.08]
		},
		
		gothamBook: {
			src: '/_assets/swf/gothamBook.swf'
		},
		
		masterReplace: function(swf,options){
			if (typeof(sIFR)=='object'){
				sIFR.replace(swf, {
					selector: options.selector,
					css: options.css,
					wmode: 'transparent'
				});
			}
		}
	}
	$j.Avaya.SifrConfig.init();

/* 
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
		CLASS: CustomSelect
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/

	$j.Avaya.CustomSelect = function(sb,options){
		//if (!container) return;
		
	/*****Initialize*******/	
		var selectbox = sb;
		selectbox.wrap('<div class="selectParent"></div>');
		this.container = selectbox.parents(".selectParent");
		
		this.select = selectbox;
		if (!this.select.get(0)) return;
		
		this.index = $j.Avaya.global.CustomSelects.length;
		$j.Avaya.global.CustomSelects.push(this);
		
		var self = this;
		this.isOpen = this.isFocused = 0;
		
		this.settings = $j.extend({
			maxHeight: 150,
			zIndex: 10,
			openZIndex: 50000,
			ignoredValue:false, //Options with ignored value will only be processed by javascript
			functions:'',
			submitFunction: false //Click or enter on an option will submit the form, which calls the submitFunction if it is defined, opts with ignoredValue will not trigger submit
		},options);
		
		this.parentForm = this.select.parent('form');
		//this.select.get(0).selectedIndex = this.currentIndex; //Set initial selected index to the specified one - TODO: add possiblity to look for selected=selected on pageload
		//this.select.addClass('hasJS'); //Hides the select for only those with js
		
	/******Create DropDown*******/
		
		this.wrapper = $j('<div id="customSelect_'+this.index+'" class="selectWrapper"></div>');
		this.dropDown = $j('<div class="selectDropDown"></div>');
		this.listContainer = $j('<div class="selectScroller"></div>');
		this.list = $j('<ul class="selectList"></ul>');
		
		this.opts = this.select.find('option');
		var liString = '';
		this.currentIndex = 0;
		
		this.opts.each(function(index){
			if (this.selected) { self.currentIndex = index; }
			liString += '<li class="selectOpt_'+index+'">'+this.innerHTML+'</li>';
		});
		
		this.list.append($j(liString));
		
		this.display = $j('<div class="selectDisplay"><span>'+this.opts[this.currentIndex].innerHTML+'</span></div>');
		this.displaySpan = this.display.find('span');
		
		this.listContainer.append(this.list);
		this.dropDown.append(this.listContainer);
		this.wrapper.append(this.display);
		this.wrapper.append(this.dropDown);
		this.container.append(this.wrapper);
		
		this.listItems = this.list.find('li');
		this.listItems.eq(this.currentIndex).addClass('selected');
		
		if (this.dropDown.height()>this.settings.maxHeight){
			this.listContainer.css({height:this.settings.maxHeight});
			this.scrollPane = this.listContainer.jScrollPane({showArrows:true});
		}

	/******Bind Events ******/
		
		$j(document).click(function(e){
			if (self.isOpen){
				var parent = '#customSelect_'+self.index;
				if (!$j(e.target).parents(parent).get(0)){
					self.close();
				}
			}
		}).keyup(function(e){
			if (self.isFocused||self.isOpen){
				self.changeValue();
				if (e.keyCode==9 || e.keyCode==13 || e.keyCode == 27){
					if (e.keyCode == 13){
						self.clickOption();
					}
					self.close();
				}
			}
		});
		
		this.display.click(function(){
			self.select.focus();
			self.isOpen ? self.close() : self.open();
		}).hover(function(){
			$j(this).addClass('hovered');
		},function(){
			$j(this).removeClass('hovered');
		});
		
		this.list.delegate('click',{
			'li' : function(e){
				e.preventDefault();
				self.clickOption(e.target);
				self.select.focus();
			}
		});
		
		this.list.find('li').hover(function(e){
			$j(this).addClass('hovered');
		},function(e){
			$j(this).removeClass('hovered');
		});
		
		this.select.focus(function(e){
			self.isFocused = true;
		}).blur(function(e){
			self.isFocused = false;
		});
	}

	/*******CustomSelect methods ******/
		//call after an option has been removed/added/edited
		$j.Avaya.CustomSelect.prototype.updateList = function(){
			//Empty
			this.list.empty();
			this.listItems.empty();
			
			this.opts = this.select.find('option');
			var liString = '';
		
			this.opts.each(function(index){
				liString += '<li class="selectOpt_'+index+'">'+this.innerHTML+'</li>';
			});
			
			this.list.append($j(liString));
			
			this.listItems = this.list.find('li');
			this.listItems.eq(this.currentIndex).addClass('selected');
			
			if (this.scrollPane){
				this.scrollPane = this.listContainer.jScrollPane({showArrows:true});
			}
		}
	
		$j.Avaya.CustomSelect.prototype.open = function(){
			if (this.isOpen) return;
			this.dropDown.addClass('open');
			this.container.css({zIndex:1000});
			if (this.scrollPane) {
				this.scrollPane = this.listContainer.jScrollPane({showArrows:true});
				this.scrollPane[0].scrollTo('li.selected');
			}
			
			this.isOpen = true;
		}

		$j.Avaya.CustomSelect.prototype.close = function(){
			if (!this.isOpen) return;
			this.container.css({zIndex:1000});
			this.dropDown.removeClass('open');
			this.isOpen = false;
		}

		$j.Avaya.CustomSelect.prototype.clickOption = function(tar){
			var select = this.select.get(0);
			var index;
			
			if (tar){
				index = parseInt(tar.className.split('_')[1]);
			} else {
				index = select.selectedIndex;
			}

			var value = select[index].value;
			
			if (this.settings.ignoredValue&&value.search(this.settings.ignoredValue) != -1){	
				
				if (typeof(this.settings.functions[value.replace(this.settings.ignoredValue + " ", "")])=='function'){
					
					this.settings.functions[value.replace(this.settings.ignoredValue + " ", "")]();
				
				}
				
			} else {
				select.selectedIndex = index;
				
				if (typeof(this.settings.submitFunction)=='function'){
					this.settings.submitFunction();
				}
				
				this.changeValue();
			}
			
			this.close();
		}

		$j.Avaya.CustomSelect.prototype.changeValue = function(){
			var index = this.select.get(0).selectedIndex;
			if (index==this.currentIndex) return;
			
			this.listItems.eq(this.currentIndex).removeClass('selected'); //remove selected class from old item
			
			var newItem = this.listItems.eq(index).addClass('selected');
			
			if (this.itemVisible(newItem)==false&&this.scrollPane){
				this.scrollPane[0].scrollTo('li.selected');
			}
			
			this.displaySpan.html(newItem.html());
			
			this.currentIndex = index;
		}

		//returns bool
		$j.Avaya.CustomSelect.prototype.itemVisible = function(item){
			var pos = item.offset().top;
			var top = this.dropDown.offset().top;
			if (pos>top && pos+item.height()<top+this.dropDown.height()){
				return true;
			}
			return false;
		}
		
		$j.Avaya.CustomSelect.prototype.jumpToIndex = function(index){
			if (index<this.select.length){
			
				this.select.get(0).selectedIndex = index;
				this.changeValue();
			
			}
		}
		
	/* 
		>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
			EXTENSION: Remove JScrollPane
		>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	*/
	$j.fn.jScrollPaneRemove = function() {
		$j(this).each(function() {
			$this = $j(this);
			var $c = $this.parent();
			if ($c.is('.jScrollPaneContainer')) {
				$this.css(
					{
						'top':'',
						'height':'',
						'width':'',
						'padding':'',
						'overflow':'',
						'position':''
					}
				);
				$c.after($this).remove();
			}
		});
	}

	/*
		>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
			EXTENSION: Cookie
		>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	*/
	$j.cookie = function(name, value, options) {
		if (typeof value != 'undefined') { // name and value given, set cookie
			options = options || {};
			if (value === null) {
				value = '';
				options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
				options.expires = -1;
			}
			var expires = '';
			if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
				var date;
				if (typeof options.expires == 'number') {
					date = new Date();
					date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
				} else {
					date = options.expires;
				}
				expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
			}
			// NOTE Needed to parenthesize options.path and options.domain
			// in the following expressions, otherwise they evaluate to undefined
			// in the packed version for some reason...
			var path = options.path ? '; path=' + (options.path) : '';
			var domain = options.domain ? '; domain=' + (options.domain) : '';
			var secure = options.secure ? '; secure' : '';
			document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
		} else { // only name given, get cookie
			var cookieValue = null;
			if (document.cookie && document.cookie != '') {
				var cookies = document.cookie.split(';');
				for (var i = 0; i < cookies.length; i++) {
					var cookie = $j.trim(cookies[i]);
					// Does this cookie string begin with the name we want?
					if (cookie.substring(0, name.length + 1) == (name + '=')) {
						cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
						break;
					}
				}
			}
			return cookieValue;
		}
	};