

/////////// FEATURE ROTATOR /////////////

fadeStepInt = 20;
selectedFeature = 0;
function showFeature(f,userInput) {	
	// fade out selected feature
	fadeOut('featureDetails'+selectedFeature,'fadeInRequestedFeature();');
	if (f == 4) f = 0;
	if (userInput) clearInterval(featureRotator);
	selectedFeature = f;
	scroll2TargetTo(document.getElementById('hp_featureThumbPointer'),((f*101)+44),50,1);
}
function fadeInRequestedFeature() {
	for (i=0;i<4;i++) {
		document.getElementById('featureBtn'+i).className = (selectedFeature==i) ? 'selected' : '';
		document.getElementById('featureDetails'+i).className = (selectedFeature==i) ? 'selected' : '';
	}
	fadeIn('featureDetails'+selectedFeature);
}
function nextFeature(userInput) {
	showFeature((selectedFeature+1),userInput);
}
featureRotator = setInterval("nextFeature();",12000);



function scroll2TargetTo(el,leftTarget,step,smooth) {
	if (smooth) {
		// go 10% of the way
		smoothStep = Math.ceil(0.3*(leftTarget - parseInt(el.style.left)));
		if (!smoothStep && (leftTarget - parseInt(el.style.left))) smoothStep = -1;
		// limit speed to step
		if (Math.abs(smoothStep) > Math.abs(step)) smoothStep = (smoothStep > 0) ? step : -1*step;
		el.style.left = (parseInt(el.style.left)+parseInt(smoothStep))+'px';
	} else {
		el.style.left = (parseInt(el.style.left)+parseInt(step))+'px';
	}
	if (Math.abs(leftTarget - parseInt(el.style.left)) < 1) {
		el.style.left = leftTarget + 'px';
		return true;
	}
	setTimeout("scroll2TargetTo(document.getElementById('"+el.getAttribute('id')+"'),'"+leftTarget+"','"+step+"','"+smooth+"')",20);
}



/////////// ACTION TABS /////////////

function hp_showTab(tabId) {
	for(i=1;i<=2;i++) {
		document.getElementById('tabContent'+i).style.display = (i==tabId) ? 'block' : 'none';
		document.getElementById('tab'+i+'Selected').style.display = (i==tabId) ? 'inline' : 'none';
		document.getElementById('tab'+i+'NotSelected').style.display = (i==tabId) ? 'none' : 'inline';
	}
}







////////// DONATION TAB ////////////

function checkRadio(r) {
	document.getElementById('otherOption').style.display = (r==3) ? 'block' : 'none';
	document.getElementById('otherLabel').style.display = (r==3) ? 'none' : 'inline';
	if (r==3) setTimeout("document.frontlinerForm.otherValue.select();",10);
}

function postFrontlinerForm() {
	mvValue = 0;
	for (i=0;i<document.frontlinerForm.monthlyValue.length;i++) {
		if (document.frontlinerForm.monthlyValue[i].checked) {
			mvValue = document.frontlinerForm.monthlyValue[i].value;
			break;
		}
	}
	if (mvValue=='Other') mvValue = Math.ceil(document.frontlinerForm.otherValue.value);
	if (!mvValue) mvValue = '';
	window.location = "/support/monthly_giving.php?donation_value="+mvValue;
}



/////////////// VIDEOS ////////////////

function hp_showVid(idname,btnId,vidTitle) {
	ovn = document.getElementById('hp_vidTitle').innerHTML;
	for(i=0;i<6;i++) {
		document.getElementById('vidBtn'+i).className = (i==btnId) ? 'selected' : '';
		document.getElementById('hp_vidFrame').src = 'about:blank';
		document.getElementById('hp_vidMoreInfoLink').href = "/media/videos.php?vid="+idname;
		vidShareUrl = "http://www.AnimalsAustralia.org/media/videos.php?vid="+idname;
		vidShareTitle = vidTitle;
		setTimeout("document.getElementById('hp_vidFrame').src = 'http://www.animalsaustralia.org/swf/video.swf?v="+idname+"'",10);
	}
}





