
// FUNCTION TO FIND THE FIELD THE EMPTY FIELD OF LOGIN FORM
function checkLoginEmpty()
{
	if(document.getElementById("user_id").value == "")
	{
		alert ("Please Fill the Username");	
		document.getElementById("user_id").focus();	
		return false;
	}
	if(document.getElementById("user_password").value == "")
	{
		alert ("Please Fill the Password");	
		document.getElementById("user_password").focus();	
		return false;
	}
}


// FUNCTION TO FIND THE FIELD THE EMPTY FIELD OF CHANGE PASSWORD FORM 
function checkEmptyPassword()
{
	if(document.getElementById("newpassword").value == "")
	{	
		alert ("Please Fill the New Password. New Password Cannot be Blank !!");	
		document.getElementById("newpassword").focus();
		return false; 
	}
	if(document.getElementById("confpassword").value == "")
	{
		alert ("Please Fill the Confirm Password. Re-enter Password !!");	
		document.getElementById("confpassword").focus(); 
		return false;	
	}
	if(document.getElementById("newpassword").value != document.getElementById("confpassword").value)	
	{
		alert ("Your Confirm Password is not Matched with New Password");
		document.getElementById("confpassword").focus(); 
		return false;	
	}
}
// END OF FUNCTION


// FUNCTION TO FIND THE FIELD THE EMPTY FIELD OF ADD CATEGORY FORM 
function checkEmptyProductCategory()
{
	if(document.add_product_category.categoryname.value == "")
	{
		alert("Category Name Cannot be blank. Please Enter a Category Name First !!!");
		document.add_product_category.categoryname.focus();
		return false;
	}
}

// FUNCTION TO OPEN THE PAGE
function open_category(url_link)
{
	window.open(url_link+document.update_supplier.categories.value,'Category_And_Subcategory','width=600,height=500,menubar=no,status=yes,location=no,toolbar=no,scrollbars=yes');
}
// END OF FUNCTION


// FUNCTION TO OPEN THE PAGE
function open_category_supplier(url_link)
{
	window.open(url_link+document.add_supplier.categories.value,'Category_And_Subcategory','width=600,height=500,menubar=no,status=yes,location=no,toolbar=no,scrollbars=yes');
}
// END OF FUNCTION





// VALIDATE UNAUTHENTICATE
function validate_unauthenticate()// this function is for confirming unauthentication of supplier
{
	var response;	
	response = window.confirm("Are You sure you want to UnAuthenticate this Supplier");	
	if(!response)
	{		
		return false;
	}
	return true;
}
// end function


// FUNCTION TO DISPLAY THE OTHER TEXT BOX
function display_other_text_box_shipping()
{
	var other;
	other = "<input type='text' name='other_shipping' id='other_shipping'>";
	if(document.getElementById("shipping_method_other").checked == true)
	{
		document.getElementById("other_shipping_method").innerHTML = other;
	}
	else
	{
		document.getElementById("other_shipping_method").innerHTML = "";
	}
	
}
// END OF FUNCTION



// FUNCTION TO DISPLAY THE OTHER TEXT BOX
function display_other_text_box_payment_second()
{
	var other;
	other = "<input type='text' name='other_pay' id='other_pay'>";
	if(document.getElementById("second_payment_other").checked == true)
	{
		document.getElementById("other_second_payment").innerHTML = other;
	}
	else
	{
		document.getElementById("other_second_payment").innerHTML = "";
	}
	
}
// END OF FUNCTION


// FUNCTION TO CHECK THE MEMBER REGISTRATION FORM
function check_member_registration()
{
	if(document.getElementById("first_name").value == "")
	{	
		alert ("Please Enter the First Name !!");	
		document.getElementById("first_name").focus();
		return false; 
	}
	if(document.getElementById("last_name").value == "")
	{
		alert ("Please Enter the Last Name !!");	
		document.getElementById("last_name").focus(); 
		return false;	
	}
	if(document.getElementById("email_id").value == "")	
	{
		alert ("Your Enter the Email Id");
		document.getElementById("email_id").focus(); 
		return false;	
	}
	if(document.getElementById("country").value == 0)	
	{
		alert ("Your Select the Country");
		document.getElementById("country").focus(); 
		return false;	
	}
}
// END OF FUNCTION

// DISPLAY ANSWERS ON SUPPORT PAGE
function display_answer(n) 
{ 
	if ((document.getElementById(n).style.display == "") || (document.getElementById(n).style.display == "none")) 
	{ 
		document.getElementById(n).style.display = "block"; 
		document.getElementById(n + "btn").src = "images/collapse.gif";
	}
	else
	{
		document.getElementById(n).style.display = "none"; 
		document.getElementById(n + "btn").src = "images/expand.gif";
	} 
}
// END OF FUNCTIONS





// FUNCTION TO CHECK THE ADVERTISE US FORM FIELDS
function check_advertise_us_form()
{
	if(document.getElementById("").value == "")
	{
		alert("");
		document.getElementById("").focus();
		return false;
	}
}
// END OF FUNCTION



// FUNCTION TO CHECK THE MEMBER REGISTRATINO AFTER CONFIRMATION
function check_member_registration_after_paypal()
{
	if(document.getElementById("user_id").value == "")
	{	
		alert ("Please Fill the User Id !!");	
		document.getElementById("user_id").focus();
		return false; 
	}
	if(document.getElementById("password").value == "")
	{	
		alert ("Please Fill the Password. Password Cannot be Blank !!");	
		document.getElementById("password").focus();
		return false; 
	}
	if(document.getElementById("confirm_password").value == "")
	{
		alert ("Please Fill the Confirm Password. Re-enter Password !!");	
		document.getElementById("confirm_password").focus(); 
		return false;	
	}
	if(document.getElementById("password").value != document.getElementById("confirm_password").value)	
	{
		alert ("Your Confirm Password is not Matched with Password");
		document.getElementById("confirm_password").focus(); 
		return false;	
	}
	if(document.getElementById("first_name").value == "")
	{
		alert ("Please Fill the First Name !!");	
		document.getElementById("first_name").focus(); 
		return false;	
	}
	if(document.getElementById("last_name").value == "")
	{
		alert ("Please Fill the Last Name !!");	
		document.getElementById("last_name").focus(); 
		return false;	
	}
	if(document.getElementById("email_id").value == "")
	{
		alert ("Please Fill the Email Id !!");	
		document.getElementById("email_id").focus(); 
		return false;	
	}
	if(document.getElementById("confirm_email").value == "")
	{
		alert ("Please Fill the Confirm Email Id !!");	
		document.getElementById("confirm_email").focus(); 
		return false;	
	}
	if(document.getElementById("email_id").value != document.getElementById("confirm_email").value)	
	{
		alert ("Your Confirm Email is not Matched with Email");
		document.getElementById("confirm_email").focus(); 
		return false;	
	}
}
// END OF FUNCTION


// FUNCTION TO CHECK THE SUPPLIER REGISTERATION FORM
function check_supplier_registration_form()
{
	if(document.getElementById("accept_statement").checked == false)
	{
		alert("Please First Accept the Statement of BigBrand Wholesale Suppliers Listing then Continue");
		document.getElementById("accept_statement").focus();
		return false;
	}
	if(document.getElementById("company_name").value == "")
	{
		alert("Please Enter the Company Name");
		document.getElementById("company_name").focus();
		return false;
	}
	if(document.getElementById("supplier_website").value == "")
	{
		alert("Please Enter the Website Address without http://www.");
		document.getElementById("supplier_website").focus();
		return false;
	}
	if(document.getElementById("address1").value == "")
	{
		alert("Please Enter the Address");
		document.getElementById("address1").focus();
		return false;
	}
	if(document.getElementById("city").value == "")
	{
		alert("Please Enter the City");
		document.getElementById("city").focus();
		return false;
	}
	if(document.getElementById("state").value == "")
	{
		alert("Plese Enter the State");
		document.getElementById("state").focus();
		return false;
	}
	if(document.getElementById("zip").value == "")
	{
		alert("Please Enter the Zip Code");
		document.getElementById("zip").focus();
		return false;
	}
	if(document.getElementById("country").value == 0)
	{
		alert("Please Select the Country");
		document.getElementById("country").focus();
		return false;
	}
	if(document.getElementById("contact_name").value == "")
	{
		alert("Please Enter the Contact Person Name of the Supplier");
		document.getElementById("contact_name").focus();
		return false;
	}
	if(document.getElementById("contact_email").value == "")
	{
		alert("Please Enter the Contact Person Email Id");
		document.getElementById("contact_email").focus();
		return false;
	}
	if(document.getElementById("contact_phone").value == "")
	{
		alert("Please Enter the Phone Number");
		document.getElementById("contact_phone").focus();
		return false;
	}
	if((document.getElementById("supplier_type_wholesaler").checked == false) && (document.getElementById("supplier_type_dropshipper").checked == false) && (document.getElementById("supplier_type_manufacturer").checked == false) && (document.getElementById("supplier_type_liquidator").checked == false))
	{
		alert("Please Select the Business Type");		
		return false;
	}
	if((document.getElementById("international_shipping_yes").checked == false) && (document.getElementById("international_shipping_no").checked == false))
	{
		alert("Please Select The International Shipping");		
		return false;
	}
	if((document.getElementById("dropshipping_yes").checked == false) && (document.getElementById("dropshipping_no").checked == false))
	{
		alert("Please Select the Dropshipping");		
		return false;
	}
	if(document.getElementById("categories_show").value == "")
	{
		alert("Please Select Atleast 10 Categories");
		document.getElementById("categories_show").focus();
		return false;
	}
	if((document.getElementById("shipping_method_ups").checked == false) && (document.getElementById("shipping_method_usps").checked == false) && (document.getElementById("shipping_method_fedex").checked == false) && (document.getElementById("shipping_method_dhl").checked == false) && (document.getElementById("shipping_method_other").checked == false))
	{
		alert("Please Select the Shipping Method");		
		return false;
	}
	if(document.getElementById("minimum_order").value == "")
	{
		alert("Please Enter The Minimum Order");
		document.getElementById("minimum_order").focus();
		return false;
	}
	if((document.getElementById("reseller_tax_id_yes").checked == false) && (document.getElementById("reseller_tax_id_no").checked == false))
	{
		alert("Please Select the Reseller");		
		return false;
	}
	if((document.getElementById("first_payment_credit_card").checked == false) && (document.getElementById("first_payment_paypal").checked == false) && (document.getElementById("first_payment_escrow").checked == false) && (document.getElementById("first_payment_cod").checked == false) && (document.getElementById("first_payment_letter").checked == false))
	{
		alert("Please Select the First Payment Method");		
		return false;
	}
	if((document.getElementById("second_payment_wes").checked == false) && (document.getElementById("second_payment_bank").checked == false) && (document.getElementById("second_payment_other").checked == false))
	{
		alert("Please Select the Second Payment Method");		
		return false;
	}
	if(document.getElementById("description").value == "")
	{
		alert("Please Enter the Breif Description");
		document.getElementById("description").focus();
		return false;
	}
	if(document.getElementById("products").value == "")
	{
		alert("Please Enter the Products separated by the comma");
		document.getElementById("products").focus();
		return false;
	}
}
// END OF FUNCTION



/*
//  check for valid numeric strings         
function IsNumeric(strString)
{
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

function deleteproduct()
{
	if(confirm("Are you sure You want to delete Product?")==true)
		return true;
  	else
    	return false;
	
}
function deletecategory()
{
	if(confirm("Are you sure You want to delete Category?")==true)
		return true;
  	else
    	return false;
	
}
*/

function validate_registration_form()
{
	var emailValidation = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	var only_chars		= /^[a-zA-z\s]+$/;
	var only_nums		= /^[0-9]+$/;
	
	if(document.getElementById("dd").value=="")
	{
		alert("Please Select Date !");
		document.getElementById("dd").focus();	
		return false;
	}
	if(document.getElementById("mm").value=="")
	{
		alert("Please Select Month !");
		document.getElementById("mm").focus();	
		return false;
	}
	if(document.getElementById("yy").value=="")
	{
		alert("Please Select Year !");
		document.getElementById("yy").focus();	
		return false;
	}
	if(document.getElementById("location").value=="")
	{
		alert("Please Select Location !");
		document.getElementById("location").focus();	
		return false;
	}
	
	if(document.getElementById("f_name").value=="")
	{
		alert("Please enter the First Name");
		document.getElementById("f_name").focus();	
		return false;
	}
	if(!document.getElementById("f_name").value.match(only_chars))
	{
		alert("Please enter only alphabets for the First Name");
		document.getElementById("f_name").focus();	
		return false;
	}
	
	if(document.getElementById("l_name").value=="")
	{
		alert("Please enter the Last Name");
		document.getElementById("l_name").focus();	
		return false;
	}
	if(!document.getElementById("l_name").value.match(only_chars))
	{
		alert("Please enter only alphabets for the Last Name");
		document.getElementById("l_name").focus();	
		return false;
	}
	
	if(document.getElementById("email").value=="")
	{
		alert("Please enter Email Id.");
		document.getElementById("email").focus();
		return false;
	}
	if(document.getElementById("email").value!="")
	{
		if(!(document.getElementById("email").value.match(emailValidation)))
		{
		alert("Please enter Valid Email Id.");
		document.getElementById("email").focus();
		return false;
		}
	}
	
	if(document.getElementById("company").value=="")
	{
		alert("Please enter Company.");
		document.getElementById("company").focus();
		return false;
	}
	
	if(document.getElementById("address").value=="")
	{
		alert("Please enter Address.");
		document.getElementById("address").focus();
		return false;
	}
	
	if(document.getElementById("phone").value=="")
	{
		alert("Please enter Phone No.");
		document.getElementById("phone").focus();
		return false;
	}
	if(document.getElementById("phone").value!="")
	{
		if(document.getElementById("phone").value.length<8 || document.getElementById("phone").value.length>14)
		{
			alert("Please enter the valid Phone Number");
			document.getElementById("phone").focus();
			return false;
		}
	
		if(isNaN(document.getElementById("phone").value))
		{
			alert("Please enter valid phone Number");
			document.getElementById("phone").focus();
			return false;
		}
	}
	
	
	if(document.getElementById("fax").value!="")
	{
		if(document.getElementById("fax").value.length<8 || document.getElementById("fax").value.length>14)
		{
			alert("Please enter the valid Fax Number");
			document.getElementById("fax").focus();
			return false;
		}
	
		if(isNaN(document.getElementById("fax").value))
		{
			alert("Please enter valid Fax Number");
			document.getElementById("fax").focus();
			return false;
		}
	}
}
