// JavaScript Document

function checkEmail()
{

if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.user_registration.email.value))
           {
				return true;
			}
		else
		{
			alert("Invalid E-mail Address! Please re-enter From Address.")
			document.user_registration.email.select();
			document.user_registration.email.focus();
			return false;
		} 
}

function mandatoryfill()
	{	
		var f1=document.user_registration;	
		
		if((f1.firstname.value==null)||(f1.firstname.value==""))
		{
			alert("First Name is mandatory");
			f1.firstname.focus();
			return false;
		}
		else if((f1.lastname.value==null)||(f1.lastname.value==""))
		{
			alert("Last Name is mandatory");
			f1.lastname.focus();
			return false;
		}
	 	 else if((f1.address1.value==null)||(f1.address1.value==""))
		{
			alert("address1 can not be blank");
			f1.address1.focus();
			return false;
		}
		
		else if((f1.city.value==null)||(f1.city.value==""))
		{
			alert("city is mandatory");
			f1.city.focus();
			return false;
		}
		else if(f1.country.value=="")
		{
			alert("Please select country");
			f1.country.focus();
			return false;
		}
		
		else if((f1.email.value==null)||(f1.email.value==""))
		{
			alert("email is mandatory");
			f1.email.focus();
			return false;
		}
		
		else if((f1.username.value==null)||(f1.username.value==""))
		{
			alert("User Name is mandatory");
			f1.username.focus();
			return false;
		}
		else if((f1.password.value==null)||(f1.password.value==""))
		{
			alert("Password is mandatory");
			f1.password.focus();
			return false;
		}
		else if((f1.passagain.value==null)||(f1.passagain.value==""))
		{
			alert("Please confirm your Password again");
			f1.passagain.focus();
			return false;
		}
		
		return true;
 	}
	
function ChkPassword()
 {
	 var f1=document.user_registration;
	 if(f1.password.value==f1.passagain.value)
	 {
		return true;
	 }
	 else
	 { 
	 	alert("Confirm passwords doesn't match");
		 f1.passagain.focus();
		return false;
	}
 }
 
function formvalidate()
{
	if((mandatoryfill()) && (checkEmail()) && ChkPassword())
	{	
		document.user_registration.submit();
	}
	
}

function Password()
 {
	 var f1=document.user_registration;
	 if((f1.password.value==null)||(f1.password.value==""))
		{
			alert("Password is mandatory");
			f1.password.focus();
			return false;
		}
		else if((f1.passagain.value==null)||(f1.passagain.value==""))
		{
			alert("Please confirm your Password again");
			f1.passagain.focus();
			return false;
		}
		return true;
 }
function SubmitInfo()
{
	if(ChkPassword() && Password())
	{	
		document.user_registration.submit();
	}
	
}



function ValidateReply()
{
	var f1=document.NewsPage;
	if((f1.reply.value==null)||(f1.reply.value==""))
		{
			alert("Sorry You Can't send blank reply");
			f1.reply.focus();
			return false;
		}
	return true;
}
function PostReply()
{
	if(ValidateReply())
	{	
		document.NewsPage.submit();
	}
	
}


function ValidateOffer()
{
	var f1=document.OffersPage;
	if((f1.offer_sub.value==null)||(f1.offer_sub.value==""))
		{
			alert("Subject can't be blank");
			f1.offer_sub.focus();
			return false;
		}
		else if((f1.offer.value==null)||(f1.offer.value==""))
		{
			alert("You can't send a blank offer");
			f1.offer.focus();
			return false;
		}
	return true;
}
function PostOffer()
{
	if(ValidateOffer())
	{	
		document.OffersPage.submit();
	}
	
}

function ValidateNews()
{
	var f1=document.NewsPAge;
	if((f1.news_heading.value==null)||(f1.news_heading.value==""))
		{
			alert("Heading can't be blank");
			f1.news_heading.focus();
			return false;
		}
		else if((f1.news.value==null)||(f1.news.value==""))
		{
			alert("You can't post a blank News");
			f1.news.focus();
			return false;
		}
	return true;
}
function PostNews()
{
	if(ValidateNews())
	{	
		document.NewsPAge.submit();
	}
	
}

function dotcheck()
 {
	 var str=document.discount.discount_rate.value;
	 
	 var dot="."
	 
	 if (str.indexOf(dot)==-1)
		{
		   alert("Enter value in 0.00 format")
		   return false;
		}
		return true;
}
		
		function ValidateDiscount()
		{
			if(document.discount.currency_id.value=="")
			{
			alert("Please select Currency")
		   return false;
		}
		
		return true;
 }
 function PostDiscount()
{
	var id=document.discount.ID.value;
	document.discount.method="post";
	document.discount.action="AdmServ?ID="+id;
	document.discount.param.value="updateDiscount";
	
		document.discount.submit();
	
	
}

function PostDiscount1()
{
	var id=document.discount.ID.value;
	document.discount.method="post";
	document.discount.action="AdmServ?ID="+id;
	document.discount.param.value="updateDiscount1";
	
		document.discount.submit();
	
	
}
function PostDiscount2()
{
	var id=document.discount.ID.value;
	document.discount.method="post";
	document.discount.action="AdmServ?ID="+id;
	document.discount.param.value="updateDiscount2";
	
		document.discount.submit();
	
	
}
function PostDiscount3()
{
	var id=document.discount.ID.value;
	document.discount.method="post";
	document.discount.action="AdmServ?ID="+id;
	document.discount.param.value="updateDiscount3";
	
		document.discount.submit();
	
	
}
function PostDiscount4()
{
	var id=document.discount.ID.value;
	document.discount.method="post";
	document.discount.action="AdmServ?ID="+id;
	document.discount.param.value="updateDiscount4";
	
		document.discount.submit();
	
	
}
function PostDiscount5()
{
	var id=document.discount.ID.value;
	document.discount.method="post";
	document.discount.action="AdmServ?ID="+id;
	document.discount.param.value="updateDiscount5";
	
		document.discount.submit();
	
	
}
function PostDiscount6()
{
	var id=document.discount.ID.value;
	document.discount.method="post";
	document.discount.action="AdmServ?ID="+id;
	document.discount.param.value="updateDiscount6";
	
		document.discount.submit();
	
	
}function PostDiscount7()
{
	var id=document.discount.ID.value;
	document.discount.method="post";
	document.discount.action="AdmServ?ID="+id;
	document.discount.param.value="updateDiscount7";
	
		document.discount.submit();
	
	
}function PostDiscount8()
{
	var id=document.discount.ID.value;
	document.discount.method="post";
	document.discount.action="AdmServ?ID="+id;
	document.discount.param.value="updateDiscount8";
	
		document.discount.submit();
	
	
}


function ValidateEnquiry()
{
	var f1=document.enq_form;
	if((f1.ques.value==null)||(f1.ques.value==""))
		{
			alert("Sorry You Can't send blank question");
			f1.ques.focus();
			return false;
		}
	return true;
}
function PostEnquiry()
{
	if(ValidateEnquiry())
	{	
		document.enq_form.submit();
	}
	
}

function cancel()
{
	history.back();
}

 