function checkFSMandatoryFields(formName,fsMandFields,errorText,incompleteFields) {
var overallPass=true;
var pass=true;
var incompleteCounter = 0;
var prevRadioName = '';
if (document.images) {
for (i=0;i<formName.length;i++) {
var tempobj=formName.elements[i];
for(j=0;j<fsMandFields.length;j++) {
var checkManField = false;
if (tempobj.name == fsMandFields[j]) {
checkManField = true;
break;
}
}
if (checkManField) {
if (((tempobj.type=="text")&& tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&& tempobj.selectedIndex==0)
|| (tempobj.type.toString()=="checkbox" && tempobj.checked==false)) {
pass=false;
overallPass=false;
incompleteFields[incompleteCounter] = tempobj.name;
incompleteCounter++;
} else if(tempobj.type=="radio") {
var radiogroup = formName.elements[tempobj.name];
pass = false;
if(radiogroup.length != NaN)
{
for(var k=0;k<radiogroup.length;k++){
if(radiogroup[k].checked) {
pass = true;
}
}
}
if(!radiogroup.length)
{
if(radiogroup.checked) {
pass = true;
}
}
if((pass==false) && (tempobj.name != prevRadioName)) {
overallPass=false;
incompleteFields[incompleteCounter] = tempobj.name;
incompleteCounter++;
prevRadioName = tempobj.name;
}
}
}
}
}
if (!overallPass) {
if (document.layers)
alert(errorText);
return false;
} else {
return true;
}
}
mandatoryFieldsActive = true;
function toggleMandatoryFields(aForm,clickedCheckBox) {
if (clickedCheckBox.checked) {
mandatoryFieldsActive = false;
resetAllMandFieldIndicators();
resetAllLabelColor();
} else if (!clickedCheckBox.checked) {
mandatoryFieldsActive = true;
showAllMFI(aForm,null);
}
}
function getCurrentManFields(aForm) {
temporaryMandatoryFields = new Array();
temporaryMandatoryFieldsIndex = 0;
if (mandatoryFieldsActive) {
for( i=0 ; i<flightSellingMandatoryFields.length ; i++) {
if (flightSellingMandatoryFields[i][3] == "") {
temporaryMandatoryFields[temporaryMandatoryFieldsIndex++] = flightSellingMandatoryFields[i][0];
} else if (flightSellingMandatoryFields[i][3] == "TEXT") {
textObject=eval("aForm."+flightSellingMandatoryFields[i][4]);
if (textObject && textObject.value != "") {
temporaryMandatoryFields[temporaryMandatoryFieldsIndex++] = flightSellingMandatoryFields[i][0];
}
} else if (flightSellingMandatoryFields[i][3] == "CHECKBOX") {
checkBoxObject=eval("aForm."+flightSellingMandatoryFields[i][4]);
if (checkBoxObject && checkBoxObject.checked) {
temporaryMandatoryFields[temporaryMandatoryFieldsIndex++] = flightSellingMandatoryFields[i][0];
}
} else if (flightSellingMandatoryFields[i][3] == "RADIO") {
radioObject=eval("aForm."+flightSellingMandatoryFields[i][4]);
if (radioObject) {
for( j=0 ; j < radioObject.length ; j++ ) {
if (radioObject[j].value == flightSellingMandatoryFields[i][5]) {
mandRadioIndex = j;
break;
}
}
if (radioObject[mandRadioIndex].checked) {
temporaryMandatoryFields[temporaryMandatoryFieldsIndex++] = flightSellingMandatoryFields[i][0];
}
}
} else if (flightSellingMandatoryFields[i][3] == "DROPDOWN") {
dropdownObject=eval("aForm."+flightSellingMandatoryFields[i][4]);
dropdownMandatoryValues=flightSellingMandatoryFields[i][5];
dropdownMandatoryValuesArray=dropdownMandatoryValues.split(",");
if (dropdownObject) {
dropdownValue = dropdownObject.options[dropdownObject.selectedIndex].value;
for( j=0 ; j < dropdownMandatoryValuesArray.length ; j++ ) {
if (dropdownMandatoryValuesArray[j] == dropdownValue) {
temporaryMandatoryFields[temporaryMandatoryFieldsIndex++]=flightSellingMandatoryFields[i][0];
}
}
}
}
else if (flightSellingMandatoryFields[i][3] == "DROPDOWN_EXC")
{
dropdownObject=eval("aForm."+flightSellingMandatoryFields[i][4]);
if (dropdownObject)
{
dropdownMandatoryValues=flightSellingMandatoryFields[i][5];
dropdownMandatoryValuesArray=dropdownMandatoryValues.split(",");
dropdownValue = dropdownObject.options[dropdownObject.selectedIndex].value;
var mandatory = true;
for(j=0; j<dropdownMandatoryValuesArray.length; j++)
{
if(dropdownMandatoryValuesArray[j] == dropdownValue)
{
mandatory = false;
break;
}
}
if (mandatory) temporaryMandatoryFields[temporaryMandatoryFieldsIndex++]=flightSellingMandatoryFields[i][0];
}
}
else if (flightSellingMandatoryFields[i][3] == "TEXTVALUE_EXC")
{
textObject=eval("aForm."+flightSellingMandatoryFields[i][4]);
if (textObject)
{
textMandatoryValues=flightSellingMandatoryFields[i][5];
textMandatoryValuesArray=textMandatoryValues.split(",");
textValue = textObject.value;
var mandatory = true;
for(j=0; j<textMandatoryValuesArray.length; j++)
{
if(textMandatoryValuesArray[j] == textValue)
{
mandatory = false;
break;
}
}
if (mandatory) temporaryMandatoryFields[temporaryMandatoryFieldsIndex++]=flightSellingMandatoryFields[i][0];
}
}
}
}
return temporaryMandatoryFields;
}
function submitAndCheckForm(aForm,errorText) {
currentIncompleteFieldsList = new Array();
currentManFieldsList = getCurrentManFields(aForm);
if(checkFSMandatoryFields(aForm,currentManFieldsList,"Please ensure all required fields are completed",currentIncompleteFieldsList)) {
aForm.submit();
} else if (!document.layers) {
showErrors('errorMsg',currentIncompleteFieldsList,errorText);
showHideDiv(aForm.name,'off');
showHideDiv(aForm.name,'on');
}
}
function showAllMFI(aForm,switchOff) {
if (switchOff != null) {
switchOffList = new Array();
switchOfffListIndex = 0;
for( i=0 ; i<flightSellingMandatoryFields.length ; i++ ) {
if (flightSellingMandatoryFields[i][4] == switchOff) {
switchOffList[switchOfffListIndex++] = flightSellingMandatoryFields[i][0];
}
}
resetMandFieldIndicators(switchOffList);
resetLabelColor(switchOffList);
}
currentManFieldsList = getCurrentManFields(aForm);
for ( i=0 ; i<currentManFieldsList.length ; i++ ) {
showHideDiv(fsIndicatorLookup[currentManFieldsList[i]],'on');
}
}
function showHideDiv(divName,onOrOff) {
if (document.layers) {
divObject = eval('document.'+divName);
if (divObject) { divObject.visibility = (onOrOff.toLowerCase()=='on') ? 'show' : 'hide'; }
}
else if (document.all) {
divObject = eval('document.all.'+divName);
if (divObject) { divObject.style.visibility = (onOrOff.toLowerCase()=='on') ? 'visible' : 'hidden'; }
}
else if (!document.all && document.getElementById) {
divObject = document.getElementById(divName);
if (divObject) { divObject.style.visibility = (onOrOff.toLowerCase()=='on') ? 'visible' : 'hidden'; }
}
}
function changeLblColor(divName,color) {
if (document.layers) {
} else {
thisdivObject = getPageObject(divName);
if (thisdivObject) { thisdivObject.style.color = color; }
}
}
function getPageObject(objectID) {
if (document.layers) {
pageObject = eval('document.'+objectID);
} else if (document.all) {
pageObject = eval('document.all.'+objectID);
} else if (!document.all && document.getElementById) {
pageObject = document.getElementById(objectID);
}
return pageObject;
}
var content;
function showErrors(errorMsgObjectID,fieldsList,errorText) {
resetAllLabelColor();
resetSharedLabelColor();
content ='<table><tr><td><img src="/cms/s.gif" width="1" height="3" border="0" /></td></tr><tr><td class=maintextintroerror style=position:relative;>'+errorText+ '</td></tr></table>\n';
for (i=0 ; i<fieldsList.length ; i++) {
currentLabel = fsLabelLookup[fieldsList[i]];
previousLabel = (i!=0) ? fsLabelLookup[fieldsList[i-1]] : null;
divObject = getPageObject(currentLabel);
changeLblColor(currentLabel,'Red');
if (!hasSecondaryTitle(fieldsList[i],divObject)) {
if (divObject && (currentLabel != previousLabel)) { content += '- '+divObject.innerHTML+'<br/>\n'; }
}
}
changeLayerContent(errorMsgObjectID,content);
if (document.documentElement && document.documentElement.scrollTop)
{
document.documentElement.scrollTop=1;
}
else if (document.body && document.body.scrollTop)
{
document.body.scrollTop=1;
}
}
var translatedBillingAddress ='';
function setTranslatedBillingAddress(translation){
translatedBillingAddress = translation;
}
function hasSecondaryTitle(field,primaryLabelObject) {
if ((field == "AddressLine1") || (field == "AddressLine2") || (field == "AddressLine3"))
{
if (primaryLabelObject) { content += '- ' + translatedBillingAddress + ' ' +primaryLabelObject.innerHTML+'<br/>\n'; }
changeLblColor('BillingAddressLbl','Red');
return true;
}
return false;
}
function resetAllMandFieldIndicators() {
for ( i=0 ; i<flightSellingMandatoryFields.length ; i++ ) {
showHideDiv(flightSellingMandatoryFields[i][1],'off');
}
}
function resetMandFieldIndicators(fieldList) {
for ( i=0 ; i<fieldList.length ; i++ ) {
showHideDiv(fsIndicatorLookup[fieldList[i]],'off');
}
}
function resetAllLabelColor() {
for ( i=0 ; i<flightSellingMandatoryFields.length ; i++ ) {
changeLblColor(flightSellingMandatoryFields[i][2],'');
}
}
function resetLabelColor(fieldList) {
for ( i=0 ; i<fieldList.length ; i++ ) {
changeLblColor(fsLabelLookup[fieldList[i]],'');
}
}
function resetSharedLabelColor() {
changeLblColor('BillingAddressLbl','');
}
function changeLayerContent(divName,newContent){
if(document.layers) {
} else {
divObject = getPageObject(divName);
if (divObject) { divObject.innerHTML=newContent; }
}
}
