var fVersion=deconcept.SWFObjectUtil.getPlayerVersion();
var queryStr=String(window.location);
var useFlash=(fVersion['major']>=8) ? ((queryStr.indexOf('?noflash')>=0) ? false : true ) : false ;

var animTime=0.3;
var animTimeLong=0.7;
var isAnimating=false;
var cTabID;
function loadTab(tabID) {
	if (typeof(tabID)=='object') {tabID=$$('.tabGroup1')[0].id;}

	if (!isAnimating && (cTabID!=tabID)) {
		hidePopup(tabID+'_popup');
		isAnimating=true;
		$$('.flash').each(function(e){e.update('')});
		$$('.productSpecificRightrailJS').each(function(e){e.style.display='none';});
		$('rightrail').getElementsByClassName(tabID)[0].style.display='block';
		$$('#tabs .tabOn, #tabs .tabOff, #tabs .tabOffRO').each(function(e){
			$(e).removeClassName('tabOn').removeClassName('tabOff').removeClassName('tabOffRO').addClassName(($(tabID).identify()==$(e).identify()) ? 'tabOn' : 'tabOff' );
			if ($(tabID).identify()==$(e).identify()) {
				$($(e).identify()+'_body').style.display='none';
				new Effect.Opacity($($(e).identify()+'_body'),{
					delay: animTime,
					duration: animTime, 
					to: 1,
					beforeUpdate: function() {
						if ($(tabID+'_body').style.display!='block') {
							$(tabID+'_body').style.display='block';
						}
					},
					afterFinish: function() {
						doFlash(tabID);
						isAnimating=false;
						cTabID=tabID;
					}
				});
			} else {
				if (cTabID==$(e).identify()) {
					new Effect.Opacity($($(e).identify()+'_body'),{
						duration: animTime, 
						to: 0,
						afterFinish: function() {
							$($(e).identify()+'_body').style.display='none';
							if ($(tabID+'_body').style.display!='block') {
								$(tabID+'_body').style.display='block';
							}
						}
					});
				}
			}
		});
	}
	return false;
}

function doFlash(whichSwf) {
	var so = new SWFObject('/microsites/backup/swf/flash_'+whichSwf+'.swf', 'flash', '350', '240', '8', '#ffffff');
	var txtPieces=$(whichSwf+'_body').getElementsByClassName('noflash')[0].getElementsByClassName('passToFlash');
	var txtStr='<xml>';
	for (var txtPiece=0;txtPiece<txtPieces.length;txtPiece++) {
		txtPieceClasses=$w(txtPieces[txtPiece].className)
		for (var whichClass=0;whichClass<txtPieceClasses.length;whichClass++) {
			if (txtPieceClasses[whichClass]!='passToFlash') {
				txtStr+='<textlabel id="'+txtPieceClasses[whichClass]+'">'+txtPieces[txtPiece].innerHTML+'</textlabel>';
			}
		}
	}
	txtStr+='<textlabel id="replay">'+replayTextLabel+'</textlabel>';
	txtStr+='</xml>';
	txtStr=txtStr.split('"').join('[[DQ]]');
	so.addVariable('txtStr',txtStr);
	so.addParam('wmode','transparent');
	so.write($(whichSwf+'_body').getElementsByClassName('flash')[0]);
}

function loadTabFromLanding(whichTab) {
	if (!isAnimating && setupComplete) {
		isAnimating=true;
		whichTab=(whichTab==undefined) ? {} : whichTab ;
		$$('.flash').each(function(e){e.update('')});
		new Effect.Opacity($('wrapperSubhead'),{
			duration: animTime, 
			to: 0
		});
		new Effect.Opacity($('landingWrapper'),{
			duration: animTime, 
			to: 0,
			afterFinish: function() {
				$('landingWrapper').style.display='none';
				$('wrapperSubhead').style.display='none';
				$('tabs').style.display='block';
				$('tabs').setOpacity(0);
				$(whichTab+'_body').getElementsByClassName('flash')[0].update('');
				isAnimating=false;
				$$('.tabBody').each(function(e){
					e.style.display='none';
					e.setOpacity(0);
				});
				$('tabsWrapper').style.display='block';
				$(whichTab+'_body').style.display='block';
				cTabID=whichTab;
				$$('#tabs .tabOn, #tabs .tabOff, #tabs .tabOffRO').each(function(e){e.removeClassName('tabOn').removeClassName('tabOff').removeClassName('tabOffRO').addClassName(($(whichTab).identify()==e.identify()) ? 'tabOn' : 'tabOff' );});
				$$('.productSpecificRightrailJS').each(function(e){e.style.display='none';});
				$('rightrail').setOpacity(0);
				$('rightrail').getElementsByClassName(whichTab)[0].style.display='block';
			}
		});
		widthTweens=new Array();
		widthTweens.push(new Effect.Morph($('wrapper'),{
			style: {
				width: '782px',
				height: '561px'
			},
			sync:true
		}));
		$$('.corner').each(function(e) {
			widthTweens.push(new Effect.Morph(e,{
				style: {
					width: '782px',
					height: '561px'
				},
				sync:true
			}));
		});
		new Effect.Parallel(widthTweens,{duration:animTimeLong,delay:animTime});
		new Effect.Opacity($('rightrail'),{
			delay: animTime,
			duration: animTimeLong,
			to: 1
		});
		new Effect.Opacity($('tabs'),{
			delay: animTime+animTimeLong,
			duration: animTime,
			to: 1
		});
		new Effect.Opacity($(whichTab+'_body'),{
			delay: animTime+animTimeLong,
			duration: animTime, 
			to: 1,
			afterFinish: function() {
				isAnimating=false;
				doFlash(whichTab);
			}
		});
	}
	return false;
}

function goHome() {
	if (!isAnimating) {
		$$('.popup').each(function(e){hidePopup(e.id);});
		isAnimating=true;
		$$('.flash').each(function(e){e.update('');});
		new Effect.Opacity($(cTabID+'_body'),{
			duration: animTime, 
			to: 0,
			afterFinish: function() {
				$(cTabID+'_body').setOpacity(1);
				$('landingWrapper').style.display='block';
				$('landingWrapper').setOpacity(0);
				$('wrapperSubhead').style.display='block';
				$('wrapperSubhead').setOpacity(0);
				$('tabsWrapper').style.display='none';
			}
		});
		new Effect.Opacity($('tabs'),{
			duration: animTime,
			to: 0
		});
		widthTweens=new Array();
		widthTweens.push(new Effect.Morph($('wrapper'),{
			style: {
				width: '1000px',
				height: '561px'
			},
			sync:true
		}));
		$$('.corner').each(function(e) {
			widthTweens.push(new Effect.Morph(e,{
				style: {
					width: '1000px',
					height: '561px'
				},
				sync:true
			}));
		});
		new Effect.Parallel(widthTweens,{duration:animTimeLong,delay:animTime});
		new Effect.Opacity($('rightrail'),{
			delay: animTime,
			duration: animTimeLong,
			to: 0
		});
		new Effect.Opacity($('landingWrapper'),{
			delay: animTime+animTimeLong,
			duration: animTime, 
			from:0 ,to: 1,
			afterFinish: function() {
				isAnimating=false;
			}
		});
		new Effect.Opacity($('wrapperSubhead'),{
			delay: animTime+animTimeLong,
			duration: animTime, 
			from:0 ,to: 1
		});
	}
	return false;
}

var activePopup=null;
var mouseOverTolerance=0;
function showPopup(trigger,popup) {
	try {
		$(popup).setStyle({
			top: '-1000px',
			left: '-1000px',
			opacity: 0,
			paddingLeft: '0px',
			paddingBottom: '0px',
			display: 'none'
		});
		$(popup).getElementsByClassName('thetext')[0].update($(trigger.id+'_panel').getElementsByClassName('panelhead')[0].innerHTML.stripTags());
		var triggerPos=$(trigger).positionedOffset();
		var triggerDims=$(trigger).getDimensions();
		var popupDims=$(popup).getDimensions();
		$(popup).setStyle({
			top: (triggerPos.top-popupDims.height)+'px',
			left: (triggerPos.left+15)+'px',
			paddingBottom: '0px',
			display: 'block',
			cursor: 'pointer'
		});
		new Effect.Opacity($(popup),{
			delay: 0.1,
			from: 0,
			to: 1,
			duration: 0.1,
			fps: 30
		});
	} catch(e) {
	}
}
function hidePopup(popup) {
	try {
		$(popup).setStyle({
			top: '-1000px',
			left: '-1000px',
			opacity: 0,
			paddingLeft: '0px',
			paddingBottom: '0px',
			display: 'none'
		});
	} catch(e) {
	}
}

function tabsRover(which) {
	if (!$(which).hasClassName('tabOn')) {
		$(which).removeClassName('tabOff').addClassName('tabOffRO');
		showPopup(which,which.id+'_popup');
	}
}

function tabsRout(which) {
	if (!$(which).hasClassName('tabOn')) {
		$(which).removeClassName('tabOffRO').addClassName('tabOff');
		hidePopup(which.id+'_popup');
	}
}

function doSIFR() {
	if (useFlash && useSIFR && (typeof sIFR == "function")) {
		sIFR.bHideBrowserText = true;
		//sIFR.debug();
		sIFR.setup();
		sIFR.replaceElement("#wrapperHeadTextTop", named({sFlashSrc: "/_admin/swf/metamedium.swf", sColor: "#ffffff", sWmode:'transparent'}));
		sIFR.replaceElement("#wrapperHeadTextBottom", named({sFlashSrc: "/_admin/swf/metamedium.swf", sColor: "#ffffff", sWmode:'transparent'}));
	}
}

function killLoadScreen() {
	new Effect.Opacity($('loadscreen'),{
		to: 0,
		duration: 0.5,
		fps: 30,
		afterFinish: function() {
			$('loadscreen').remove();
		}
	});
}

var setupComplete=false;
function setup() {
	setupComplete=true;
	setTimeout(killLoadScreen, 500); // had to do this because of IE refusing to do scriptaculous when called in onload events
	$('wrapper').style.width='1000px';
	$('wrapper').style.height='561px';
	$$('.corner').each(function(e){e.style.height='561px';});
	$('rightrail').style.position='absolute';
	$('rightrail').style.top='0px';
	$('rightrail').style.left='792px';
	$('rightrail').style.zIndex=80;
	$('rightrail').setOpacity(0);
	$$('.tabBody').each(function(e){e.style.paddingBottom='0px';});
	$$('.productSpecificRightrail').each(function(e){
		$('rightrail').insert({ bottom: '<div class="'+$w(e.className)[0]+' productSpecificRightrailJS">'+e.innerHTML+'</div>' });
		e.remove();
	});
	$$('.productSpecificRightrailTop').each(function(e){e.remove();});
	$$('.productSpecificRightrailBottom').each(function(e){e.remove();});
	$('tabs').setOpacity(0);
	$$('.productSpecificRightrailJS').each(function(e){e.style.display='none';});
	if ($('js_hider').style.display=='none') {
		$$('.'+'tabGroup1').each(function(e){
			$($(e).identify()+'_body').style.display='none';
			$($(e).identify()+'_body').setOpacity(0);
		});
		$$('.'+'flash').each(function(e){$(e).style.display='none';});
		$$('.'+'noflash').each(function(e){$(e).style.display='none';});
		if (useFlash) {
			$$('.'+'flash').each(function(e){$(e).style.display='block';});
		} else {
			$$('.'+'noflash').each(function(e){$(e).style.display='block';});
		}
		$('js_hider').style.display='block';
		$('js_hider_rightrail').style.display='block';
	}
}
Event.observe(window, 'load', setup);

/* IE 6 ROLLOVER FIX, INCLUDES A COMPRESSED VERSION OF BEHAVIOUR */

/* Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work of Simon Willison http://ripcord.co.nz/behaviour/ */   
var Behaviour={list:new Array,register:function(_1){Behaviour.list.push(_1);},start:function(){Behaviour.addLoadEvent(function(){Behaviour.apply();});},apply:function(){for(h=0;sheet=Behaviour.list[h];h++){for(selector in sheet){list=document.getElementsBySelector(selector);if(!list){continue;}for(i=0;element=list[i];i++){sheet[selector](element);}}}},addLoadEvent:function(_2){var _3=window.onload;if(typeof window.onload!="function"){window.onload=_2;}else{window.onload=function(){_3();_2();};}}};Behaviour.start();function getAllChildren(e){return e.all?e.all:e.getElementsByTagName("*");};document.getElementsBySelector=function(_5){if(!document.getElementsByTagName){return new Array();}var _6=_5.split(" ");var _7=new Array(document);for(var i=0;i<_6.length;i++){token=_6[i].replace(/^\s+/,"").replace(/\s+$/,"");if(token.indexOf("#")>-1){var _9=token.split("#");var _a=_9[0];var id=_9[1];var _c=document.getElementById(id);if(_a&&_c.nodeName.toLowerCase()!=_a){return new Array();}_7=new Array(_c);continue;}if(token.indexOf(".")>-1){var _9=token.split(".");var _a=_9[0];var _d=_9[1];if(!_a){_a="*";}var _e=new Array;var _f=0;for(var h=0;h<_7.length;h++){var _11;if(_a=="*"){_11=getAllChildren(_7[h]);}else{_11=_7[h].getElementsByTagName(_a);}for(var j=0;j<_11.length;j++){_e[_f++]=_11[j];}}_7=new Array;var _13=0;for(var k=0;k<_e.length;k++){if(_e[k].className&&_e[k].className.match(new RegExp("(\\s+|^)"+_d+"(\\s+|$)"))){_7[_13++]=_e[k];}}continue;}if(token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)){var _a=RegExp.$1;var _15=RegExp.$2;var _16=RegExp.$3;var _17=RegExp.$4;if(!_a){_a="*";}var _e=new Array;var _f=0;for(var h=0;h<_7.length;h++){var _11;if(_a=="*"){_11=getAllChildren(_7[h]);}else{_11=_7[h].getElementsByTagName(_a);}for(var j=0;j<_11.length;j++){_e[_f++]=_11[j];}}_7=new Array;var _13=0;var _18;switch(_16){case "=":_18=function(e){return (e.getAttribute(_15)==_17);};break;case "~":_18=function(e){return (e.getAttribute(_15).match(new RegExp("(^|\\s+)"+_17+"(\\s+|$)")));};break;case "|":_18=function(e){return (e.getAttribute(_15).match(new RegExp("^"+_17+"-?")));};break;case "^":_18=function(e){return (e.getAttribute(_15).indexOf(_17)==0);};break;case "$":_18=function(e){return (e.getAttribute(_15).lastIndexOf(_17)==e.getAttribute(_15).length-_17.length);};break;case "*":_18=function(e){return (e.getAttribute(_15).indexOf(_17)>-1);};break;default:_18=function(e){return e.getAttribute(_15);};}_7=new Array;var _13=0;for(var k=0;k<_e.length;k++){if(_18(_e[k])){_7[_13++]=_e[k];}}continue;}if(!_7[0]){return;}_a=token;var _e=new Array;var _f=0;for(var h=0;h<_7.length;h++){var _11=_7[h].getElementsByTagName(_a);for(var j=0;j<_11.length;j++){_e[_f++]=_11[j];}}_7=_e;}return _7;};

Behaviour.register({
	'.panelWrapper a' : function(e) {
		e.onmouseover=function() {
			e.style.backgroundImage='url(/microsites/backup/images/panel_on.gif)';
		};
		e.onmouseout=function() {
			e.style.backgroundImage='url(/microsites/backup/images/panel_off.gif)';
		};
	}
});