// GENERAL FUNCTIONALITY
$(document).ready(function() {
		$("#showTooltip").qtip({
			content: '<h3>Gift Aid</h3><p>Gift Aid is fantastic! Charities can receive 28% extra from the government on your donations at no further cost to you. For example, on a gift of &pound;1 the government will give an additional 28p as Gift Aid. That&rsquo;s a huge difference!</p><h3>YES - I am a UK Taxpayer</h3><p>Then please tick the gift aid box to ensure that we take "all donations and payments&nbsp;I make from the date of this declaration, until I notify you otherwise, as Gift Aid payments".</p><h3>NO - I am not a UK Taxpayer</h3><p>So please DO NOT tick the box.</p><p>*Note: You must pay an amount of income tax and/or capital gains tax for each tax year (6 April one year to 5 April the next) that is at least equal to the tax that the charity reclaims on your donations in the appropriate tax year.</p><p>Please let us know if either your address or the amount of tax you pay changes.</p><p>You can cancel this Declaration at any time by notifying us.</p>',
			style: { 
			name: 'blue', // Inherit from preset style
			width: 400

			}
		});
     //REFRESH TOTAL AMOUNT RAISED
	 $("#raisedTxt").load("/includes/raisedAmt.php");
     var refreshId = setInterval(function() {
      	$("#raisedTxt").load('/includes/raisedAmt.php?uid='+ Math.random());
      }, 8000);
     //END
	 //LOAD LATEST NEWS
	 $("#latestNews").load("/func/latestNews.php");
	 //END
	//CHARITY REGISTRATION FORM
	$("#frmCharitySignUp").validationEngine({
		ajaxSubmit: false,
		validationEventTriggers:"blur",
		success :  false,
		failure : function() {}
	});
	//END
	//CHARITY SUGGESTION FORM
	$("#frmSuggestCharity").validationEngine({
		ajaxSubmit: false,
		validationEventTriggers:"blur",
		success :  false,
		failure : function() {}
	});
	//END
	//SEND MESSAGE TO SUPPORTERS
	$("#frmEmailSupporter").validationEngine({
		ajaxSubmit: true,
		ajaxSubmitFile: "func/messageSupporter.php",
		ajaxSubmitMessage: "Thank you, your email has been sent",
		validationEventTriggers:"blur",
		success :  false,
		failure : function() {}
	});
	//END
	//SEND MESSAGE TO CHARIRT
	$("#frmEmailCharity").validationEngine({
		ajaxSubmit: true,
		ajaxSubmitFile: "func/messageCharity.php",
		ajaxSubmitMessage: "Thank you, your message has been sent",
		validationEventTriggers:"blur",
		success :  false,
		failure : function() {}
	});
	//END
	//CHARITY NOMINATION
	$("#frmNominateCharity").validationEngine({
		ajaxSubmit: true,
		ajaxSubmitFile: "func/nominateCharity.php",
		ajaxSubmitMessage: "Thank you, your nomination has been registered",
		validationEventTriggers:"blur",
		success :  false,
		failure : function() {}
	});
	//END
	//Dontate form
	$("#frmDonate").validationEngine({
		ajaxSubmit: false,
		validationEventTriggers:"blur",
		success :  false,
		failure : function() {}
	});
	//END
	//SUPPORTER REGISTRATION FORM
	$("#frmSupporterSignUp").validationEngine({
		ajaxSubmit: false,
		validationEventTriggers:"blur",
		success :  false,
		failure : function() {}
	});
	//END
	//LOGIN FORM
	$("#frmSignIn").validationEngine({
		ajaxSubmit: false,
		validationEventTriggers:"blur",
		success :  false,
		failure : function() {}
	});
	//END
	//LOST PASSWORD FORM
	$("#frmLostPassword").validationEngine({
		ajaxSubmit: true,
		ajaxSubmitFile: "func/lostPassword.php",
		ajaxSubmitMessage: "We have sent you en email containing your password<br /><a href=\"sign-in.php\">Please click here to sign in</a>",
		validationEventTriggers:"blur",
		success :  false,
		failure : function() {}
	});
	//END
	//COUNTDOWN
	var countdown = {
        init: function() {
            countdown.remaining = countdown.max - $(countdown.obj).val().length;
            if (countdown.remaining > countdown.max) {
                $(countdown.obj).val($(countdown.obj).val().substring(0,countdown.max));
            }
            $(countdown.obj).siblings(".remaining").html(countdown.remaining + " characters remaining.");
        },
        max: null,
        remaining: null,
        obj: null
    };
    $(".countdown").each(function() {
        $(this).focus(function() {
            var c = $(this).attr("class");
            countdown.max = parseInt(c.match(/limit_[0-9]{1,}_/)[0].match(/[0-9]{1,}/)[0]);
            countdown.obj = this;
            iCount = setInterval(countdown.init,1000);
        }).blur(function() {
            countdown.init();
            clearInterval(iCount);
        });
    });
	jQuery(function($) {
		 $("img").pngfix();
		 $("div").pngfix();
		 $("div.inner").pngfix();
	});

//END
});
function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}
