function showDropDown()
{
	 document.getElementById("linkDrop").style.display = "inline";
}
function hideDropDown()
{
	 document.getElementById("linkDrop").style.display = "none";
}
function showDropDown1()
{
	 document.getElementById("linkDrop2").style.display = "inline";
}
function hideDropDown1()
{
	 document.getElementById("linkDrop2").style.display = "none";
}


function check_admin_login()
{
	var check = checkLoginFields();
	if(check!=false)
	{
		document.admin_login.action="check_admin_login.php";
		document.admin_login.submit();
	}
}
function checkLoginFields()
{
		if(document.admin_login.username.value=="")
		{
				alert("Enter username.");
				document.admin_login.username.focus();
				return false;
		}
		if(document.admin_login.pwd.value=="")
		{
				alert("Enter password.");
				document.admin_login.pwd.focus();
				return false;
		}
}

function selectAll(action)
{
		if(action=='user')
		{
			var arrAll = document.getElementsByName('chkUser');
		}
		if(action=='member')
		{
			var arrAll = document.getElementsByName('chkUser');
		}
		if(action=='cure')
		{
			var arrAll = document.getElementsByName('chkCure');
		}
		if(action=='search')
		{
				var arrAll = document.getElementsByName('chkUser');
		}
		for(var j=0;j<arrAll.length;j++)
		{
			if(document.getElementById('checkAll').checked)
			{
				arrAll[j].checked= true;
			}
			else
			{
				arrAll[j].checked= false;
			}
		}
}



function change_admin_password()
{
	var check = checkPasswordFields();
	if(check!=false)
	{
		document.change_admin_pwd.action="save_admin_password.php";
		document.change_admin_pwd.submit();
	}
}
function checkPasswordFields()
{
		if(document.change_admin_pwd.oldPwd.value=="")
		{
				alert("Enter your old password.");
				document.change_admin_pwd.oldPwd.focus();
				return false;
		}
		if(document.change_admin_pwd.newPwd.value=="")
		{
				alert("Enter your new password.");
				document.change_admin_pwd.newPwd.focus();
				return false;
		}
		if(document.change_admin_pwd.confirmPwd.value=="")
		{
				alert("Re-enter the password to confirm.");
				document.change_admin_pwd.confirmPwd.focus();
				return false;
		}
}

function submit_content_page()
{
	var check = check_content_fields();
	if(check!=false)
	{
		document.cms.action="save_content_data.php";
		document.cms.submit();	
	}
}
function check_content_fields()
{
	if(document.cms.pages.options[document.cms.pages.selectedIndex].value=="0")
		{
				alert("Select the Page.");
				document.cms.pages.focus();
				return false;
		}
}

function getSelectedPageId()
{
	
	if(document.cms.pages.options[document.cms.pages.selectedIndex].value!=0)
	{
		var pageId = document.cms.pages.options[document.cms.pages.selectedIndex].value;
		document.cms.pageValue.value = pageId;
		document.cms.action = "manage_cms.php";
		document.cms.submit();	
		
	}
	
}

function submit_coupon(action)
{
	var check = check_coupon_fields(action);
	if(check!=false)
	{
		document.coupon.action="save_coupon_data.php?action="+action;

		document.coupon.submit();	
	}	
}

function check_coupon_fields(action)
{
	if((action=="edit") && (action=="expire") && (action=="delete"))
	{
			if(document.coupon.coupon_code.options[document.coupon.coupon_code.selectedIndex].value==0)
			{
					alert("Select Coupon Code.");
					document.coupon.coupon_code.focus();
					return false;
			}
			
	}
	if((action=="add") && (action=="edit"))
	{
		if(document.coupon.address.value=="")
		{
				alert("Enter Address.");
				document.coupon.address.focus();
				return false;
		}
		if(document.coupon.phone.value=="")
		{
				alert("Enter phone.");
				document.coupon.phone.focus();
				return false;
		}
		if(document.coupon.website_addr.value=="")
		{
				alert("Enter website address.");
				document.coupon.website_addr.focus();
				return false;
		}
		if(document.coupon.dataArea0.value=="")
		{
				alert("Enter end date.");
				document.coupon.dataArea0.focus();
				return false;
		}
		if(document.coupon.conditions.value=="")
		{
				alert("Enter terms/conditions.");
				document.coupon.conditions.focus();
				return false;
		}
		if(document.coupon.code.value=="")
		{
				alert("Enter coupon code.");
				document.coupon.code.focus();
				return false;
		}
	}
	
}

function getCouponCode()
{
	if(document.coupon.coupon_code.options[document.coupon.coupon_code.selectedIndex].value!=0)
	{
		var code = document.coupon.coupon_code.options[document.coupon.coupon_code.selectedIndex].value;
		document.coupon.codeValue.value = code;
		document.coupon.action = "edit_coupons.php";
		document.coupon.submit();	
		
	}	
}

function submit_change_password()
{
		if(document.change_pwd.new_pwd.value=="")
		{
				alert("Enter you new password.");
				document.change_pwd.new_pwd.focs();
				
		}
		else
		{
				document.change_pwd.action="save_change_password.php";
				document.change_pwd.submit();
		}
}