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; }
	  CountryName.value = Country.options[Country.options.selectedIndex].innerHTML.replace(/\r|\n/, '');	  

    }
  }
  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(notFull) {
	
	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.country.value    = ltrim(CountryName.value);
		form.fax.value        = ltrim(Fax.value);
		form.zip.value        = ltrim(ZipCode.value);
		form.authorsNumber.value = ltrim(AuthorCount.options[AuthorCount.options.selectedIndex].innerHTML.replace(/\r|\n/, '')); //# of Authors
		form.phoneWithExt.value = ltrim(Phone.value); //Phone with extension
		form.city.value = ltrim(City.value); //City
		form.street.value     = ltrim (NumberStreet.value);
		var others = "";
		if (Position.options.selectedIndex != 0)
			others += "Position: " + ltrim(Position.options[Position.options.selectedIndex].innerHTML.replace(/\r|\n/, '')) + "\n";
		if (Referral.options.selectedIndex != 0)
			others += "Referral: " + ltrim(Referral.options[Referral.options.selectedIndex].innerHTML.replace(/\r|\n/, '')) + "\n";
		if (SelectTimeframe.options.selectedIndex != 0)
			others += "Timeframe for selecting a CMS: " + ltrim(SelectTimeframe.options[SelectTimeframe.options.selectedIndex].innerHTML.replace(/\r|\n/, '')) + "\n";
		if (CMSPhase.options.selectedIndex != 0)
			others += "Phase of CMS selection: " + ltrim(CMSPhase.options[CMSPhase.options.selectedIndex].innerHTML.replace(/\r|\n/, '')) + "\n";
		if (BudgetAllocated.options.selectedIndex != 0)
			others += "Budget allocated: " + ltrim(BudgetAllocated.options[BudgetAllocated.options.selectedIndex].innerHTML.replace(/\r|\n/, '')) + "\n";
		others += "Reason: " + Reason.value;
		form.description.value = others;
      }
	  
			
      form.submit();
    }
	
    setTimeout(function() { document.forms['registration_download'].submit(); }, 4000);
  }
  return false;
}

function ltrim(str) {
	while (str.charAt(0) == " ")
		str = str.substring(1, str.length);
	return str;
}