function setFocus(f,d){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  document.forms[frm].elements[f].focus();
}
function testEmail(f,d){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  var a = document.forms[frm].elements[f].value;
  var at = a.indexOf("@")
  var name = a.substring(0, at)
  var isp = a.substring(at + 1, a.length)
  var dot = a.lastIndexOf(".")
  if (at == -1 || at == 0 || name == "" || isp == "" || dot == -1 || dot == (a.length - 1)) {
    alert('You must enter a valid Email Address');
    setFocus(f,d);
  } else {
    return true;
  }
}
function testEmailMsg(f,t,d){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  var a = document.forms[frm].elements[f].value;
  var at = a.indexOf("@")
  var name = a.substring(0, at)
  var isp = a.substring(at + 1, a.length)
  var dot = a.lastIndexOf(".")
  if (at == -1 || at == 0 || name == "" || isp == "" || dot == -1 || dot == (a.length - 1)) {
    alert('You must enter ' + t);
    setFocus(f,d);
  } else {
    return true;
  }
}
function testText(f,t,d){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  if(document.forms[frm].elements[f].value != ""){
    return true;
  } else {
    alert('You must enter ' + t);
    setFocus(f,d);
  }
}
function testAlphaPassword(f,d,t){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];
  var ele = doc.elements[f];
  var str = false;
  if(ele.value == ""){
    alert("Please enter your " + t);
    setFocus(f,d);
  } else {
    if(/[^a-zA-z0-9]/i.test(ele.value)){
      alert("Sorry, your " + t + " may only contain letters and numbers");
      setFocus(f,d);
    } else if(ele.value.indexOf('_') > -1){
      alert("Sorry, your " + t + " may only contain letters and numbers");
      setFocus(f,d);
    } else {
      str = true;
    }
  }
  return str;
}
function testArea(f,t){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  if(document.forms[frm].elements[f].length > 0){
    return true;
  } else {
    alert('You must enter ' + t);
    setFocus(f,d);
  }
}
function testDate(f,d){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  var a = document.forms[frm].elements[f].value;
  var dateObj = new Date(a);
  if(a == ""){
    alert('Please enter a date');
    setFocus(f,d);
  } else if(isNaN(dateObj)){
    alert('You must enter a valid date');
    setFocus(f,d);
  } else {
    return true;
  }
}
function testRadio(f,t,d){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  var radioName = document.forms[frm].elements[f];
  var str = "";
  for(i = 0; i < radioName.length; i++){
    if(radioName[i].checked == true){
      str = "yes";
	break;
    } else {
      str = "no";
    }
  }
  if(str == "yes"){
    return true;
  } else {
    alert('You must choose ' + t);
  }
}
function getRadioValue(f,d){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  var radioName = document.forms[frm].elements[f];
  var str = "";
  for(i = 0; i < radioName.length; i++){
    if(radioName[i].checked == true){
      str = radioName[i].value;
    }
  }
  return str;
}
function testCheck(f,t,d){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  var checkName = document.forms[frm].elements[f];
  var str = "";
  for(i = 0; i < checkName.length; i++){
    if(checkName[i].checked == true){
      str = "yes";
	break;
    } else {
      str = "no";
    }
  }
  if(str == "yes"){
    return true;
  } else {
    alert('You must choose ' + t);
  }
}
function testSelect(f,t,d){
  if(d.length > 0){
    var frm = d;
  } else {
    var frm = 0;
  }
  var sel = document.forms[frm].elements[f];
  if(sel.selectedIndex > 0){
    return true;
  } else {
    alert('You must select ' + t);
    setFocus(f,d);
  }
}
//************************************
function validate_enquiry(){
  var doc = document.forms[0];
  if( (doc.enquiryFirstName.value == "First name") || (doc.enquiryLastName.value == "Last name") || (doc.enquiryEmailAddress.value == "Email address") ){ 
    alert('You must enter your own name');
  } else if( testText('enquiryFirstName','your first name','0') && testText('enquiryLastName','your last name','0') && testEmail('enquiryEmailAddress','0') && testText('enquiryComments','a Question or Comment','0') ){
    if(doc.enquiryCompany.value == "Company"){ doc.enquiryCompany.value = ""; }
    if(doc.enquiryComments.value == "Comment" || doc.enquiryComments.value == "" ){
      alert("You must enter a comment");
    } else {
      var newdoc = document.forms['enquiry'];
      newdoc.FirstName.value = doc.enquiryFirstName.value;
      newdoc.LastName.value = doc.enquiryLastName.value;
      newdoc.EmailAddress.value = doc.enquiryEmailAddress.value;
      newdoc.Company.value = doc.enquiryCompany.value;
      newdoc.Comments.value = doc.enquiryComments.value;
      newdoc.ReturnURL.value = location.href;
      newdoc.submit();
    }
  }
}
function validate_live_help_enquiry(){
  var doc = document.forms['enquiry'];
  if( testText('FullName','your full name','enquiry') && testText('Company','your company','enquiry') && testEmail('EmailAddress','enquiry') && testText('Comments','a Question or Comment','enquiry') ){
    doc.ReturnURL.value = location.href;
    doc.submit();
  }
}
function setTechStepNumber(stepFrom,stepTo){
  if (stepFrom == "1") {
    if( (testText('Company','Company','')) && (testText('Company_Address1','Address','')) && (testText('Company_City','City','')) && (testSelect('Company_Country','Country','')) && (testText('Company_Telephone','Telephone','')) && (testText('Company_Fax','Fax','')) && (testText('Delivery_PreferredMethod','Method of Shipping','')) && (testText('Delivery_Problems','Customs Issues','')) ) {
      document.forms[0].StepNumber.value = stepTo;
      document.forms[0].submit();
    }
  } else if (stepFrom == "2" && stepTo != "1") {
    if( (testText('ManagementName','Management Contact Name','')) && (testText('ManagementTitle','Management Contact Job Title','')) && (testText('ManagementTelephone','Management Contact Telephone','')) && (testEmailMsg('ManagementEmail','a Management Contact Email','')) && (testText('TechName','Technical Contact Name','')) && (testText('TechTitle','Technical Contact Job Title','')) && (testText('TechTelephone','Technical Contact Telephone','')) && (testEmailMsg('TechEmail','a Technical Contact Email','')) && (testText('DataName','Data Contact Name','')) && (testText('DataTitle','Data Contact Job Title','')) && (testText('DataTelephone','Data Contact Telephone','')) && (testEmailMsg('DataEmail','a Data Contact Email','')) && (testText('ShippingName','Shipping Contact Name','')) && (testText('ShippingTitle','Shipping Contact Job Title','')) && (testText('ShippingTelephone','Shipping Contact Telephone','')) && (testEmailMsg('ShippingEmail','a Shipping Contact Email','')) ){
      document.forms[0].StepNumber.value = stepTo;
      document.forms[0].submit();
    }
  } else if (stepFrom == "2" && stepTo == "1") {
    document.forms[0].StepNumber.value = stepTo;
    document.forms[0].submit();
  } else if (stepFrom == "3" && stepTo != "2") {
    if ( (testRadio('EutelsatW2A','EutelsatW2A','')) && (testRadio('AsiaSat5','AsiaSat5','')) && (testRadio('AMC3','AMC3','')) && (testRadio('PanAmSat9','PanAmSat9','')) && (testText('DishSize','Dish Size','')) && (testRadio('DishConstruction','Dish Construction','')) && (testText('DishLocation','Dish Location','')) && (testRadio('DishMovement','Dish Movement','')) && (testRadio('LNB','LNB','')) && (testText('CableLength','Cable Length','')) && (testText('NewsroomSystem','Newsroom System','')) && (testRadio('FreePort','Free Port','')) && (testRadio('NewsDesk','News Desk','')) && (testRadio('Convertor','Convertor','')) && (testText('LNBMake','LNB Make','')) && (testText('LOFrequency','LO Frequency','')) && (testText('RFType','RF Type','')) && (testRadio('LineAMP','Line Amp','')) && (testRadio('Splitter','Splitter','')) ) {
      document.forms[0].StepNumber.value = stepTo;
      document.forms[0].submit();
    }
  } else if (stepFrom == "3" && stepTo == "2") {
    document.forms[0].StepNumber.value = stepTo;
    document.forms[0].submit();
  }
}
function cancelTechQuestionnaire(){
  document.forms[0].StepNumber.value = "CANCEL";
  document.forms[0].submit();
}
function validateBSEventBooking(){
  var str = document.forms[0].CompanyAddress.value;

  if( (testSelect('LivePosition','a Live Position','')) && (testDate('BookDate','')) && (testText('StartTime','Start Time','')) && (testText('EndTime','End Time','')) && (testRadio('Standard','a Standard','')) && (testSelect('Format','a Format','')) && (testText('DestinationCompany','Feed Destination Company','')) && (testText('DestinationCountry','Feed Destination Country','')) && (testSelect('Routing','a Routing','')) && (testText('Name','Name','')) && (testText('Company','Company','')) && (testText('CompanyAddress','Company Address','')) && (testText('City','City','')) && (testSelect('Country','a Country','')) && (testEmail('EmailAddress','')) && (testText('Telephone','Telephone','')) ){
    if( getRadioValue('AlternativeTime','') == "yes"){
      if( (testText('AltStartTime','Alternative Start Time','')) && (testText('AltEndTime','Alternative End Time','')) ){
        if(str.indexOf('http://') > -1){
          alert('URLs are not permitted');
        } else {
          document.forms[0].submit();
        }
      }
    } else {
      if(str.indexOf('http://') > -1){
        alert('URLs are not permitted');
      } else {
        document.forms[0].submit();
      }
    }
  }
}
function validateEntertainmentScreener(){
  if( (testCheck('Programme','a Programme','')) && (testText('Name','a Name','')) && (testText('JobTitle','a Job Title','')) && (testText('Company','a Company','')) && (testText('Address','an Address','')) && (testText('City','a City','')) && (testSelect('Country','a Country','')) && (testEmail('EmailAddress','')) && (testText('Telephone','Telephone','')) && (testRadio('Format','a Format','')) ){
    document.forms[0].submit();
  }
}
function validateBSEventRequest(){
  if( (testText('Name','Name','')) && (testEmail('EmailAddress','')) && (testText('Company','Company','')) && (testSelect('Country','a Country','')) && (testText('Telephone','Telephone','')) ){
    document.forms[0].submit();
  }
}
function validateMESEventBooking(){
  if( (testText('Name','Name','')) && (testEmail('EmailAddress','')) && (testText('Company','Company','')) && (testSelect('Country','a Country','')) && (testText('Telephone','Telephone','')) && (testRadio('BookChoice','what you would like','')) ){
    if ( getRadioValue('BookChoice','') == "book") {
      if ( (testText('BookDate','a Date','')) ){
        document.forms[0].submit();
      }
    } else {
      if ( testSelect('Want','what you require','') ){
        document.forms[0].submit();
      }
    }
  }
}
function validateBSBooking(){
  var doc = document.forms[0];
  var str_services = doc.ServicesHTML.value;
  var services = str_services.split('~');
  var str = "Y";
  if( (testText('Name','Name','')) && (testEmail('EmailAddress','')) && (testText('Company','Company','')) && (testSelect('Country','a Country','')) && (testText('Telephone','Telephone','')) ) {
   //** Satellite
    if( (str_services.indexOf('satellite') > -1) && (str == "Y") ){
      if( (testRadio('Satellite_RequestType','the satellite booking request type','')) && (testText('Satellite_Date','the satellite booking date','')) && (testText('Satellite_StartTime','the satellite booking start time','')) && (testText('Satellite_EndTime','the satellite booking end time','')) && (testSelect('Satellite_TransmissionPointUNID','the satellite booking  transmission point','')) && (testText('Satellite_ReceivePoint','the satellite booking receive point','')) && (testText('Satellite_Duration','the satellite booking duration','')) && (testSelect('Satellite_Format','the satellite booking format','')) ){
	  if(doc.Satellite_TransmissionPointUNID.options[doc.Satellite_TransmissionPointUNID.selectedIndex].value == "other"){
	    if( (testText('Satellite_TransmissionPointOther','the satellite booking transmission point','')) ){
            str = "Y";
          } else {
		str = "F"
          }
	  } else {
	    str = "Y";
        }
      } else {
        str = "F"
      }
    }
    //** Crewing
    if( (str_services.indexOf('crewing') > -1) && (str == "Y") ){
	if( (testRadio('Crewing_RequestType','the crewing booking request type','')) && (testText('Crewing_Date','the crewing booking date','')) && (testSelect('Crewing_WhereUNID','the crewing booking location','')) && (testSelect('Crewing_Crew','the crewing booking crew details','')) && (testText('Crewing_StartTime','the crewing booking start time','')) && (testText('Crewing_Duration','the crewing booking duration','')) && (testText('Crewing_Format','the crewing booking format','')) && (testRadio('Crewing_Transport','the crewing booking transport requirments','')) ){
	  if(doc.Crewing_WhereUNID.options[doc.Crewing_WhereUNID.selectedIndex].value == "other"){
          if( testText('Crewing_WhereOther','the crewing booking location','') ){
		str = "Y";
          } else {
		str = "F";
          }
	  } else {
 	    str = "Y";
	  }
      } else {
	  str = "F";
	}
    }
    //** Editing
    if( (str_services.indexOf('editing') > -1) && (str == "Y") ){
	if( (testRadio('Editing_RequestType','the editing booking request type','')) && (testText('Editing_Date','the editing booking date','')) && (testText('Editing_WhereUNID','the editing booking location','')) && (testRadio('Editing_Editor','the editing booking editor requirments','')) && (testText('Editing_StartTime','the editing booking start time','')) && (testText('Editing_Duration','the editing booking duration','')) && (testText('Editing_Format','the editing booking format','')) ){
	  if(doc.Editing_WhereUNID.options[doc.Editing_WhereUNID.selectedIndex].value == "other"){
          if( testText('Editing_WhereOther','the editing booking location','') ){
		str = "Y";
          } else {
		str = "F";
          }
	  } else {
 	    str = "Y";
        }
      } else {
	  str = "F";
	}
    }
    //** Studio
    if( (str_services.indexOf('studio') > -1) && (str == "Y") ){
	if( (testRadio('Studio_RequestType','the studio booking request type','')) && (testText('Studio_Date','the studio booking date','')) && (testSelect('Studio_WhereUNID','the studio booking location','')) && (testRadio('Studio_RecordType','the studio booking transmission type','')) && (testText('Studio_Cameras','the studio booking camera requirements','')) && (testText('Studio_Guests','the number of studio booking guests','')) && (testText('Studio_Time','the studio booking start time','')) && (testText('Studio_Duration','the studio booking duration','')) ){
	  if(doc.Studio_WhereUNID.options[doc.Studio_WhereUNID.selectedIndex].value == "other"){
          if( testText('Studio_WhereOther','a studio booking location','') ){
		str = "Y";
          } else {
		str = "F";
          }
	  } else {
 	    str = "Y";
	  }
      } else {
	  str = "F";
	}
    }
    //** Live Position
    if( (str_services.indexOf('live_position') > -1) && (str == "Y") ){
	if( (testRadio('Bureau_RequestType','the bureau live position booking request type','')) && (testText('Bureau_Date','the bureau live position booking date','')) && (testSelect('Bureau_WhereUNID','the bureau live position booking location','')) && (testText('Bureau_StartTime','the bureau live position booking start time','')) && (testText('Bureau_Duration','the bureau live position booking duration','')) ){
	  if(doc.Bureau_WhereUNID.options[doc.Bureau_WhereUNID.selectedIndex].value == "other"){
          if( testText('Bureau_WhereOther','the bureau live position booking location','') ){
		str = "Y";
          } else {
		str = "F";
          }
	  } else {
 	    str = "Y";
	  }
      } else {
	  str = "F";
	}
    }
    //** Connect
    if( (str_services.indexOf('connect') > -1) && (str == "Y") ){
	if( (testText('Connect_Date','the connect booking date','')) && (testText('Connect_StartTime','the connect booking start time','')) && (testText('Connect_EndTime','the connect booking end time','')) && (testSelect('Connect_TransmissionPoint','the connect booking transmission point','')) && (testSelect('Connect_RecievePoint','the connect booking receive point','')) && (testText('Connect_Duration','the connect booking duration','')) && (testSelect('Connect_Bandwidth','the connect booking bandwidth size','')) ){
	  str = "Y";
      } else {
	  str = "F";
	}
    }
    if(str == "Y"){
      document.forms[0].submit();
    }
  }
}
function setMESStepNumber(stepFrom,stepTo){
  if (stepFrom == "1") {
    if( (testText('Name','Name','')) && (testEmail('EmailAddress','')) && (testText('Company','Company','')) && (testSelect('Country','a Country','')) && (testText('Telephone','Telephone','')) && (testCheck('Services','a Service','')) ) {
      document.forms[0].StepNumber.value = stepTo;
      document.forms[0].submit();
    }
  } else if (stepFrom == "2" && stepTo != "1") {
    
    var doc = document.forms[0];
    var str_services = doc.ServicesV.value;
    var services = str_services.split(';');
    var str = "Y";
    //** Satellite
      if( (str_services.indexOf('satellite') > -1) && (str == "Y") ){
        if( (testRadio('Satellite_RequestType','the satellite booking request type','')) && (testText('Satellite_Date','the satellite booking date','')) && (testText('Satellite_StartTime','the satellite booking start time','')) && (testText('Satellite_EndTime','the satellite booking end time','')) && (testSelect('Satellite_TransmissionPointUNID','the satellite booking  transmission point','')) && (testText('Satellite_ReceivePoint','the satellite booking receive point','')) && (testText('Satellite_Duration','the satellite booking duration','')) && (testSelect('Satellite_Format','the satellite booking format','')) ){
	    if(doc.Satellite_TransmissionPointUNID.options[doc.Satellite_TransmissionPointUNID.selectedIndex].value == "other"){
	      if( (testText('Satellite_TransmissionPointOther','the satellite booking transmission point','')) ){
		  str = "Y";
		} else {
		  str = "F"
		}
	    } else {
	      str = "Y";
          }
        } else {
          str = "F"
        }
	}
    //** Crewing
      if( (str_services.indexOf('crewing') > -1) && (str == "Y") ){
	  if( (testRadio('Crewing_RequestType','the crewing booking request type','')) && (testText('Crewing_Date','the crewing booking date','')) && (testSelect('Crewing_WhereUNID','the crewing booking location','')) && (testSelect('Crewing_Crew','the crewing booking crew details','')) && (testText('Crewing_StartTime','the crewing booking start time','')) && (testText('Crewing_Duration','the crewing booking duration','')) && (testText('Crewing_Format','the crewing booking format','')) && (testRadio('Crewing_Transport','the crewing booking transport requirments','')) ){
	    if(doc.Crewing_WhereUNID.options[doc.Crewing_WhereUNID.selectedIndex].value == "other"){
		if( testText('Crewing_WhereOther','the crewing booking location','') ){
		  str = "Y";
		} else {
		  str = "F";
		}
	    } else {
 	      str = "Y";
	    }
        } else {
	    str = "F";
	  }
	}
    //** Editing
      if( (str_services.indexOf('editing') > -1) && (str == "Y") ){
	  if( (testRadio('Editing_RequestType','the editing booking request type','')) && (testText('Editing_Date','the editing booking date','')) && (testText('Editing_WhereUNID','the editing booking location','')) && (testRadio('Editing_Editor','the editing booking editor requirments','')) && (testText('Editing_StartTime','the editing booking start time','')) && (testText('Editing_Duration','the editing booking duration','')) && (testText('Editing_Format','the editing booking format','')) ){
	    if(doc.Editing_WhereUNID.options[doc.Editing_WhereUNID.selectedIndex].value == "other"){
		if( testText('Editing_WhereOther','the editing booking location','') ){
		  str = "Y";
		} else {
		  str = "F";
		}
	    } else {
 	      str = "Y";
	    }
        } else {
	    str = "F";
	  }
	}
    //** Studio
      if( (str_services.indexOf('studio') > -1) && (str == "Y") ){
	  if( (testRadio('Studio_RequestType','the studio booking request type','')) && (testText('Studio_Date','the studio booking date','')) && (testSelect('Studio_WhereUNID','the studio booking location','')) && (testRadio('Studio_RecordType','the studio booking transmission type','')) && (testText('Studio_Cameras','the studio booking camera requirements','')) && (testText('Studio_Guests','the number of studio booking guests','')) && (testText('Studio_Time','the studio booking start time','')) && (testText('Studio_Duration','the studio booking duration','')) ){
	    if(doc.Studio_WhereUNID.options[doc.Studio_WhereUNID.selectedIndex].value == "other"){
		if( testText('Studio_WhereOther','a studio booking location','') ){
		  str = "Y";
		} else {
		  str = "F";
		}
	    } else {
 	      str = "Y";
	    }
        } else {
	    str = "F";
	  }
	}
    if(str == "Y"){
      document.forms[0].StepNumber.value = stepTo;
      document.forms[0].submit();
    }
  } else if (stepFrom == "2" && stepTo == "1") {
    document.forms[0].StepNumber.value = stepTo;
    document.forms[0].submit();
  }
}
function cancelMESBooking(){
  document.forms[0].StepNumber.value = "CANCEL";
  document.forms[0].submit();
}
function validatemyAccountForm(){
  var doc = document.forms[0];
  if( testText('FirstName','your first name','') && testText('LastName','your last name','') && testEmail('EmailAddress','') && testText('Telephone','your telephone','') && testText('Position','your position','') && testText('Company','your company','') && testText('Address1','your address','') && testText('City','your city','') && testSelect('Country','country','') ) {
    if( testText('UserName','a username','') && testText('PasswordV','a password','') && testText('ConfirmPassword','a confirmation password','') ){
      if(doc.PasswordV.value != doc.ConfirmPassword.value) {  
         alert('The Password & Confirm Password must be the same');
         setFocus('ConfirmPassword','');
      } else {
        if(doc.PasswordV.value.toLowerCase() == "password"){
           alert('Your Password cannot be the word Password');
           setFocus('Password','');
        } else {
          if( testAlphaPassword('UserName','','username') && testAlphaPassword('PasswordV','','password') ){
		if ( doc.elements['Services1'].checked == false && doc.elements['Services2'].checked == false && doc.elements['Services3'].checked == false && doc.elements['Services4'].checked == false && doc.elements['Services5'].checked == false ){
              alert('Please select the service/s you wish to access');
		} else {
              if(doc.elements['Services5'].checked == true){
                var streas = "";
                for(i=0; i < doc.elements['EmailAlertsSections'].length; i++){
                  if(doc.elements['EmailAlertsSections'][i].checked == true){ streas += "x"; }
                }
                if(streas == ""){
                  alert('Please select at least one area of interest for Email Alerts');
                } else {
                  doc.submit();
                }
              } else {
                doc.submit();
              }
		}
          }
        }
      }
    }
  }
}
//function validateMyAccountRegistration1() {
//  var doc = document.forms[0];
//  if( testText('FirstName','your first name','') && testText('LastName','your last name','') && testEmail('EmailAddress','') && testText('Telephone','your telephone','') && testText('Position','your position','') && testText('Company','your company','') && testText('Address1','your address','') && testText('City','your city','') && testSelect('Country','country','') ) {
//    doc.submit();
//  }
//}
//function validateMyAccountRegistration2() {
//  var doc = document.forms[0];
//  if( testText('UserName','a username','') && testText('PasswordV','a password','') && testText('ConfirmPassword','a confirmation password','') && testCheck('Services','a service','') ){
//    if(doc.PasswordV.value != doc.ConfirmPassword.value) {  
//       alert('The Password & Confirm Password must be the same');
//       setFocus('ConfirmPassword','');
//    } else {
//      if(doc.PasswordV.value.toLowerCase() == "password"){
//         alert('Your Password cannot be the word Password');
//         setFocus('Password','');
//      } else {
//        if( testAlphaPassword('UserName','','username') && testAlphaPassword('PasswordV','','password') ){
//          doc.submit();
//        }
//      }
//    }
//  }
//}
//
//function setRegistrationStepNumber(stepnumber) {
//  var doc = document.forms[0];
//  var currentStepNumber = doc.StepNumber.value;
//  doc.StepNumber.value = stepnumber;
//  if (stepnumber == "STEP2" && currentStepNumber != "STEP3") {
//    validateMyAccountRegistration1();
//  } else if ( (stepnumber == "STEP1") || (stepnumber == "STEP3") ) {
//    validateMyAccountRegistration2();
//  } else {
//    doc.submit();
//  }
//}
//
//function cancelRegistration(){
//  if (confirm('Are you sure?')) {
//    setRegistrationStepNumber('CANCEL');
//  }
//}
function updatePassword() {
  var doc = document.forms[0];
  if( testText('PasswordV','a password','') && testText('ConfirmPassword','a confirmation password','')){
    if(doc.PasswordV.value != doc.ConfirmPassword.value) {  
       alert('The Password & Confirm Password must be the same');
       setFocus('ConfirmPassword','');
    } else {
      if(doc.PasswordV.value.toLowerCase() == "password"){
         alert('Your Password cannot be the word Password');
         setFocus('Password','');
      } else {
        if( testAlphaPassword('PasswordV','','password') ){
          doc.submit();
        }
      }
    }
  }
}
function vnrSearch(){
var searchText = document.forms['vnr_search'].VNRText.value
  if (searchText == "") {
    alert('You must enter a search query');
    setFocus('VNRText','vnr_search');
  } else {
    document.forms['vnr_search'].submit()
  }
}
function websiteLogin(){
  var doc = document.forms[0];
  var u = doc.myaptn_name.value;
  var p = doc.myaptn_password.value;
  if(u == "name" || u == ""){
    alert('You must enter a username');
    setFocus("myaptn_name","");
  } else if (p == "password" || p == ""){
    alert('You must enter a password');
    setFocus("myaptn_password","");
  } else {
    var url = window.location.href;
    var checkName = document.forms[0].elements['remember'];
    var str = "no";
    if(checkName.checked == true){
      str = "yes";
    }
    location.href = "/80256FE40039EB88/(Login)?OpenAgent&us="+u+"&ps="+p+"&cook="+str+"&url="+url;
  }
}
function websiteLogout(){
  url = window.location.href;
  location.href = "/names.nsf?logout&redirectto=" + url
}
function liveHelpLogin(){
  var doc = document.forms[0];
  var u = doc.myaptn_name.value;
  var p = doc.myaptn_password.value;
  if( (u == "name") || (u == "") ){
    alert('You must enter a username');
    setFocus("myaptn_name","");
  } else if ( (p == "password") || (p == "") ){
    alert('You must enter a password');
    setFocus("myaptn_password","");
  } else {
    location.href = "/names.nsf?login&username="+u+"&password="+p+"&redirectto=/80257037004660D6/httpLiveHelp?ReadForm"
  }
}
function validatePlannedCoverage(){
  var doc = document.forms[0];
  if( (testRadio('LiveTape','if the coverage is Live, Tape or TBA','')) && (testText('Title','Story Title','')) ){
    doc.submit();
  }
}
function validateBSEvent(){
  var doc = document.forms[0];
  if( (testText('Title','Title','')) && (testText('Location','Location','')) && (testText('AddLive1_Title','an Origin Title','')) && (testText('StartDate','Start Date','')) && (testText('EndDate','End Date','')) && (testText('Summary','Summary','')) ){
    doc.submit();
  }
}
function OLDvalidatePlannedCoverage(){
  var doc = document.forms[0];
  var tt = doc.elements['Time_Text'].value;
  if( (testRadio('LiveTape','if the coverage is Live, Tape or TBA','')) && (testText('Title','Story Title','')) ){
    if( (tt.charAt(0) == "1") || (tt.charAt(0) == "2") || (tt.charAt(0) == "3") || (tt.charAt(0) == "4") || (tt.charAt(0) == "5") || (tt.charAt(0) == "6") || (tt.charAt(0) == "7") || (tt.charAt(0) == "8") || (tt.charAt(0) == "9") || (tt.charAt(0) == "0") ){
      if( (tt.charAt(1) == "1") || (tt.charAt(1) == "2") || (tt.charAt(1) == "3") || (tt.charAt(1) == "4") || (tt.charAt(1) == "5") || (tt.charAt(1) == "6") || (tt.charAt(1) == "7") || (tt.charAt(1) == "8") || (tt.charAt(1) == "9") || (tt.charAt(1) == "0") ){
        if(tt.charAt(2) == ":"){
          if( (tt.charAt(3) == "1") || (tt.charAt(3) == "2") || (tt.charAt(3) == "3") || (tt.charAt(3) == "4") || (tt.charAt(3) == "5") || (tt.charAt(3) == "6") || (tt.charAt(3) == "7") || (tt.charAt(3) == "8") || (tt.charAt(3) == "9") || (tt.charAt(3) == "0") ){
            if( (tt.charAt(4) == "1") || (tt.charAt(4) == "2") || (tt.charAt(4) == "3") || (tt.charAt(4) == "4") || (tt.charAt(4) == "5") || (tt.charAt(4) == "6") || (tt.charAt(4) == "7") || (tt.charAt(4) == "8") || (tt.charAt(4) == "9") || (tt.charAt(4) == "0") ){
              doc.submit();
            } else {
              alert('Please enter a valid time');
            }
          } else {
            alert('Please enter a valid time');
          }
        } else {
          alert('Please enter a valid time');
        }
      } else {
        alert('Please enter a valid time');
      }
    } else {
      alert('Please enter a valid time');
    }
  }
}
function validateAlert(){
  if( (testText('Title','Title','')) && (testText('Text','the Copy','')) ){
    document.forms[0].submit();
  }
}
function clearAlert(url){
  if (confirm('Are you sure?')) {
    window.location.href = url;
  }
}
function deletePlannedCoverage(url){
  if (confirm('Are you sure?')) {
    window.location.href = url;
  }
}
function validateTopStory(){
  if( (testText('Title','Title','')) && (testText('Body','a Story','')) ){
    document.forms[0].submit();
  }
}
function validateEmergencyScript(){
  if( (testText('Title','Title','')) && (testText('StoryDate','Date','')) && (testText('Bulletin','Bulletin','')) && (testText('Body','a Script','')) ){
    document.forms[0].submit();
  }
}
function validateVideoSelect(){
  if( (testRadio('Type','Type','')) && (testText('Title','Title','')) && (testText('Text','Text','')) ){
    document.forms[0].submit();
  }
}
function validateComingUp(action){
  if( (testText('Title','Title','')) && (testText('Body','a Story','')) ){
    document.forms[0].Action.value = action;
    document.forms[0].submit();
  }
}
function validateNewsGuideAdvisory(){
  if( (testText('Title','Title','')) && (testText('Summary','the Advisory Text','')) ){
    document.forms[0].submit();
  }
}
function deleteTopStory(url){
  if (confirm('Are you sure?')) {
    window.location.href = url;
  }
}
function deleteAllEmergencyScripts(url){
  if (confirm('Are you sure you want to delete ALL Emergency Scripts?')) {
    window.location.href = url;
  }
}
function activateEmergencyScripts(url){
  if (confirm('Are you sure you want to Activate Emergency Scripts?')) {
    window.location.href = url;
  }
}
function deactivateEmergencyScripts(url){
  if (confirm('Are you sure you want to Deactivate Emergency Scripts?')) {
    window.location.href = url;
  }
}
function activateEmergencyScriptsEmail(url){
  if (confirm('Are you sure you want to send an ACTIVATION email to ALL SCRIPTS USERS?')) {
    window.location.href = url;
  }
}
function deactivateEmergencyScriptsEmail(url){
  if (confirm('Are you sure you want to send a DEACTIVATION email to ALL SCRIPTS USERS?')) {
    window.location.href = url;
  }
}
function deleteNewsGuideAdvisory(url){
  if (confirm('Are you sure?')) {
    window.location.href = url;
  }
}
function deleteGlossaryEntry(url){
  if (confirm('Are you sure?')) {
    window.location.href = url;
  }
}
function validateTopShot(){
  if( (testText('Title','Title','')) ){
    document.forms[0].submit();
  }
}
function validateNewsOutlook(){
  if (document.forms[0].Body.value.length > 14000){
    alert("Your Outlook is too large to save. Please reduce the number of characters in the text.");
  } else {
    if( (testText('Body','a News Outlook','')) ){
      document.forms[0].submit();
    }
  }
}
function validateSurvey(){
  var doc = document.forms[0];
  if( (testText('Name','a Name','')) && (testText('Title','a Title',''))&& (testText('Company','a Company','')) && (testSelect('Country','a Country','')) && (testEmail('Email','')) ){
    doc.submit();
  }
}
function validateEntSurvey(){
  var doc = document.forms[0];
  if( (testText('Name','a Name','')) && (testText('SalesDivision','a Sales Division',''))&& (testText('Territory','a Territory','')) ){
    doc.submit();
  }
}
function validateEdSurvey(){
  var doc = document.forms[0];
  if( (testText('Name','a Name','')) && (testText('EdDepartment','an Editorial Department',''))&& (testText('Location','a Location','')) ){
    doc.submit();
  }
}
function validateAdvancedSearch(){
  var doc = document.forms[0];
  if( (testText('KeywordQuery','a Keyword','')) ){
    doc.submit();
  }
}
function validateDirectSatelliteEnd(){
  var doc = document.forms[0];
  if( getRadioValue('ReplaceWith','0') == "planned_coverage") {
    if( testSelect('PlannedEvent','Planned Event','0')) {
      document.forms[0].submit();
    }
  } else if( getRadioValue('ReplaceWith','0') == "live_now") {
    if( (testText('StartTime','a Start Time','')) && (testText('Event','an Event','')) ){
      document.forms[0].submit();
    }
  } else if( getRadioValue('ReplaceWith','0') == "") {
    alert('Please select either Live Now, Slate or Planned Coverage')
  } else {
    document.forms[0].submit();
  }
}
function deleteSatellite(url){
  if (confirm('Are you sure you wish to delete this LIVE NOW entry?')) {
    window.location.href = url;
  }
}
function validateearthTVTrial(){
  var doc = document.forms[0];
  if( (testText('Name','a Name','')) && (testText('Company','a Company','')) && (testText('Address1','an Address','')) && (testText('City','a City','')) && (testText('Country','a Country','')) && (testText('PostCode','a Post code/Zip','')) && (testEmail('EmailAddress','')) && (testText('Telephone','a Telephone','')) && (testCheck('Media_Format','a Business Type','')) && (testText('RandomNumberVerify','the Verification Code','')) ){
    if(doc.RandomNumberVerify.value == document.forms[0].RandomNumber.value){
      doc.submit();
    } else {
      alert('Please make sure you have entered the verification code correctly');
    }
  }
}
function validateTrial(){
  var doc = document.forms[0];
  if( (testText('Name','a Name','')) && (testText('Company','a Company','')) && (testText('Address1','an Address','')) && (testText('City','a City','')) && (testText('Country','a Country','')) && (testText('PostCode','a Post code/Zip','')) && (testEmail('EmailAddress','')) && (testText('Telephone','a Telephone','')) && testCheck('Media_Format','the Media Type you work with','') && (testText('RandomNumberVerify','the Verification Code','')) ){
    if(doc.RandomNumberVerify.value == document.forms[0].RandomNumber.value){
      doc.submit();
    } else {
      alert('Please make sure you have entered the verification code correctly');
    }
  }
}
//function moveToLiveNow(){
//  if( (testText('Title','Story Title','')) ){
//    if (confirm('Move to Live Now?')) {
//      document.forms[0].Action.value = "MOVE";
//      document.forms[0].submit();
//    }
//  }
//}
//function clearSatellite(url){
//  if (confirm('Are you sure?')) {
//    window.location.href = url;
//  }
//}
