var fieldstocheck = new Array();
fieldnames = new Array();
function checkform() {
    for (i=0;i<fieldstocheck.length;i++) {
    if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
            alert("Please enter your "+fieldnames[i]);
            eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
            return false;
        }
    }
    if($("#list1").attr("checked"))  $("#list4").attr("checked", true);

    document.getElementById("emailconfirm").value=document.getElementById("email").value;
    return true;
}
function addFieldToCheck(value,name) {
fieldstocheck[fieldstocheck.length] = value;
fieldnames[fieldnames.length] = name;
}

jQuery(document).ready(function()
{
	// the minimum required value to be entered.
	// in this case PayPal takes $0.35 from a $1
	// donation, hence we ask for at least $1.35
	var minimum_value = 1.35;
 
	// attach this script to the form's submit action
	jQuery('#form_paypal').submit(function()
	{
		// check if there is an amount entered
		if (jQuery('#input_amount').val() > null)
		{
			// is the amount equal to or higher than the minimum_value?
			if (jQuery('#input_amount').val() < minimum_value)
			{
				// need more amount
				// hide messages, show more amount error
				jQuery('#msg_noamount').hide();
				jQuery('#msg_moreamount').fadeIn();
				return false; // prevent the form from submitting
			}
			else
			{
				// amount is more than minimum_value
				// hide messages, show activity
				jQuery('#msg_moreamount').hide();
				jQuery('#msg_noamount').hide();
				jQuery('#msg_activity').fadeIn();
				return true; // submit the form
			}
		}
		else
		{
			// no amount entered at all
			// hide messages, show no amount error
			jQuery('#msg_moreamount').hide();
			jQuery('#msg_noamount').fadeIn();
			return false; // prevent the form from submitting
		}
	});
	//FANCYBOX
    $("a.fancybox").each(function() {
        t = $(this);
        th = t.attr("href");
        text = t.hasClass("text");
        opts = {
            'title':this.title, 
            'titlePosition' : 'inside',
            'showCloseButton' : false,
            'titleFormat' : formatTitle
        }
        if(th.substring(0,1)=="#") {
            //if is inline
            $(th).wrap('<div style="display:none"></div>');
            if(text)$(th).addClass("fancybox-text");
            t.fancybox(opts); 
        } else if(th.indexOf("youtube.com") > -1) {
            t.fancybox({
    			'padding'		: 0,
    			'autoScale'		: false,
    			'transitionIn'	: 'none',
    			'transitionOut'	: 'none',
    			'titleShow'     : false,
    			'width'		: 680,
    			'height'		: 495,
    			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
    			'type'			: 'swf',
    			'swf'			: {
    			   	 'wmode'		: 'transparent',
    				'allowfullscreen'	: 'true'
    			},
    			'titlePosition'  : 'over'
    		});

        } else {
            t.fancybox(opts);    
         } 
    });
    
    //Homepage flash banner
    
    
    $("body.home div#flash-banner a.alt").flash(
        { src: '/wp-content/themes/justdoit/swf/banner_post-Lush-pink.swf',
          width: 910,
          height: 170,
          wmode: 'transparent' },
        { version: 8 }
    );  
    //Homepage Radio
    
$("#radio-listen").click(function() {
    window.open("http://just-do-it.org.uk/wp-content/uploads/2010/09/Dissident-Island-Radio-Emily-and-James-from-the-Just-do-it-the-film-project.mp3","DescriptiveWindowName","resizable=no,scrollbars=no,status=no,width=200,height=200");
    return false;
});

});

function formatTitle(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip7-title"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="/wp-content/themes/justdoit/images/closelabel.gif" /></a></span>' + (title && title.length ? '<strong>' + title + '</strong>' : '' ) + '</div>';
}


