function emailCard(){
	var err=Array();
	if(trim($("#fromName").val())==""){
		err.push("your name");
	}
	if(!validateEmail($("#fromMail").val())){
		err.push("your email");
	}
	/*if(trim($("#toName").val())==""){
		err.push("Recipient Name");
	}
	if(!validateEmail($("#toMail").val())){
		err.push("Recipient Email");
	}*/
	var emails=Array()
	var names=Array()

	var r=0;
	if(1){
		var recpName=$("input[name=\"RecipientName[]\"]");
		var recpEmail=$("input[name=\"RecipientEmail[]\"]");
		for(i=0;i<4;i++){
			if(trim($(recpName[i]).val())!="" || $(recpEmail[i]).val()!=""){
				

				if(trim($(recpName[i]).val())==""){
					err.push("recipient "+(i+1)+"  name");
				}
				if(!validateEmail($(recpEmail[i]).val())){
					err.push("recipient"+(i+1)+"  email");
				}
				emails.push($(recpEmail[i]).val());
				names.push($(recpName[i]).val());
				r=1;
			}

		}

	}
	if(!r){
		err.push("recipient name and email " )
	}

	if(err.length){
		$("div#div_msg").html("Please fill in "+err.join(","));
		$("div#div_msg").show();
	}else{
		var param=getRequestBody(document.forms["frm_mail_card"])
			param['RecipientEmails']=emails.join(",")
			param['RecipientNames']=names.join(",")
		$("div#div_msg").load("mail.php", param);
//		$("div#div_msg").load("mail.php", param,hideStatus);
		$("div#div_msg").show();
	}

}
function deleteCard(card_id,card_name,loc){
	  var oParams			= {};
	  oParams["card_id"]	= card_id;
	  oParams["card_name"]	= card_name;
	  oParams["loc"]		= loc;

	$.post("ecard_delete.php", oParams,function (sts){ deleteStatus(sts,card_name)}); 

}
function getPoem(poem_id){
		var oParams			= {};
		oParams["poem_id"]	= poem_id;
		$.post("requests.php", oParams,editPoem); 
}
function editPoem(poem,poem_id){
	if(poem!='---ERROR---'){
		parts=poem.split("---")
		$("#poem").val(parts[1])
		$("#poemTitle").val(parts[0])
		//$("#poemID").val()
		//alert(parts)

	}else{
	}
}
function deleteStatus(sts,card_name){
	if(sts==1){
	 param="limit="+$("#limit").val()+"&ecardCat="+$("#ecardCat").val()+"&from="+$("#from").val()
		$("div#div_listcard").load("listcards.php?"+param,function (){$("div#div_msg").html("Card "+card_name+" has been deleted");$("div#div_msg").show();});
	}else{
		$("div#div_msg").html("Card "+card_name+" could not be deleted");
		$("div#div_msg").show();

	}
}


function hideStatus(){
	setTimeout(function (){
		$("div#div_msg").html("");
		$("div#div_msg").hide("slow");
	},10000)
}
function validateLogin(frm){
	var msg=Array();		

	if(frm.txt_login_id.value==""){
		msg.push("Login ID");
	}
	if(frm.txt_login_pass.value==""){
		msg.push("Password");
	}
	
	if(msg.length){

		$("div#div_msg").html("Please enter "+msg.join(",")+" to proceed");
		$("div#div_msg").show();

		return false;
	}else{
		return true;
	}
}
