// Validation in javascript 
//==============================================
// Function name : validation_login
// Function Use : For validation
//====================================================================
function validation_login(){
	if(document.login_frm.username.value==""){
	alert("Enter The Username"); 
	document.login_frm.username.focus();
	return false;
	}
	if(document.login_frm.password.value==""){
	alert("Enter The Password"); 
	document.login_frm.password.focus();
	return false;
	}
}
//====================================================================
// Function name : changepass_validate
// Function Use : For validation
//====================================================================
function changepass_validate(){
	if(document.form1.opassword.value==""){
	alert("Enter The Old Password ...!");
	document.form1.opassword.focus();
	return false;
	}
	if(document.form1.npassword.value==""){
	alert("Enter The New Password ...!");
	document.form1.npassword.focus();
	return false;
	}
	if(document.form1.cpassword.value==""){
	alert("Enter The Con Password ...!");
	document.form1.cpassword.focus();
	return false;
	}
	if(document.form1.npassword.value!=document.form1.cpassword.value){
	alert("New Password And Confirm Password Is Not Same Password ...!");
	document.form1.cpassword.focus();
	return false;
	}
}
//======================================================================
// Function name : frmValidate_editpagename
// Function Use : For validation
//====================================================================
function frmValidate_editpagename(){
	if (document.edit_page_frm.pagesectionname.value==""){
		alert("Please Enter Page Name...!");
		document.edit_page_frm.pagesectionname.focus();
		return false;
	}
	if (document.edit_page_frm.meta_description.value==""){
		alert("Please Enter Meta Description...!");
		document.edit_page_frm.meta_description.focus();
		return false;
	}
	if (document.edit_page_frm.meta_keyword.value==""){
		alert("Please Enter Meta Keyword...!");
		document.edit_page_frm.meta_keyword.focus();
		return false;
	}
	if (document.edit_page_frm.page_title.value==""){
		alert("Please Enter Page Title...!");
		document.edit_page_frm.page_title.focus();
		return false;
	}
}

//====================================================================
function validate_addpage(){
	if (document.add_page_frm.page_title.value==""){
		alert("Please Enter Page Title...!");
		document.add_page_frm.page_title.focus();
		return false;
	}
	if (document.add_page_frm.meta_description.value==""){
		alert("Please Enter Meta Description...!");
		document.add_page_frm.meta_description.focus();
		return false;
	}
	if (document.add_page_frm.meta_keyword.value==""){
		alert("Please Enter Meta Keyword...!");
		document.add_page_frm.meta_keyword.focus();
		return false;
	}
	if (document.add_page_frm.pagesectionname.value==""){
		alert("Please Enter Page Name For English...!");
		document.add_page_frm.pagesectionname.focus();
		return false;
	}
	if (document.add_page_frm.pagesectionname_deutsch.value==""){
		alert("Please Enter Page Name For Deutsch...!");
		document.add_page_frm.pagesectionname_deutsch.focus();
		return false;
	}
	if (document.add_page_frm.pagebanner.value==""){
		alert("Please Enter Page Banner...!");
		document.add_page_frm.pagebanner.focus();
		return false;
	}
	
	
}
//========================================================================

//==============================================
// Function name : news_validate
// Function Use : For Newsletter validation
//==============================================
function news_validate(){
	if (document.frmnews.news_subject.value==""){
		alert("Please Enter News Subject...!");
		document.frmnews.news_subject.focus();
		return false;
	}
}

//========================================================================

// Function name : validate_addcategory
// Function Use : For validation
//====================================================================
function validate_addcategory()
{
	if(document.addcat_frm.catname.value=="")
	{
		alert("Please Enter Category Name...!");
		document.addcat_frm.catname.focus();
		return false;
	}
}
//====================================================================
// Function name : validate_editcategory
// Function Use : For validation
//====================================================================
function validate_editcategory()
{
	if(document.editcat_frm.catname.value=="")
	{
		alert("Please Enter Category Name...!");
		document.editcat_frm.catname.focus();
		return false;
	}
}

//====================================================================
// Function name : subscribe_validate
// Function Use : For Front subscribe validation
//====================================================================
function subscribe_validate()
{
	if(document.subscribeform.name.value=="Name" || document.subscribeform.name.value=="")
	{
		alert("Please Enter Subscriber Name...!");
		document.subscribeform.name.focus();
		return false;
	}
	
	if(document.subscribeform.email.value!="")
	{
		if(document.subscribeform.email.value.indexOf("@")==-1 ||
			document.subscribeform.email.value.indexOf(".")==-1 ||
			document.subscribeform.email.value.indexOf("")==-1 ||
			document.subscribeform.email.value.length < 6)
		{
			alert("Sorry, the e-Mail Address is not valid.");
			document.subscribeform.email.focus();
			return false;		
		}
	}
	else
	{
		alert("Please enter e-Mail Address.");
		document.subscribeform.email.focus();
		return false;	
	}
}

//====================================================================
// Function name : validate_categorylist
// Function Use : For validation
//====================================================================
function validate_memberlist()
{
	return confirm("Are You Sure To Delete This Member? ");
}

//====================================================================
// Function name : validate_categorylist
// Function Use : For validation
//====================================================================
function validate_categorylist()
{
	return confirm("Are You Sure To Delete This Category? ");
}
//====================================================================
// Function name : validate_addcategory
// Function Use : For validation
//====================================================================
function validate_addproduct()
{
	if(document.addproduct_frm.catid.value=="")
	{
		alert("Please Select Category Name...!");
		document.addproduct_frm.catid.focus();
		return false;
	}
	if(document.addproduct_frm.product_name.value=="")
	{
		alert("Please Enter Product Name...!");
		document.addproduct_frm.product_name.focus();
		return false;
	}
	if(document.addproduct_frm.product_price.value=="")
	{
		alert("Please Enter Product Price...!");
		document.addproduct_frm.product_price.focus();
		return false;
	}
	if(document.addproduct_frm.product_image.value=="")
	{
		alert("Please Browse Product Image...!");
		document.addproduct_frm.product_image.focus();
		return false;
	}
}
//====================================================================
// Function name : validate_editproduct
// Function Use : For validation
//====================================================================
function validate_editproduct()
{
	if(document.editproduct_frm.category.value=="")
	{
		alert("Please Select Category Name...!");
		document.editproduct_frm.category.focus();
		return false;
	}
	if(document.editproduct_frm.product_name.value=="")
	{
		alert("Please Enter Product Name...!");
		document.editproduct_frm.product_name.focus();
		return false;
	}
	if(document.editproduct_frm.product_price.value=="")
	{
		alert("Please Enter Product Price...!");
		document.editproduct_frm.product_price.focus();
		return false;
	}
}
//====================================================================
// Function name : validate_productlist
// Function Use : For validation
//====================================================================
function validate_productlist()
{
	return confirm("Are You Sure To Delete This Product ? ");
}
//====================================================================

//==============================================
// Function name : CheckAll
// Function Use : Check all checkboxes for send news 
//==============================================

function CheckAll(chk)
{
for (var i=0;i < document.forms[0].elements.length;i++)
	{
		var e = document.forms[0].elements[i];
		if (e.type == "checkbox")
		{
			e.checked = chk.checked;
		}
	}
}


//====================================================================================

function validate_sendnews()
{	
	if(document.frmsendnews.news_id.value=="")
	{
		alert("Please select newletter to send");
		document.frmsendnews.news_id.focus();
		return false;
		
	}
	var checked ;
	checked=false;
	elements=document.getElementsByName("subsc_id[]");
	for(var i=0; i < elements.length; i++)
    {
		if(elements[i].checked)
		{
			checked = true;
		}
	}
	
	if (!checked) {
		alert('Please select at least 1 email id  to send newletter');
		return false;
	}else
	{
		return checked;
	}
	

}

