	// JavaScript Document

function submit_login_page()
{
	
		var chk = check_login_fields();
		if(chk!=false)
		{
				document.login.action="check_admin_login.php";
				document.login.submit();
		}
}
function check_login_fields()
{
		if(document.login.username.value=="")
		{
				alert("Enter username.");
				document.login.username.focus();
				return false;
		}
		if(document.login.pwd.value=="")
		{
				alert("Enter password.");
				document.login.pwd.focus();
				return false;
		}
} 
function submit_product_form()
{
		var chk = check_product_fields();
		if(chk!=false)
		{
				setHiddenVal("description");
				var description = document.getElementById('hdndescription').value;
				document.getElementById('desc').value = escape(description);		
				var a =document.getElementById('desc').value = escape(description);
				if(a==""){
					alert("Body must be filled");
				}else
				{
						document.prod.action="save_product_data.php";
						document.prod.submit();
				}
		}
				
}
function check_product_fields(action)
{
			if(document.prod.prod_name.value=="")
			{
					alert("Enter Product Name.");
					document.prod.prod_name.focus();
					return false;
			}
			/*if(document.prod.photo.value=="")
			{
				alert("Choose Upload Image");
				document.prod.photo.focus();
				return false;
			}
			if(document.prod.productfile.value=="")
			{
				alert("Choose Upload File");
				document.prod.productfile.focus();
				return false;
			}
			if(document.prod.Desc.value=="")
			{
					alert("Enter Product Description.");
					document.prod.Desc.focus();
					return false;
			}*/
			if(document.prod.Price.value=="")
			{
					alert("Enter Product Price.");
					document.prod.Price.focus();
					return false;
			}
			else
			{
			var amt= document.prod.Price.value;
			var blnFlag =false;
			for(i=0;i<=amt.length;i++)
			{	
				//alert(phone.charAt(i));
				if ((amt.charAt(i)!=".") && (isNaN(amt.charAt(i))))
				{
					blnFlag = true;
					break;
				}
			}
			if(blnFlag==true)
			{
				alert("Enter a number for Price.");
				document.prod.Price.value="";
				document.prod.Price.focus();
				return false;
			}
			}
			/*if(amt<1)
			{
				alert("Enter Price Proper.");
				document.prod.Price.value="";
				document.prod.Price.focus();
				return false;
			}*/
}
function editproduct()
{		
		var chk = check_product_fields();
		var id=document.prod.prdId.value;
		if(chk!=false)
		{
				setHiddenVal("description");
				var description = document.getElementById('hdndescription').value;
				document.getElementById('desc').value = escape(description);		
				var a =document.getElementById('desc').value = escape(description);
				if(a==""){
					alert("Body must be filled");
				}else
				{
						document.prod.action="edit_product_data.php?id="+id;
						document.prod.submit();
				}
								
		}
}
 function submit_PasswordFields()
 {
		var chk = check_password_fields();
		if(chk!=false)
		{
				document.change.action="change_pwd.php";
				document.change.submit();
		}
}
function submit_cms_form()
{
			if(document.cms.pages.options[document.cms.pages.selectedIndex].value==0)
		{
				alert("Select page.");
				document.cms.pages.focus();
		}
		else
		{
				setHiddenVal("description");
				var description = document.getElementById('hdndescription').value;
				document.getElementById('desc').value = escape(description);
				document.cms.action="save_content_data.php";
				document.cms.submit();
		}
}
function getSelectedPage()
{
	var page = document.cms.pages.options[document.cms.pages.selectedIndex].value;
	document.cms.page_name.value = page;
	document.cms.action="contentMgmt.php";
	document.cms.submit();
}
/*function submit_newsletter_form()
{
	if(document.newsletter.subject.value == "")
	{
			alert("Enter subject.");
			document.newsletter.subject.focus();
	}
	else
	{
		setHiddenVal("description");
		var description = document.getElementById('hdndescription').value;
		document.getElementById('desc').value = description;
		document.newsletter.action="send_newsletter_code.php";
		document.newsletter.submit();
	}
}*/
function submit_newsletter_form()
{
	if(document.newsletter.subject.value == "")
	{
			alert("Enter subject.");
			document.newsletter.subject.focus();
	}
	else {
	setHiddenVal("description");
	var description = document.getElementById('hdndescription').value;
	document.getElementById('desc').value = description;		
	var a =document.getElementById('desc').value = escape(description);
	if(a==""){
		alert("Body must be filled");
	}else{
	document.newsletter.action="send_newsletter_code.php";
	document.newsletter.submit();
	}
	}
}
/*function submit_responder_form()
{
				setHiddenVal("description");
				var description = document.getElementById('hdndescription').value;
				document.getElementById('desc').value = escape(description);
				document.cms.action="save_responder_data.php";
				document.cms.submit();
}*/
function submit_responder_form()
{
	if(document.newsletter.subject.value == "")
	{
			alert("Enter subject.");
			document.newsletter.subject.focus();
	}
	else {
	setHiddenVal("description");
				var description = document.getElementById('hdndescription').value;
				document.getElementById('desc').value = escape(description);
				document.newsletter.action="save_responder_data.php";
				document.newsletter.submit();
	}
	
}
function check_password_fields()
{
		if(document.change.newpwd.value=="")
		{
				alert("Enter Old Password.");
				document.change.newpwd.focus();
				return false;
		}
		if(document.change.pwd.value=="")
		{
				alert("Enter New Password.");
				document.change.pwd.focus();
				return false;
		}
		if(document.change.cpwd.value=="")
		{
				alert("Confirm password.");
				document.change.cpwd.focus();
				return false;
		}
		if((document.change.pwd.value)!=(document.change.cpwd.value))
		{
			alert("Password does not match");
			document.change.pwd.value = "";
			document.change.cpwd.value = "";
			document.change.pwd.focus();
				return false;
		}
}
function submit_guest_book()
{
		var chk = check_guest_fields();
		if(chk!=false)
		{
				
				document.prod.action="save_guest_data.php";
				document.prod.submit();
				
		}
		
}
function approve_guest(action)
{		
		var chkstr="";
		var chkArr=document.getElementsByName("chkUser");
		
		for(i=0; i < chkArr.length; i++)
		{
				if(chkArr[i].checked)
				{
						if(chkstr=="")
						{
								chkstr=chkArr[i].value;
						}
						else
						{
								chkstr=chkstr+","+chkArr[i].value;
						}
				}
		}

		var guestObj=document.getElementById("gstId");
		guestObj.value=chkstr;
		if(guestObj.value!="") 	
		{
			if (action=="Approve")
	  		{
				document.prod.action="approveguest.php";
				document.prod.submit();
		}
		 else
	  	{
				document.prod.action = "deleteSelectedGuest.php"; 
	  	}
	  			document.prod.submit();
		}
		else
		{
				alert("Select atleast one checkbox");
		}
}
function selectAll()
{
		var chkArr=document.getElementsByName("chkUser");
		for(i=0;i<chkArr.length;i++)
		{
			if(document.getElementById("checkAll").checked)
			{
					chkArr[i].checked=true;
			}else
			{
					chkArr[i].checked=false;
			}
		}
}
function check_guest_fields(action)
{
		
			if(document.prod.guest_name.value=="")
			{
					alert("Enter Guest Email.");
					document.prod.guest_name.focus();
					return false;
			}
			else
			{
				var mail = document.prod.guest_name.value;
				if(mail.search("@.")==-1)
				{
						alert("Entered email is invalid. Try again.");
						document.prod.guest_name.value="";
						document.prod.guest_name.focus();
						return false;
				}
		}
			if(document.prod.guest_comment.value=="")
			{
					alert("Enter Guest Comments.");
					document.prod.guest_comment.focus();
					return false;
			}

			
}
function submit_subscription_page()
{
	
		var chk = check_subscription_fields();
		if(chk!=false)
		{
				document.subscription.action="deletesubscription.php";
				document.subscription.submit();
		}
}
function check_subscription_fields()
{
		if(document.subscription.mail.value=="")
		{
				alert("Enter Email.");
				document.subscription.mail.focus();
				return false;
		}
		else
			{
				var mail = document.subscription.mail.value;
				if(mail.search("@.")==-1)
				{
						alert("Entered email is invalid. Try again.");
						document.subscription.mail.value="";
						document.subscription.mail.focus();
						return false;
				}
		}
		
}
function emailvalidate()
{
		var chk = chkfields();
		if(chk!=false)
		{
				document.email.action="send_email.php";
				document.email.submit();
		}			
		
}

function submit_email_page()
{
	
		var chk = check_email_fields();
		if(chk!=false)
		{
				document.news.action="save_email_data.php";
				document.news.submit();
		}
}
function check_email_fields()
{
		if(document.news.textfield.value=="")
		{
				alert("Enter Email.");
				document.news.textfield.focus();
				return false;
		}
		else
			{
				var mail = document.news.textfield.value;
				if(mail.search("@.")==-1)
				{
						alert("Entered email is invalid. Try again.");
						document.news.textfield.value="";
						document.news.textfield.focus();
						return false;
				}
		}
		
}
function emailvalidate()
{
		var chk = chkfields();
		if(chk!=false)
		{
				document.email.action="send_email.php";
				document.email.submit();
		}			
		
}
function chkfields()
{
		name=document.email.guest_name.value;
		if(name=="")
		{
				alert("Enter Name");
				document.email.guest_name.focus();
				return false;
		}
		emails=document.email.guest_email.value;
		if(emails=="")
		{
				alert("Enter Email");
				document.email.guest_email.focus();
				return false;
		}
		else
		{
				var mail = document.email.guest_email.value;
				if(mail.search("@.")==-1)
				{
						alert("Entered email is invalid. Try again.");
						document.email.guest_email.value="";
						document.email.guest_email.focus();
						return false;
				}
		}
		company=document.email.guest_comment.value;
		if(company=="")
		{
				alert("Enter Comment");
				document.email.guest_comment.focus();
				return false;
		}
}

function submit_for_payment(id)
{

		//location.href = "payment.php?picId="+ id +"&amt="+ amt;
		document.abc.action="payment.php?picId="+id;
		document.abc.submit();
}

function uploadfilecheck()
{
	/*var chk = chkuploadfields();
	if(chk!=false)
	{*/
		document.upload.action="save_upload_file.php";
		document.upload.submit();
	//}
}
function uploadfilexit()
{
	/*var chk = chkuploadfields();
	if(chk!=false)
	{*/
		document.upload.action="save_upload_filexit.php";
		document.upload.submit();
	//}
}
/*function chkuploadfields()
{
	photo1=document.upload.photo1.value;
	photo2=document.upload.photo2.value;
	photo3=document.upload.photo3.value;
	photo4=document.upload.photo4.value;
	photo5=document.upload.photo5.value;
	
	if(photo1=="")
	{
		alert("Choose File1 to upload");
		document.upload.photo1.focus();
		return false;
	}
	if(photo2=="")
	{
		alert("Choose File2 to upload");
		document.upload.photo2.focus();
		return false;
	}
	if(photo3=="")
	{
		alert("Choose File3 to upload");
		document.upload.photo3.focus();
		return false;
	}	
	if(photo4=="")
	{
		alert("Choose File4 to upload")
		document.upload.photo4.focus();
		return false;
	}
	if(photo5=="")
	{
		alert("Choose File5 to upload");
		document.upload.photo5.focus();
		return false;
	}
}*/