function checkValueNotNull(val)
{
  if (val == null || val == "" || val == 0)
  {
    return false;
  }
  else
  {
    return true;
  }
}

function checkRegisterMode2(thisForm)
{    
  
  var bValid = true;  
  var red = '#CC0000';
  var black = '#000000';
  var msg = 'Please make sure the following fields are filled in correctly before proceeding:\n';

  ChangeColor('lbOSTKLogin', black);
  ChangeColor('lbOSTKpass', black);
  ChangeColor('lbUserID', black);  
  ChangeColor('lbFirstName', black);
  ChangeColor('lbLastName', black);
   
  
  if (!isEmailEx(thisForm.edOSTKLogin.value))
  {
    msg += 'Overstock Username is not a valid email address\n';
    ChangeColor('lbOSTKLogin', red);    
    bValid =  false;
  }

  if (!checkValueNotNull(thisForm.edOSTKpass.value))
  {
    msg += 'Password\n';
    ChangeColor('lbOSTKpass', red);
    bValid = false;
  }
      
  if (!checkValueNotNull(thisForm.edLogin.value))
  {
    msg += 'Screen Name\n';
    ChangeColor('lbUserID', red);
    bValid = false;
  }  
  
  if (!checkValueNotNull(thisForm.edFirst.value))
  {
    msg += 'First Name\n';
    ChangeColor('lbFirstName', red);
    bValid = false;
  }
    
  if (!checkValueNotNull(thisForm.edLast.value))
  {
    msg += 'Last Name\n';
    ChangeColor('lbLastName', red);
    bValid =  false;
  }
  
  if (!thisForm.agree.checked)
  {   
    msg += 'Please accept the Terms and Conditions by clicking below.\n'; 
    bValid = false;
  }
          
           
  var el = document.getElementById("ValidationMsg");
  ChangeColor("ValidationMsg", red);
  
  if(bValid)
  {
    el.style.visibility = 'hidden';
  }
  else
  {
    alert(msg);
    el.style.visibility = 'visible';
  }
  
  return bValid;
}

function checkRegisterMode3(thisForm)
{
  var bValid = true;  
  var red = '#CC0000';
  var black = '#000000';
  var msg = 'Please make sure the following fields are filled in correctly before proceeding:\n';

  ChangeColor('ccFirstName', black);      
  ChangeColor('ccLastName', black);
  ChangeColor('ccNum', black);    
  ChangeColor('ccAddress', black);
  ChangeColor('ccCity', black);
  ChangeColor('ccMonth',black);
  ChangeColor('ccYear',black);
  ChangeColor('ccState', black);
  ChangeColor('ccZip', black);
  ChangeColor('ccPhone', black);  
  ChangeColor('shipAddress', black);
  ChangeColor('shipCity', black);
  ChangeColor('shipState', black);
  ChangeColor('shipZip', black);
   

  if (!checkValueNotNull(thisForm.ccFirstname.value))
  {
    msg += 'Credit Card First Name\n';
    ChangeColor('ccFirstName', red);    
    bValid =  false;
  }
  
  if (!checkValueNotNull(thisForm.ccLastname.value))
  {
    msg += 'Credit Card Last Name\n';
    ChangeColor('ccLastName', red);    
    bValid =  false;
  } 
  
  if (!checkValueNotNull(thisForm.ccNum.value))
  {
    msg += 'Credit Card Number\n';
    ChangeColor('ccNum', red);    
    bValid =  false;
  }
  
  if (!checkValueNotNull(thisForm.ccAddress1.value))
  {
    msg += 'Credit Card Address\n';
    ChangeColor('ccAddress1', red);    
    bValid =  false;
  }     
  
  if (!checkValueNotNull(thisForm.ccCity.value))
  {
    msg += 'Credit Card City\n';
    ChangeColor('ccCity', red);    
    bValid =  false;
  }
    
  if (!checkValueNotNull(thisForm.ccMonth.value))
  {
    msg += 'Credit Card Month\n';
    ChangeColor('ccMonth', red);    
    bValid =  false;
  }  
  
  if (!checkValueNotNull(thisForm.ccYear.value))
  {
    msg += 'Credit Card Year\n';
    ChangeColor('ccYear', red);    
    bValid =  false;
  } 
  
  if (!checkValueNotNull(thisForm.ccState.value))
  {
    msg += 'Credit Card State\n';
    ChangeColor('ccState', red);    
    bValid =  false;
  }   

  if (!checkValueNotNull(thisForm.ccZip.value))
  {
    msg += 'Credit Card Zip Code\n';
    ChangeColor('ccZip', red);    
    bValid =  false;
  }  
  
  if (!checkValueNotNull(thisForm.ccPhone.value))
  {
    msg += 'Credit Card Phone\n';
    ChangeColor('ccPhone', red);    
    bValid =  false;
  }
    
  if (!checkValueNotNull(thisForm.shipAddress1.value) && !thisForm.same.checked)
  {
    msg += 'Shipping Address\n';
    ChangeColor('shipAddress1', red);    
    bValid =  false;
  }     
  
  if (!checkValueNotNull(thisForm.shipCity.value) && !thisForm.same.checked)
  {
    msg += 'Shipping City\n';
    ChangeColor('shipCity', red);    
    bValid =  false;
  }
      
  if (!checkValueNotNull(thisForm.shipState.value) && !thisForm.same.checked)
  {
    msg += 'Shipping State\n';
    ChangeColor('shipState', red);    
    bValid =  false;
  }       
  
  if (!checkValueNotNull(thisForm.shipZip.value) && !thisForm.same.checked)
  {
    msg += 'Shipping Zip Code\n';
    ChangeColor('shipZip', red);    
    bValid =  false;
  }  
  
  if (!checkValueNotNull(thisForm.shipPhone.value) && !thisForm.same.checked)
  {
    msg += 'Shipping Phone\n';
    ChangeColor('shipPhone', red);    
    bValid =  false;
  }  
  
  if (!checkValueNotNull(thisForm.birthYear.value))
  {
    msg += 'Birth Year\n';
    ChangeColor('birthYear', red);
    bValid = false;
  }
  
  if (!checkValueNotNull(thisForm.birthMonth.value))
  {
    msg += 'Birth Month\n';
    ChangeColor('birthMonth', red);
    bValid = false;
  }
  
  if (!checkValueNotNull(thisForm.birthDay.value))
  {
    msg += 'Birth Day\n';
    ChangeColor('birthDay', red);
    bValid = false;
  }
    
    
  var el = document.getElementById("ValidationMsg");
  ChangeColor("ValidationMsg", red);
  
  if(!bValid)
  {    
    alert(msg);
    el.style.visibility = 'visible';
  }
  
  return bValid;  
}

function checkRegisterMode4(thisForm)
{    
  
  var bValid = true;    
  var msg = 'Please accept the Terms and Conditions by clicking below.\n';

  if (!thisForm.agree.checked)
  {    
    bValid = false;
  }
          
  if(!bValid)
  {
    alert(msg); 
  }
  
  return bValid;
}

function toggleShipping(thisForm)
{
  if (thisForm.same.checked)
  {
    thisForm.shipAddress1.disabled=true;
    thisForm.shipAddress2.disabled=true;
    thisForm.shipCity.disabled=true;
    thisForm.shipState.disabled=true;
    thisForm.shipZip.disabled=true;
    thisForm.shipPhone.disabled=true;
  }
  else
  {
    thisForm.shipAddress1.disabled=false;
    thisForm.shipAddress2.disabled=false;
    thisForm.shipCity.disabled=false;
    thisForm.shipState.disabled=false;    
    thisForm.shipZip.disabled=false;
    thisForm.shipPhone.disabled=false;
  }
}