// JavaScript Document

var Browser = {
  Version: function() {
    var version = 999; // we assume a sane browser
    if (navigator.appVersion.indexOf("MSIE") != -1)
      // bah, IE again, lets downgrade version number
      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    return version;
  }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var hideOpacity = 0;
var hideAnimation = null;
var offset = 0;

function hide(func){

	//window.scroll(0,0);
	
	var div = document.getElementById('hider');
	div.style.filter = 'alpha(opacity=0)';
	div.style.MozOpacity=0;
	div.style.opacity=0;
	div.style.display = "block";
	
	offset = window.pageYOffset;
	
	//div.style.height = (document.height+document.body.scrollHeight-150)+'px';
	
	//var body = document.getElementsByTagName('body');
	//body[0].style.overflow = "hidden";
	
	if(hideAnimation)
		clearInterval(hideAnimation);
	hideAnimation = setInterval(function(){fadeHider(1,func)},1);	

}

function fadeHider(dir,func){

	if(!dir)
		dir = 1;

	hideOpacity += dir*5;

	var div = document.getElementById('hider');
	div.style.filter = 'alpha(opacity=' + hideOpacity + ')';
	div.style.MozOpacity=hideOpacity/100;
	div.style.opacity=hideOpacity/100;
	
	if(hideOpacity >= 80){
	
		clearInterval(hideAnimation);
		if(func)
			func();
	
	} else if(hideOpacity <= 0){
		
		
		clearInterval(hideAnimation);
		div.style.display = "none";
		if(func)
			func();
	}

}

function signUp(){

	document.getElementById('flash').style.display = "none";
	hide(signUpNow);

}

function signUpNow(){

	// show sign up form
	var form = document.getElementById('signUpDiv');
	
	form.style.display = "block";
	
	var body = document.getElementsByTagName('body');
	
	form.style.left = ((body[0].offsetWidth-form.offsetWidth)/2)+'px';
	form.style.top = '200px';

}

function rescroll(){
	
	//var body = document.getElementsByTagName('body');
	//body[0].style.overflow = "";
	
	//window.scroll(0,offset);
	
}

function closeSignUp(){
	
	var form = document.getElementById('signUpDiv');
	form.style.display = "none";
	
	if(hideAnimation)
		clearInterval(hideAnimation);
	hideAnimation = setInterval(function(){document.getElementById('flash').style.display = "";fadeHider(-1,rescroll)},1);	
	
}

function donateNow(){

	var amt = 0;
	
	for(var i=1;i<=7;i++){
	
		if(document.getElementById('amount'+i) && document.getElementById('amount'+i).checked)
			amt = document.getElementById('amount'+i).value;
	
	}
	
	if(document.getElementById('amount8').checked){
		
		amt = document.getElementById('amt').value;
	
	}
	
	document.getElementById('amount').value = amt;
	
	document.getElementById('donationFrm').submit();

}

function checkDonate(){

	var amt = document.getElementById('amount').value;
	
	switch(amt){
	
		case "5,000.00":
		
			document.getElementById('amount1').checked = true;
		
		break;
		case "2,500.00":
		
			document.getElementById('amount2').checked = true;
		
		break;
		case "500.00":
		
			document.getElementById('amount3').checked = true;
		
		break;
		case "250.00":
		
			document.getElementById('amount4').checked = true;
		
		break;
		case "100.00":
		
			document.getElementById('amount5').checked = true;
		
		break;
		case "50.00":
		
			document.getElementById('amount6').checked = true;
		
		break;
		case "25.00":
		
			document.getElementById('amount7').checked = true;
		
		break;
		default:
		
			document.getElementById('amount8').checked = true;
			document.getElementById('amt').value = amt;
		
		break;
	
	}

}

function clearDonate(){

	document.getElementById('amt').value = '';

}

function donateForm(){

	document.getElementById('donationFrm').action = "https://www.paypal.com/cgi-bin/webscr";
	document.getElementById('donationFrm').submit();

}