var bStopRotating = false;
function StopRotation() {
	bStopRotating = true;   
}
function StartRotation() {
	bStopRotating = false;   
}
function ShowSpirituality() {
	if (!bStopRotating) {
		document.getElementById("FrontPageRotate").src="images/FrontPageSpirituality.png";
		document.getElementById("FrontPageRotateClick").src="images/FrontPageSpiritualityClick.png";
		document.getElementById("FrontPageClickPage").href="Stories.php?name=blancharts";
		setTimeout("ShowCommitments()",5000);
	} else {
		setTimeout("ShowSpirituality()",1000);
	}   
}
function ShowCommitments() {
	if (!bStopRotating) {
		document.getElementById("FrontPageRotate").src="images/FrontPageCommitments.png";
		document.getElementById("FrontPageRotateClick").src="images/FrontPageCommitmentsClick.png";
		document.getElementById("FrontPageClickPage").href="Stories.php?name=robert";
		setTimeout("ShowStories()",5000);
	} else {
		setTimeout("ShowCommitments()",1000);
	}   
}
function ShowStories() {
	if (!bStopRotating) {
		document.getElementById("FrontPageRotate").src="images/FrontPageStories.png";
		document.getElementById("FrontPageRotateClick").src="images/FrontPageStoriesClick.png";
		document.getElementById("FrontPageClickPage").href="Stories.php?name=mahoney";
		setTimeout("ShowSpirituality()",5000);
	} else {
		setTimeout("ShowStories()",1000);
	}   
}
function Georgesvalidation() { 
	document.getElementById("FullName").style.backgroundColor = "";
	document.getElementById("Address").style.backgroundColor = "";
	document.getElementById("City").style.backgroundColor = "";
	document.getElementById("Zip").style.backgroundColor = "";
	document.getElementById("Email").style.backgroundColor = "";
	document.getElementById("Acknowledgement").style.backgroundColor = "";

	if (document.mailinglistform.FullName.value =='')
		{ 
			document.getElementById("FullName").style.backgroundColor = "wheat";
			alert("Please enter FullName");
			document.mailinglistform.FullName.focus();
			return false;
		}
	if (document.mailinglistform.Address.value =='')
		{	
			document.getElementById("Address").style.backgroundColor = "wheat";
			alert("Please enter Address!");
			document.mailinglistform.Address.focus();
			return false;
		}
	if (document.mailinglistform.City.value =='')
		{	
			document.getElementById("City").style.backgroundColor = "wheat";
			alert("Please enter City!");
			document.mailinglistform.City.focus();
			return false;
		}
	if (document.mailinglistform.State.value =='')
		{	
			document.getElementById("State").style.backgroundColor = "wheat";
			alert("Please enter State!");
			document.mailinglistform.State.focus();
			return false;
		}
	if (document.mailinglistform.Zip.value =='')
		{	
			document.getElementById("Zip").style.backgroundColor = "wheat";
			alert("Please enter Zip Code!");
			document.mailinglistform.Zip.focus();
			return false;
		}
		else
		if (!IsNumeric(document.mailinglistform.Zip.value))
			{	
			document.getElementById("Zip").style.backgroundColor = "wheat";
			alert("Zipcode can only contain numeric values!");
			document.mailinglistform.Zip.focus();
			return false;
			}
	if (document.mailinglistform.Email.value =='')
		{	
			document.getElementById("Email").style.backgroundColor = "wheat";
			alert("Please enter Email Address!");
			document.mailinglistform.Email.focus();
			return false;
		}
	if (document.mailinglistform.Acknowledgement.checked == false)
			{	
				document.getElementById("Acknowledgement").style.backgroundColor = "wheat";
				alert("Please check Acknowledgement!");
				document.mailinglistform.Acknowledgement.focus();
				return false;
			}
}
function assistantvalidation() { 
		document.getElementById("FullName").style.backgroundColor = "";
		document.getElementById("Address").style.backgroundColor = "";
		document.getElementById("City").style.backgroundColor = "";
		document.getElementById("Zip").style.backgroundColor = "";
		document.getElementById("Email").style.backgroundColor = "";
		document.getElementById("learnbuttons").style.backgroundColor = "";
		document.getElementById("degreebuttions").style.backgroundColor = "";
		document.getElementById("Colleges").style.backgroundColor = "";
		document.getElementById("OccupationalBackground").style.backgroundColor = "";
		document.getElementById("SpecialSkills").style.backgroundColor = "";
		document.getElementById("VolunteerExperience").style.backgroundColor = "";
		document.getElementById("WorkExperience").style.backgroundColor = "";
		document.getElementById("WhenAvailableForService").style.backgroundColor = "";
		document.getElementById("HowLongToServe").style.backgroundColor = "";
		document.getElementById("ContactedOtherLArcheCommunities").style.backgroundColor = "";

		if (document.assistantapplication.FullName.value =='')
			{ 
				document.getElementById("FullName").style.backgroundColor = "wheat";
				alert("Please enter FullName");
				document.assistantapplication.FullName.focus();
				return false;
			}
		if (document.assistantapplication.Address.value =='')
			{	
				document.getElementById("Address").style.backgroundColor = "wheat";
				alert("Please enter Address!");
				document.assistantapplication.Address.focus();
				return false;
			}
		if (document.assistantapplication.City.value =='')
			{	
				document.getElementById("City").style.backgroundColor = "wheat";
				alert("Please enter City!");
				document.assistantapplication.City.focus();
				return false;
			}
		if (document.assistantapplication.State.value =='')
			{	
				document.getElementById("State").style.backgroundColor = "wheat";
				alert("Please enter State!");
				document.assistantapplication.State.focus();
				return false;
			}
		if (document.assistantapplication.Zip.value =='')
			{	
				document.getElementById("Zip").style.backgroundColor = "wheat";
				alert("Please enter Zip Code!");
				document.assistantapplication.Zip.focus();
				return false;
			}
			else
			if (!IsNumeric(document.assistantapplication.Zip.value))
				{	
				document.getElementById("Zip").style.backgroundColor = "wheat";
				alert("Zipcode can only contain numeric values!");
				document.assistantapplication.Zip.focus();
				return false;
				}
		if (document.assistantapplication.Email.value =='')
			{	
				document.getElementById("Email").style.backgroundColor = "wheat";
				alert("Please enter Email Address!");
				document.assistantapplication.Email.focus();
				return false;
			} 
		slearn = jsGetRadioValue(document.assistantapplication.WhereDidYouLearnAboutLArche);
		sdegree = jsGetRadioValue(document.assistantapplication.Degree);
		if (slearn =='')
			{
				document.getElementById("learnbuttons").style.backgroundColor = "wheat";
				alert("Please tell how you learned about L'Arche");
				document.assistantapplication.WhereDidYouLearnAboutLArche[0].focus();
				return false;
			}
		if (sdegree =='')
			{
				document.getElementById("degreebuttions").style.backgroundColor = "wheat";
				alert("Please enter your education level.");
				document.assistantapplication.Degree[0].focus();
				return false;
			}
		if (document.assistantapplication.Colleges.value =='')
			{	
				document.getElementById("Colleges").style.backgroundColor = "wheat";
				alert("Please enter your colleges!");
				document.assistantapplication.Colleges.focus();
				return false;
			} 
		if (document.assistantapplication.OccupationalBackground.value =='')
			{	
				document.getElementById("OccupationalBackground").style.backgroundColor = "wheat";
				alert("Please enter your background!");
				document.assistantapplication.OccupationalBackground.focus();
				return false;
			} 
		if (document.assistantapplication.SpecialSkills.value =='')
			{
				document.getElementById("SpecialSkills").style.backgroundColor = "wheat";
				alert("Please enter your skills!");
				document.assistantapplication.SpecialSkills.focus();
				return false;
			} 
		if (document.assistantapplication.VolunteerExperience.value =='')
			{	
				document.getElementById("VolunteerExperience").style.backgroundColor = "wheat";
				alert("Please enter your volunteer experience!");
				document.assistantapplication.VolunteerExperience.focus();
				return false;
			} 
		if (document.assistantapplication.WorkExperience.value =='')
			{	
				document.getElementById("WorkExperience").style.backgroundColor = "wheat";
				alert("Please enter your work experience!");
				document.assistantapplication.WorkExperience.focus();
				return false;
			} 
		if (document.assistantapplication.WhenAvailableForService.value =='')
			{	
				document.getElementById("WhenAvailableForService").style.backgroundColor = "wheat";
				alert("Please enter when you will be available for service!");
				document.assistantapplication.WhenAvailableForService.focus();
				return false;
			} 
		if (document.assistantapplication.HowLongToServe.value =='')
			{	
				document.getElementById("HowLongToServe").style.backgroundColor = "wheat";
				alert("Please tell us much time do you plan to serve at L'Arche!");
				document.assistantapplication.HowLongToServe.focus();
				return false;
			} 
		if (document.assistantapplication.ContactedOtherLArcheCommunities.value =='')
			{	
				document.getElementById("ContactedOtherLArcheCommunities").style.backgroundColor = "wheat";
				alert("Please tell us whom you have contacted!");
				document.assistantapplication.ContactedOtherLArcheCommunities.focus();
				return false;
			}
		return true;
	}

function IsNumeric(sText) {
	var ValidChars = "0123456789.";
	var Char;
	for (i = 0; i < sText.length; i++) { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
         return false;
		}
    }
   return true;
}

function jsGetRadioValue(pRadioObj) {
	for (i=0; i < pRadioObj.length; i++) {
		if (pRadioObj[i].checked) {
			return pRadioObj[i].value;
		}
	}
	return '';
}
function jsSetRadioValue(pRadioObj, strValue) {
	for (i=0; i < pRadioObj.length; i++) {
		if (pRadioObj[i].value == strValue) {
			pRadioObj[i].checked = true;
			return true;
		}
	}
	return false;
}
function ShowPopUpWindow(sPopUp2Sub,pWindowName,strQuickMsg,pWidth,pHeight,pAdjustmentLevel) {
	// Parameter Descriptions:
	// sPopUp2Sub				- subroutine and parameter names, 		i.e.('subroutinename pValue1,pValue2,...')
	// pWidth						- width in pixels of popup window, 		i.e.default value is 0
	// pHeight					- width in pixels of popup window, 		i.e.default value is 0
	// pAdjustmentLevel	- cascades popup windows, 						i.e.values are 0,1,2,3,etc.
	// pMultiPopUp			- allows multiple popup windows, 			i.e.values are "Yes, "NO", "NO1", "NO2", "NO3"
	// 																												Use NO1, NO2, NO3 if there are other popups on the same window
	var w = 686;
	var h = screen.height * .80;
	if (!pWidth.undefined) {
		w = pWidth;
	}
	if (!pHeight.undefined) {
		h = pHeight;
	}
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	if (isNaN(pAdjustmentLevel)) {
		var adj = 0;
	}else{	
		var adj = 20*pAdjustmentLevel;
	}
	winl = winl - adj;
	wint = wint - (.5*adj);
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',status=no,titlebar=no,directories=no,location=no,scrollbars=yes,menubar=no,resizable=no,alwaysRaised,hotkeys=no';

	newwin = window.open('', pWindowName, winprops);
	if (parseInt(navigator.appVersion) >= 4) {
		newwin.window.focus();
	}
	if (!isEmpty(strQuickMsg)) {
		newwin.document.writeln(strQuickMsg);
		newwin.document.close();
	} 
	if (!isEmpty(sPopUp2Sub)) {
		saveaction = document.forms[0].action;
		document.forms[0].action = sPopUp2Sub;
		savetarget = document.forms[0].target;
		document.forms[0].target = pWindowName;   
		document.forms[0].submit();
		document.forms[0].target = savetarget;
		document.forms[0].action = saveaction;
	}
	return newwin;
}
function isEmpty(s){
	if (s.undefined || (s == null) || (s.length == 0)) {
		return true;
	}
	if (typeof(s) == "string") {
		for(var i=0;i<s.length;i++) {
			if (s.substring(i,i+1) != ' ') {
				return false;
			}
		}
		return true;
	}
	return false;
}
function BuyCalendars() {
	var qty = document.BB_BuyButtonForm.item_quantity_1.value;
	if (isEmpty(qty) || isNaN(qty)) {
		alert ('Please enter a valid numeric value'); 
		return false;
	}
	if (qty >= 25)
		document.BB_BuyButtonForm.item_price_1.value = 8;
		
	// Remove giftwrap if it is empty
	var gift_wrap_qty = document.BB_BuyButtonForm.item_quantity_3.value;
	if (isEmpty(gift_wrap_qty) || isNaN(gift_wrap_qty) || gift_wrap_qty <= 0)
		bGiftWrapIsEmpty = true;
	else
		bGiftWrapIsEmpty = false;

	// Remove shipping if it is picked up at L'Arche	
	if (document.BB_BuyButtonForm.pickup_larche.checked)
		bNoShipping = true;
	else {
		bNoShipping = false;
		document.BB_BuyButtonForm.item_quantity_2.value = qty;
	}
		
	if (bNoShipping) {
		if (bGiftWrapIsEmpty) {
			x = document.BB_BuyButtonForm.item_name_2;
			x.parentNode.removeChild(x);
			x = document.BB_BuyButtonForm.item_description_2;
			x.parentNode.removeChild(x);
			x = document.BB_BuyButtonForm.item_quantity_2;
			x.parentNode.removeChild(x);
			x = document.BB_BuyButtonForm.item_price_2;
			x.parentNode.removeChild(x);
			x = document.BB_BuyButtonForm.item_currency_2;
			x.parentNode.removeChild(x);
		} else {
			document.BB_BuyButtonForm.item_name_2.value = document.BB_BuyButtonForm.item_name_3.value;
			document.BB_BuyButtonForm.item_description_2.value = document.BB_BuyButtonForm.item_description_3.value;
			document.BB_BuyButtonForm.item_quantity_2.value = document.BB_BuyButtonForm.item_quantity_3.value;
			document.BB_BuyButtonForm.item_price_2.value = document.BB_BuyButtonForm.item_price_3.value;
			document.BB_BuyButtonForm.item_currency_2.value = document.BB_BuyButtonForm.item_currency_3.value;
		}
	}	

	if (bGiftWrapIsEmpty || bNoShipping) {
		x = document.BB_BuyButtonForm.item_name_3;
		x.parentNode.removeChild(x);
		x = document.BB_BuyButtonForm.item_description_3;
		x.parentNode.removeChild(x);
		x = document.BB_BuyButtonForm.item_quantity_3;
		x.parentNode.removeChild(x);
		x = document.BB_BuyButtonForm.item_price_3;
		x.parentNode.removeChild(x);
		x = document.BB_BuyButtonForm.item_currency_3;
		x.parentNode.removeChild(x);
	}
	
	// Remove checkbox as it will mess up Google Checkout
	x = document.BB_BuyButtonForm.pickup_larche;
	x.parentNode.removeChild(x);

	return true;
}

function OpenVideo() {
	sHtmlText = '<html><head><title>L&lsquo;Arche Video</title></head><body>' +
             '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" align="middle" width="550" height="400" />' + 
             '<param name="flashvars" value="file=Video/LarcheWeb.flv&autostart=true" />' +
             '<param name="allowScriptAccess" value="sameDomain" />' +
             '<param name="movie" value="Video/mediaplayer.swf" />' +
             '<param name="quality" value="high" />' +
             '<param name="bgcolor" value="#ffffff" />' +
             '<embed flashvars="file=LarcheWeb.flv&autostart=true" src="Video/mediaplayer.swf" quality="high" bgcolor="#ffffff" name="button1" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="550" height="400" />' + 
             '</object>' +
             '</body></html>';
							//flashvars="file=test.flv&image=test.JPG" />
	ShowPopUpWindow('','LArcheVideo',sHtmlText,570,430);
}