var SAFARI_STYLESHEET_REFERENCE = "style/styles_safari.css";
var SENDTHISPAGE_REFERENCE = "http://www.infineon.com/cms/en/services/send-page.html";
/********************************************************************/
/*START: Fix IE 6 Text Selection Bug & Flickering Background Images */
if (window.createPopup && document.compatMode && document.compatMode=="CSS1Compat" && !window.XMLHttpRequest) {
	document.onreadystatechange = function fixIE6AbsPos()
	{
		if( !document.body ) {
			return;
		}
		if( document.readyState == "complete" ) {
			document.body.style.height = document.documentElement.scrollHeight + 'px';
		}
	}

	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
}
/*END: Fix IE 6 Text Selection Bug & Flickering Background Images */
/********************************************************************/
/********************************************************************/
/*START: browser detection*/
function BrowserDetection()
{
	var sUserAgent = navigator.userAgent.toLowerCase();

	// browser name
	this.isIE = (sUserAgent.indexOf('msie') != -1 && typeof window.opera == "undefined");
	this.isIE7 = (this.isIE && typeof window.XMLHttpRequest != "undefined");
	this.isSafari = (sUserAgent.indexOf('safari') != - 1);
	this.isMozilla = (sUserAgent.indexOf('gecko') != -1 && this.isSafari == false);
	this.isFirefox = (this.isMozilla == true && sUserAgent.indexOf('firefox') != -1);
	this.isFirefox_1_0 = (this.isFirefox == true && sUserAgent.indexOf('firefox/1.0') != -1);
	this.isOpera = (sUserAgent.indexOf('opera') != -1 || typeof window.opera != "undefined");
}

var oBrowser = new BrowserDetection();
/*END: browser detection*/
/********************************************************************/
/********************************************************************/
/*START: helper functions */
function getWindowInnerSize(win)
{
	if(!win) win = window;
		var objWin = new Object();
		if(typeof win.innerWidth != 'undefined') {
			objWin.width = win.innerWidth;
			objWin.height = win.innerHeight;
		} else {
			var obj = getBody(win);
			objWin.width = parseInt(obj.clientWidth);
			objWin.height = parseInt(obj.clientHeight);
		}
		return objWin;
}

function getBody(w)
{
	return (w.document.compatMode && w.document.compatMode == "CSS1Compat") ? w.document.documentElement : w.document.body || null;
}

// show and hide elements
function showElem(sId)
{
	if($(sId)){
		$(sId).style.display = 'block';
	}
}

function hideElem(sId)
{
	if($(sId)){
		$(sId).style.display = 'none';
	}
}
/*END: helper functions */
/********************************************************************/
/********************************************************************/
/*START: functions for layout modification*/
var placeholder_id = "footer-position-placeholder";
var footer_id = "footer-zone-wrapper";

function positionFooter_onload()
{
	//function based on prototype.js

	var iWindowHeight = getWindowInnerSize().height;
	var iFooterHeight = ($(footer_id)) ? Element.getHeight($(footer_id)) : 0;
	var iFooterTopPosition = ($(footer_id)) ? Position.positionedOffset($(footer_id))[1] : 0;
	var iFooterPlaceholderHeight = 0;
	var iNewFooterPlaceholderHeight = 0;

	if ($(placeholder_id)) {
		if ((iFooterTopPosition + iFooterHeight) < iWindowHeight) {
			iNewFooterPlaceholderHeight = (iWindowHeight- iFooterTopPosition - iFooterHeight);
			$(placeholder_id).setStyle({height: iNewFooterPlaceholderHeight + "px"});
		}
	}
}

function positionFooter()
{
	//function based on prototype.js

	if( !$(placeholder_id) ) return;
	var iWindowInnerHeight = getWindowInnerSize().height;
	var iFooterHeight = ($(footer_id)) ? Element.getHeight($(footer_id)) : 0;
	var iFooterTopPosition = ($(footer_id)) ? Position.positionedOffset($(footer_id))[1] : 0;
	var iFooterPlaceholderHeight = ($(placeholder_id)) ? Element.getHeight($(placeholder_id)) : 0;
	var iNewFooterPlaceholderHeight = 0;

	var iWindowMinPos = iWindowInnerHeight - iFooterHeight;
	if ( iWindowMinPos > iFooterTopPosition ) {
		iNewFooterPlaceholderHeight = iWindowMinPos - iFooterTopPosition;
		iNewFooterPlaceholderHeight += iFooterPlaceholderHeight;
	} else {
		iNewFooterPlaceholderHeight = iFooterPlaceholderHeight - (iFooterTopPosition - iWindowMinPos);
	}
	if(iNewFooterPlaceholderHeight < 0) iNewFooterPlaceholderHeight = 0;
	$(placeholder_id).setStyle({height: iNewFooterPlaceholderHeight + "px"});
}

function fixOperaLayout()
{
	if(oBrowser.isOpera)
	{
		var elemListW108 = document.getElementsByClassName('search');
		for (var i = 0; i < elemListW108.length; i++)
		{
			elemListW108[i].setStyle({width: "106px"});
		}
		
		var buttons = document.getElementsByClassName('button');
		for (var i = 0; i < buttons.length; i++)
		{
			if(buttons[i].down())buttons[i].down().setStyle({'min-width': '0'});
		}
	}
}

function fixIETableFirstChild()
{
	if(oBrowser.isIE && !oBrowser.isIE7)
	{
		var commonTables = $$('table.common');
		var rows, children, firstchild;
		for(var i = 0; i < commonTables.length; i++)
		{
			rows = $(commonTables[i]).getElementsByTagName('TR');
			firstchild = $(rows[0]).down();
			if(firstchild && firstchild.hasClassName("fc")) break;//already dealt with
			for(var j = 0; j < rows.length; j++)
			{
				children = rows[j].childNodes;
				for (var i = 0; i < children.length; i++) 
				{
					if(children[i].nodeType == 1){//check for element node
						Element.addClassName(children[i], "fc");
						break;
					}
				}
			}
		}
	}
}

function initLayout()
{
	positionFooter();
	fixOperaLayout();
}
/*END: functions for layout modification*/
/********************************************************************/
/********************************************************************/
/*START: Function to rewrite pwd-field */
function handlePassword()
{
	var inputPwd = $('login-password');
	if (inputPwd) {
		var inputDummy = document.createElement("input");
		inputDummy.value = "Password";
		inputDummy.name = "dummy";
		inputDummy.id = "dummy";
		inputDummy.className = "password";
		inputPwd.style.display = "none";
		inputPwd.parentNode.insertBefore(inputDummy, inputPwd.nextSibling);

		inputDummy.inputPwd = inputPwd;
		inputDummy.onfocus = function() {
			this.style.display = "none";
			this.inputPwd.style.display = "inline";
			this.inputPwd.value = "";
			this.inputPwd.focus();
		}

		inputPwd.inputDummy = inputDummy;
		inputPwd.onblur = function () {
			if (this.value.length==0) {
				this.style.display = "none";
				this.inputDummy.style.display = "inline";
			}
		}
	}
}

function checkRemoveDummy(e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13) {
		removeDummy();
	}
}

/*remove dummy field before submitting form*/
function removeDummy()
{
	var inputDummy = $("dummy");
	var inputPwd = $('login-password');
	if(inputDummy && inputPwd) {
		inputDummy.up().removeChild(inputDummy);
		inputPwd.style.display = "inline";
	}
}
/*END: Function to rewrite pwd-field */
/********************************************************************/
/********************************************************************/
/*START: Checkbox Group Controller*/
var CheckboxGroupController = {
	check: function(checkboxNode) {
		if (!checkboxNode) return;
		var checkBoxGroup = $(checkboxNode).up('.checkbox-group');
		if (!checkBoxGroup) return;
		var checkBoxAll = $(checkBoxGroup).down('input.check-all');
		var checkBoxOneway = $(checkBoxGroup).down('input.check-oneway');
		if (!checkBoxAll) // special treatment IE5.5
		{
			checkBoxAll = $(checkBoxGroup).getElementsBySelector('input.check-all')[0];
			checkBoxOneway = $(checkBoxGroup).getElementsBySelector('input.check-oneway')[0];
		}
		if (!checkBoxAll) return;
		var checkBoxes = $(checkBoxGroup).getElementsByClassName('input-checkbox');
		if (checkBoxes.length == 0) // special treatment IE5.5
		{
			checkBoxes = $(checkBoxGroup).getElementsBySelector('input.input-checkbox');
		}
		if (!checkBoxes || checkBoxes.length == 0) return;
		if(checkboxNode == checkBoxAll)
		{
			if(checkboxNode.checked)
			{
				$(checkBoxes).each(function(n){
					n.checked = true;
				});
			}else{
				$(checkBoxes).each(function(n){
					n.checked = false;
				});
			}
		}else{
			if(checkboxNode.checked)
			{
				var areAllChecked= true;
				$(checkBoxes).each(function(n){
					if(!n.checked && n != checkBoxAll){
						areAllChecked = false;
					}
				});
				if (areAllChecked && !checkBoxOneway) checkBoxAll.checked = true;
			}else{
				checkBoxAll.checked = false;
			}
		}
	},
	
	uncheck: function(checkboxNode) {
		if (!checkboxNode) return;
		var checkBoxGroup = $(checkboxNode).up('.checkbox-group');
		if (!checkBoxGroup) return;
		var checkBoxAll = $(checkBoxGroup).down('input.uncheck-all');
		if (!checkBoxAll) // special treatment IE5.5
		{
			checkBoxAll = $(checkBoxGroup).getElementsBySelector('input.uncheck-all')[0];
		}
		if (!checkBoxAll) return;
		var checkBoxes = $(checkBoxGroup).getElementsByClassName('input-checkbox');
		if (checkBoxes.length == 0) // special treatment IE5.5
		{
			checkBoxes = $(checkBoxGroup).getElementsBySelector('input.input-checkbox');
		}
		if (!checkBoxes || checkBoxes.length == 0) return;
		if(checkboxNode == checkBoxAll)
		{
			if(checkboxNode.checked)
			{
				$(checkBoxes).each(function(n){
					if(n != checkBoxAll) n.checked = false;
				});
			}
		}else{
			checkBoxAll.checked = false;
		}
	},
	
	uncheckAllIn: function(checkboxGroup) {
		if (!checkboxGroup || !$(checkboxGroup)) return;
		var checkBoxGroup = $(checkboxGroup);
		
		var checkBoxes = $(checkBoxGroup).getElementsByClassName('input-checkbox');
		if (checkBoxes.length == 0) // special treatment IE5.5
		{
			checkBoxes = $(checkBoxGroup).getElementsBySelector('input.input-checkbox');
		}
		if (!checkBoxes || checkBoxes.length == 0) return;
		$(checkBoxes).each(function(n){
			n.checked = false;
		});
	}
};
/*END: Checkbox Group Controller*/
/********************************************************************/
/********************************************************************/
/*START: Show and Hide Confirmation*/
var ConfirmationController = {
	showConfirmation: function(buttonNode) {
		if (!buttonNode) return;
		var toolLayer = $(buttonNode).up('.tool');
		if(!$(toolLayer)) return;
		$(toolLayer).addClassName("confirmed");
	},

	hideConfirmation: function(buttonNode){
		if (!buttonNode) return;
		var toolLayer = $(buttonNode).up('.tool');
		if(!$(toolLayer)) return;
		$(toolLayer).removeClassName("confirmed");
	},

	toggleConfirmation: function(buttonNode){
		if (!buttonNode) return;
		var toolLayer = $(buttonNode).up('.tool');
		if(!$(toolLayer)) return;
		if($(toolLayer).hasClassName="confirmed") $(toolLayer).removeClassName("confirmed");
		else $(toolLayer).addClassName("confirmed");
	}
};

/*END: Show and Hide Generic Menu Layers*/
/********************************************************************/
/********************************************************************/
/*START: Show and Hide Generic Menu Layers*/
var ToggleLink = Class.create();
ToggleLink.prototype = {
	initialize: function(toggleLinkSelector, toggleLayerSelector) {
		if (!toggleLinkSelector || !toggleLayerSelector) return;
		this.toggleLinkSelector = toggleLinkSelector;
		this.toggleLayerSelector = toggleLayerSelector;
		this.delayID = null;
		
		if(!this.toggleLinkSelector.hasClassName('disable-rollover'))
		{
			Event.observe(this.toggleLinkSelector, 'mouseover', this.showLayer.bindAsEventListener(this));
			Event.observe(this.toggleLinkSelector, 'mouseout', this.delayedHideLayer.bindAsEventListener(this));
			Event.observe(this.toggleLayerSelector, 'mouseover', this.showLayer.bindAsEventListener(this));
			Event.observe(this.toggleLayerSelector, 'mouseout', this.delayedHideLayer.bindAsEventListener(this));
		}
	},

	showLayer: function(e){
		if(e) Event.stop(e);
		this.clearHideLayer();
		showElem(this.toggleLayerSelector);
		if(this.controller) this.controller.setActiveLayer(this);
	},

	hideLayer: function(){
		hideElem(this.toggleLayerSelector);
		if (this.delayID) {
			clearTimeout(this.delayID);
			this.delayID = null;
		}
	},

	delayedHideLayer: function(e){
		if(e) Event.stop(e);
		if (this.toggleLayerSelector.style.display == 'block'){
			this.delayID = setTimeout(this.hideLayer.bind(this), 200);
		}
	},

	clearHideLayer: function(){
		if(this.controller)
		{
			var activeLayer = this.controller.getActiveLayer();
			if(activeLayer && activeLayer != this) activeLayer.hideLayer();
		}

		if (this.delayID) {
			clearTimeout(this.delayID);
			this.delayID = null;
		}
	},
	
	registerController: function(controllerObj){
		this.controller = controllerObj;
		if(this.toggleLayerSelector && $(this.toggleLayerSelector).hasClassName("show")) this.showLayer();
	}
};

/*END: Show and Hide Generic Menu Layers*/
/********************************************************************/
/********************************************************************/
/*START: Main Navigation Tabs*/
var NavigationTab = Class.create();
NavigationTab.prototype = {
	initialize: function(navigationTabSelector, navigationTabBar) {
		if (!navigationTabSelector) return;
		this.navigationTabSelector = navigationTabSelector;
		this.navigationTabBar = navigationTabBar;
		this.navigationTabWrapper = null;
		this.navigationTabContent = null;
		this.navigationTabsIframe = null;
		var ancestors = this.navigationTabSelector.ancestors();
		for(i=0; i < ancestors.length; i++)
		{
			if(ancestors[i].hasClassName('nav-tab-wrapper'))
			{
				this.navigationTabWrapper = ancestors[i];
				break;
			}
		}
		if(!this.navigationTabSelector.hasClassName('disable-rollover'))
		{
			if(this.navigationTabBar ) this.navigationTabsIframe = this.navigationTabBar.getIframe();;
			Event.observe(this.navigationTabSelector, 'mouseover', this.showLayer.bindAsEventListener(this));
			Event.observe(this.navigationTabSelector, 'mouseout', this.delayedHideLayer.bindAsEventListener(this));
			if(this.navigationTabSelector.next('.nav-tab-content'))
			{
				this.navigationTabContent = this.navigationTabSelector.next('.nav-tab-content');
				Event.observe(this.navigationTabContent, 'mouseover', this.showLayer.bindAsEventListener(this));
				Event.observe(this.navigationTabContent, 'mouseout', this.delayedHideLayer.bindAsEventListener(this));
				if(this.navigationTabContent.hasClassName('fluid-width')) this.positionLayer();
			}
		}
	},

	positionLayer: function() {
		if (!this.navigationTabContent || !this.navigationTabContent.hasClassName('fluid-width')) return;
		var obj = this.navigationTabSelector;
		var layer = this.navigationTabContent;
		var tabwidth = $(obj).getWidth();
		var tabposition = Position.positionedOffset(obj);
		var layerwidth = $(layer).getWidth();
		var layerborder = parseInt($(layer).getStyle('borderRightWidth')) + parseInt($(layer).getStyle('borderLeftWidth'));
		var offset = 58+11; //left and right
		if(tabwidth+offset <= layerwidth+layerborder){
			layer.style.left = (tabposition[0]-58+(layerwidth+layerborder-(tabwidth+offset))) + "px";
		}else{
			layer.style.left = (tabposition[0]-58) + "px";
			if ((!document.compatMode || document.compatMode == 'BackCompat') && document.all) {
				//IE5 with MS box model
				layer.style.width = (tabwidth+offset) + "px";
			} else {
				//standards-mode browser with w3c box model
				layer.style.width = (tabwidth+offset-layerborder) + "px";
			} 
		}
	},

	showLayer: function(e) {
		Event.stop(e);
		this.clearHideLayer();
		if (!this.navigationTabWrapper.hasClassName('show')) {
			this.navigationTabWrapper.addClassName('show');
		}
		if (this.navigationTabsIframe) this.ieShowFrame();
		this.navigationTabContent.style.zIndex=2;
		this.navigationTabBar.moveToForeground();
		this.navigationTabBar.setActiveLayer(this);
	},

	hideLayer: function(){
		if (this.navigationTabWrapper.hasClassName('show')) {
			this.navigationTabWrapper.removeClassName('show');
		}
		if (this.navigationTabsIframe) this.ieHideFrame();
		this.navigationTabBar.moveToBackground();
		this.navigationTabContent.style.zIndex=1;
		if (this.navigationTabBar.delayID) {
			clearTimeout(this.navigationTabBar.delayID);
			this.navigationTabBar.delayID = null;
		}
	},

	delayedHideLayer: function(e) {
		if (!e) var e = window.event;
		
		if(e)
		{
			//don't close tab when selecting from a drop down list within
			var evtElement = Event.element(e);
			if(evtElement && ($(evtElement).tagName=="SELECT" || $(evtElement).tagName=="OPTION" || $(evtElement).tagName=="INPUT") && $(evtElement).descendantOf($(this.navigationTabContent))) return;
		}

		if(e)Event.stop(e);
		if (this.navigationTabWrapper.hasClassName('show')){
			this.clearHideLayer();
			this.navigationTabBar.delayID = setTimeout(this.hideLayer.bind(this), 250);
		}
	},

	clearHideLayer: function(){
		var activeTab = this.navigationTabBar.getActiveLayer();
		if(activeTab && activeTab != this) activeTab.hideLayer();

		if (this.navigationTabBar.delayID) {
			clearTimeout(this.navigationTabBar.delayID);
			this.navigationTabBar.delayID = null;
		}
	},
	
	ieShowFrame: function (obj)
	{
		if (this.navigationTabsIframe && this.navigationTabContent) {
			var obj = this.navigationTabContent;
			var iframe = this.navigationTabsIframe;
			var tabdimension = $(obj).getDimensions();
			var tabposition = Position.positionedOffset(obj);
			iframe.style.left = tabposition[0] + "px";
			iframe.style.top = tabposition[1] +"px";
			iframe.style.width = tabdimension.width + "px";
			iframe.style.height = tabdimension.height + "px";
			iframe.style.display = "block";
		}
	},

	ieHideFrame: function()
	{
		if (this.navigationTabsIframe) {
			this.navigationTabsIframe.style.display = "none";
		}
	}
};

var NavigationTabBar = Class.create();
NavigationTabBar.prototype = {
	initialize: function(navigationTabBarSelector, navigationTabBarController) {
		this.navigationTabsSelector = navigationTabBarSelector;
		this.navigationTabBarController = navigationTabBarController;
		if (!this.navigationTabsSelector) return;
		this.zIndexOriginal = this.navigationTabsSelector.style.zIndex;

		this.activeTab = null;
		this.delayID = null;
		
		this.tabSelectors = null;
		this.navigationTabs = new Array();
		this.tabSelectors = document.getElementsByClassName('nav-tab', this.navigationTabsSelector);
		if(this.tabSelectors.length == 0) // special treatment IE5.5
		{
			var tabSelectorsTemp = $$('div.nav-tab');
			for(var i = 0; i < tabSelectorsTemp.length; i++)
			{
				if($(tabSelectorsTemp[i]).descendantOf($(this.navigationTabsSelector))){
					this.tabSelectors.push(tabSelectorsTemp[i]);
				}
			}
		}
		
		var parentTabBar = this;
		var tempTabArray = [];
		this.tabSelectors.each(function(element, index) {
			tempTabArray.push(new NavigationTab(element, parentTabBar));
		});
		this.navigationTabs= tempTabArray;
	},

	moveToForeground: function()
	{
		this.navigationTabsSelector.style.zIndex=foregroundZIndex;
	},
	
	moveToBackground: function()
	{
		this.navigationTabsSelector.style.zIndex=this.zIndexOriginal;
	},

	setActiveLayer: function(activeTab)
	{
		this.activeTab = activeTab;
		this.navigationTabBarController.setActiveLayer(activeTab);
	},

	getActiveLayer: function()
	{
		var tempActiveTab = this.navigationTabBarController.getActiveLayer();
		if(!tempActiveTab) tempActiveTab = this.activeTab;
		return tempActiveTab;
	},
	
	getIframe: function()
	{
		if(!this.iFrameSelector){
			var iFrameSelectors = document.getElementsByClassName('iframe-layer', this.navigationTabsSelector);
			if(iFrameSelectors.length == 0) // special treatment IE5.5
			{
				var iFrameSelectorsTemp = $$('iframe.iframe-layer');
				for(var i = 0; i < iFrameSelectorsTemp.length; i++)
				{
					if($(iFrameSelectorsTemp[i]).descendantOf($(this.navigationTabsSelector))){
						iFrameSelectors.push(iFrameSelectorsTemp[i]);
					}
				}
			}
			if(iFrameSelectors.length>0) this.iFrameSelector = iFrameSelectors[0];
			else this.iFrameSelector=null;
		}
		return this.iFrameSelector;
	}
};

var NavigationTabBars = {
	initialize: function() {
		//find and create navigation tabs
		this.navigationTabBarSelectors = $$('div.nav-tab-bar');
		if (!this.navigationTabBarSelectors) return;

		this.navigationTabBars = new Array();
		var parentTabBars = this;
		var tempTabBarArray = [];
		this.navigationTabBarSelectors.each(function(element, index) {
			tempTabBarArray.push(new NavigationTabBar(element, parentTabBars));
		});
		this.navigationTabBars= tempTabBarArray;
		
		//create simple rollover menus
		this.rolloverMenus =[];
		this.rolloverMenus.push(new ToggleLink($('select-language-link'), $('select-language')));
		this.rolloverMenus.push(new ToggleLink($('login-link'), $('login')));
		
		this.rolloverMenus.invoke('registerController', this)
	},
	
	setActiveLayer: function(activeTab)
	{
		this.activeTab = activeTab;
	},

	getActiveLayer: function()
	{
		return this.activeTab;
	}
};

var foregroundZIndex=40;
/*END: Main Navigation Tabs*/
/********************************************************************/
/********************************************************************/
/*START: Tools Tabs*/
var ToolsTab = Class.create();
ToolsTab.prototype = {
	initialize: function(toolsTabSelector, toolsTabBar) {
		if (!toolsTabSelector) return;
		this.toolsTabSelector = toolsTabSelector;
		this.toolsTabBar = toolsTabBar;
		this.toolsTabContent = $(this.toolsTabSelector.id+'-content');
		if (!this.toolsTabContent) return;
		this.toolsTabContent.linkedTab = this;

		if(!this.toolsTabSelector.hasClassName('disable-tab'))
		{
			Event.observe(this.toolsTabSelector, 'click', this.showLayer.bindAsEventListener(this));
		}
		if(this.toolsTabSelector.hasClassName('active'))
		{
			this.showLayer();
		}
	},

	showLayer: function(e) {
		if(e) Event.stop(e);
		if(this.toolsTabContent)
		{
			this.toolsTabContent.show();
			this.toolsTabSelector.addClassName('active');
			this.toolsTabBar.setActiveLayer(this);
		}
	},

	hideLayer: function(){
		if(this.toolsTabContent)
		{
			this.toolsTabContent.hide();
			this.toolsTabSelector.removeClassName('active');
		}
	}
};

var ToolsTabBar = Class.create();
ToolsTabBar.prototype = {
	initialize: function(toolsTabBarSelector) {
		this.toolsTabsSelector = toolsTabBarSelector;
		if (!this.toolsTabsSelector) return;

		this.activeTab = null;
		this.toolsTabs = new Array();
		
		this.tabSelectors = null;
		this.tabSelectors = document.getElementsByClassName('tab', this.toolsTabsSelector);
		if(this.tabSelectors.length == 0) // special treatment IE5.5
		{
			var tabSelectorsTemp = $$('li.tab');
			for(var i = 0; i < tabSelectorsTemp.length; i++)
			{
				if($(tabSelectorsTemp[i]).descendantOf($(this.toolsTabsSelector))) this.tabSelectors.push(tabSelectorsTemp[i]);
			}
		}
		var parentTabBar = this;
		var tempTabArray = [];
		this.tabSelectors.each(function(element, index) {
			tempTabArray.push(new ToolsTab(element, parentTabBar));
		});
		this.toolsTabs= tempTabArray;
	},

	setActiveLayer: function(activeTab)
	{
		if(this.activeTab && !(this.activeTab == activeTab)) this.activeTab.hideLayer();
		this.activeTab = activeTab;
	}
};

var ToolsTabBars = {
	initialize: function() {
		this.toolsTabBarSelectors = $$('ul.tabbed-tools-nav');
		if (!this.toolsTabBarSelectors) return;

		this.toolsTabBarSelectors.each(function(element, index) {
			new ToolsTabBar(element);
		});
	}
};
/*END: Tools Tabs*/
/********************************************************************/
/********************************************************************/
/*START: Collapsables*/
var CollapsableElement = Class.create();
CollapsableElement.prototype = {
	state_collapsed: 'collapsed',
	state_expanded: 'expanded',
	//tooltip_collapsed: 'expand',
	//tooltip_expanded: 'collapse',

	initialize: function(collapsableSelector) {
		if (!collapsableSelector) return;
		this.collapsableSelector = collapsableSelector;
		this.collapsableLinkSelector = null;
		this.collapsableLinkSelector = $(this.collapsableSelector).previous('.toggle-icon');

		if(!this.collapsableSelector.hasClassName('disabled') && this.collapsableLinkSelector)
		{
			Event.observe(this.collapsableLinkSelector, 'click', this.toggleContent.bindAsEventListener(this));
		}
		
		if(this.collapsableSelector.hasClassName(this.state_expanded))
		{
			this.showContent(false);
		} else {
			this.hideContent(false);
		}
	},

	toggleContent: function(e) {
		if(!this.collapsableLinkSelector) return;
		if(e)
		{
			var elt = $(Event.element(e));
			if(!elt.tagName) elt = elt.parentNode; // safari link clicked
			if(!elt.hasClassName('toggle-link') && elt != this.collapsableLinkSelector) return;
		}
		if(this.collapsableSelector.hasClassName(this.state_collapsed))
		{
			this.showContent(true);
			if(oBrowser.isFirefox_1_0 || (oBrowser.isMozilla && !oBrowser.isFirefox))
			{
				//force window repaint to remove unwanted gaps
				document.body.style.height="100.1%";
				document.body.style.height="100%";
			}
		} else {
			this.hideContent(true);
		}
		positionFooter();
		this.collapsableLinkSelector.blur();
	},

	showContent: function(saveState) {
		if(this.collapsableSelector)
		{
			this.collapsableSelector.removeClassName(this.state_collapsed);
			this.collapsableSelector.addClassName(this.state_expanded);
			this.collapsableLinkSelector.removeClassName(this.state_collapsed);
			this.collapsableLinkSelector.addClassName(this.state_expanded);
			//this.collapsableLinkSelector.title = this.tooltip_expanded;
			if(saveState && window.location.href.indexOf('collaboration') != -1) {
				new Ajax.Request('/cttf?openFolder=true&folderId=' + this.collapsableSelector.id);
			}
		}
	},

	hideContent: function(saveState){
		if(this.collapsableSelector)
		{
			this.collapsableSelector.removeClassName(this.state_expanded);
			this.collapsableSelector.addClassName(this.state_collapsed);
			this.collapsableLinkSelector.removeClassName(this.state_expanded);
			this.collapsableLinkSelector.addClassName(this.state_collapsed);
			//this.collapsableLinkSelector.title = this.tooltip_collapsed;
			if(saveState && window.location.href.indexOf('collaboration') != -1) {
				new Ajax.Request('/cttf?openFolder=false&folderId=' + this.collapsableSelector.id);
			}
		}
	}
};

var CollapsableGroup = Class.create();
CollapsableGroup.prototype = {
	state_collapsed: 'collapsed',
	state_expanded: 'expanded',
	tooltip_collapsed: 'expand all',
	tooltip_expanded: 'collapse all',
	
	initialize: function(collapsableGroupSelector, collapsables) {
		if (!collapsableGroupSelector || !collapsables) return;
		this.collapsableGroupSelector = collapsableGroupSelector;
		this.groupedCollapsables = new Array();
		this.groupLinkSelector = null;
		this.groupLinkSelector = $(this.collapsableGroupSelector).previous('.toggle-all-icon').down();

		for(var i = 0; i < collapsables.length; i++)
		{
			if($(collapsables[i].collapsableLinkSelector).descendantOf($(this.collapsableGroupSelector)))
			{
				this.groupedCollapsables.push(collapsables[i]);
			}
		}

		if(this.groupLinkSelector && this.groupedCollapsables.length > 0)
		{
			Event.observe(this.groupLinkSelector, 'click', this.toggleAll.bindAsEventListener(this));
		}
	},

	toggleAll: function(e) {
		if(!this.groupLinkSelector) return;
		if(this.groupLinkSelector.hasClassName(this.state_collapsed))
		{
			this.showAll();
		} else {
			this.hideAll();
		}
		positionFooter();
		this.groupLinkSelector.blur();
	},

	showAll: function() {
		//open all collapsables in group
		for(var i = 0; i < this.groupedCollapsables.length; i++)
		{
			this.groupedCollapsables[i].showContent(false);
		}
		this.groupLinkSelector.removeClassName(this.state_collapsed);
		this.groupLinkSelector.addClassName(this.state_expanded);
	},

	hideAll: function(){
		//hide all collapsables in group
		for(var i = 0; i < this.groupedCollapsables.length; i++)
		{
			this.groupedCollapsables[i].hideContent(false);
		}
		this.groupLinkSelector.removeClassName(this.state_expanded);
		this.groupLinkSelector.addClassName(this.state_collapsed);
	}
};

var CollapsableElements = {
	initialize: function() {
		this.collapsablesSelectors = $$('dd.collapsable', 'ul.collapsable');
		if (!this.collapsablesSelectors) return;

		this.elements = new Array();

		var tempArray = [];
		this.collapsablesSelectors.each(function(element, index) {
			tempArray.push(new CollapsableElement(element));
		});
		this.elements= tempArray;
		
		this.groupSelectors = $$('div.toggle-all-group');
		if (!this.groupSelectors || !this.elements) return;
		
		this.groupSelectors.each(function(element, index) {
			new CollapsableGroup(element, tempArray);
		});
	}
};
/*END: Collapsables*/
/********************************************************************/
/********************************************************************/
/*START: Popups*/
function openWindow(location, width, height, name, toolbar, scrollbars, status, resizable, otherAttrib) {
	//openWindow object properties
	this.location=(location != null) ? location:'#';
	this.width=(width != null) ? width:'380';
	this.height=(height != null) ? height:'200';
	this.name=(name != null) ? name:'';
	this.toolbar=(toolbar != null) ? toolbar:'0';
	this.scrollbars=(scrollbars != null) ? scrollbars:'0';
	this.status=(status != null) ? status:'0';
	this.resizable=(resizable != null) ? resizable:'no';
	this.otherAttrib=(otherAttrib != null) ? otherAttrib:'';
	this.screenWidth=screen.width;
	this.screenHeight=screen.height;
	this.leftPos=(this.screenWidth/2)-(this.width/2);
	this.topPos=(this.screenHeight/2)-(this.height/2);

	//open method opens a window in the center of the screen
	this.open=function()
	{
		this.name = window.open(this.location, this.name, 'toolbar='+this.toolbar+',status='+this.status+',scrollbars='+this.scrollbars+',resizable='+this.resizable+','+this.otherAttrib+',left='+this.leftPos+',top='+this.topPos+',height='+this.height+',width='+this.width);
		this.name.focus();
	}
}

function sendThisPage(sUrl)
{
	this.sUrl = (sUrl) ? sUrl: SENDTHISPAGE_REFERENCE;
	var oWin = new openWindow(this.sUrl, 392, 260, 0, 0, 0, 0, 'yes');
	oWin.open();
}

function openDocuments(sUrl)
{
	this.sUrl = (sUrl);
	var oWin = new openWindow(this.sUrl, 681, 200, 0, 0, 0, 0, 'yes');
	oWin.open();
}
/*END: Popups*/
/********************************************************************/
/********************************************************************/
/*START: resize popup window*/
var PopUpWindow = {
	resizeWindow: function() {
		this.domSelector = $('popup-wrapper');
		if (!this.domSelector) return;
		
		this.isOnLoad = true;
		var x,y;
		if (self.innerHeight) // all except Explorer
		{
			x = self.innerWidth;
			y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		
		var h,w;
		var dimensions = this.domSelector.getDimensions();
		w = dimensions.width;
		h = dimensions.height;

		if(w > x || h > y)
		{
			if (self.outerHeight) // all except Explorer
			{
				var offsetW = w-x;
				var offsetH = h-y;
				var outerW = self.outerWidth+offsetW;
				var outerH = self.outerHeight+offsetH;
				window.resizeTo(outerW,outerH);
				if(oBrowser.isOpera) this.domSelector.style.overflow="hidden"; //remove unnecessary scrollbar
			}else{
				var offsetW = 16;
				var offsetH = 35;
				var outerW = w+offsetW;
				var outerH = h+offsetH;
				window.resizeTo(outerW, outerH);
	
				if (document.documentElement && document.documentElement.clientHeight)
					// Explorer 6 Strict Mode
				{
					x = document.documentElement.clientWidth;
					y = document.documentElement.clientHeight;
				}
				else if (document.body) // other Explorers
				{
					x = document.body.clientWidth;
					y = document.body.clientHeight;
				}
				offsetW = outerW-x;
				offsetH = outerH-y;
				
				window.resizeTo(w+offsetW, h+offsetH);
			}
		}
	},

	resizeContent: function() {
		this.domSelector = $('popup-zone');
		if (!this.domSelector) return;
		
		var x,y;
		if (self.innerHeight) // all except Explorer
		{
			x = self.innerWidth;
			y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		
		var h,w;
		var dimensions = this.domSelector.getDimensions();
		w = dimensions.width;
		h = dimensions.height;
		
		this.domSelector.style.width = x+"px"; 
		this.domSelector.style.height = y+"px";
		
		if(w > x || h > y) this.domSelector.style.overflow="auto"; //show scrollbar when needed
	}
};
/*END: resize popup window */
/********************************************************************/
/********************************************************************/
/*START: Safari Browser Detection and Serve Styles */
if (oBrowser.isSafari)
{
	document.write ("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + SAFARI_STYLESHEET_REFERENCE + "\" />");
}
/*END: Safari Browser Detection and Serve Styles */
/********************************************************************/
/********************************************************************/
/*START: Functions onload and onresize */
if (typeof addDOMLoadEvent != "undefined") {
	addDOMLoadEvent(NavigationTabBars.initialize.bind(NavigationTabBars));
	addDOMLoadEvent(handlePassword);
	addDOMLoadEvent(initLayout);
	addDOMLoadEvent(ToolsTabBars.initialize.bind(ToolsTabBars));
	addDOMLoadEvent(CollapsableElements.initialize.bind(CollapsableElements));
	addDOMLoadEvent(PopUpWindow.resizeWindow.bind(PopUpWindow));
	if(oBrowser.isIE) addDOMLoadEvent(fixIETableFirstChild);
} else {
	Event.observe(window, 'load', NavigationTabBars.initialize.bind(NavigationTabBars), false);
	Event.observe(window, 'load', handlePassword, false);
	Event.observe(window, 'load', initLayout, false);
	Event.observe(window, 'load', ToolsTabBars.initialize.bind(ToolsTabBars), false);
	Event.observe(window, 'load', CollapsableElements.initialize.bind(CollapsableElements), false);
	Event.observe(window, 'load', PopUpWindow.resizeWindow.bind(PopUpWindow), false);
	if(oBrowser.isIE) Event.observe(window, 'load', fixIETableFirstChild, false);
}

Event.observe(window, 'resize', PopUpWindow.resizeContent.bind(PopUpWindow), false);
Event.observe(window, 'resize', initLayout, false);
/*END: Functions onload and onresize */
/********************************************************************/
/********************************************************************/
/*START: SWFObject v1.5 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
/*END: SWFObject v1.5 */
/********************************************************************/
/*START: addDOMLoadEvent*/
function addDOMLoadEvent(f){if(!window.__ADLE){var n=function(){if(arguments.callee.d)return;arguments.callee.d=true;if(window.__ADLET){clearInterval(window.__ADLET);window.__ADLET=null}for(var i=0;i<window.__ADLE.length;i++){window.__ADLE[i]()}window.__ADLE=null};if(document.addEventListener)document.addEventListener("DOMContentLoaded",n,false);/*@cc_on @*//*@if (@_win32)var proto="src='javascript:void(0)'";if(location.protocol=="https:")proto="src=//:";document.write("<scr"+"ipt id=__ie_onload defer "+proto+"><\/scr"+"ipt>");var s=document.getElementById("__ie_onload");s.onreadystatechange=function(){if(this.readyState=="complete")n()};/*@end @*/if(/WebKit/i.test(navigator.userAgent)){window.__ADLET=setInterval(function(){if(/loaded|complete/.test(document.readyState)){n()}},10)}window.onload=n;window.__ADLE=[]}window.__ADLE.push(f)}
/*END: addDOMLoadEvent*/
/********************************************************************/