/*############################### VARIABLES ######################*/
var issetFrequency = "false"
var issetPhaseMatching = "false"
var issetMaxCableDiameter = "false"
var issetBendingradius = "false"
var issetTemperature = "false"

//var theForm = document.forms[0]
var sleevesEnabled = true
var splusMessage
var boots
var pigtail = false
var issetConnector2 = false
var cableSelected = false
var marking = false
var newInput = false
var maxCabLen = ""
var minCabLen = ""
var maximumQty = 500
var minCabLen_with
var minCabLen_without
//var microMiniature = false
var  Lunit
var heatshrinkMessage
var pigtailMessage
var resetMessage
var dataresetMessage
var strippingMessage, strippingMessage2, strippingMessage3
var qtyMsg, qtyMsg2, qtyMsg3
var qtyBtn_selected
var countrySplus, cableSplus, conn1Splus, conn2Splus, bootSplus, sleevesSplus, qtySplus, lenSplus, specsSplus
var lenMsg, lenMsg2, lenMsg2A, lenMsg3, lenMsg4, lenMsg_microminiatureA, lenMsg_microminiatureB
var nameMsg
var companyMsg
var zipMsg
var countryMsg
var telMsg
var emailMsg, emailMsg2, emailMsg3
var applicationMsg
var cblMsg
var cblMsg2
var connMsg
var connMsg2
var conn_1Msg
var conn_2Msg
var boot_1Msg
var boot_2Msg
var shrink1Msg
var shrink2Msg
var pigtailMsg1
var markingMsg1
var markingMsg2
var conn_pigtailMsg
var conn_pigtailMsg2


if (fr){
//French texts
heatshrinkMessage = "Vous avez déjà choisi l'option manchon.\nVoulez vous remplacer ce manchon par une gaine thermo?"
pigtailMessage= "Vous avez déjà choisi le 2ème connecteur.\nVoulez vous remplacer ce connecteur par un pigtail?"
resetMessage="Toutes les zones seront effacées.\nVoulez vous continuer?"
dataresetMessage="Toutes les données techniques seront effacées.\nVoulez vous continuer?"
strippingMessage="Veuillez compléter les informations de dénudage."
strippingMessage2="Veuillez entrer une valeur valide pour la longueur de dénudage"
strippingMessage3="La longueur de dénudage totale est supérieure à la longueur du câble!"
qtyMsg = "Veuillez entrer une quantité valide (maximum "+maximumQty+")."
qtyMsg2 = "Veuillez entrer seulement des chiffres dans la zone \"Quantité\"."
qtyMsg3 = "Veuillez entrer une quantité valide."
qtyMsg4 = "Veuillez entrer une quantité valide dans la zone \"Quantité 1\"."
lenMsg = "Veuillez entrer la longueur de votre cordon."
lenMsg2 = "longueur du câble :\n"
lenMsg3 = "Veuillez entrer uniquement des chiffres dans la zone \"Longueur\"."
lenMsg4 = "Veuillez entrer un nombre valide dans la zone \"Longueur\"."
lenMsg_microminiatureA = "La longueur maximum avec les connecteurs microminiatures est "
lenMsg_microminiatureB = "\nPour des longueurs supérieures, veuillez nous consulter"
nameMsg = "Veuillez compléter la zone \"Nom\"."
companyMsg = "Veuillez compléter la zone \"Société\"."
zipMsg = "Veuillez compléter la zone \"Ville/Code postal\"."
countryMsg = "La première option \"Sélectionnez un pays\" n'est pas une sélection valide. Veuillez choisir une autre option."
telMsg = "Veuillez compléter la zone \"Tel\"."
emailMsg = "Veuillez entrer une adresse e-mail valide."
emailMsg2 = "Veuillez sélectionner une des adresses e-mail."
emailMsg3 = "Veuillez entrer l'adresse e-mail de votre correspondant Radiall."
applicationMsg = "Veuillez indiquer votre application."
cblMsg = "Veuillez sélectionner un câble."
cblMsg2 = "Veuillez d'abord sélectionner le câble."
connMsg = "Veuillez d'abord sélectionner le connecteur 1."
connMsg2 = "Veuillez d'abord sélectionner le connecteur 2."
conn_1Msg = "Veuillez faire une sélection pour le connecteur 1."
conn_2Msg = "Veuillez faire une sélection pour le connecteur 2."
boot_0Msg = "Veuillez d'abord choisir\nentre manchon ou gaine thermo."
boot_1Msg = "Veuillez faire une sélection pour le manchon 1."
boot_2Msg = "Veuillez faire une sélection pour le manchon 2."
shrink1Msg = "Veuillez sélectionner noir ou blanc\npour la gaine thermo."
shrink2Msg = "Veuillez sélectionner noir ou blanc\npour la gaine thermo 2."
pigtailMsg1 = "Veuillez choisir entre connecteur 2 ou pigtail."
markingMsg1 = "Veuillez sélectionner une des options \"Marquage\"."
markingMsg2 = "Veuillez entrer un texte pour le marquage de votre cordon."
conn_pigtailMsg = "Veuillez d'abord choisir\nentre connecteur 2 ou pigtail."
conn_pigtailMsg2 = "Veuillez d'abord choisir\nentre connecteur 2 ou pigtail."
var boot_sleeveMsg = "Veuillez d'abord choisir\nentre Manchons ou Gaine thermo"
var frequencyMSG = "Veuillez sélectionner MHz ou GHz" 
var unitMSG =  "Veuillez sélectionner mm ou inch"
var tempMSG = "Veuillez sélectionner °C ou °F"
var phasematchingMSG = "Veuillez sélectionner 'Per lot', 'To master' ou 'value'"
var phasematchingvalueMSG = "Veuillez entrer une valeur dans la zone \"value\""

}else{
// English texts
heatshrinkMessage = "You have already selected the optional boot,\ndo you want to replace this boot with a heatshrink sleeve?"
pigtailMessage= "You have already selected the 2nd connector,\ndo you want to replace this connector with a pigtail?"
resetMessage="All fields will be canceled.\nAre you sure you want to continue?"
dataresetMessage="All technical data will be reset.\nContinue?"
strippingMessage="Please complete the Stripping informations"
strippingMessage2="Please enter a valid value for the length of the stripping"
strippingMessage3="Total length of stripping exceeds length of cable!"
qtyMsg = "Please enter a correct quantity (not exceeding "+maximumQty+")."
qtyMsg2 = "Please enter only digit characters in a \"Quantity\" field."
qtyMsg3 = "Please enter a correct quantity."
qtyMsg4 = "Please enter a quantity in the \"Quantity 1\" field first."
lenMsg = "Please enter the length of your cable."
lenMsg2 = "Cable length:\n"
lenMsg3 = "Please enter only digit characters in the \"Length\" field."
lenMsg4 = "Please enter a valid number in the \"Length\" field."
lenMsg_microminiatureA = "The maximum length with microminiature connectors : "
lenMsg_microminiatureB = "\nFor longer assemblies, please consult us."
nameMsg = "Please enter a value for the \"name\" field."
companyMsg = "Please enter a value for the \"Company name\" field."
zipMsg = "Please enter a value for the \"City/Zip code\" field."
countryMsg = "The first \"Country\" option is not a valid selection.  Please choose one of the other options."
telMsg = "Please enter a value for the \"Tel\" field."
emailMsg = "Please enter a valid Email address."
emailMsg2 = "Please select one of the email addresses."
emailMsg3 = "Please enter the email address of your Radiall contact."
applicationMsg = "Please specify your application."
cblMsg = "Please Select a cable."
cblMsg2 = "Please select cable first"
connMsg = "Please select connector 1 first"
connMsg2 = "Please select connector 2 first"
conn_1Msg = "Please make a selection for connector 1."
conn_2Msg = "Please make a selection for connector 2."
boot_0Msg = "Please make your selection\nfor boots or heatshrink sleeves."
boot_1Msg = "Please make a selection for boot 1."
boot_2Msg = "Please make a selection for boot 2."
//shrink1Msg = "Please select black or white\nfor heatshrink sleeve(s)."
shrink1Msg = "Please enter a description for the heatshrink sleeve(s)."
shrink2Msg = "Please enter a description for for heatshrink sleeve 2."
pigtailMsg1 = "Connector 2 or pigtail?."
markingMsg1 = "Please select one of the \"Marking\" options."
markingMsg2 = "Please enter a text for your cable marking."
conn_pigtailMsg = "Please make your selection\nfor connector 2 or pigtail first"
conn_pigtailMsg2 = "Please make your selection\nfor connector 2 or pigtail first"
var boot_sleeveMsg = "Please make your selection\nfor Boots or Sleeves first"
var frequencyMSG = "Please select MHz or GHz"
var unitMSG =  "Please select mm or inch"
var tempMSG = "Please select °C or °F"
var phasematchingMSG = "Please select 'Per lot', 'To master' or 'value'"
var phasematchingvalueMSG = "Please enter a value in the \"value\" field"

}
/*############################### INIT ###########################*/

function init(){
	setCableLength()
//alert("INIT")
//alert("enableFields")
	enableFields()
//alert("checkMicroMiniature")
	checkMicroMiniature()
/*	if (theForm.bootSet[0].checked && !theForm.bootSet[1].checked){//boots are set, sleeves not
		boots=true
	}
	if (!theForm.bootSet[0].checked && theForm.bootSet[1].checked){//boots are not set
		boots=false
	}*/
	checkConnector2()
	doConnector2()
//alert("setBoot1() ")
	setBoot1()
//alert("setBoot2() ")
	setBoot2()+
//alert("setSleeves() ")
	setSleeves()
//alert("doBoot1() ")
	doBoot1()
//alert("doBoot2() ")
	doBoot2()
//alert("initStripping() ")
	initStripping()
//alert("checkotherCableDescription")
checkOtherCableDescription()
	checkRightDisabled()
//alert("initPigtail() ")
	initPigtail()
//alert("doMarking() ")
	doMarking()
//alert("set_stars ")
	set_stars()
	checkUnits()
//	if (document.forms[0].length_unit[1].checked){ Lunit = " inches"}else{Lunit = " mm"}
	if(document.forms[0].cable_pn.value!=document.forms[0].cable_pn.defaultValue){cableSelected=true}

	//Other application
	if (!document.forms[0].application[5].checked){document.forms[0].application_description.disabled=true}

	setDatasheets()
	setSplus()
}


/*############################### CABLE & LENGTH ############################*/

function checkOtherCableDescription(){
   //var theForm = document.forms[0]
	if(document.forms[0].cable_pn.value==document.forms[0].cable_pn.defaultValue && theForm.othercabledescription.value != ""){
		disableBoot1()
		disableBoot2()
		disableConnector1()

		theForm.btn_connector2.disabled = true
		theForm.connector_2[0].checked=false;
//		theForm.connector_2[1].checked = false
		theForm.Connector_2_type.value = "N/A"
		theForm.Connector_2_type.style.backgroundColor = "#DDDDDD"
		theForm.connector_2_pn.value="N/A"
		document["star0_con2"].src = star0.src
		document["star_con2"].src = star0.src
	}else{
		theForm.Connector_1.style.backgroundColor = "#FFFFFF"
		document["star_con1"].src = star1.src
		document["star0_con2"].src = star1.src
	}
}

function doOtherCableDescription(){
   //var theForm = document.forms[0]
	if(document.forms[0].cable_pn.value==document.forms[0].cable_pn.defaultValue && theForm.othercabledescription.value != ""){
//		theForm.rightDisabled.value = "true"
		theForm.Cable.value = "See 'or describe others'"
		theForm.splus_cable.value = "false"
	}else if(document.forms[0].cable_pn.value==document.forms[0].cable_pn.defaultValue && theForm.othercabledescription.value == ""){
		datareset()
	}else{
		//alert("niks")
	}
checkOtherCableDescription()
}

function setCableLength(){
//without boots (even with heatshrinks): mini = 80 mm  max= 10 m 
//1 or 2 boots = mini = 170 mm  max = 10 m 
theForm = document.forms[0]
//var minCabLen_with
//var minCabLen_without
  if ( theForm.length_unit[0].checked){//millimeters for length

	if (microMiniature()){
		maxCabLen = 1000
	}else{
		maxCabLen = 10000
	}

	minCabLen_with = 170
	minCabLen_without = 80
  }else{//inches for length
	if (microMiniature()){
		maxCabLen = 39
	}else{
		maxCabLen = 390
	}
	minCabLen_with = 6.7
	minCabLen_without = 3.15
  }
  //check for at least one boot
  if (theForm.boot_1_pn.value!=theForm.boot_1_pn.defaultValue||theForm.boot_2_pn.value!=theForm.boot_2_pn.defaultValue){
	minCabLen = minCabLen_with
  }else{
	minCabLen = minCabLen_without
  }
}


function setDatasheets(){
	//var theForm = document.forms[0]
	if(cableSelected)
	{
		theForm.btn_cabledatasheet.disabled=false
	}else{
		theForm.btn_cabledatasheet.disabled=true
	}

	if(theForm.connector_1_pn.value==theForm.connector_1_pn.defaultValue)
	{
		theForm.btn_connectorsheet1.disabled=true
	}else{
		theForm.btn_connectorsheet1.disabled=false
	}

	if(theForm.connector_2_pn.value==theForm.connector_2_pn.defaultValue)
	{
		theForm.btn_connectorsheet2.disabled=true
	}else{
		theForm.btn_connectorsheet2.disabled=false
	}
}




/*############################### CONNECTOR1 ############################*/

function doOtherConn1Description(){
   //var theForm = document.forms[0]
	if(theForm.Connector_1.value!=theForm.Connector_1.defaultValue && theForm.otherconnector1description.value == ""){
		if(theForm.onlyOtherconn1.value == "true"){
			theForm.Connector_1.value=theForm.Connector_1.defaultValue
			theForm.onlyOtherconn1.value = "false"
			theForm.splus_connector1.value = "true"
		}
	}else if(theForm.connector_1_pn.value==theForm.connector_1_pn.defaultValue && theForm.otherconnector1description.value != ""){
		theForm.onlyOtherconn1.value = "true"
		theForm.Connector_1.value = "See 'or describe others'"
		theForm.splus_connector1.value = "false"
	}else if(theForm.connector_1_pn.value==theForm.connector_1_pn.defaultValue && theForm.otherconnector1description.value == ""){
		theForm.onlyOtherconn1.value = "false"
		theForm.splus_connector1.value = "true"
	}else{
		//alert("niks")
	}
}

function enableConnector1(){
	//var theForm = document.forms[0]
	theForm.Connector_1.value=theForm.Connector_2_type.defaultValue
	theForm.Connector_1.style.backgroundColor = "#FFFFFF"
	theForm.connector_1_pn.value=theForm.connector_2_pn.defaultValue

	theForm.btn_connector1.disabled = false

	document["star_con1"].src = star1.src
}

function disableConnector1(){
	//var theForm = document.forms[0]
	theForm.Connector_1.value="N/A"
	theForm.Connector_1.style.backgroundColor = "#DDDDDD"
	theForm.connector_1_pn.value=theForm.connector_1_pn.defaultValue

	theForm.btn_connector1.disabled = true

	document["star_con1"].src = star0.src
}



/*############################### CONNECTOR2 ############################*/


function doConnector2(){
if (!issetConnector2){
	//var theForm = document.forms[0];//alert("test40")
	if (theForm.connector_2[0].checked){   //NO PIGTAIL


if(cableSelected){
		if (theForm.Connector_2_type.value=="N/A"){
			theForm.Connector_2_type.value = theForm.Connector_2_type.defaultValue
		}
		theForm.Connector_2_type.style.backgroundColor = "#FFFFFF"
		theForm.btn_connector2.disabled = false
	   	if(!microMiniature()){
			theForm.no_boot_2.value = "false"
			theForm.boot_2_valid.value = "true"
			theForm.boot_2.disabled = false
			theForm.boot_2.checked = false
			theForm.Boot2_color.value = theForm.Boot2_color.defaultValue
			enableSleeves()
//			theForm.heatshrink_sleeve2.disabled = false
//			theForm.heatshrink_sleeves2_color[0].disabled=false
//			theForm.heatshrink_sleeves2_color[1].disabled=false
	   	}
		issetConnector2 = true
}
		theForm.otherconnector2description.value = theForm.otherconnector2description.defaultValue
		theForm.otherconnector2description.disabled = false
		theForm.otherconnector2description.style.backgroundColor = "#FFFFFF"
		disableStripping()
		pigtail=false
	}
set_stars()
}
}



function checkConnector2(){
	//var theForm = document.forms[0]
	if (theForm.connector_2[0].checked){
		issetConnector2 = true
		disableStripping()
	}else{
		issetConnector2 = false
	}
}


function doOtherConn2Description(){
   //var theForm = document.forms[0]
	if(theForm.Connector_2_type.value!=theForm.Connector_2_type.defaultValue && theForm.otherconnector2description.value == ""){
		if(theForm.onlyOtherconn2.value == "true"){
			theForm.Connector_2_type.value=theForm.Connector_2_type.defaultValue
			theForm.onlyOtherconn2.value = "false"
			theForm.splus_connector2.value = "true"
		}
	}else if(theForm.connector_2_pn.value==theForm.connector_2_pn.defaultValue && theForm.otherconnector2description.value != ""){
		theForm.onlyOtherconn2.value = "true"
		theForm.Connector_2_type.value = "See 'or describe others'"
		theForm.splus_connector2.value = "false"
	}else if(theForm.connector_2_pn.value==theForm.connector_2_pn.defaultValue && theForm.otherconnector2description.value == ""){
		theForm.onlyOtherconn2.value = "false"
		theForm.splus_connector2.value = "true"
	}else{
		//alert("niks")
	}
}

function disableConnector2(){
	//var theForm = document.forms[0]
	theForm.Connector_2_type.value="N/A"
	theForm.Connector_2_type.style.backgroundColor = "#DDDDDD"
	theForm.connector_2_pn.value=theForm.connector_2_pn.defaultValue

	theForm.btn_connector2.disabled = true
	theForm.connector_2[0].checked=false;
	theForm.connector_2[0].disabled=true;

	document["star_con2"].src = star0.src
}

function enableConnector2(){
	//var theForm = document.forms[0]
	theForm.Connector_2_type.value=theForm.Connector_2_type.defaultValue
	theForm.Connector_2_type.style.backgroundColor = "#FFFFFF"
	theForm.connector_2_pn.value=theForm.connector_2_pn.defaultValue

	theForm.btn_connector2.disabled = false
	theForm.connector_2[0].disabled=false;

	if(cableSelected){document["star_con2"].src = star1.src}
}


/*############################### SLEEVES ############################*/

//CHECKING SLEEVES  VS BOOTS

function checkSleeves(theForm){
  if (theForm.Boot1_pn.value!=''||theForm.Boot2_pn.value!=''){
	 if(!confirm(heatshrinkMessage)){
			theForm.sleeveSet[0].checked=false;
			theForm.sleeveSet[1].checked=true;
			return (false)
	 }
 }
			setSleeves();
			init();
}

function setSleeves(){//alert("setsleeves 00")
	//var theForm = document.forms[0]
	if(theForm.sleeveSet[1].checked){//alert("setsleeves 01")
		disableSleevedescription()
	}else if(theForm.sleeveSet[0].checked){
		disableSleevedescription()
		if(!theForm.boot_1.checked && !theForm.boot_2.checked){
			//alert("setsleeves 02")
			theForm.boot_1.checked=true
			theForm.boot_2.checked=true
			boots=false
		}
	}else if(theForm.sleeveSet[2].checked){//alert("setsleeves 03")
		enableSleevedescription()
	}
}

function noSleeves(){
	setSleeves()
	init()
}


function disableSleeves(){
	//var theForm = document.forms[0]
	if(!theForm.sleeveSet[2].checked){// if not other description
		theForm.sleeveSet[1].checked=true
	}
	theForm.sleeveSet[0].checked=false
	theForm.sleeveSet[0].disabled=true
//	theForm.sleeveSet[1].disabled=true
//	disableSleevedescription()
	sleevesEnabled = false
}

function enableSleeves(){
	//var theForm = document.forms[0]
	theForm.sleeveSet[0].disabled=false
	theForm.sleeveSet[1].disabled=false
//	enableSleevedescription()
	setSleeves()
	sleevesEnabled = true
}

function enableSleevedescription(){
//var theForm = document.forms[0]
	theForm.heatshrink_sleeves_description.style.backgroundColor = "#FFFFFF"
	theForm.heatshrink_sleeves_description.disabled=false
}

function disableSleevedescription(){
//var theForm = document.forms[0]
	theForm.heatshrink_sleeves_description.value=""
	theForm.heatshrink_sleeves_description.style.backgroundColor = "#DDDDDD"
	theForm.heatshrink_sleeves_description.disabled=true
}


/*############################### BOOTS ############################*/

function checkConnectors_forBoots(){
//var theForm = document.forms[0]
//one of the connectors no boot
	if (theForm.no_boot_1.value == "true" ||theForm.no_boot_2.value == "true"){
		boots = false
		theForm.boot_1_valid.value = false
		theForm.boot_2_valid.value = false
		theForm.bootSet[0].disabled = true
		theForm.bootSet[1].checked = true
	}
//both connectors have boot possibility
	if (theForm.no_boot_1.value == "false" && theForm.no_boot_2.value == "false"){
		theForm.bootSet[0].disabled = false
		theForm.bootSet[1].checked = true
	}
}

function setBoot1(){//alert("setboot1-01")
	//var theForm = document.forms[0]
	if (theForm.boot_1.checked && theForm.boot_2.checked){enableSleeves()}
	if (theForm.boot_1.checked){//alert("setboot1-03")
		theForm.Boot1_pn.value = theForm.Boot1_pn.defaultValue
		theForm.boot_1_pn.value = theForm.boot_1_pn.defaultValue
		theForm.boot_1_color.value = theForm.boot_1_color.defaultValue

//		theForm.boot_1_valid.value = theForm.boot_1_valid.defaultValue

		if (theForm.boot_1_valid.value == "false"){//alert("setboot1-04")
			theForm.btn_clrboot1.disabled = true
		}else{
			theForm.boot_1_valid.value = theForm.boot_1_valid.defaultValue
		}
	}else{
//		disableSleeves()
		if (!theForm.boot_1.checked && !theForm.boot_2.checked){//alert("setboot1-05")		
			if(!theForm.sleeveSet[1].checked && !theForm.sleeveSet[2].checked){//alert("setboot1-06")
				theForm.sleeveSet[1].click()
			}
		}		
	}
}


function setBoot2(){
	//var theForm = document.forms[0]
	if (theForm.boot_1.checked && theForm.boot_2.checked){enableSleeves()}
	if (theForm.boot_2.checked){
		theForm.Boot2_pn.value = theForm.Boot2_pn.defaultValue
		theForm.boot_2_pn.value = theForm.boot_2_pn.defaultValue
		theForm.boot_2_color.value = theForm.boot_2_color.defaultValue
		if (theForm.boot_2_valid.value == "false"){
			theForm.btn_clrboot2.disabled = true
		}else{
			theForm.boot_2_valid.value = theForm.boot_2_valid.defaultValue
		}
	}else{
		if (!theForm.boot_1.checked && !theForm.boot_2.checked){		
			if(!theForm.sleeveSet[1].checked && !theForm.sleeveSet[2].checked){
				theForm.sleeveSet[1].click()
			}
		}		
	}
	
}

function doBoot1(){
//var theForm = document.forms[0]
  if (microMiniature()||theForm.onlyOtherconn1.value == "true"||theForm.no_boot_1.value == "true"){
    disableBoot1()
  }else{//alert("Boot1B")
//    enableBoot1()
	if (theForm.boot_1.checked){//alert("Boot1C")
		theForm.boot_1_valid.value = "false"
		theForm.Boot1_color.value = "N/A"
//		theForm.Boot1_color.disabled = true
	}else{//alert("Boot1D")
		theForm.boot_1_valid.value = "true"
		theForm.btn_clrboot1.disabled = false
	}
	if (theForm.boot_1_valid.value == "false"){//alert("Boot1E")
		theForm.btn_clrboot1.disabled = true
	}else{//alert("Boot1F")
		theForm.btn_clrboot1.disabled = false
	}
	if (theForm.no_boot_1.value == "true"){//alert("Boot1G")
		theForm.boot_1.disabled = true
	}else{//alert("Boot1H")
		theForm.boot_1.disabled = false
	}
  }
}

function doBoot2(){
//var theForm = document.forms[0]
  if (microMiniature()||theForm.onlyOtherconn2.value == "true"||theForm.no_boot_2.value == "true"){
    disableBoot2()
  }else{
//    enableBoot2()
	if (theForm.boot_2.checked){
		theForm.boot_2_valid.value = "false"
		theForm.Boot2_color.value = "N/A"
	}else{
		theForm.boot_2_valid.value = "true"
		theForm.btn_clrboot2.disabled = false
		}

	if (theForm.boot_2_valid.value == "false"){
			theForm.btn_clrboot2.disabled = true
	}else{
			theForm.btn_clrboot2.disabled = false
			theForm.boot_2.disabled = false
	}
	if (theForm.no_boot_2.value == "true"){
		theForm.boot_2.disabled = true
	}else{
		theForm.boot_2.disabled = false;//alert("test20")
	}
  }
}


function disableBoot1(){;//alert("test60")
	//var theForm = document.forms[0]
	theForm.boot_1.checked=true
	theForm.boot_1.disabled = true
	theForm.Boot1_color.disabled = true
	theForm.btn_clrboot1.disabled = true

	theForm.no_boot_1.value = "true"
	theForm.boot_1_valid.value = "false"
	theForm.boot_1_pn.value = theForm.boot_1_pn.defaultValue
	theForm.Boot1_pn.value = theForm.Boot1_pn.defaultValue
	theForm.Boot1_color.value = "N/A"
	theForm.boot_1_color.value = theForm.boot_1_color.defaultValue
}

function enableBoot1(){
	//var theForm = document.forms[0]
	theForm.boot_1.disabled = false
	theForm.Boot1_color.disabled = false
	theForm.btn_clrboot1.disabled = false

	theForm.boot_1_valid.value = theForm.boot_1_valid.defaultValue
	theForm.no_boot_1.value = theForm.no_boot_1.defaultValue
	theForm.Boot1_pn.value = theForm.Boot1_pn.defaultValue
	theForm.boot_1_pn.value = theForm.boot_1_pn.defaultValue
	theForm.Boot1_color.value = theForm.Boot1_color.defaultValue
	theForm.boot_1_color.value = theForm.boot_1_color.defaultValue
}

function enableBoot2(){
	//var theForm = document.forms[0]
	theForm.boot_2.disabled = false
	theForm.Boot2_color.value = theForm.Boot2_color.defaultValue
	theForm.Boot2_color.disabled = false
	theForm.btn_clrboot2.disabled = false

	theForm.boot_2_valid.value = theForm.boot_2_valid.defaultValue
	theForm.no_boot_2.value = theForm.no_boot_2.defaultValue
	theForm.Boot2_pn.value = theForm.Boot2_pn.defaultValue
	theForm.boot_2_pn.value = theForm.boot_2_pn.defaultValue
	theForm.Boot2_color.value = theForm.Boot1_color.defaultValue
	theForm.boot_2_color.value = theForm.boot_2_color.defaultValue
}

function disableBoot2(){
	//var theForm = document.forms[0]
	theForm.boot_2.checked=true
	theForm.boot_2.disabled = true
	theForm.Boot2_color.disabled = true
	theForm.btn_clrboot2.disabled = true

	theForm.Boot2_pn.value = theForm.Boot2_pn.defaultValue
	theForm.Boot2_color.value = "N/A"
	theForm.no_boot_2.value = "true"
	theForm.boot_2_valid.value = "false"
	theForm.boot_2_pn.value = theForm.boot_2_pn.defaultValue
	theForm.boot_2_color.value = theForm.boot_2_color.defaultValue
}



/*############################### PIGTAIL , STRIPPING ETC ############################*/

function doPigtail(){
    //var theForm = document.forms[0]
    if (theForm.connector_2[1].checked){ //PIGTAIL
		initPigtail()
		enableStripping()
		pigtail = true
		issetConnector2 = false
    }
set_stars()
}


function checkPigtail(thisBox,theForm){
  if (theForm.connector_2_pn.value != theForm.connector_2_pn.defaultValue){
	 if(confirm(pigtailMessage)){
		if(theForm.connector_2[1].checked){
			doPigtail();
			init();
		}
	 }else{
		theForm.connector_2[0].checked=true
		theForm.connector_2[1].checked=false
	 }
 }else{
			doPigtail();
			init();
 }
}


function initPigtail(){
	//var theForm = document.forms[0]
	if (theForm.connector_2[1].checked){
		issetConnector2 = false
		theForm.boot_2.disabled = true
		theForm.btn_clrboot2.disabled = true
		theForm.btn_connector2.disabled = true

		theForm.Connector_2_type.value = "N/A"
//		theForm.Connector_2_type.disabled=true
		theForm.Connector_2_type.style.backgroundColor = "#DDDDDD"
//		theForm.otherconnector2description.value = "N/A"
//		theForm.otherconnector2description.disabled = true
//		theForm.otherconnector2description.style.backgroundColor = "#DDDDDD"
		theForm.onlyOtherconn2.value = "false"
		theForm.connector_2_pn.value = theForm.connector_2_pn.defaultValue
		theForm.boot_2.checked = true
		theForm.Boot2_color.value = "N/A"
		theForm.Boot2_pn.value = theForm.Boot2_pn.defaultValue
		theForm.Boot2_color.value = "N/A"
		theForm.boot_2_valid.value = "false"
		theForm.no_boot_2.value = "true"

		if (!theForm.boot_1.checked){//because slevve1 and boot1 don't go together
			disableSleeves()
		}



		pigtail=true
	}else{
		theForm.otherconnector2description.disabled = false
		theForm.otherconnector2description.style.backgroundColor = "#FFFFFF"
		pigtail=false
	}

}

function disablePigtail(){
	//var theForm = document.forms[0]
	pigtail=false
	theForm.connector_2[1].checked=false;
	theForm.connector_2[1].disabled=true;
	disableStripping()
}

function enablePigtail(){
	//var theForm = document.forms[0]
	theForm.connector_2[1].disabled=false;
	enableStripping();
}




function doStripping(){
 if (!us){
   //var theForm = document.forms[0]
	if (theForm.stripping[1].checked){
		theForm.stripping_a_length.value = "N/A"
		theForm.stripping_b_length.value = "N/A"
		theForm.stripping_c_length.value = "N/A"
		theForm.stripping_a_length.disabled=true
		theForm.stripping_b_length.disabled=true
		theForm.stripping_c_length.disabled=true
		theForm.stripping_unit[0].disabled=true
		theForm.stripping_unit[1].disabled=true
		theForm.tinned_inner_conductor[0].checked=false
		theForm.tinned_inner_conductor[0].disabled=true
		theForm.tinned_braid[0].checked=false
		theForm.tinned_braid[0].disabled=true
		theForm.tinned_inner_conductor[1].checked=true
		theForm.tinned_inner_conductor[1].disabled=true
		theForm.tinned_braid[1].checked=true
		theForm.tinned_braid[1].disabled=true
	}else{
		theForm.stripping_a_length.value = theForm.stripping_a_length.defaultValue
		theForm.stripping_b_length.value = theForm.stripping_b_length.defaultValue
		theForm.stripping_c_length.value = theForm.stripping_c_length.defaultValue
		theForm.stripping_a_length.disabled=true
		theForm.stripping_a_length.disabled=false
		theForm.stripping_b_length.disabled=false
		theForm.stripping_c_length.disabled=false
		theForm.tinned_inner_conductor[0].disabled=false
		theForm.stripping_unit[0].disabled=false
		theForm.stripping_unit[1].disabled=false
		theForm.tinned_braid[0].disabled=false
		theForm.tinned_inner_conductor[1].disabled=false
		theForm.tinned_braid[1].disabled=false
	}
 }
}



function initStripping(){
	//var theForm = document.forms[0]
	if (theForm.stripping[0].checked){
		theForm.tinned_inner_conductor[0].disabled = false
		theForm.tinned_inner_conductor[1].disabled = false
		theForm.tinned_braid[0].disabled = false
		theForm.tinned_braid[1].disabled = false
		theForm.stripping_a_length.disabled = false
		theForm.stripping_b_length.disabled = false
		theForm.stripping_c_length.disabled = false
		theForm.stripping_unit[0].disabled=false
		theForm.stripping_unit[1].disabled=false
	}else{
		theForm.tinned_inner_conductor[0].disabled = true
		theForm.tinned_inner_conductor[1].disabled = true
		theForm.tinned_braid[0].disabled = true
		theForm.tinned_braid[1].disabled = true
		theForm.stripping_a_length.disabled = true
		theForm.stripping_b_length.disabled = true
		theForm.stripping_unit[0].disabled=true
		theForm.stripping_unit[1].disabled=true
		theForm.stripping_c_length.disabled = true
	}
}

function enableStripping(){
	//var theForm = document.forms[0]
	theForm.stripping[0].disabled=false
	theForm.stripping[1].disabled=false
	theForm.stripping[0].click()
}

function disableStripping(){
	//var theForm = document.forms[0]
	theForm.stripping[1].click()
	theForm.stripping[0].disabled=true
	theForm.stripping[1].disabled=true
}


/*###############################  MARKING #######################*/
function doMarking(){
//var theForm = document.forms[0]
	if (theForm.marking[0].checked){
		theForm.othermarking.value="N/A"
		theForm.othermarking.disabled=true
		document["star_marking"].src = star0.src
		marking = false
	}
	if (theForm.marking[1].checked){
		theForm.othermarking.disabled=false
		document["star_marking"].src = star1.src
		marking = true
	}
}

function resetMarking(theForm){
	if (marking == false){
		theForm.othermarking.disabled=false
		marking = true
		theForm.othermarking.value="" // theForm.othermarking.defaultValue
		theForm.othermarking.focus()
	}
}

/*###############################  ANGLE #########################*/

function doAngleRight(angle){
//var theForm = document.forms[0]
	if(angle!=""){
	  theForm.angle_for_rightangle_bulkhead_connector.value=""
	}
}

function doAngleBulk(angle){
//var theForm = document.forms[0]
	if(angle!=""){
	  theForm.angle_for_2_rightangle_connectors.value=""
	}
}





/*############################### MICROMINIATURE ######################*/

function microMiniature(){
	theForm = document.forms[0]
	var cableNmbr = theForm.cable_pn.value
	var conn1Nmbr = theForm.connector_1_pn.value
	if ((cableNmbr.charAt(0) == "*" || cableNmbr.charAt(0) == "@") && conn1Nmbr.charAt(0) == "*"){
	   theForm.microminiature_text.value="Your choice: With microminiature connector"
	   theForm.microminiature_text2.value="Your choice: With microminiature connector"
	   return(true)
	}else{
	   theForm.microminiature_text.value="Your choice: Without microminiature connector"
	   theForm.microminiature_text2.value="Your choice: Without microminiature connector"
	   return(false)
	}
}


function checkMicroMiniature(){
	//var theForm = document.forms[0]
	if (microMiniature()){
		disableBoot1()
		disableBoot2()
		disableSleeves()
	}
}
/*############################### CRITICAL SPECIFICATIONS #####################*/

function checkUnits(){
	//var theForm = document.forms[0]
	if (theForm.length_unit[1].checked){ Lunit = " inches"}else{Lunit = " mm"}
	if (theForm.stripping_unit[0].checked){
		document["strippingunit0"].src = unitmm.src
		document["strippingunit1"].src = unitmm.src
		document["strippingunit2"].src = unitmm.src
	}else{
		document["strippingunit0"].src = unitinch.src
		document["strippingunit1"].src = unitinch.src
		document["strippingunit2"].src = unitinch.src
	}
	if (theForm.length_unit[0].checked)
	{
		document["lengthunitpic"].src = unitmm.src
	}else{
		document["lengthunitpic"].src = unitinch.src
	}
	setCableLength()


//frequency
	if (!theForm.Frequency_unit[0].checked && !theForm.Frequency_unit[1].checked)
	{
		issetFrequency = "false"
	}else{
		if (theForm.Frequency_unit[0].checked){issetFrequency = "MHz"}else{issetFrequency = "GHz"}
	}


//phase matching
	if (!theForm.phase_matching_spec[0].checked && !theForm.phase_matching_spec[1].checked && !theForm.phase_matching_spec[2].checked)
	{
		issetPhaseMatching = "false"
		theForm.phase_matching_value.value=""
		theForm.phase_matching_value.disabled=true
	}else{
		if (theForm.phase_matching_spec[0].checked)
		{
			issetPhaseMatching = "Per lot"
			theForm.phase_matching_value.value=""
			theForm.phase_matching_value.disabled=true
		}
		if (theForm.phase_matching_spec[1].checked)
		{
			issetPhaseMatching = "to master"
			theForm.phase_matching_value.value=""
			theForm.phase_matching_value.disabled=true
		}
		if (theForm.phase_matching_spec[2].checked)
		{
			issetPhaseMatching = "value"
			theForm.phase_matching_value.disabled=false
		}
	}


//maxcablediameter
	if (!theForm.max_cablediameter_unit[0].checked && !theForm.max_cablediameter_unit[1].checked)
	{
		issetMaxCableDiameter = "false"
	}else{
		if (theForm.max_cablediameter_unit[0].checked){issetMaxCableDiameter = "mm"}else{issetMaxCableDiameter = "inch"}
	}


//bending radius
	if (!theForm.bending_radius_unit[0].checked && !theForm.bending_radius_unit[1].checked)
	{
		issetBendingradius = "false"
	}else{
		if (theForm.bending_radius_unit[0].checked){issetBendingradius = "mm"}else{issetBendingradius = "inch"}
	}
//temperature
	if (!theForm.temperature_unit[0].checked && !theForm.temperature_unit[1].checked)
	{
		issetTemperature = "false"
	}else{
		if (theForm.temperature_unit[0].checked){issetTemperature = "celsius"}else{issetTemperature = "fahrenheit"}
	}
}


/*############################### SERVICEPLUS #########################*/


function makeSplusMessage(){
	if (serviceplus()) {
		splusMessage = "<br><br><b><font size=\"1\"   color=\"#006CD9\">Your request meets the Service+ specifications</font></b>"
	}else{
		splusMessage = "<br><br><table><tr><td nowrap><b><font size=\"1\"  color=\"#FF0000\">Subjects that do not meet Service+ specifications:</font></b></td></tr><tr><td><ul>"
		if (document.forms[0].splus_country.value=="false"){
			splusMessage+="<li>"
			splusMessage+="<font size=\"1\">Country</font></li>"
		}
		if (document.forms[0].splus_cable.value=="false"){
			splusMessage+="<li>"
			splusMessage+="<font size=\"1\">Cable</font></li>"
		}
		if (document.forms[0].splus_connector1.value=="false"){
			splusMessage+="<li>"
			splusMessage+="<font size=\"1\">Connector 1</font></li>"
		}
		if (document.forms[0].splus_connector2.value=="false"&&!pigtail){
			splusMessage+="<li>"
			splusMessage+="<font size=\"1\">Connector 2</font></li>"
		}
		if (!bootsSplus()){
			splusMessage+="<li>"
			splusMessage+="<font size=\"1\">Boot(s)</font></li>"
		}

		if (!SleeveSplus()){
			splusMessage+="<li>"
		splusMessage+="<font size=\"1\">Heatshrink sleeves</font></li>"
		}

		if (!LengthSplus()){
			splusMessage+="<li>"
			splusMessage+="<font size=\"1\">Length of assembly</font></li>"
		}
		if (!quantitySplus()){
			splusMessage+="<li>"
			splusMessage+="<font size=\"1\">Quantity</font></li>"
		}
		if (!specificationsSplus()){
			splusMessage+="<li>"
			splusMessage+="<font size=\"1\">Critical specifications</font></li>"
		}
		splusMessage+="</ul></td></tr></table>"
	}
}

function serviceplus(){
	//var theForm = document.forms[0]

//	if (theForm.serviceplus.value=="false"){return (false)}

	if (!LengthSplus()){lenSplus=false;return (false)}else{lenSplus=true;}
	if (!quantitySplus()){qtySplus=false;return (false)}else{qtySplus=true}

	if (!constructionSplus()){qtySplus=false;lenSplus=false;return (false)}

	if (!bootsSplus()){qtySplus=false;lenSplus=false;bootSplus=false;return (false)}else{bootSplus=true}
	if (!SleeveSplus()){qtySplus=false;lenSplus=false;sleevesSplus=false;return (false)}else{sleevesSplus=true}
	if (!specificationsSplus()){specsSplus=false;return (false)}else{specsSplus=true}

return (true)
}

function bootsSplus(){
	//var theForm = document.forms[0]
	if (theForm.boot_2_pn.value == theForm.boot_2_pn.defaultValue && theForm.boot_1_pn.value != theForm.boot_1_pn.defaultValue){return (false)}
	if (theForm.boot_1_pn.value == theForm.boot_1_pn.defaultValue && theForm.boot_2_pn.value != theForm.boot_2_pn.defaultValue){return (false)}
	return (true)
}

function constructionSplus(){
	//var theForm = document.forms[0]
	if (theForm.splus_country.value=="false"){return (false)}else{}
	if (theForm.splus_cable.value=="false"){cableSplus=false;return (false)}else{cableSplus=true;}
	if (theForm.splus_connector1.value=="false"){conn1Splus=false;return (false)}else{conn1Splus=true}
	if (theForm.sleeveSet[2].checked){sleevesSplus=false;return (false)}else{sleevesSplus=true}
	if (theForm.splus_boot1.value=="false"){bootSplus=false;return (false)}
	if (theForm.splus_connector2.value=="false"&&!pigtail){conn2Splus=false;return (false)}else{conn2Splus=true}
	if (theForm.splus_boot2.value=="false"){bootSplus=false;return (false)}

	return (true)
}


function SleeveSplus(){
	if (theForm.sleeveSet[2].checked){sleevesSplus=false;return (false)}else{sleevesSplus=true;return (true)}
}



function LengthSplus(){
	//var theForm = document.forms[0]
	if (theForm.Length.value !="" && (theForm.Length.value>maxCabLen ||theForm.Length.value<minCabLen)){return (false)}
	return (true)
}

function quantitySplus(){
	//var theForm = document.forms[0]
	if (theForm.qty1.value !="" && (theForm.qty1.value>maximumQty)){return (false)}
	if (theForm.qty2.value !="" && (theForm.qty2.value>maximumQty)){return (false)}
	if (theForm.qty3.value !="" && (theForm.qty3.value>maximumQty)){return (false)}
	if (theForm.qty4.value !="" && (theForm.qty4.value>maximumQty)){return (false)}
	return (true)
}

function specificationsSplus(){
	//var theForm = document.forms[0]
	if (theForm.Frequency.value!=""){return (false)}
	if (theForm.inertion_loss.value!=""){return (false)}
	if (theForm.VSWR.value!=""){return (false)}
	if (theForm.Screening_effectiveness.value!=""){return (false)}
	if (theForm.phase_matching.value!=""){return (false)}
	if (theForm.phase_matching_value.value!=""){return (false)}
	if (theForm.max_cablediameter.value!=""){return (false)}
	if (theForm.bending_radius.value!=""){return (false)}
	if (theForm.temperature.value!=""){return (false)}
	if (theForm.other_specification.value!=""){return (false)}
	if (theForm.FILE1.value!=""){return (false)}
	if (theForm.comment_on_drawing.value!=""){return (false)}
	if (theForm.environment[1].checked){return (false)}
	if (theForm.environment[2].checked){return (false)}
	return (true)
}


/*############################### EMAIL SEND-FORM ##################*/

function setSplus(){//SWITCHES SEND PAGES ACCORDING TO S+
	//var theForm = document.forms[0]
	if (serviceplus()){
		document["splus"].src = splus1.src
		turnOff('rfqadresses')
		turnOn('splusadresses')
	}else{
		document["splus"].src = splus0.src
		turnOn('rfqadresses')
		turnOff('splusadresses')
	}
}


function resetEmail(){
	//var theForm = document.forms[0]
  for (i = 0;  i < theForm.recipient2.length;  i++)
  {
    theForm.recipient2[i].checked=false
  }

}


/*############################### OTHER SETTINGS ############################*/

function set_stars(){
//var theForm = document.forms[0]

if(theForm.splus_cable.value == "true" && theForm.Cable.value != ""){
		document["cablimg"].src = splusSmall1.src
}else{
		document["cablimg"].src = splusSmall0.src
}

if(theForm.splus_connector1.value == "true" && 
		theForm.Connector_1.value != "" &&
		theForm.connector_1_pn.value !=theForm.connector_1_pn.defaultValue)
{
		document["conn1img"].src = splusSmall1.src
}else{
		document["conn1img"].src = splusSmall0.src
}
if(theForm.splus_connector2.value == "true" && 
		theForm.Connector_2_type.value != "" &&
		theForm.connector_2_pn.value !=theForm.connector_2_pn.defaultValue)
{
		document["conn2img"].src = splusSmall1.src
}else{
		document["conn2img"].src = splusSmall0.src
}
if(theForm.splus_boot1.value == "true" && theForm.Boot1_pn.value != ""){
		document["boot1img"].src = splusSmall1.src
}else{
		document["boot1img"].src = splusSmall0.src
}
if(theForm.splus_boot2.value == "true" && theForm.Boot2_pn.value != ""){
		document["boot2img"].src = splusSmall1.src
}else{
		document["boot2img"].src = splusSmall0.src
}


if(!theForm.boot_2.checked || !theForm.boot_2.checked ||!sleevesEnabled){
	document["star_sleeve1"].src = star0.src
}


if (!theForm.boot_1.checked){
		document["star_sleeve1"].src = star0.src
		document["star_boot1"].src = star1.src
}else{
		document["star_boot1"].src = star0.src
}

if (!theForm.boot_2.checked){
		document["star_sleeve1"].src = star0.src
		document["star_boot2"].src = star1.src
		theForm.btn_clrboot2.disabled = false
}else{
		document["star_boot2"].src = star0.src
		theForm.btn_clrboot2.disabled = true
}


if ((theForm.boot_1.checked || theForm.boot_2.checked) && sleevesEnabled){
		document["star_sleeve1"].src = star1.src
}


if (theForm.sleeveSet[0].checked){
		document["star_boot1"].src = star0.src
		document["star_boot2"].src = star0.src
}

 if (theForm.connector_2[1].checked){            //pigtail
/*		theForm.boot_2.disabled = true
		theForm.btn_clrboot2.disabled = true
		theForm.btn_connector2.disabled = true

		theForm.heatshrink_sleeve2.disabled = true
*/
		document["star_con2"].src = star0.src
		document["star_boot2"].src = star0.src
		document["star_stripping"].src = star1.src



/*
	if(!us){
		theForm.stripping[0].disabled = false
		theForm.stripping[1].disabled = false
	}
		theForm.stripping_a_length.disabled=false
		theForm.stripping_b_length.disabled=false
		theForm.stripping_c_length.disabled=false
		if (!theForm.stripping[1].checked){
			theForm.tinned_inner_conductor[0].disabled = false
			theForm.tinned_inner_conductor[1].disabled = false

			theForm.tinned_braid[0].disabled = false
			theForm.tinned_braid[1].disabled = false
		}
*/
		pigtail = true
 	
 }

 if (theForm.connector_2[0].checked){    //no pigtail
		document["star_stripping"].src = star0.src
		if(cableSelected){document["star_con2"].src = star1.src}
		pigtail=false
 }

}




/*############################### VARIOUS FUNCTIONS ############################*/

function checkPN(){
   if(cableSelected){
	if(confirm(dataresetMessage)){
	   return(true)
	}else{
	   return(false)
	}
   }else{
	return(true)
   }
}


function pagereset(First,Last){
	//var theForm = document.forms[0]
		for (i = First;  i <= Last;  i++){
			var elm = theForm.elements[i]
			switch (elm.type){
			case "select-one":
				elm.options.selectedIndex = 0
				break
			case "text":
				elm.value = elm.defaultValue
				if (elm.defaultValue == "black"){
					elm.disabled = false
				}
				break
			case "textarea":
				elm.value = elm.defaultValue
				break
			case "checkbox":
				if (elm.defaultChecked){
					elm.checked=true;
				}else{
					elm.checked=false;
				}
				elm.disabled=false
				break
			case "radio":
				if (elm.defaultChecked){
					elm.checked=true;
				}else{
					elm.checked=false;
				}
				elm.disabled=false
				break
			case "button":
				elm.disabled = false
				//nothing
			case "hidden":
				elm.value = elm.defaultValue
				break
			default:
				//elm.value = elm.defaultValue
			}
  		}
init()
}

function hiddenfieldsReset(){
	//var theForm = document.forms[0]
	theForm.cable_pn.value=theForm.cable_pn.defaultValue
	theForm.connector_1_pn.value=theForm.connector_1_pn.defaultValue
	theForm.connector_2_pn.value=theForm.connector_2_pn.defaultValue
	theForm.no_boot_1.value=theForm.no_boot_1.defaultValue
	theForm.no_boot_2.value=theForm.no_boot_2.defaultValue
	theForm.boot_1_valid.value=theForm.boot_1_valid.defaultValue
	theForm.boot_2_valid.value=theForm.boot_2_valid.defaultValue
	theForm.boot_1_pn.value=theForm.boot_1_pn.defaultValue
	theForm.boot_2_pn.value=theForm.boot_2_pn.defaultValue
	theForm.boot_1_color.value=theForm.boot_1_color.defaultValue
	theForm.boot_2_color.value=theForm.boot_2_color.defaultValue
	theForm.LengthUnit.value=theForm.LengthUnit.defaultValue
	theForm.rightDisabled.value=theForm.rightDisabled.defaultValue
	theForm.splus_cable.value=theForm.splus_cable.defaultValue
	theForm.splus_connector1.value=theForm.splus_connector1.defaultValue
	theForm.splus_boot1.value=theForm.splus_boot1.defaultValue
	theForm.splus_connector2.value=theForm.splus_connector2.defaultValue
	theForm.splus_boot2.value=theForm.splus_boot2.defaultValue
	theForm.serviceplus.value=theForm.serviceplus.defaultValue

}



function datareset(){
	var tempadres1 = theForm.recipient1.value
	pigtail = false
	//var theForm = document.forms[0]
	var L = theForm.length
//first construction field
	var firstField = 21
		for (i = firstField;  i < L;  i++){
			var elm = theForm.elements[i]
			switch (elm.type){
			case "select-one":
				elm.options.selectedIndex = 0
				break
			case "text":
				elm.value = elm.defaultValue
				if (elm.defaultValue == "black"){
					elm.disabled = false
				}
				break
			case "textarea":
				elm.value = elm.defaultValue
				break
			case "checkbox":
				if (elm.defaultChecked){
					elm.checked=true;
				}else{
					elm.checked=false;
				}
				elm.disabled=false
				break
			case "radio":
				if (elm.defaultChecked){
					elm.checked=true;
				}else{
					if(elm.name!="recipient2")
					{
						elm.checked=false;
					}
				}
				elm.disabled=false
				break
			case "button":
				elm.disabled = false
				//nothing
			case "hidden":
				elm.value = elm.defaultValue
				break
			default:
				//elm.value = elm.defaultValue
			}
  		}
theForm.recipient1.value = tempadres1 // keep the contact email address

cableSelected=false
theForm.Connector_2_type.style.backgroundColor = "#FFFFFF"
theForm.Connector_1.style.backgroundColor = "#FFFFFF"
init()  		
}

function doReset() {
   if(confirm(resetMessage)){
	var form = document.forms[0]
/*
	for (i = 0; i < form.elements.length; i++) {
			form.elements[i].disabled=false
	}
*/
        form.reset()
//	datareset()
	init()
   }
cableSelected=false
}


function checkRightDisabled(){ //special case of microminiature
	//var theForm = document.forms[0]
	if (theForm.rightDisabled.value == "true"){
		disableRight()
		return (true)
	}
}

function disableRight(){//special case: microminiature , no conn 2, pigtail no stripping
	//var theForm = document.forms[0]
	theForm.connector_2[1].click()
	theForm.stripping[1].click()
	theForm.connector_2[1].checked = true
	theForm.connector_2[0].disabled = true
	theForm.Connector_2_type.value = "N/A"
	theForm.Connector_2_type.style.backgroundColor = "#DDDDDD"
	theForm.connector_2_pn.value="N/A"
	document["star0_con2"].src = star0.src
	document["star_con2"].src = star0.src
	theForm.no_boot_1.value="true"
	theForm.no_boot_2.value="true"
	theForm.boot_1_valid.value="false"
	theForm.boot_2_valid.value="false"
	theForm.boot_1_pn.value=theForm.boot_1_pn.defaultValue
	theForm.boot_2_pn.value=theForm.boot_2_pn.defaultValue
	theForm.boot_1_color.value="N/A"
	theForm.boot_2_color.value="N/A"
	if(!us){
		theForm.stripping[0].checked = false
		theForm.stripping[1].checked = false
		theForm.stripping[0].disabled = true
		theForm.stripping[1].disabled = true
	}
	theForm.tinned_inner_conductor[0].checked = false
	theForm.tinned_inner_conductor[1].checked = false
	theForm.tinned_inner_conductor[0].disabled = true
	theForm.tinned_inner_conductor[1].disabled = true
	theForm.tinned_braid[0].checked = false
	theForm.tinned_braid[1].checked = false
	theForm.tinned_braid[0].disabled = true
	theForm.tinned_braid[1].disabled = true
	theForm.stripping_a_length.value = "N/A"
	theForm.stripping_b_length.value = "N/A"
	theForm.stripping_c_length.value = "N/A"
	theForm.stripping_a_length.disabled = true
	theForm.stripping_b_length.disabled = true
	theForm.stripping_c_length.disabled = true
}

function disableFields(){
	//var theForm = document.forms[0]
	theForm.Cable.disabled = true
	theForm.Connector_1.disabled = true
	theForm.Connector_2_type.disabled = true
	theForm.Boot1_pn.disabled = true
	theForm.Boot1_color.disabled = true
	theForm.Boot2_pn.disabled = true
	theForm.Boot2_color.disabled = true
}

function enableFields(){
	//var theForm = document.forms[0]
	theForm.Cable.disabled = false
	theForm.Connector_1.disabled = false
	theForm.Connector_2_type.disabled = false
	theForm.Boot1_pn.disabled = false
	theForm.Boot1_color.disabled = false
	theForm.Boot2_pn.disabled = false
	theForm.Boot2_color.disabled = false
	enableSleeves()
}


function formCleanUp(frm){
var i
  for(i=0; i<frm.elements.length; i++) {
    var elt = frm.elements[i]
    var t = elt.type;

    switch (t) {
     case "text":
      case "hidden":
      case "password":
      case "textarea":
        elt.value="" 
      break;
      case "checkbox":
        elt.checked=false;
      break;
      case "option":
        elt.selected=false;
      break;
    }
  }
}

/*############################### floater #################################*/
var slideTime = 700, 
topMargin = 20;
floatLeft = 600
function floatStart()
{

//  topMargin = xPageY('logo');
  winOnResize(); // set initial position
  xAddEventListener(window, 'resize', winOnResize, false);
  xAddEventListener(window, 'scroll', winOnScroll, false);
  return;
}
function winOnResize() {
//  xMoveTo('floater', xPageX('logo')+xWidth('logo')+10, topMargin);
  xMoveTo('floater', floatLeft, topMargin);
  xShow('floater');
  winOnScroll(); // initial slide
}
function winOnScroll() {
//  xSlideTo('floater', xLeft('floater'), xScrollTop() + topMargin, slideTime);
  xSlideTo('floater', floatLeft, xScrollTop() + topMargin, slideTime);
}
function setSlideTime(st) {
  st = parseInt(st);
  if (!isNaN(st)) slideTime = st;
  var e = xGetElementById('st');
  e.value = st;
  return false;
}

/*#################################################################################
###										###
###										###
###				FORM VALIDATOR					###
###										###
###										###
###################################################################################*/

function FormValidator(theForm)

{
/*
 if (!checkPersonal(theForm))
 {
	return (false)
 }
*/
 if (!checkConstruction(theForm))
 {
	return (false)
 }

  return (true);
}

//###################### quantities #############


function checkQtyInput(theForm,thisElm){
	newInput = true
	qtyBtn_selected = thisElm
	theForm.serviceplus.value = theForm.serviceplus.defaultValue
	checkQty(theForm,thisElm)
	newInput = false
	setSplus()
}


function checkQty(theForm,thisElm){
if (thisElm.name != "qty1"){
	if (theForm.qty1.value<1){
		alert(qtyMsg4)
		thisElm.value = ""
		theForm.qty1.focus()
		return (false)
	}
}

/*
  if (serviceplus()){
     if (thisElm.value > maximumQty)
     {
   	    alert(qtyMsg);
   	    location = "#quantity"
qtyWarningSlideIn()
   	    thisElm.select();
   	    return (false);
     }
  }

*/

if ((!newInput && thisElm.name=="qty1")||newInput)
  {
  if (thisElm.value <= 0)
  {
      alert(qtyMsg3);
      location = "#quantity"
      thisElm.select();
      return (false);
  }
}  

  var checkOK = "0123456789-";
  var checkStr = thisElm.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    location = "#quantity"
    alert(qtyMsg2);
    thisElm.select();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  var doQtyCheck=false
  if(qtySplus){doQtyCheck=true}else{doQtyCheck=false}//because qtySplus is being altered by serviceplus()

  if (serviceplus()||(newInput && lenSplus && doQtyCheck && thisElm.name!="qty1")||(newInput && lenSplus && thisElm.name=="qty1")){//no use if length of cable not S+ and another qty already not S+
    if (chkVal != "" && prsVal > maximumQty)
    {
	location = "#quantity"
	qtyWarningSlideIn()//show warning
	return (false);
    }
  }//else{
    if (chkVal != "" && prsVal <= "0")
    {
      location = "#quantity"
      alert(qtyMsg3);
      thisElm.focus();
      return (false);
    }
//  }
setSplus()
return (true)
}



//########## stripping #################

function checkstripping(theForm,thisElm)
{
if (!checkRightDisabled()){
  var checkOK = "0123456789-.";
  var checkStr = thisElm.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  if(checkStr==""){thisElm.value="0"}
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ".")
      allNum += ch;
  }
  if (!allValid)
  {
    alert(strippingMessage2);
    thisElm.select();
    return (false);
  }
  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "0"))
  {
    alert(strippingMessage2);
    thisElm.select();
    return (false);
  }
  return (true);
}
}


function checkLengthInput(theForm){
	newInput = true
	theForm.serviceplus.value = theForm.serviceplus.defaultValue
	checkLength(theForm)
	newInput = false
}



function checkLength(theForm){
//alert("TEST LENGTH")

//################# CHECKING LENGTH OF CABLE #################
// #### min and max determined in formsettings ###
	setCableLength()
	// detect boots

  if (theForm.Length.value == "")

  {
    alert(lenMsg);
    location = "#cablelength"	
    theForm.Length.focus();
    return (false);
  }

    if (serviceplus()||microMiniature()){
	if (microMiniature()){
		lenMsg2A = lenMsg2 + "Minimum : " + minCabLen + Lunit + "\n" + lenMsg_microminiatureA +maxCabLen + Lunit+ lenMsg_microminiatureB
	}else{
		lenMsg2A = lenMsg2 + "Minimum : " + minCabLen + Lunit + "\n" + "Maximum : " + maxCabLen + Lunit
	}
    }else{
		lenMsg2A = lenMsg2 + "Minimum : " + minCabLen + Lunit
    }


//The maximum length with microminiature connectors is 1 meter. For longer assemblies, please consult us

  var checkOK = "0123456789-.";
  var checkStr = theForm.Length.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else
      allNum += ch;
  }
  if (!allValid)
  {
    alert(lenMsg3);
    theForm.Length.blur();
    location = "#cablelength"	
    theForm.Length.select();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert(lenMsg4);
    location = "#cablelength"	
    theForm.Length.blur();
    theForm.Length.select();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseFloat(allNum);
//  if (serviceplus()||microMiniature()){
  if (serviceplus()||(newInput && qtySplus)){ // no use if quantity not S+
  	if (chkVal != "" && !(prsVal >= minCabLen && prsVal <= maxCabLen))
  	{
		lengthWarningSlideIn();
		location = "#cablelength"	
    		theForm.Length.blur();
//    		theForm.Length.select();
    		return (false);
  	}
  }else{
/*

  	if (chkVal != "" && prsVal < minCabLen)
  	{
    		alert(lenMsg2A);
		location = "#cablelength"	
    		theForm.Length.blur();
    		theForm.Length.select();
    		return (false);
  	}
*/
  }
setSplus()
}


//################# personal ###############

function checkPersonal(theForm)
{
var radioselected
  if (theForm.Name.value == "")
  {
    alert(nameMsg);
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Company_name.value == "")
  {
    alert(companyMsg);
    theForm.Company_name.focus();
    return (false);
  }

  if (theForm.City_zip.value == "")
  {
    alert(zipMsg);
    theForm.City_zip.focus();
    return (false);
  }

  if (theForm.Country.selectedIndex == 0)
  {
    alert(countryMsg);
    theForm.Country.focus();
    return (false);
  }


/*
  if (theForm.Telephone.value == "")
  {
    alert(telMsg);
    theForm.Telephone.focus();
    return (false);
  }

  if (theForm.Fax.value == "")
  {
    alert("Please enter a value for the \"Fax\" field.");
    theForm.Fax.focus();
    return (false);
  }

*/
//  Email validation



   apos=theForm.Email.value.indexOf("@");
   dotpos=theForm.Email.value.lastIndexOf(".");
   lastpos=theForm.Email.value.length-1;
   if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
  {
    alert(emailMsg);
    theForm.Email.focus();
    return (false);
  }


// application
 radioSelected = false;
  for (i = 0;  i < theForm.application.length;  i++)
  {
    if (theForm.application[i].checked)
	{radioSelected = true;}
  }
  if (!radioSelected)
  {
    location="#application"
    alert(applicationMsg);
    return (false);
  }


if (theForm.application[5].checked && theForm.application_description.value.length < 3)
  {
    location="#application"
    alert(applicationMsg);
    theForm.application_description.focus()
    return (false);
  }

return (true)
}



//################ construction ################

function checkConstruction(theForm)
{
var radioselected
// THE CABLE
  if (theForm.Cable.value == "")
  {
    alert(cblMsg);
    theForm.btn_cable.focus();
    return (false);
  }

//CONNECTOR 1

 if (theForm.Connector_1.value == "")
  {
    alert(conn_1Msg);
//  theForm.btn_connector1.focus();
    theForm.btn_connector1.click();
    return (false);
  }



  if (!theForm.boot_1.checked && theForm.Boot1_pn.value == "")
  {
    alert(boot_1Msg);
//    theForm.btn_clrboot1.focus();
    location="#heatshrink2"

    theForm.btn_clrboot1.click();
    return (false);
  }

  if (theForm.sleeveSet[2].checked && theForm.heatshrink_sleeves_description.value=="")
  {
    alert(shrink1Msg);
    location="#heatshrink2"
    theForm.heatshrink_sleeves_description.focus()
    return (false);
  }



//CONNECTOR 2

  radioSelected = false;
  for (i = 0;  i < theForm.connector_2.length;  i++)
  {
    if (theForm.connector_2[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert(pigtailMsg1);
    location="#pigtail"
    return (false);
  }

//if (pigtail){alert("PIGTAIL")}else{alert("NO PIGTAIL")}


if (!pigtail){

  if (theForm.Connector_2_type.value == "")
  {
    alert(conn_2Msg);
//    theForm.btn_connector2.focus();
    theForm.btn_connector2.click();
    return (false);
  }

  if (!theForm.boot_2.checked && theForm.Boot2_pn.value == "")
  {
    alert(boot_2Msg);
    location="#heatshrink2"
//    theForm.btn_clrboot2.focus();
    theForm.btn_clrboot2.click();
   return (false);
  }


/*
  if (theForm.heatshrink_sleeve2[0].checked && theForm.heatshrink_sleeves2_color.value=="")
  {
    alert(shrink2Msg);
    location="#heatshrink2"
    theForm.heatshrink_sleeves2_color.focus()
    return (false);
  }
*/

} // END NO PIGTAIL


//################# CHECKING LENGTH OF CABLE #################
// see fonction at top
if(checkLength(theForm)==false){return (false)}


//############## END CHECKING LENGTH OF CABLE



//################### if PIGTAIL
if (pigtail && !checkRightDisabled()){
	if (!us){
	  radioSelected = false;
	  for (i = 0;  i < theForm.stripping.length;  i++)
	  {
	    if (theForm.stripping[i].checked)
	        radioSelected = true;
	  }
	  if (!radioSelected)
	  {
	    alert(strippingMessage);
	    location="#stripping"
	    return (false);
	  }
	}
	if (theForm.stripping[0].checked)
	{
		if(!checkstripping(theForm,theForm.stripping_a_length)){return(false)}
		if(!checkstripping(theForm,theForm.stripping_b_length)){return(false)}
		if(!checkstripping(theForm,theForm.stripping_c_length)){return(false)}
	}
//###################
	  if (theForm.stripping[0].checked&&theForm.stripping_a_length.value == "0" && theForm.stripping_b_length.value == "0" && theForm.stripping_c_length.value == "0")
	  {
	    alert(strippingMessage);
	    location="#stripping"
	    return (false);
	  }
	  
	  var  total_strippingLegth = parseInt(theForm.stripping_a_length.value) + parseInt(theForm.stripping_b_length.value) + parseInt(theForm.stripping_c_length.value)
	  if (theForm.stripping[0].checked && (total_strippingLegth >= theForm.Length.value))
	  {
	    alert(strippingMessage3);
	    location="#stripping"
	    return (false);
	  }



	  radioSelected = false;
	  for (i = 0;  i < theForm.tinned_inner_conductor.length;  i++)
	  {
	    if (theForm.tinned_inner_conductor[i].checked)
	        radioSelected = true;
	  }
	  if (!radioSelected)
	  {
	    alert(strippingMessage);
	    location="#stripping"
	    return (false);
	  }
	
	  radioSelected = false;
	  for (i = 0;  i < theForm.tinned_braid.length;  i++)
	  {
	    if (theForm.tinned_braid[i].checked)
	        radioSelected = true;
	  }
	  if (!radioSelected)
	  {
	    alert(strippingMessage);
	    location="#stripping"
	    return (false);
	  }
}



//###################################### END PIGTAIL



// ##################################### QUANTITIES
   if (theForm.qty1.value == "")
  {
    if (serviceplus()){alert(qtyMsg)}else{alert(qtyMsg3)};
    location="#quantity"
    theForm.qty1.select();
    return (false);
  }

if(!checkQty(theForm,theForm.qty1)){return(false)}
if(!checkQty(theForm,theForm.qty2)){return(false)}
if(!checkQty(theForm,theForm.qty3)){return(false)}
if(!checkQty(theForm,theForm.qty4)){return(false)}

// ########### MARKING ####################
  radioSelected = false;
  for (i = 0;  i < theForm.marking.length;  i++)
  {
    if (theForm.marking[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert(markingMsg1);
    return (false);
  }

  if (theForm.marking[1].checked){
	  if (theForm.othermarking.value == ""||theForm.othermarking.value == "N/A")
	  {
	    alert(markingMsg2);
	    theForm.othermarking.focus();
	    return (false);
	  }
  }

return (true)
}


function checkSpecifications(theForm){

	if(issetFrequency!='false' && theForm.Frequency.value==""){
			alert("PLease enter a value in the 'Frequency' field")
			theForm.Frequency.focus();
			return (false)
	}

	if(theForm.Frequency.value!="" && issetFrequency=='false'){
			alert(frequencyMSG)
			theForm.Frequency_unit[0].focus();
			return (false)
	}


	if (issetPhaseMatching != "false" && theForm.phase_matching.value==""){
			alert("PLease enter a value in the 'Phase Matching' field")
			theForm.phase_matching.focus();
			return (false)
	}

	if (issetPhaseMatching == "false" && theForm.phase_matching.value!=""){
			alert("Phase matching: "+phasematchingMSG)
			theForm.phase_matching.focus();
			return (false)
	}

	if (theForm.phase_matching_spec[2].checked){
		if (theForm.phase_matching_value.value==""){
			alert("PLease enter a value in the 'Phase Matching'-'value' field")
			theForm.phase_matching_value.focus();
			return (false)
		}
	}


	if (theForm.phase_matching_spec[2].checked && theForm.phase_matching_value.value == ""){
			alert(phasematchingvalueMSG);
			theForm.phase_matching_value.focus();
			return (false);
	}

	if(issetMaxCableDiameter!='false' && theForm.max_cablediameter.value==""){
			alert("PLease enter a value in the 'max cable diameter' field")
			theForm.max_cablediameter.focus();
			return (false)
	}

	if(issetMaxCableDiameter=='false' && theForm.max_cablediameter.value!=""){
			alert('max cable diameter: '+unitMSG)
			theForm.max_cablediameter_unit[0].focus();
			return (false)
	}

	if(issetBendingradius!='false' && theForm.bending_radius.value==""){
			alert("PLease enter a value in the 'Bending radius' field")
			theForm.bending_radius.focus();
			return (false)
	}

	if(issetBendingradius=='false' && theForm.bending_radius.value!=""){
			alert('Bending radius: '+unitMSG)
			theForm.bending_radius_unit[0].focus();
			return (false)
	}

	if(issetTemperature!='false' && theForm.temperature.value==""){
			alert("PLease enter a value in the 'temperature' field")
			theForm.temperature.focus();
			return (false)
	}

	if(issetTemperature=='false' && theForm.temperature.value!=""){
			alert('temperature: '+tempMSG)
			theForm.temperature_unit[0].focus();
			return (false)
	}
	return (true)
}

