function validEmail(email) 
{ 
    if (email == ""){return false;} 
    badStuff = ";:/,' \"\\"; 
     
    for (i=0; i<badStuff.length; i++) 
    { 
        badCheck = badStuff.charAt(i) 
        if (email.indexOf(badCheck,0) != -1){return false;} 
    } 

    posOfAtSign = email.indexOf("@",1) 
     
    if (posOfAtSign == -1){return false;} 

    if (email.indexOf("@",posOfAtSign+1) != -1){return false;} 
    posOfPeriod = email.indexOf(".", posOfAtSign) 
     
    if (posOfPeriod == -1){return false;} 
    if (posOfPeriod+2 > email.length){return false;} 
     
return true; 
} 





function left_chk()
{

		var errorstr = '';
		var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
		
		with(document.formleft)
		{ 	
			if(username.value=='') { errorstr += "- Please enter username.\n"; }
			if (password.value=='') { errorstr += "- Please enter password.\n";}
		}	
		
		if (errorstr != '')
		{
			msgstr = msgstr + errorstr;
			alert(msgstr);
			return false;
		}
		else
		{
			return true;
		}	
			
} 



function IsEmpty(objWord)
{
	var blnIsEmpty = true;	
	var blnObjectPrm=false;
	var i=0;	
	var strWord='';
	var objThis;
	strWord = objWord;
	while(i<strWord.length && blnIsEmpty) {
		if (strWord.charAt(i)!=' ')
			blnIsEmpty=false;
		i++;
  	}
	if (blnIsEmpty)
	{
		return true;
	}
	else
	{
		return false;
	}
	
}




function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
	}
	else
	{
       countfield.value = maxlimit - field.value.length;
    }
}




// product add form
function validate_add_review(frm)
{
	var errorstr = '';
	var msgstr = "There is a slight problem with your form submission.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (IsEmpty(fullname.value)) { errorstr += "- Please enter your name.\n";}
		if (!validEmail(email.value)) { errorstr += "- Please enter a valid email address.\n";}
		if (IsEmpty(title.value)) { errorstr += "- Please enter review title.\n";}
		if (code.value=='') { errorstr += "- Please enter image code.\n";}
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}


function validate_forgot(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (IsEmpty(account_number.value)) { errorstr += "- Please enter account number.\n";}
		if (!validEmail(email.value)) { errorstr += "- Please enter a valid email address.\n";}
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}





function validate_recommend(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (IsEmpty(Full_Name.value)) { errorstr += "- Please enter full name.\n";}
		if (IsEmpty(Address.value)) { errorstr += "- Please enter address.\n";}
		if (IsEmpty(Telephone.value)) { errorstr += "- Please enter telephone.\n";}
		if (!validEmail(Email_Address.value)) { errorstr += "- Please enter a valid email address.\n";}
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}






function validate_subscribe(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		
		if (!validEmail(email.value)) { errorstr += "- Please enter a valid email address.\n";}
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}







function validate_new_account(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (IsEmpty(acc_no.value)) { errorstr += "- Please enter account number.\n";}
		if (IsEmpty(postcode.value)) { errorstr += "- Please enter post code.\n";}
		if (IsEmpty(contact_name.value)) { errorstr += "- Please enter contact name.\n";}
		if (IsEmpty(telephone.value)) { errorstr += "- Please enter telephone.\n";}
		if (IsEmpty(address1.value)) { errorstr += "- Please enter address line 1.\n";}
		
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}


function validate_set_password(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (!validEmail(email.value)) { errorstr += "- Please enter a valid email address.\n";}
		if (IsEmpty(password.value)) { errorstr += "- Please enter a password.\n";}
		if (password.value!=cpassword.value) { errorstr += "- Please enter same passwords in both the textboxes.\n";}
	}
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}



function validate_change_password(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (!IsEmpty(password.value))
		{
			if (password.value!=cpassword.value) { errorstr += "- Please enter same passwords in both the textboxes.\n";}
		}
		if (!validEmail(email.value)) { errorstr += "- Please enter a valid email address.\n";}
		if (IsEmpty(password_hint.value)) { errorstr += "- Please enter a password hint.\n";}
		
	}
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}







function validate_claim_1(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (i_accept.checked==false) { errorstr += "- Please accept the terms and conditions.\n";}
		
		
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}





function validate_claim_2(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (store.value=='') { errorstr += "- Please select a store.\n";}
		
		
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}



function validate_claim_3(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (amount.value=='') { errorstr += "- Please enter order amount.\n";}
		
		
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}



function validate_claim_4(frm)
{
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (IsEmpty(amount.value)) { errorstr += "- Please enter order amount.\n";}
		if (IsEmpty(commission.value)) { errorstr += "- Please enter missing commission .\n";}
		if (IsEmpty(order_number.value)) { errorstr += "- Please enter order number.\n";}
		if (IsEmpty(transaction_ref.value)) { errorstr += "- Please enter transaction reference.\n";}
		
		
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}

