
function trim(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}
//////////////////////validation for Login Page////////////////////
function Logincheck(formNm)
{
	if(formNm.uname.value=='')
	{
		alert("Enter the User name.");
		formNm.uname.focus();
		return false;
	}
	else if(formNm.password.value=='')
	{
		alert("Enter the Password.");
		formNm.password.focus();
		return false;
	}
	else 
		return true;
}

/////////////////////////////////To Add category//////////////////
function Addcategorycheck(formNm)
{
	
	if(trim(formNm.cname.value)=='')
	{
		alert("Please enter the Category name.");
		formNm.cname.focus();
		return false;
	}
	else
		return true;
}


////////////////////////////////////Add Product check///////////////////

function Addproductcheck(formNm)
{
	/*alert("hi");*/
	if(formNm.prod_cat_id.value==0)
	{
		alert("Please select the category name");
		formNm.prod_cat_id.focus();
		return false;
	}
	else if(trim(formNm.prod_name.value)=='')
	{
		alert("Please enter the product name.");
		formNm.prod_name.focus();
		return false;
	}
	else if(trim(formNm.prod_old_price.value)=='')
	{
		alert("Please enter the old price.");
		formNm.prod_old_price.focus();
		return false;
	}
	/*else if(!/^[1-9.][0-9.]*$/.test(formNm.prod_old_price.value)){
		alert("Please enter a valid price");
		formNm.prod_old_price.focus();
		return false;
	}*/
	else if(trim(formNm.prod_new_price.value)=='')
	{
		alert("Please enter the new price.");
		formNm.prod_new_price.focus();
		return false;
	}
	/*else if(!/^[1-9.][0-9.]*$/.test(formNm.prod_new_price.value)){
		alert("Please enter a valid price");
		formNm.prod_new_price.focus();
		return false;
	}*/
	
	else
	{
		return true;
	}
}
//////////////////////////Search Category///////////////////////
function Searchcategory(formNm)
{
	if(trim(formNm.catname.value)=="")
	{
		alert("Please enter the text to search");
		formNm.catname.focus();
		return false;
	}
	else
		return true;
	
}
///////////////////////Search Product////////////////////////////
function Searchproduct(formNm)
{
	if((trim(formNm.txtProd.value)=="")&&(formNm.selCat.value=="0"))
	{
		alert("Please enter any one search content");
		formNm.selCat.focus();
		return false;
	}
	else
		return true;
	
}


/////////////////////////validation for Change password page///////////
function Changecheck(formNm)
{
	if(trim(formNm.uname.value)=='')
	{
		alert("Enter the User name.");
		formNm.uname.focus();
		return false;
	}
	else if(trim(formNm.opassword.value)=='')
	{
		alert("Enter the Old Password.");
		formNm.opassword.focus();
		return false;
	}
	else if(trim(formNm.npassword.value)=='')
	{
		alert("Enter the New Password.");
		formNm.npassword.focus();
		return false;
	}
	else if(trim(formNm.cpassword.value)=='')
	{
		alert("Enter the Confirm Password.");
		formNm.cpassword.focus();
		return false;
	}
	else if((formNm.cpassword.value)!=(formNm.npassword.value))
	{
		alert("New password and Confirm password are not same");
		formNm.cpassword.focus();
		return false;
	}
	else
		return true;
	
}

/////////////////////////Product category Drop///////////
function displayProd(inID){
	
		if (document.getElementById(inID).style.display == 'none') {
			document.getElementById(inID).style.display = 'block';
		}else{
			document.getElementById(inID).style.display = 'none';
		}

}

/////////////////////////Opens image in a pop up ///////////
function openimagepop(url){
	window.open(url,'ViewImage',"scrollbars=no,menubar=no,width=700,height=200");
}