
function switchHomeVisual(which, img_no) {
	which = $(which);
	var switchButtons = which.up('ul').select('li');
	var imgCnt = switchButtons.length;
	
	switchButtons.each(function(swButton){
		swButton.removeClassName('selected');
		swButton.down('a').removeClassName('selected');
	});
	$('te-marquee-btn-'+img_no).addClassName('selected');
	$('te-marquee-btn-'+img_no).up('li').addClassName('selected');
	
	for (var i=1;i<=imgCnt;i++) {
		$('te-marquee-img-'+i).hide();
	}
	$('te-marquee-img-'+img_no).show();
		
}

function prevHPFeature() {
	var currFeature = parseInt($('hp_feature_cnt').innerHTML, 10);
	currFeature--;
	
	if (currFeature < 1) {
		currFeature = homeFeatureCnt;
	}
	updateHPFeature(currFeature);
}

function nextHPFeature() {
	var currFeature = parseInt($('hp_feature_cnt').innerHTML, 10);
	currFeature++;
	if (currFeature > homeFeatureCnt) {
		currFeature = 1;
	}
	updateHPFeature(currFeature);
}

function updateHPFeature(featureIdx) {
	$('hp_feature_cnt').update(featureIdx);

	var currData = featureData[featureIdx-1];
	
	$('hp_feature_lnk1').href = currData.linkurl;
	$('hp_feature_lnk1').target = currData.linktarget;
	$('hp_feature_lnk2').href = currData.linkurl;
	$('hp_feature_lnk2').target = currData.linktarget;
	$('hp_feature_lnk3').href = currData.linkurl;
	$('hp_feature_lnk3').target = currData.linktarget;
	$('hp_feature_pic').src = currData.picture;
	$('hp_feature_headline').update( currData.headline );
	$('hp_feature_lnk2').update( currData.product );
}

function closeOverlay(which) {
	which = $(which);
	which.hide();
}

var overlayTimeouts = new Array();

function showOverlay(which) {
	which = $(which);
	if (overlayTimeouts[which.id]) {
		window.clearTimeout(overlayTimeouts[which.id]);
		overlayTimeouts[which.id] = null;
	}
	for(i=1;i<=overlayCount;i++) {
		if ($('overlay_'+i)) $('overlay_'+i).hide();
	}
	which.show();
}

function delayHideOverlay(which) {
	which = $(which);
	overlayTimeouts[which.id] =	window.setTimeout(function(){
		which.hide();
	}, 1000);
}

function closeDialog(which) {
	which = $(which);
	which.up('.dijitDialog').hide();
	$('_underlay').hide();
	if (Prototype.Browser.IE && (navigator.appVersion.indexOf('MSIE 6')!=-1) ) {
		$(document.body).setStyle({overflow:''});
	}
}

function showCountryChooser() {
	if (Prototype.Browser.IE && (navigator.appVersion.indexOf('MSIE 6')!=-1) ) {
		$('_underlay').setStyle({height:$('te-page').getHeight()+'px'});
		$(document.body).setStyle({overflow:'hidden'});
	}
	$('_underlay').show();
	
	var leftStyle = (document.viewport.getWidth() / 2 ) - 175;
	$('countryChooser').setStyle({left:leftStyle+'px'});
	$('countryChooser').show();
}
