var fVersion=deconcept.SWFObjectUtil.getPlayerVersion();
var queryStr=String(window.location);
var useFlash=(fVersion['major']>=8) ? ((queryStr.indexOf('?noflash')>=0) ? false : true ) : false ;

var isAnimating=true;
var setupComplete=false;
var cTab;
var oTab;
var config=new Object();
config['fps']=20;
config['introDelay']=0.3;
config['introDuration']=4;
config['animTime']=0.3;
config['animTimeLong']=0.7;
var so;

function doFlash(whichTarget,whichSwf,txtContent) {
	if (useFlash) {
		if (cTab=='page0') {
			so = new SWFObject(whichSwf, 'flash', 560,  345, '8', '#ffffff');
		} else {
			so = new SWFObject(whichSwf, 'flash', 360,  260, '8', '#ffffff');
		}
		so.addVariable('xmlTxtStr',txtContent);
		so.addParam('wmode','transparent');
		so.write(whichTarget);	
	}
}

function switchMainTab(which) {
	if (!isAnimating && (cTab!=which)) {
		
		//TRACKING
		//make tracking string
		tStr='';
		if ($(which.replace('page','tab')).select('div').length) {
			$(which.replace('page','tab')).select('div').each(function(e){
				if (e.innerHTML!='') {tStr+=e.innerHTML.stripTags()+' ';}
			});
		} else {
			$(which.replace('page','tab')).select('td').each(function(e){
				if (e.innerHTML!='') {tStr+=e.innerHTML.stripTags()+' ';}
			});
		}
		//do tracking
		var s=s_gi('emc-emccom');
		s.dynamicAccountSelection=true
		s.dynamicAccountList="emc-lithuania=lithuania.emc.com;emc-latvia=latvia.emc.com;emc-estonia=estonia.emc.com;emc-slovakia=slovakia.emc.com;emc-slovenia=slovenia.emc.com;emc-argentina=argentina.emc.com;emc-australia=australia.emc.com;emc-austria=austria.emc.com;emc-belgium=belgium.emc.com;emc-brazil=brazil.emc.com;emc-canada=canada.emc.com;emc-chile=chile.emc.com;emc-china=china.emc.com;emc-colombia=colombia.emc.com;emc-czech=czech.emc.com;emc-denmark=denmark.emc.com;emc-venezuela=venezuela.emc.com;emc-finland=finland.emc.com;emc-france=france.emc.com;emc-germany=germany.emc.com;emc-greece=greece.emc.com;emc-hk=hk.emc.com;emc-hungary=hungary.emc.com;emc-india=india.emc.com;emc-israel=israel.emc.com;emc-italy=italy.emc.com;emc-japan=japan.emc.com;emc-korea=korea.emc.com;emc-mexico=mexico.emc.com;emc-middleeast=middle-east.emc.com;emc-netherlands=netherlands.emc.com;emc-norway=norway.emc.com;emc-peru=peru.emc.com;emc-poland=poland.emc.com;emc-portugal=portugal.emc.com;emc-puertorico=puertorico.emc.com;emc-russia=russia.emc.com;emc-singapore=singapore.emc.com;emc-singapore=southasia.emc.com;emc-southafrica=southafrica.emc.com;emc-spain=spain.emc.com;emc-suisse=suisse.emc.com;emc-sweden=sweden.emc.com;emc-switzerland=switzerland.emc.com;emc-taiwan=taiwan.emc.com;emc-turkey=turkey.emc.com;emc-uk=uk.emc.com;emc-indonesia=indonesia.emc.com;emc-thailand=thailand.emc.com;emc-malaysia=malaysia.emc.com;emc-philippines=philippines.emc.com;emc-dev2008=.isus.emc.com;emc-emccom=."
		s.tl(true,'o',window.s.pageName+': '+tStr);
		//END TRACKING

		isAnimating=true;
		oTab=cTab;
		cTab=which;
		//clear old flash for IE
		if (useFlash) {
			$(cTab).select('.pageFlash')[0].update('');
		}
		
		$$('.tab').each(function(e){
			$(e).style.backgroundPosition='0px '+$(e).readAttribute('originalBgPosY');
			$(e).style.color='#ffffff';
		});
		$$('.buttonSmall').each(function(e){
			$(e).select('.smallButtonLeft')[0].style.backgroundPosition='0px 0px';
			$(e).select('.smallButtonCenter')[0].style.backgroundPosition='0px -50px';
			$(e).select('.smallButtonRight')[0].style.backgroundPosition='-14px 0px';
		});
		switch (cTab) {
			case 'page0':
			case 'page5':
				$(cTab.replace('page','tab')).select('.smallButtonLeft')[0].style.backgroundPosition='0px -25px';
				$(cTab.replace('page','tab')).select('.smallButtonCenter')[0].style.backgroundPosition='0px -75px';
				$(cTab.replace('page','tab')).select('.smallButtonRight')[0].style.backgroundPosition='-14px -25px';
				break;
			default :
				$(cTab.replace('page','tab')).style.backgroundPosition='-156px '+$(cTab.replace('page','tab')).readAttribute('originalBgPosY');
				$(cTab.replace('page','tab')).style.color='#1a429f';
			break;
		}
		
		if (cTab=='page0') {
			new Effect.Opacity('tab0',{
				framerate: config['fps'],
				duration: config['animTime'],
				to: 0,
				afterFinish: function() {
					$('tab0').setOpacity(1).style.visibility='hidden';
				}
			});
		} else if (oTab=='page0') {
			setTimeout(function(){
				$('tab0').setOpacity(0).style.visibility='visible';
				new Effect.Opacity('tab0',{
					framerate: config['fps'],
					duration: config['animTime'],
					from: 0,
					to: 1
				});
			},config['animTime']*1000);
		}

		$$('.pagesForAnims').each(function(e){
			if (cTab!=e.id) {
				new Effect.Opacity(e,{
					framerate: config['fps'],
					duration: config['animTime'],
					to: 0
				});
			}
		});
		setTimeout(function(){
			$$('.pagesForAnims').each(function(e){
				$(e).style.display='none';
			});
			$(cTab).style.display='block';
			if (cTab=='page0') { //resize page to match content (wouldn't have to do this if it weren't for that meddling IE6!)
				$('bgTabs').style.height='349px'; 
			} else {
				$('bgTabs').style.height=$(cTab).getHeight()+'px';
			}
			if (parseInt($('bgTabs').style.height)<349) {
				$('bgTabs').style.height='349px';
			}
		},config['animTime']*1000);
		new Effect.Opacity(cTab,{
			delay: config['animTime'],
			framerate: config['fps'],
			duration: config['animTime'],
			to: 1,
			afterFinish: function() {
				isAnimating=false;
				doFlash($$('#'+cTab+' .pageFlash')[0],$$('#'+cTab+' .pageFlash')[0].readAttribute('flashurl'),$$('#'+cTab+' .pageFlash')[0].readAttribute('flashxmltxt'));
			}
		});
	}
}

var origColorTop;
var origColorBot;
function doIntro() {
	
	$$('#page0 .pageFlash')[0].style.visibility='visible';
	
	cumulativeDelay=0;
	
	if (useFlash) {
		doFlash($$('#'+cTab+' .pageFlash')[0],$$('#'+cTab+' .pageFlash')[0].readAttribute('flashurl'),$$('#'+cTab+' .pageFlash')[0].readAttribute('flashxmltxt'));
		cumulativeDelay+=config['introDuration'];
	} else {
		cumulativeDelay+=config['introDelay'];
	}

	//title in
	new Effect.Morph($$('#page0 .titleText .topLine')[0],{
		delay: cumulativeDelay,
		framerate: config['fps'],
		duration: config['animTime'],
		style: {color: origColorTop}
	});
	new Effect.Morph($$('#page0 .titleText .bottomLine')[0],{
		delay: cumulativeDelay,
		framerate: config['fps'],
		duration: config['animTime'],
		style: {color: origColorBot}
	});
	cumulativeDelay+=config['animTime'];

	//animate interface in
	$$('.tab').each(function(e){
		new Effect.Opacity($(e),{
			delay: cumulativeDelay,
			framerate: config['fps'],
			duration: config['animTime'],
			to: 1
		});
		cumulativeDelay+=config['animTime'];
	});

	//final setup and interaction enabler
	setTimeout(function() {
		
		isAnimating=false;
		
	},cumulativeDelay);
}

function setup() {
	cTab='page0';
	origColorTop=$$('#page0 .titleText .topLine')[0].getStyle('color');
	origColorBot=$$('#page0 .titleText .bottomLine')[0].getStyle('color');
	$$('#page0 .titleText .topLine')[0].style.color='#ffffff';
	$$('#page0 .titleText .bottomLine')[0].style.color='#ffffff';
	$$('#'+cTab+' .titleText')[0].style.display='block';
	$(cTab).style.display='block';
	$('bgTabs').style.height='329px';
	ie6fixcount=0;
	$$('.tab').each(function(e){
		//this is done in a bad way to fix IE6, original code left in below but commented out for sanity
		obp=ie6fixcount*80*-1;
		ie6fixcount++;
		$(e).writeAttribute('originalBgPosY',obp+'px');
		//  obp=$(e).getStyle('backgroundPosition');
		//  obp=obp.split(' ');
		//  $(e).writeAttribute('originalBgPosY',obp[1]);
		$(e).setOpacity(0);
		$(e).style.visibility='visible';
	});
	$$('#pageBody .pagesForAnims').each(function(e){
		if (cTab!=e.id) {
			$(e).setOpacity(0);
			$(e).style.display='none';
		}
	});
	$('bgTabs').style.height=$(cTab).getHeight()+'px';

	$(cTab.replace('page','tab')).select('.smallButtonLeft')[0].style.backgroundPosition='0px -25px';
	$(cTab.replace('page','tab')).select('.smallButtonCenter')[0].style.backgroundPosition='0px -75px';
	$(cTab.replace('page','tab')).select('.smallButtonRight')[0].style.backgroundPosition='-14px -25px';
	
	setupComplete=true;

	setTimeout(doIntro, 500); // had to do this because of IE refusing to do scriptaculous when called in onload events
}
Event.observe(window, 'load', setup);

/* 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;};

var clickedThumb='';

Behaviour.register({
	'.pageFlash' : function (e) { //set up flash URLs and text
		if (useFlash) {
			txtStr='<xml>';
			$(e).select('div').each(function(e2){
				txtPieceClasses=$w(e2.className).each(function(e3){
					txtStr+='<textlabel id="'+e3+'">'+e2.innerHTML+'</textlabel>';
				});
			});
			txtStr+='<textlabel id="replay">'+replayTextLabel+'</textlabel>';
			txtStr+='</xml>';
			// double quote compatibility, this f/r will be reversed in flash
			changeArray=new Array();
			processedText=txtStr.split('"').join('[[DQ]]').split('<br>').join('[[BR]]').split('<br/>').join('[[BR]]').split('<BR>').join('[[BR]]').split('<BR/>').join('[[BR]]').split('<b>').join('[[B]]').split('</b>').join('[[/B]]').split('<B>').join('[[B]]').split('</B>').join('[[/B]]').split('<i>').join('[[I]]').split('</i>').join('[[/I]]').split('<I>').join('[[I]]').split('</I>').join('[[/I]]');
			txtStr=processedText; 
			$(e).writeAttribute('flashxmltxt',txtStr);
			$(e).writeAttribute('flashurl',$(e).select('img')[0].src.split('-noflash').join('').split('.gif').join('.swf').split('.jpg').join('.swf').split('.png').join('.swf'));
		} else {
			$(e).select('img')[0].style.visibility='visible';
		}
	},
	'a.tab' : function(e) { // main tabs
		e.onmouseover=function() {
			if (!isAnimating) {
				e.style.backgroundPosition='-156px '+$(e).readAttribute('originalBgPosY');
				e.style.color='#1a429f';
			}
		};
		e.onmouseout=function() {
			if (cTab!=e.id.replace('tab','page')) {
				e.style.backgroundPosition='0px '+$(e).readAttribute('originalBgPosY');
				e.style.color='#ffffff';
			}
		};
		e.onclick=function() {
			if (!isAnimating) {
				e.style.backgroundPosition='-156px '+$(e).readAttribute('originalBgPosY');
				e.style.color='#1a429f';
				switchMainTab(e.id.replace('tab','page'));
				return false;
			}
		};
	},
	'a.buttonSmall' : function (e) {
		e.onmouseover=function() {
			if (!isAnimating) {
				$(e).select('.smallButtonLeft')[0].style.backgroundPosition='0px -25px';
				$(e).select('.smallButtonCenter')[0].style.backgroundPosition='0px -75px';
				$(e).select('.smallButtonRight')[0].style.backgroundPosition='-14px -25px';
			}
		};
		e.onmouseout=function() {
			if (cTab!=e.id.replace('tab','page')) {
				$(e).select('.smallButtonLeft')[0].style.backgroundPosition='0px 0px';
				$(e).select('.smallButtonCenter')[0].style.backgroundPosition='0px -50px';
				$(e).select('.smallButtonRight')[0].style.backgroundPosition='-14px 0px';
			}
		};
		e.onclick=function() {
			if (!isAnimating) {
				$(e).select('.smallButtonLeft')[0].style.backgroundPosition='0px -25px';
				$(e).select('.smallButtonCenter')[0].style.backgroundPosition='0px -75px';
				$(e).select('.smallButtonRight')[0].style.backgroundPosition='-14px -25px';
				switchMainTab(e.id.replace('tab','page'));
				return false;
			}
		};
	}});