

$(document).ready(function(){

      $( "#register").click(function() {
      $("#registerformcontainer" ).dialog( "open" );
      });

      $( "#registerformcontainer" ).dialog({
      autoOpen: false,
      title: 'Register with Cubro',
      height: 670,
      width: 560,
      modal: true
      });

});


function pageSetUp(){
      $('txtUserName').focus();
      // clear these cookies
      storeCookie('OrderNumber','');
      storeCookie('DeliveryMethod','');
      }
      /* function to validate form field */

function validateForm()
      {

      var oForm = document.forms["frmCustomForm1"];
      var errors = [];
      var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
      var email = oForm._isb_EmailId1.value;
      var fname=oForm._isb_First_Name.value;
      var phone=oForm._isb_Contact_Phone.value;

      if(oForm._isb_First_Name.value=="")
      {
      errors[errors.length] = "Please enter your first name.";
      }

      if(oForm._isb_Last_Name.value=="")
      {
      errors[errors.length]="Please enter your last name";
  }

      if(oForm._isb_Company_or_Organization.value=="")
      {
      errors[errors.length]="Please enter your company or organization name";
       }

      if (oForm._isb_Company_or_Organization_Overview.value == "") {
          errors[errors.length] = "Please enter your company or organization overview";
      }
  

      if(oForm._isb_EmailId1.value=="")
      {
      errors[errors.length]="You must enter an email address";

      }
      else if (!ck_email.test(email)) {
      errors[errors.length]="You must enter a valid email address.";
      }
      if(oForm._isb_Contact_Phone.value=="")
      {
      errors[errors.length]="Please enter your phone number";
      }

      if(oForm._isb_Physical_Address1.value=="")
      {
      errors[errors.length]="Please enter your valid address";
      }
      if(oForm._isb_Physical_City_or_Town.value=="")
      {
      errors[errors.length]="Please enter your city or town name";
      }
      if(oForm._isb_Postal_Address1.value=="")
      {
      errors[errors.length]="Please enter your valid postal address.";
      }
      if(oForm._isb_Postal_City_or_Town.value=="")
      {
      errors[errors.length]="Please enter your postal city or town name.";
      }
      if (errors.length > 0) {
        reportErrors(errors);
        return false;
       }
            return true;
      }

function reportErrors(errors){
      var msg = "The correct the following errors and try again.\n";
      var ln=errors.length;
      for(var i=0;i<(ln);i++)
      {
      var errorNum=i+1;
      msg+="\n"+errorNum+". "+errors[i];
      }
      alert(msg);
}
