			
	function ajax_moredetails(letterId) {
		var url ="ajax.php?action=detailLetter&letterId="+letterId;
		$.get(url,function(data){ jAlert('info',data,'Letter Details' ); });
		document.getElementById('deliveredprocessing').style.display='block';
   	}
	
	// Function for Ajax Login (Top Login Box)
	function ajax_login(){
		var useremail=$("#useremail").val();
		var userpass = $("#userpassword").val();
		var loggedin =  document.getElementById("logged_in").checked;
		if(userpass == "" || useremail == ""){
			jAlert("info","User name / Email cannot be empty ");
		}
		else if(!emailcheck(useremail)){
			jAlert("info","<center>Invalid Email, Please try again!</center> ",'Email Invalid',function(){ document.getElementById("useremail").value=""; $("#useremail").focus(); });
		}
		else{
			var url ="ajax.php?action=signin&signemail="+useremail+"&signpassword="+userpass+"&loggedin="+loggedin;
			$.get(url,function(data){ if(data == 1){document.location.href=document.location.href;}else{jAlert("info","<center><h2>Invalid Email / Password , Please try again</center>","Login Failed",function(){document.getElementById("useremail").value="Email";document.getElementById("userpassword").value="123456";} ); }});
		}
		return false;
	}//end of function

	//function for Date validations for Register		
	function date_validate(dob_month,dob_day,dob_year){	
		var DayCount;
		var days;
		var TodayDate;
		var DateOfBirth;
		TodayDate = new Date();
		DateOfBirth = new Date(dob_year,dob_month,dob_day-1);
		if (DateOfBirth > TodayDate) { 
			return false;
		}
		if ((dob_month == 4) ||
			(dob_month == 6) ||
			(dob_month == 9) ||
			(dob_month == 11)) {
			if (dob_day > 30 ) {
				return false;
			}
		}
		if (dob_month == 2 ) {
			DayCount = 28;
			if ((dob_year == 2000) ||
				(dob_year == 2004) ||
				(dob_year == 2008) ||
				(dob_year == 2012) ||
				(dob_year == 2016) ||
				(dob_year == 2020) ||
				(dob_year == 2024)) {
					DayCount = 29;
			}
			if (dob_day > DayCount ) {
			return false;
			}
		}
		return true;
	}//end of functions
		

	//function for Date validations for Register		
	function date_validate_scheduler(){	
		var dateSch = document.getElementById("dateSelector").value;
		var dateArray = dateSch.split("/");
		dob_month= dateArray[0];
		dob_year=dateArray[2];
		dob_day=dateArray[1];
		var DayCount;
		var days;
		var TodayDate;
		var DateOfBirth;
		TodayDate = new Date();
		DateOfBirth = new Date(dob_year,dob_month-1,dob_day);
		if ( TodayDate>DateOfBirth) { 
			return 1;
		}
		if ((dob_month == 4) ||
			(dob_month == 6) ||
			(dob_month == 9) ||
			(dob_month == 11)) {
			if (dob_day > 30 ) {
				return 2;
			}
		}
		if (dob_month == 2 ) {
			DayCount = 28;
			if ((dob_year == 2000) ||
				(dob_year == 2004) ||
				(dob_year == 2008) ||
				(dob_year == 2012) ||
				(dob_year == 2016) ||
				(dob_year == 2020) ||
				(dob_year == 2024)) {
					DayCount = 29;
				}
			if (dob_day > DayCount ) {
			return 2;
				}
			}
		return 3;
	}//end of functions
		

	//Function for Ajax Registration
	function ajax_register(){
		var userfirstname=$("#registerfirstname").val();
		var useremail=$("#registeremail").val();
		var userpass1 = $("#registerpass1").val();
		var dob_month = $("#month").val();
		var dob_day = $("#day").val();
		var dob_year = $("#year").val();
		var str ="<center>";
		var error = 0;
		if(userfirstname == "" || useremail == "" || userpass1==""){
			str +="<h2> All fields are required</h2>";
			error=1;
		}
    	if(!emailcheck(useremail)){
			str += "<h2> Email is invalid</h2>";
			error=1;
		}
		if(!date_validate(dob_month,dob_day,dob_year)){ 
			str += "<h2> DOB is invalid</h2>";
			error=1; 
		}
		if(error == 1){
			jAlert("info","<center>"+str+"</center>",'Registration Errors');
		}
		else{
			$.alerts.okButton = "Close";
			var url ="ajax.php?action=registeruser&useremail="+useremail+"&userpassword="+userpass1+"&userfirstname="+userfirstname+"&month="+dob_month+"&day="+dob_day+"&year="+dob_year;
			$.get(url,function(data){ if(data == 1){ 
										 jAlert("info","<center><h3>Welcome "+userfirstname+".</h3></center>","Register Successfull",function(){ document.location.href = document.location.href; }); } 
								 else if(data == 2) {
													jAlert("info","<center><h3>Welcome "+userfirstname+".<h3><br/><b>You have a balance of 1 prayer. Select Apply From Balance during checkout to send your prayer for FREE.</b></center>","Register Successfull",function(){ document.location.href = document.location.href; });
											 }
										 else if(data==0){ jAlert("info","<center><h2> Sorry! User with same email exits!","Another User Exist"); } else{jAlert("info","<center><h2>Sorry Registration doesnt succeed</h2><br/> Please try again</center>","Login Failed"); }});
		}
		return false;
	}//end of function

	//Function for Ajax Forget Password
	function ajax_forgotPass(){
		var useremail=$("#forgetemail").val();
		var str ="<center>";
		var error = 0;
		if(useremail == ""){
			str +="<h2> All fields are required</h2>";
			error=1;
		}
		if(!emailcheck(useremail)){
			str += "<h2> Invalid Email , Please Try Again</h2>";
			error=1;
		}
		if(error == 1){
			jAlert("info","<center>"+str+"</center>",'Errors');
		}
		else{
			$.alerts.okButton = "Close";
			var url ="ajax.php?action=forgot_pass&useremail="+useremail;
			$.get(url,function(data){ 
							   if(data == 0){
								   jAlert("info","<center><h2> Sorry! This email-address not exists!","Email not Exist") }else if(data==1){ jAlert("info","<center>Thank you. An email has been sent to the address on file.</center>","Password Sent Successfully",function(){ document.location.href = document.location.href; }); }});
		}
		return false;
	}//end of function

	//function for Login from Login Box		
	function loginbox(action){
		if(action == 1){
			var useremail=document.getElementById('boxemail').value;
			var userpass = $("#boxpassword").val();
			if(userpass == "" || useremail == ""){
				jAlert("info","<center><h2>User name / Email cannot be empty </h2> </center>",'Login Error');
			}
			else{
				var url ="ajax.php?action=signin&signemail="+useremail+"&signpassword="+userpass;
				$.get(url,function(data){ 
				if(data == 1){
					document.location.href=document.location.href;
				}
				else{ 
				  jAlert("info","<center><h2>Invalid Email/Password, Please try again </h2> </center>",'Login Error');}
									 });
			}
		}
		return false;
	}//end of function
	
	//function to get Letters at MyAccount Page
	function ajaxletter(page,action) {
		document.getElementById('processing').style.display='block';
		document.getElementById('letterdata').style.display='none';
		$("#letterdata").load("ajax.php?action="+action+"&page="+page, function(){document.getElementById('processing').style.display='none';
		//delay(3000);																					 
		document.getElementById('letterdata').style.display='block'; } );
	}//end of function
		
	function ajaxscheduleletters(page,action,show) {
		if(show=="true"){
			document.getElementById('processing2').style.display='block';
			document.getElementById('ajaxletter2').style.display='none';
			var pass= {"action":action,"page":page,"show":show};
			$("#ajaxletter2").load("ajax.php",pass, function(){document.getElementById('processing2').style.display='none';
			//delay(3000);																					 
			document.getElementById('ajaxletter2').style.display='block'; } );
		}
		else{
			if(document.getElementById('prayerprocessing')){
				document.getElementById('prayerprocessing').style.display='block';
				document.getElementById('prayerscheduleletter').style.display='none';
				var pass= {"action":action,"page":page,"show":show};
				$("#prayerscheduleletter").load("ajax.php",pass, function(){document.getElementById('prayerprocessing').style.display='none';
				//delay(3000);																					 
				document.getElementById('prayerscheduleletter').style.display='block'; } );
			}
		}
	}//end of function




	//function to show Message (Myaccount Page)			
	function showMessage(obj){
		$('#message'+obj).toggle();
	}//end of function
			
	//function to validate 		
	function validateForm(){
		var pack =document.getElementsByName('pack');
		var len = pack.length;
		for(var i=0;i<len-1;i++){
			if(pack[i].checked==true)
				break;
     	}
		var value= pack[i].value;
		document.getElementById('packid').value= pack[i].id;
		document.purchaseform.submit();
																   
																								   
		  
		}//end of function
		
	//function for showing invite box to Gift a letter to friend		
	function giftShowInvite(bal,fbid){

			$.alerts.okButton = "Next";
			var r=1;
			checkBal(r,bal,2);
			
		/*if(fbid!="-U5" && fbid!="-10"){
			//showFriendSelection(1);
			$.alerts.okButton = "Next";
			var r=1;
			checkBal(r,bal,2);
		}
		else{
			hideSelect();
			$.alerts.okButton = "Next";
			var r=1;
			checkBal(r,bal,2);
		}*/
	}//end of function

	//function to check the prayer balance
	function checkBal(r,bal,type){
		if(isNumeric(r)&& r!=0){
			if(r>bal){
				$.alerts.okButton = "Close";	
				jAlert('error',"<center><h4> You must have a balance of prayers to use the Gifting tool. </h4> </center>",'Low prayer balance');
			}
			else if(type == 2){
			    var noofletter =r;
				var formtext =' <table align="center"> <tr><td class="title">Your friend\'s name :</td><td><input type="text" value="" name="friendname" id = "friendname"  /></td></tr><tr><td class="title">Your friend email address :</td><td><input type="text" value="" name="friendemail" id = "friendemail" /></td></tr></table>';
				jAlert('form',formtext,'Who is your friend ?', function(r){ checkFriend(r,noofletter);} );
			}
			else if(type==1){
				sendFacebookGift();
			}
		}
		else{
			$.alerts.okButton = "Close";	
			jAlert('error',"<center><h4>Invalid Value. Please Re-enter </h4> </center>",'Invalid Value');
		}
	}//end of function
	
	function sendFacebookGift(){
		//function to send  gift for facebook friend
		$.alerts.okButton='Ok'; 
		jConfirm("<h3>Are you sure? Clicking OK will result in one prayer being deducted from your account. Your recipient will be credited one prayer in their balance after registration.</h3>","Are you sure?",function(r){ 
				if(r!="" && r!=null){
					var facebookid = document.getElementById("selectedFriend").value;
					var pass = {"action":"giftletter","friendFbid":facebookid,"noofletters":"1"}
					var url ="ajax.php";
					$.alerts.okButton='Close'; 
					$.post(url,pass,function(data){ jAlert('info',data,'Gifting Complete',function(r){location.href=location.href; }); }); 
				} 
			}
		);
		
	}
		
	//function to check friend email and ajax gift process
	function checkFriend(r,noofletter){
		if(r!=null && r!=""){
			var data = r.split('/');
			if(emailcheck(data[1])){
				$.alerts.okButton='Ok'; 
			jConfirm("<h3>Are you sure? Clicking OK will result in one prayer being deducted from your account. Your recipient will be credited one prayer in their balance after registration.</h3>","Are you sure?",function(r){ 
					if(r!="" && r!=null){
						var url ="ajax.php?action=giftletter&friendname="+data[0]+"&friendemail="+data[1]+"&noofletters="+noofletter;
						$.alerts.okButton='Close'; 
						$.get(url,function(data){ jAlert('info',data,'Gifting Complete',function(r){location.href=location.href; }); }); 
					} 
				}
			);
			}
			else{
				jAlert('error',"<center> <h3> Friend email invalid </h3> </center>",'Email Invalid');
			}
		}
	}//end of function
	
	//Function for email check		
	function emailcheck(x){
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	    if(x!=""){
	     return	reg.test(x)
	    }
	}//end of function
	
	//function to check Numeric values		
	function isNumeric(no){
		var number;
		number =/^[0-9\ ]+$/;
		if(no!="")
		return number.test(no);
	}//end of function
	
	//function to show Tip on Mouseover on Index	
	function tipthis(){
		delay(1000);
		$('#tip').show();
	}//end of function
	
	//function to hide Tip on Mouseover on Index
	function untip(){
		$('#tip').hide();
	}//end of function

	//function to provide Delay of given milliseconds			
	function delay(millis){
	 	var date = new Date();
	 	var curDate = null;
		do { curDate = new Date(); }
			while(curDate-date < millis);
	}//end of function
		 
	//function to show promotional code on Organization page		 
	function showCode(id){
		codeid = "'"+id+"'";
		code= document.getElementById(codeid).value;
		name= document.getElementById("name"+id).value;
	  jAlert('info',' <center><h4>Use the code below during check-out and a portion of our proceeds will go to this organization</h4> </center> <center> <h2> '+code+'</h2></center>',name);
	}//end of function
	
	//function to submit the letter form			
	function letterSubmit(id){
		document.letterForm.submit();
	 }//end of function
	
	/* # NEW FUNCTIONS #*/
	//function for Ajax promocode
	//function for Ajax promocode
	function ajax_promo(letterid,userid,action){
        var promocode = document.getElementById('promocode').value;  
		if(promocode!=""){
			var pass = { 'letterid':letterid, 'promocode': promocode,'user':userid,'action':action};
			$.get("ajax.php",pass,function(data){
						 if(data =="-1"){
							jAlert("info","<h4>You have applied a wrong Promo code!</h4>","Wrong Promo code");
						  }
						 else if(data == "letter"){
								top.location.href = "process.php?letter_id="+letterid+"&pcode=1";
							}
						 else if(data == "package"){
								top.location.href = "myaccount.php";
							}
						 else if(data == "scheduler"){
						 		top.location.href = "scheduler_payment.php?letter_id="+letterid;
						 	}
						 else if(data == "-2"){
							 jAlert("info","<h4>Sorry! This Promo code is not valid for this purchase</h4>","Invalid Promo code");
						 	}
						 else if(data == "-3"){
							 jAlert("info","<h4>Sorry! You have already used this Promo code! </h4>","Invalid Promo code");
						 	}
						  else{ 
							 document.getElementById('price').innerHTML=data;
							 document.getElementById('formpromocode').value= promocode;
							 document.getElementById('bpromo').value=promocode;
						   }
							
					});	
				}
		}//end of function
				
	//function to submit apply balance form 
	function balanceSubmit(){
		document.balanceform.submit();
	 }//end of function		
 
	//function to show friend invite
	function showFriendSelection(type){
		if(type==1){
		 loadFriends();
		 document.getElementById('giftFormDiv').style.display='block';
		 document.getElementById('fadeDiv').style.display='block';
		}
		else
		 showConnect();
	}//end of function
 
	function hideSelect(){
		document.getElementById('selectionDiv').style.display='none';
		document.getElementById('giftFormDiv').style.display='none';
		document.getElementById('fadeDiv').style.display='none';
	}//end of function
	
	function callEdit(letterid,user){
		var editdone=document.getElementById('editdone');
		var textArea = document.getElementById('textMessage');
		var textArea = document.getElementById('textMessage');
       
       var value = textArea.value.replace(/^\s+|\s+$/g,"");
         
		if(value.length>0){
			value = escape(value);
			if( editdone.value == "Edit"){
				editdone.setAttribute("value","Done");
				textArea.style.background ='';
				//textArea.style.height = '550px';
				textArea.style.border='1px solid #cccccc';
				textArea.removeAttribute("readOnly");
			}
			else if(editdone.value == "Done"){
				editdone.setAttribute("value","Edit");
				var msg = escape(textArea.value);
				var pass = {'user': user,'letterid':letterid,'message':msg};
				$.get("ajax_msg_save.php",pass,function(data){
				if(data==1){
					textArea.style.background = '#fff5c5';
					textArea.style.border = '1px solid #dccd87';
					textArea.style.height = "auto";
					textArea.style.height = textArea.scrollHeight+"px";
					textArea.setAttribute("readOnly","readonly");
				}
				});	
			}
		}
		
	}//end of function

	
	function checkLimit(limit){
		var editor = document.getElementById("textMessage");
		var value = editor.value.replace(/^\s+|\s+$/g,"");
		var chars =value.length;
		var editdone=document.getElementById('editdone');
		
		if(chars>0){
			editdone.style.cursor = "pointer";
			editdone.style.background = "#F5CD81";
			editdone.style.color = "#C0362C";
		}
		else{
			editdone.style.cursor = "auto";
			editdone.style.background = "#dedede";
			editdone.style.color = "#000000";	
			
		}
		//editor.style.height = editor.clientHeight+"px"; 
 		if(chars > limit){
 			var data = editor.value.substr(0,limit);
 			editor.value=data;
 		}
 	 }//end of function
	
	
	function checkConfirmFriendEmail(){
		var confirmBox = document.getElementById('friendprayer');
		if(confirmBox.checked == true){
			document.getElementById('friendemail').removeAttribute('Disabled');
		}
		else
			document.getElementById('friendemail').removeAttribute('Disabled','disabled');
 		}//end of function
	
	function prayerFormSubmit(){
		var error = 0;
		/*if(document.getElementById('emailme').checked== true && document.getElementById('confirmemail').value==""){
			jAlert("error","Confirm Email","Please enter the confirmation email");
			error = 1;
 		}
		else{
			var confirmemail = document.getElementById('confirmemail').value;
			if(!emailcheck(confirmemail)){
				 jAlert("error","Confirm Email Invalid ","Invalid Confirm Email?");
				   error = 1;
				}
			
			}	
		
		if(document.getElementById('friendprayer').checked== true && document.getElementById('friendemail').value==""){
 	       jAlert("error","Please enter your friend email","Friend Email?");
 	        error = 1;
 			}
		else if( document.getElementById('friendprayer').checked== true ){
			var friendemail = document.getElementById('friendemail').value;
			if(!emailcheck(friendemail) && friendemail!=""){
				 jAlert("error","Friend Email Invalid ","Invalid Friend Email?");
				   error = 1;
				}
			
			}	*/
			
 		
 	        if(error==0)
 			document.processForm.submit();
 }

 
 function callSchedule(user,shid,action){
	 	var pass = { 'action': action,'user':user,'shid':shid};
		if(action=="getScheduler")
	 	$.get('ajax.php',pass,function(data){ jQuery.facebox(data,"Add a Scheduled Prayer")});
		if(action == "editScheduler")
			$.get('ajax.php',pass,function(data){ jQuery.facebox(data,"Edit the Scheduled Prayer")});
		if(action == "buyMore"){
			$.get('ajax.php',pass,function(data){ jQuery.facebox(data,"Add more cycles to the scheduled prayer")});
			
		}
				
	}
 
 
 function getLetterData() {
	  document.getElementById('wallmessage').value="";
	  document.getElementById('charCount').innerHTML="";
	 letterId = document.getElementById("selectedtitles").value;
	    var pass = { 'action': 'letterdata', 'letterId': letterId};
	      $.get('ajax.php',pass,function(data) {
		  document.getElementById('wallmessage').value=$.evalJSON(data).message;
		  document.getElementById('charCount').innerHTML=$.evalJSON(data).message.length;
		});	
	}

 

 function validateScheduleForm(){
	var error =0;
 	var str = "<span>";
	if (document.scheduleform.schDate.disabled!=true){
		var datevalidate = date_validate_scheduler();
	}
	else 
		var datevalidate=3;
	
		if(datevalidate==1){
		    str+="Date should be greater then today's date<br/> ";
			error=1;
		}
		else if(datevalidate==2){
			str+="Date is invalid, please select a valid date<br/>";
			error==1;
		}
		else if(datevalidate==3){
				var prayer = document.getElementById('wallmessage').value;
				 if(prayer.length==0){
					error =1;
					str+="Prayer cannot be empty<br/>";
					 }
						}
 		
      if(error==1){
          str+="</span>"
 		  
        	  jAlert("error",str,"Scheduler Form Errors?");
        	  
           }
      else{  
      	var scheduleForm = document.getElementById("schedulerform"); 	
 		scheduleForm.submit();
          }
 }
 	
 /* Functions for Showing / Hiding Tips for character limits */
 	function limittip(){
		$('#limittip').show();
		}
	
	function limituntip(){
		document.getElementById("wallmessage").disabled = "";
		$('#limittip').hide();
		}
	
	function  limitschdeluetip(){
		$('#limitschtip').show();
	}
	
	function limitscheduleuntip(){
		document.getElementById("wallmessage").disabled = "";
		$('#limitschtip').hide();
	}
 
	//function for Scheduled Prayers Count
	function countPrayerChar (limit,colorlimit) {
		if(!document.getElementById('wallmessage')) return false;
		var editor = document.getElementById('wallmessage');
		if(!document.getElementById('charCount')) return false;
		var counterElement = document.getElementById('charCount');
		var chars =editor.value.length;
		if(chars <= limit){
		    if(chars <= colorlimit){
			 counterElement.style.color='#3062df';
			 document.getElementById("limitset").value = "false";
			 editor.disabled = "";
		 	}
			if(chars >= colorlimit){
			 var limitset = document.getElementById("limitset").value;
			 counterElement.style.color='#c5442e';
			 if(chars == limit && limitset == "false"){
				 limitschdeluetip();
				 editor.disabled = true;
				 document.getElementById("limitset").value = "true";
			 }
			}
			else{
				counterElement.style.color='#3062df';
				limitscheduleuntip();
			}
		}
		else{
			//exceeds the limit
			var data = editor.value.substr(0,limit);
			editor.value = data;
		}
			
		counterElement.innerHTML = editor.value.length;
	}//end of function
	
	
	//function for counting at index page
	function countindexPrayerChar (limit,colorlimit) {
		if(!document.getElementById('wallmessage')) return false;
		var editor = document.getElementById('wallmessage');
		if(!document.getElementById('charCount')) return false;
			var counterElement = document.getElementById('charCount');
			var val = editor.value;
			val =	val.replace(/\r+/g,'');
			editor.value = val;
			var chars =editor.value.length;
			if(chars <= limit){
				//Under total prayer limit
				if(chars <= colorlimit){
					counterElement.style.color='#3062df';
					document.getElementById("limitset").value = "false";
					editor.disabled = "";
				}
				if(chars >= colorlimit){
					
					var limitset = document.getElementById("limitset").value;
					counterElement.style.color='#c5442e';
					
					if( (chars == colorlimit) && limitset == "false"){
						limittip();
						editor.disabled = "disabled";
					 	//editor.setAttribute("readOnly","readOnly");
	        	       	document.getElementById("limitset").value = "true";
					}
					
				}
				else{
					counterElement.style.color='#3062df';
					limituntip();
				}
			}
			else{
				//exceeds the limit
				var data = editor.value.substr(0,limit);
				editor.value = data;
			}
			counterElement.innerHTML = editor.value.length;
		}//end of function
	
	//function for schedule prayer count check
	function countEditPrayerChar (limit,colorlimit) {
	 	if(!document.getElementById('wallmessage')) return false;
		var editor = document.getElementById('wallmessage');
		if(!document.getElementById('charCount')) return false;
		var counterElement = document.getElementById('charCount');
		var chars =editor.value.length;
		if(chars <= colorlimit){
			counterElement.style.color='#3062df';
			document.getElementById("limitset").value = "false";
			editor.disabled = "";
			//editor.removeAttribute("readonly");
		}
		if(chars >= colorlimit){
			var data = editor.value.substr(0,colorlimit);
			editor.value=data;
			var limitset = document.getElementById("limitset").value;
			counterElement.style.color='#c5442e';
		    if(chars == colorlimit && limitset == "false"){
		       	limitschdeluetip();
		       	editior.disabled = "disabled";
		       //	editor.setAttribute("readOnly","readOnly");
		       	document.getElementById("limitset").value = "true";
		        }
			}
		else{
		 counterElement.style.color = '#3062df';
		 limitscheduleuntip();
		}
			
		counterElement.innerHTML = editor.value.length;
	}//end of function
 
	function hideBox(){
		$(document).trigger('close.facebox');
	}//end of function


	function deleteSchedule(user,shid,action){
		$.alerts.okButton = "Yes";
		$.alerts.cancelButton = "No";
		
		jConfirm("<h2>Are You Sure to Delete this Schedule Prayer</h2>","Are you sure?",function(r){
							if(r!=null && r!=""){																							 
									var pass = {'action': action,'user':user,'shid':shid};
									$.get('ajax.php',pass,function(data){
																   		$.alerts.okButton = "Ok";
												if(data==1)
													jAlert("info","<h2>Scheduled prayer deleted successfully</h2>","Prayer Deleted",function(r){ window.location.href = window.location.href;  });  
											      }  ); } 
		}  );
	}//end of function
 

	function callPaypal(){
		//var state = document.paypalform.paypal.checked;
		//if(state==true){
					document.paypalform.submit();
				//}
			
		
	 }//end of function


	function continueButton(){
		var state = document.paypalform.paypal.checked;
		if(state==true){
			jQuery.facebox("<center><h2>Payment Options Coming Soon </h2> </center>","Payment Options");
		}	
	}//end of function

function showNewsLetter(){
	data = '<form name="ccoptin" action="http://visitor.constantcontact.com/d.jsp" target="_blank" method="post" style="margin-bottom:3;"><table width="407" cellspacing="0" cellpadding="0">'+
			'<tr><td height=10 colspan=3></td></tr><tr><td style="font-size:13px; font-weight: bold;" valign="top" width="100"><div align=center> Your Email </div></td><td valign="top"><div align="center"><input type="text" name="ea" size="30" value="" style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:10px; border:1px solid #999999;"><input type="hidden" name="m" value="1103630271789"><input type="hidden" name="p" value="oi"></div></td><td><span style="background-color:#FF9900;"><img src="https://imgssl.constantcontact.com/ui/images1/visitor/email1_trans.gif" alt="Email Newsletter icon, E-mail Newsletter icon, Email List icon, E-mail List icon" border="0" style="vertical-align:sub"></span></td></tr><tr><td colspan="3"><!-- END: Constant Contact Stylish Email Newsletter Form --><!-- BEGIN: SafeSubscribe --><div align="center" style="padding-top:5px;"><a href="http://www.constantcontact.com/safesubscribe.jsp" target="_blank"><img src="https://imgssl.constantcontact.com/ui/images1/safe_subscribe_logo.gif" border="0" width="168" height="14" alt=""/></a> </div></td></tr><!-- END: SafeSubscribe --><tr> <td colspan="3"><div align="center" style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#999999;">For <a href="http://www.constantcontact.com/jmml/email-marketing.jsp" style="text-decoration:none;font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#999999;" target="_blank">Email Marketing</a> you can trust</div> </td></tr><!-- BEGIN: Email Marketing you can trust -->  <tr><td height=30 colspan="3" >&nbsp;</td></tr>  <tr> <td height=35 colspan="3">   <div align="right" style="padding-right:5px;"><input type="submit"  class="button" value="Subscribe" /> </td></tr></table></form>';
			
			
	 jQuery.facebox(data,"Signup for Email Alerts");
	}


function checkOnce(){
	var selectedval = $("#repeatation").val();
	var cycle = document.getElementById("cycles");
	if(selectedval=="O"){
			cycle.disabled = "disabled";
			cycle.selectedIndex = 0;
	}
	else{
		cycle.disabled = false;
	}
}

function titleTip(element,type){
	if(element != 'createTip' && document.getElementById("tipShown").value == "1"){
		document.getElementById("tipShown").value = "0";
		$("#createTip").hide();
	}
	else{
		document.getElementById("tipShown").value = "1";
	}
	if(type==1)
		delay(2000);
 	
	$("#"+element).fadeIn();
 }
function hideTitleTip(element){
	delay(500);
	$("#"+element).fadeOut();
}


function sendMessage(user){
	hideSelect();
	var friendId = document.getElementById("selectedFriend").value;
	document.getElementById("selectedFriend").value = "";
	var pass = {'action': 'sendMessage','user':user,'friendid':friendId};
	$.post('ajax.php',pass,function(data){
			$.alerts.okButton = "Ok";
				if(data==1)
					jAlert("info","<h2>Message sent successfully</h2>","Message Sent");  
			      }  ); 
	} 

function checkfriendemail(){
	var friendemail = document.getElementById("friend_email").value;
	var targetImg = document.getElementById("sendemail");
	var intImg = document.getElementById("sendemaildisable");
	if(emailcheck(friendemail)){
		intImg.style.display = "none";
		targetImg.style.display = "";
	}
	else{
		intImg.style.display = "";
		targetImg.style.display = "none";
	}
}

function sendEmailToFriend(user,letterid){
	var friendId = document.getElementById("friend_email").value;
	document.getElementById("selectedFriend").value = "";
	var pass = {'action': 'sendEmail','user':user,'friendemail':friendId,'letterid':letterid};
	$.post('ajax.php',pass,function(data){
			$.alerts.okButton = "Ok";
				if(data==1)
					jAlert("info","<h2>Email sent successfully</h2>","Email Sent");  
			      }  ); 
}

//function to submit data in session
function saveLetter(){
	var prayer = $("#wallmessage").val();
	var prayershow = document.getElementById("prayerCheckbox").checked; 
	var pass = {"action":'saveMessage',"prayer":prayer,"public":prayershow};
	$.post('ajax.php',pass,function(data){
					if(data==1){
						$.get('ajaxindexregisterdata.php',function(data){ jQuery.facebox(data,"Register/Login")});
					}
				  
		      }  ); 
}


function applyBalance(){
		disablePreventMessage();
		balanceSubmit();
}
