	// -----------------------------------------------------------------------------
	// Globals
	// Major version of Flash required
	var requiredMajorVersion = 8;
	// Minor version of Flash required
	var requiredMinorVersion = 0;
	// Minor revision of Flash required
	var requiredRevision = 0;
	
	var noflash = "<div style='border:1px #999 solid;padding-top:10px;padding-bottom:10px;margin-top:5px;margin-bottom:10px;width:370px'><img class='alignnone size-full wp-image-421' title='How it works' src='http://eastlondonbond.org/wp-content/uploads/how-it-works.gif' alt='How it works' width='370' height='1547' /></div>";
	// -----------------------------------------------------------------------------

jQuery(document).ready(
	function () {
		// Add animate images
		jQuery("div.showimage img").hide();
		jQuery("div.showimage a").click(function() {
			if(jQuery(this).parent('div.showimage').children('img').css('display') == 'none') {
				jQuery(this).parent('div.showimage').children('img').fadeIn('slow');
			} else {
				jQuery(this).parent('div.showimage').children('img').fadeOut('slow');
			}
			return false;
		});

		//unwrap images
		jQuery("#supporters div.pagecontent p img").unwrap();
		
		// add show / hide text
		jQuery("#supporters div.pagecontent blockquote").hide();
		jQuery("#supporters div.pagecontent blockquote").before("<a href='#' class='showhide'>show/hide quote ></a>");
		
		jQuery("a.showhide").click(function() {
			if(jQuery(this).parent('div.pagecontent').children('blockquote').css('display') == 'none') {
				jQuery(this).parent('div.pagecontent').children('blockquote').slideDown('slow');
			} else {
				jQuery(this).parent('div.pagecontent').children('blockquote').slideUp('slow');
			}
			return false;
		});
	
		// iReveals
		jQuery("div.irevealcopy").hide();
		
		jQuery('a.irevealshow').click(function() {
			jQuery("div.irevealcopy").slideUp();
			if(jQuery(this).parent('div.ireveal').children('div.irevealcopy').css('display') == 'none') {
				jQuery(this).parent('div.ireveal').children('div.irevealcopy').slideDown('slow');
			}
			return false;
		});
		
		// Factbox Functionality	
		jQuery("div.factbox").css('display','block');
		
		window.setTimeout(function(){
			
		jQuery("p.fact-box-data:first").slideDown('slow',function() {
		
				jQuery("div.factboxfacts").cycle({ 
					fx:     'fade', 
					sync:true,
					speed:  600,
					next:   '.fact-box-data a',
					timeout: 0 
				});
	
		});

		
		},1500); 

		jQuery("div.factboxfacts-sidebar").cycle({ 
					fx:     'fade', 
					sync:true,
					speed:  600,
					next:   '.fact-box-data-sidebar a',
					timeout: 0 
				});

		// Animate testimonials
		jQuery("div.rotate").cycle({ 
			fx:     'fade', 
			speed:  500, 
			timeout: 6000,
			cleartype:  1 // enable cleartype corrections 
		});
		
		
		// Animate latest news
		jQuery("div.latestnewsarticles").cycle({ 
			fx:'scrollUp', 
			sync:true,
			speed:  1500,
			timeout: 6000,			
			delay:0
		});
		
		jQuery("#pledgeother").hide();
		jQuery("#byemailfields").hide();
		jQuery("#bypostfields").hide();
		
		jQuery("#amount").change( function() {
			if(jQuery(this).val() == "other") {
				jQuery("#pledgeother").slideDown();
			} else {
				jQuery("#pledgeother").slideUp();
			}
		});
		
		jQuery("#byemail").click( function() {
			if(jQuery(this).is(':checked')) {
				jQuery("#byemailfields").slideDown();
			} else {
				jQuery("#byemailfields").slideUp();
			}
		});
		
		jQuery("#bypost").click( function() {
			if(jQuery(this).is(':checked')) {
				jQuery("#bypostfields").slideDown();
			} else {
				jQuery("#bypostfields").slideUp();
			}
		});
		
		jQuery("#pledgeform").submit(function() {
			//Validation of Pledge form
			//Clear errors
			jQuery("#pledgeform span").hide();
			var error = false;
			if (jQuery("#amount").val() == "") {
				jQuery("#amountcross").show();
				error = true;				
			} else if (jQuery("#amount").val() == "other" && (jQuery("#other").val() == "")) {
				jQuery("#othercross").show();
				error = true;
			} else if (jQuery("#amount").val() == "other" && (jQuery("#other").val() < "500")) {
				jQuery("#othercross").show();
				error = true;
			}
			if (!jQuery("#understand").is(':checked')) {
				jQuery("#understandcross").show();
				error = true;
			}
			
			if (!jQuery("#understandprivacy").is(':checked')) {
				jQuery("#understandprivacycross").show();
				error = true;
			}
			
			if(jQuery("#title").val() == "") {
				jQuery("#titlecross").show();
				error = true;
			}
			
			if(jQuery("#name").val() == "") {
				jQuery("#namecross").show();
				error = true;
			}
			
			if(!jQuery("#byemail").is(':checked') && !jQuery("#bypost").is(':checked')) {
				jQuery("#methodcross").show();
				error = true;
			}
			
			if (jQuery("#byemail").is(':checked') && validateEmail(jQuery("#email").val())) {
				jQuery("#emailcross").show();
				error = true;
			}
			
			if (jQuery("#bypost").is(':checked') && jQuery("#address1").val() == "") {
				jQuery("#addresscross").show();
				error = true;
			}
			
			if (jQuery("#bypost").is(':checked') && jQuery("#postcode").val() == "") {
				jQuery("#pccross").show();
				error = true;
			}
			
			var bypostvalue = "";
			var byemailvalue = "";
			
			if (jQuery("#bypost").is(':checked')) {
				bypostvalue = "true";
			}
			
			if (jQuery("#byemail").is(':checked')) {
				byemailvalue = "true";
			}
			
			if (error) {
				return false;
			} else {
				//Submit form via ajax....
				jQuery.post("/wp-content/themes/eastlondonbond/sendmail.php", { 
				amount: jQuery("#amount").val(),
				other: jQuery("#other").val(),
				title: jQuery("#title").val(),
				name: jQuery("#name").val(),
				org: jQuery("#org").val(),
				bypost: bypostvalue,
				byemail: byemailvalue,
				email: jQuery("#email").val(),
				address1: jQuery("#address1").val(),
				address2: jQuery("#address2").val(),
				postcode: jQuery("#postcode").val(),
				phone: jQuery("#phone").val()
				}, function(data) {
					//Clear form
					jQuery(':input','#pledgeform')
					.not(':button, :submit, :reset, :hidden')
					.val('')
					.removeAttr('checked')
					.removeAttr('selected');
					jQuery("#response").html(data);
					jQuery("#response").show();
				});
				return false;
			}
		});
	}
);

function validateEmail(email) {
	//Check some text has been entered
	var regexp = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
	if (regexp.test(email)) {		
		return false;
	} else {
		return true;
	}
}
