$(document).ready(function() 
	{	
			//colorbox
			$(".pledge_form").colorbox({innerWidth:900, innerHeight:522, iframe:true, scrolling:false,fastIframe:true, opacity:.6, onClosed:function(){ openAreYouSure(); }});
			$(".success").colorbox({innerWidth:900, innerHeight:522, iframe:true, scrolling:false,fastIframe:false, opacity:.6});
			$(".are_you_sure").colorbox({innerWidth:612, innerHeight:215, iframe:true, scrolling:false,fastIframe:false, opacity:.6});	
			
			//setCookie('completed_pledge','no',100); //for testing only, uncomment to view pop-ups again
			setPage(); //inital function to launch pop-up if user has not signed the pledge
	});		
	
	//inital function to launch pledge form if there is no cookie found
	function setPage()
	{
		if(getCookie('completed_pledge') != "yes")
		{
			openPledgeForm();
		}
	}
	
	function setSuccessCookie()
	{
		setCookie('completed_pledge','yes',100);
	}
	
	function setCookie(c_name,value,expiredays)
	{
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
	}


	function getCookie(c_name)
	{
		if (document.cookie.length>0)
  		{
  			c_start=document.cookie.indexOf(c_name + "=");
  			if (c_start!=-1)
    		{
    			c_start=c_start + c_name.length+1;
    			c_end=document.cookie.indexOf(";",c_start);
    			if (c_end==-1) c_end=document.cookie.length;
    			return unescape(document.cookie.substring(c_start,c_end));
    		}
 		 }
		return "";
	}
	
	function openPledgeForm()
	{
    	$(".pledge_form").colorbox({open:true}); 
	}
	
	function openAreYouSure()
	{
    	if(getCookie('completed_pledge') != "yes")
    	{
    		$(".are_you_sure").colorbox({open:true}); 
    	}
	}


