function checkSingIn(input) {
  if (input.value.match(/^[0-9]*$/)) {
    document.forms['sign_in_form'].submit[0].disabled = document.forms['sign_in_form'].submit[1].disabled = false;
    document.forms['sign_in_form'].submit[0].className = document.forms['sign_in_form'].submit[1].className = 'btns';
  }
  else {
    document.forms['sign_in_form'].submit[0].disabled = document.forms['sign_in_form'].submit[1].disabled = true;
    document.forms['sign_in_form'].submit[0].className = document.forms['sign_in_form'].submit[1].className = 'btns disabled';
  }
}

function checkStep1(form) {
  with (form) {
    if (ltrim(Email.value)=='') { alert(form.name == 'sign_in_form' ? 'Visitor ID or E-mail address not specified' : 'E-mail address not specified'); return false; }
    if (form.name != 'sign_in_form')
    {
      if (ltrim(Name.value)=='') { alert('Name not specified'); return false; }
      if (ltrim(Phone.value)=='') { alert('Telephone number not specified'); return false; }
      if (ltrim(Country.options[Country.options.selectedIndex].value)=='') { alert('Country not specified'); return false; }
    }
  }
  return true;
}

function check() {
	with (document.forms['registration_download']) {
    if (ltrim(Company.value)=='') { alert('Company not specified'); return false; }
		if (ltrim(NumberStreet.value)=='') { alert('Number & Street not specified'); return false; }
		if (ltrim(City.value)=='') { alert('City not specified'); return false; }
		if (ltrim(State.options[State.options.selectedIndex].value)=='') { alert('State not specified'); return false; }
		if (ltrim(ZipCode.value)=='') { alert(' Postal / Zip Code not specified'); return false; }
    
    if (SelectTimeframe && ltrim(SelectTimeframe.value)=='') { alert('CMS selection timeframe not specified'); return false; }				
    if (CMSPhase && ltrim(CMSPhase.value)=='') { alert('Phase of CMS selection not specified'); return false; }				
    if (BudgetAllocated  && ltrim(BudgetAllocated.value)=='') { alert('Budget allocated field not specified'); return false; }
		
    if (elements['Reason']) {
			if (ltrim(Reason.value)=='') { alert('Reason for request not specified'); return false; }
		}			
	}
  return true;
}

function check_2() {
	with (document.forms['registration_download_customer_id']) {
		if (ltrim(CustomerCode.value)=='') { alert('Customer ID not specified'); return false; }
		if (elements['Reason']) {
			if (ltrim(Reason.value)=='') { alert('Reason for download not specified'); return false; }
		}	
	}
}

function salesForceCheck() {
	
	if (check())
  {
    var frame = window.frames['salesforce'];
    if (frame)
    {
      var form = frame.document.forms[0];
      with (document.forms['registration_download']) {
        form.first_name.value = ltrim(Name.value);
        form.last_name.value  = ltrim(Name.value);
        form.email.value      = ltrim(Email.value);
        form.company.value    = ltrim(Company.value);
        form.city.value       = ltrim(City.value);
        form.state.value      = ltrim(State.options[State.options.selectedIndex].innerHTML.replace(/\r|\n/, ''));
      }	  
      form.submit();
    }
    setTimeout(function() { document.forms['registration_download'].submit(); }, 700);
  }
  return false;
}

function ltrim(str) {
	while (str.charAt(0) == " ")
		str = str.substring(1, str.length);
	return str;
}