
document.write('<style type="text/css">#pc-links li.deck{display:none}</style>');

var initSite = {
	
	start: function() {
		if ($('promo-power-centre')) { initSite.powerCentre(); }
		initSite.siteFooter();
	},

	powerCentre: function() {
		pcSliders = $$('#pc-links li.deck');
		pcTogglers = $$('#pc-links img.toggle');
		sliders = [];
		pcTogglers.each(function(toggler, x) {
			pcSliders[x].setStyle('display','inline');
			sliders[x] = new Fx.Slide(pcSliders[x], {duration:100}).hide();
			$(pcTogglers[x]).addEvent('click', function() {
				sliders[x].toggle();
				if (pcTogglers[x].getProperty('alt') == 'Expand') {
					pcTogglers[x].setProperties({src:'/i/ads/powercentre-collapse.gif', alt:'Collapse'});
				} else {
					pcTogglers[x].setProperties({src:'/i/ads/powercentre-expand.gif', alt:'Expand'});
				}
			});
		});
	},

	siteFooter: function() {
		if($('page-scroll')){
			var scrollToTop = new Fx.Scroll(window, {duration:800});
			$('page-scroll').addEvent('click', function() {
				scrollToTop.toElement(document.body);
			});
		};
		var mySlider = new Fx.Slide('external-links',{duration:800}).hide();
		$('toggle-footer').addEvent('click', function() {
			if (!mySlider.isVisible()) {
				$('toggle-footer').setHTML('Hide links');
				var footerHeight = $('external-links').getStyle('height').toInt() + 30;
				$('footer').setStyle('height',footerHeight+'px');
				var scrollToBottom = new Fx.Scroll(window, {duration:400});
				scrollToBottom.toElement('footer');
				(function(){mySlider.toggle()}).delay(400);
			} else {
				$('toggle-footer').setHTML('Around ZDNet Australia');
				$('footer').setStyle('height','auto');
				mySlider.hide();
			}
		});
	}

};

//window.addEvent('domready', initSite.start);

/*-------------------------------------------------------------------
Replicate :hover pseudo class on any element for IE
------------------------------------------------------------------- */
function initStoryTools(){
	if ($('story-tools')) {
		suckerfish(sfHover, 'LI', 'story-tools');
	}
}

function suckerfish(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent('onload', function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}

var sfHover = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() { this.className+=' sfhover'; }
		sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(' sfhover\\b'), ''); }
	}
}




// ********* ********* ********//

// ***** THICKBOX FUNCTIONS ****//

// ********* ********* ********//



function TB_toggle() {

        if ($('TB_window').getStyle('display') == "none") {

            $('TB_window').setStyle('display','block');

            $('TB_overlay').setStyle('display','block');

        } else {

            $('TB_window').setStyle('display','none');

            $('TB_overlay').setStyle('display','none');

        }

}



function TB_overlaySize(){

    var yScroll = 0, xScroll = 0;

    if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {    

        yScroll = window.innerHeight + window.scrollMaxY;

        xScroll = window.innerWidth + window.scrollMaxX;

        var deff = document.documentElement;

        var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;

        var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;

        xScroll -= (window.innerWidth - wff);

        yScroll -= (window.innerHeight - hff);

    } else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){

        // all but Explorer Mac

        yScroll = document.body.scrollHeight;

        xScroll = document.body.scrollWidth;

    } else { 

        // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari

        yScroll = document.body.offsetHeight;

        xScroll = document.body.offsetWidth;

      }

    //alert("height: "+yScroll+", width: "+xScroll);

    $('TB_overlay').height=yScroll+'px';

    $('TB_overlay').width=xScroll+'px';

}



function TB_windowSize() {

    var myWidth = 0, myHeight = 0;

    if( typeof( window.innerWidth ) == 'number' ) {

        //Non-IE

        myWidth = window.innerWidth;

        myHeight = window.innerHeight;

    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {

        //IE 6+ in 'standards compliant mode'

        myWidth = document.documentElement.clientWidth;

        myHeight = document.documentElement.clientHeight;

    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {

        //IE 4 compatible

        myWidth = document.body.clientWidth;

        myHeight = document.body.clientHeight;

    }

    var arrayWindowSize = new Array(myWidth,myHeight) 

    return arrayWindowSize;

}



function lightBoxPopup(v,w,h,msg) {

    TB_overlaySize(); 

    var windowSize = TB_windowSize();

    $('TB_overlay').setStyle('display','block');

    $('TB_window').innerHTML='<div id="TB_title"><div id="TB_windowTitle">'+v+'</div><div id="TB_closeWindow"><a href="#" id="TB_closeWindowButton" title="Close" onclick="javascript:TB_toggle();">close</a></div></div><div class="TB_message"><p class="warning">'+msg+'</p></div>';

    //$('TB_window').left=Math.round((windowSize[0]-w)/2)+'px';

    //$('TB_window').top=Math.round((windowSize[1]-h)/2)+'px';

    var popupLeft = Math.round((windowSize[0]-w)/2);

    var popupTop = Math.round((windowSize[1]-h)/2);

    $('TB_window').setStyles({

       'left': popupLeft+'px',

       'top': popupTop+'px',

       'width': w+'px',

       'height': h+'px',

       'display': 'block'

    });

}





/*-------------------------------------------------------------------
Miscellaneous site functions
------------------------------------------------------------------- */


function visibilite(thingId) {
	var targetElement = document.getElementById(thingId) ;
	if (targetElement.style.display == "none") {
		targetElement.style.display = "" ;
	} else {
		targetElement.style.display = "none" ;
	}
}

function switchTabs(tabNum, parentId) {
	var tabs = document.getElementById(parentId.id).getElementsByTagName('li');
	var boxId = parentId.parentNode.id;
	for (var i = 0; i < tabs.length; i++) {
		var thisTab = tabs[i];
		if ((thisTab.id != '')) {
			document.getElementById(boxId+'-content'+i).style.display = 'none';
			if (i == tabNum) {
				if (i == 0) {
					thisTab.className = 'active first';
				} else {
					thisTab.className = 'active';
				}
				document.getElementById(boxId+'-content'+i).style.display = 'block';
			} else {
				thisTab.className = '';
			}
		}
	}
}

function snapshot(theObject){
	var snapshot_tab1 = document.getElementById('snapshot_tab1');
	var snapshot_1 = document.getElementById('snapshot_1');
	var snapshot_tab2 = document.getElementById('snapshot_tab2');
	var snapshot_2 = document.getElementById('snapshot_2');
	var snapshot_tab3 = document.getElementById('snapshot_tab3');
	var snapshot_3 = document.getElementById('snapshot_3');
	var snapshot_tab4 = document.getElementById('snapshot_tab4');
	var snapshot_4 = document.getElementById('snapshot_4');
	switch(theObject.id){
		case 'snapshot_tab1':
			snapshot_tab2.className = '';
			snapshot_tab3.className = '';
			snapshot_tab4.className = '';
			snapshot_1.style.display = 'block';
			snapshot_2.style.display = 'none';
			snapshot_3.style.display = 'none';
			snapshot_4.style.display = 'none';
			break;
		case 'snapshot_tab2':
			snapshot_tab1.className = '';
			snapshot_tab3.className = '';
			snapshot_tab4.className = '';
			snapshot_1.style.display = 'none';
			snapshot_2.style.display = 'block';
			snapshot_3.style.display = 'none';
			snapshot_4.style.display = 'none';
			break;
		case 'snapshot_tab3':
			snapshot_tab1.className = '';
			snapshot_tab2.className = '';
			snapshot_tab4.className = '';
			snapshot_1.style.display = 'none';
			snapshot_2.style.display = 'none';
			snapshot_3.style.display = 'block';
			snapshot_4.style.display = 'none';
			break;
		case 'snapshot_tab4':
			snapshot_tab1.className = '';
			snapshot_tab2.className = '';
			snapshot_tab3.className = '';
			snapshot_1.style.display = 'none';
			snapshot_2.style.display = 'none';
			snapshot_3.style.display = 'none';
			snapshot_4.style.display = 'block';
			break;
	}
	theObject.className = 'snapshot_selected'
}

function showBlogBio(bioToShow) {
	var el = $(bioToShow);
	if (el.getStyle('display') == 'none') {
		el.setStyle('display','block');
		$('expand-link').setHTML('[-] Hide bio');
	} else {
		el.setStyle('display','none');
		$('expand-link').setHTML('[+] Read bio');
	}
}

function videoThumbText(msg){
	var targetElement = document.getElementById('video-thumb-display') ;
	if(msg){
		targetElement.innerHTML = '<strong>'+msg+'</strong>';
	}else{
		targetElement.innerHTML = '<a href="/videos/">Watch more videos</a> on ZDNet Australia';
	}
}

/*-------------------------------------------------------------------
Carousel.js:
	by Aaron Newton, <aaron [dot] newton [at] cnet [dot] com>

For more documentation check out:
	http://clientside.cnet.com/cnet.gf/docs/files3/common/layout-widgets/carousel-js.html
	
Example carousel:
	new CNETcarousel('music-carousel', { buttonsSelector: '.nav-button', rotateAction: 'click', slideInterval: 4000 });
------------------------------------------------------------------- */
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('k s=f d({17:4(7,3){2.7=$(7);a(!2.7.1L(\'U\')){2.7.x(\'U\');2.9=[];2.8=[];2.M({H:d.g,D:d.g,16:d.g,13:d.g,14:".n",J:".u",15:1q,I:1i,R:0,w:"1j",A:"1k",z:"K",N:1H,p:1G},3);2.9=$(7).1b(2.3.14);2.8=$(7).1b(2.3.J);2.C();2.e(2.3.R);a(2.3.p)2.p();a(2.3.z!=\'K\')2.O(2.3.z);S 2}W S 1s},O:4(b){2.8.q(4(l,y){$(l).1u(b,4(){2.m.M(2.m.3,{Q:2.3.N});a(2.j!=y)2.e(y);2.18()}.1w(2))},2)},C:4(){2.m=f 1x.1y(2.9,{Q:2.3.I});2.9.q(4(n){n.t(\'B\',0)})},e:4(6){k b={};2.9.q(4(n,5){a(5==6&&5!=2.j){$(2.8[5]).X(2.3.A).x(2.3.w);b[5.11()]={\'B\':[1]}}W{$(2.8[5]).X(2.3.w).x(2.3.A);b[5.11()]={\'B\':[0]}}},2);2.h(\'13\',6);2.j=6;2.m.1E(b)},p:4(){2.C();2.12=2.E.1I(2.3.15,2);2.h(\'16\')},18:4(){1K(2.12);2.h(\'D\')},E:4(){v=2.j;T=(v+1>=2.9.1f)?0:v+1;2.e(T);2.h(\'H\')},1l:4(){$(2.3.o).t(\'L\',\'1m\');a(!$(2.3.o).1n())$(2.3.o).t(\'1r\',\'1t\')},1v:4(){$(2.3.o).t(\'L\',\'1A\')}});s.10(f 1B);s.10(f 1D);k 1F=s.1J({17:4(l,3){2.P(l,$1c({G:\'.1e\',V:\'F://i.i.r.r/1a.1d/i/Z/c/1g.Y\',19:\'F://i.i.r.r/1a.1d/i/Z/c/1z.Y\'},3))},e:4(6){2.8.q(4(u,5){$(u).1h(2.3.G).1o=(5==6)?2.3.V:2.3.19},2);2.P(6)}});k 1p=1C;',62,110,'||this|options|function|index|slideIndex|container|buttons|slides|if|action||Class|showSlide|new|empty|fireEvent||currentSlide|var|el|slideFx|slide|carouselContainer|autoplay|each|com|CNETcarousel|setStyle|button|current|buttonOnClass|addClass|idx|rotateAction|buttonOffClass|opacity|createFx|onStop|rotate|http|bubbleButtonBGImgSelector|onRotate|transitionDuration|buttonsSelector|none|visibility|setOptions|rotateActionDuration|setupAction|parent|duration|startIndex|return|next|hasCarousel|buttonOnGifSrc|else|removeClass|gif|fd|implement|toString|slideshowInt|onShowSlide|slidesSelector|slideInterval|onAutoPlay|initialize|stop|buttonOffGifSrc|cnwk|getElements|merge||bbg|length|green_button|getElement|500|selected|off|show|visible|isVisible|src|carousel|4000|display|false|block|addEvent|hide|bind|Fx|Elements|gray_button|hidden|Options|null|Events|start|CNETcarouselWithButtons|true|100|periodical|extend|clearInterval|hasClass'.split('|'),0,{}))

/*-------------------------------------------------------------------
SimpleSlide.js:
	Developed by Gravita, www.gravita.se

For more documentation check out:
	http://tobiaswallin.com/files/SlideShow/documentation.php
	
Example slider:
	new SimpleSlide("thumbnail-slides",{type: "scroll", goTo:2, duration:150});
------------------------------------------------------------------- */
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('a W=j L({X:8(5,7){4.5=5;4.7=7;6(4.7.n=="M"||4.7.n=="C"){a o;4.o=4.D.N(4.7.O,4,$(4.5))}b{4.D($(4.5))}},D:8(5){a f;6(4.7)f=4.7.f;b f="A";a 3;6(4.7.d){a d=4.7.d.K();d-=1}a 9=5.c().c()[0];9.r(8(e){6(e.i=="s"){3=e}});6(d||d==0){6(5.c()[0].c()[d])3=5.c()[0].c()[d];b P("Q "+d+" R S T")}b{6(!3){6(f=="A"){3=9[0].w()}b 6(f=="H"){3=5.c()[0].F()}}b{6(f=="A"){a t=5.c()[0].F();6(t==3.w()&&4.7.n=="C")$I(4.o);6(t==3)3=9[0];b 3=3.w()}b 6(f=="H"){a E=5.c()[0].V();6(E==3.J()&&4.7.n=="C")$I(4.o);6(E==3)3=5.c()[0].F();b 3=3.J()}}}6(3){6(4.7.G=="l")4.l(5,9,3);b 6(4.7.G=="h")4.h(5,9,3);b 6(4.7.G=="v")4.v(5,9,3)}},l:8(5,9,3){a l=j k.u(5,{g:4.7.g,m:8(){9.r(8(e){e.i=""});3.i="s"}}).x(3)},h:8(5,9,3){a h=j k.y(5,\'z\',{g:4.7.g,m:8(){j k.u(5,{g:1,m:8(){9.r(8(e){e.i=""});3.i="s";j k.y(5,\'z\').q(0.p,1)}}).x(3)}});h.q(1,0.p)},v:8(5,9,3){a B=4.7.g.K();a h=j k.y(5,\'z\',{g:(B/2)});h.q(1,0.p).U(8(){h.q(0.p,1)});j k.u(5,{g:B,m:8(){9.r(8(e){e.i=""});3.i="s"}}).x(3)}});',60,60,'|||child|this|container|if|options|function|children|var|else|getChildren|goTo||direction|duration|fade|id|new|Fx|scroll|onComplete|auto|automated|01|start|each|currentChild|lastElement|Scroll|scrollfade|getNext|toElement|Style|opacity|forward|durationInt|once|slider|firstElement|getLast|type|back|clear|getPrevious|toInt|Class|loop|periodical|time|alert|Slide|does|not|exist|chain|getFirst|SimpleSlide|initialize'.split('|'),0,{}))

/*-------------------------------------------------------------------
Plugin extensions
------------------------------------------------------------------- */
Fx.Slide.implement({
	isVisible: function() {
		return (this.wrapper.offsetHeight == 0 || this.wrapper.offsetWidth == 0) ? false: true;
	}
});