



function embedVideo(v) {
	alert(v);
}


function showVid(v,thumbId) {
	vids = v.split(',');
	v1 = vids[0];
	document.getElementById('vidOption1').href = "http://www.animalsaustralia-media.org/videos/"+v1+".zip";
	document.getElementById('vidOption2').href = "javascript:embedVideo('"+v+"');void(0);";
	document.getElementById('vidThumb1').className = (thumbId==1) ? "selected" : "";
	document.getElementById('vidThumb2').className = (thumbId==2) ? "selected" : "";
}

function embedVideo(v) {
	window.open("embed.php?v="+v,'aaEmbedWin','width=300,height=180');
}

function previewF2fEmail() {
	window.open("preview.php?firstname="+document.merch_form.firstName.value,'aaPreviewWin','width=750,height=500,scrollbars=yes');
}

fadeStepInt = 25;
selectedFact = 1;
function showFact(f,userInput) {
	// fade out selected fact
	fadeOut('fact'+selectedFact,'fadeInRequestedFact();');
	if (f > 6) f = 1;
	if (userInput) clearInterval(factRotator);
	selectedFact = f;
}
function fadeInRequestedFact() {
	for (i=1;i<=6;i++) {
		document.getElementById('fact'+i).className = (selectedFact==i) ? 'selected' : '';
		document.getElementById('factBtn'+i).className = (selectedFact==i) ? 'selected' : '';
	}
	fadeIn('fact'+selectedFact);
}
function nextFact(userInput) {
	showFact((selectedFact+1),userInput);
}
factRotator = setInterval("nextFact();",8000);


function checkRadio(r) {
	document.getElementById('otherOption').style.display = (r==3) ? 'block' : 'none';
	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.open("http://www.animalsaustralia.org/support/monthly_giving.php?donation_value="+mvValue,'aaDonorWin');
}






///////////// PRELOAD IMAGES ////////////////

preloadArray = new Array();
function addPreload(imgSrc) { preloadArray[preloadArray.length] = imgSrc; }
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		for (i=0; i<preloadArray.length; i++) eval("preloadImage"+i+" = newImage('"+preloadArray[i]+"');");
		preloadFlag = true;
	}
}
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}



// image swap function
// swaps src on mouseover for images using the "imageSwap" CSS class
function initImageSwap() {
	imgs = document.getElementsByTagName('IMG');
	for(i=0;i<imgs.length;i++) {
		el = imgs[i];
		if (el.className=='imageSwap') {
			el.ext = el.src.substr(el.src.length-3,3);
			addPreload(el.src.replace('1.'+el.ext,'2.'+el.ext));
			addPreload(el.src);
			if (targetId = el.getAttribute('swapTarget')) {
				// attach events to target element instead of this image
				if (!el.id) el.id = "swapTargetSrc"+Math.random();
				targetEl = document.getElementById(targetId);
				targetEl.setAttribute('swapTargetSrc',el.id);
				// is the target a form?
				targetIsForm = false;
				for(f=0;f<document.forms.length;f++) {
					if (document.forms[f]==targetEl) {
						targetIsForm = true;
						break;
					}
				}
				if (targetIsForm) {
					targetEl.onfocus = function() {
						srcImg = document.getElementById(this.getAttribute('swapTargetSrc'));
						// force animated GIFs to reload in IE
						r = (srcImg.getAttribute("swapAni") && document.all) ? "?r="+Math.random() : '';
						if (srcImg.src.indexOf('2.'+srcImg.ext)==-1) srcImg.src = srcImg.src.replace('1.'+srcImg.ext,'2.'+srcImg.ext);
						this.mactive = true;
					}
					targetEl.onblur = function() {
						// force animated GIFs to reload in IE
						r = (srcImg.getAttribute("swapAni") && document.all) ? "?r="+Math.random() : '';
						setTimeout("if (!document.getElementById('"+this.id+"').mactive) { srcImg = document.getElementById(document.getElementById('"+this.id+"').getAttribute('swapTargetSrc')); if (srcImg.src.indexOf('1.'+srcImg.ext)==-1) srcImg.src = srcImg.src.replace('2.'+srcImg.ext,'1.'+srcImg.ext)+r; }" ,250);
						this.mactive = false;
					}
				} else {
					targetEl.onmouseover = function() {
						// force animated GIFs to reload in IE
						srcImg = document.getElementById(this.getAttribute('swapTargetSrc'));
						r = (srcImg.getAttribute("swapAni") && document.all) ? "?r="+Math.random() : '';
						if (srcImg.src.indexOf('2.'+srcImg.ext)==-1) srcImg.src = srcImg.src.replace('1.'+srcImg.ext,'2.'+srcImg.ext) + r;
						this.mactive = true;
					}
					targetEl.onmouseout = function() {
						// force animated GIFs to reload in IE
						r = (srcImg.getAttribute("swapAni") && document.all) ? "?r="+Math.random() : '';
						setTimeout("if (!document.getElementById('"+this.id+"').mactive) { srcImg = document.getElementById(document.getElementById('"+this.id+"').getAttribute('swapTargetSrc')); if (srcImg.src.indexOf('1.'+srcImg.ext)==-1) srcImg.src = srcImg.src.replace('2.'+srcImg.ext,'1.'+srcImg.ext)+r; }" ,250);
						this.mactive = false;
					}
				}
			} else {
				el.onmouseover = el.onmouseup = function() {
					// force animated GIFs to reload in IE
					r = (this.getAttribute("swapAni") && document.all) ? "?r="+Math.random() : '';
					this.src = this.src.replace('1.'+this.ext,'2.'+this.ext)+r;
				}
				el.onmouseout = el.onmousedown = function() {
					// force animated GIFs to reload in IE
					r = (this.getAttribute("swapAni") && document.all) ? "?r="+Math.random() : '';
					this.src = this.src.replace('2.'+this.ext,'1.'+this.ext)+r;
				}
			}
		}
	}
}

//////////////// ONLOAD SEQUENCE //////////////


loadMeUp += "setHoverButtonMouseoverEffect();";

pageLoaded = false;
onload = function() {
	pageLoaded = true;
	initImageSwap();
	preloadImages();
}