var qnbStatus = new Object();
qnbStatus['wholesaling']=0;
qnbStatus['printing']=0;
qnbStatus['commercial_vehicle']=0;
qnbStatus['landlord']=0;
qnbStatus['restaurant']=0;
qnbStatus['tradesman']=0;
qnbStatus['surgery']=0;
qnbStatus['hotel']=0;
qnbStatus['office']=0;
qnbStatus['manufacturing']=0;
qnbStatus['shop']=0;
qnbStatus['pub']=0;
qnbStatus['motor_trader']=0;
qnbStatus['engineering']=0;
function siteIsUp() {
  return true;
}
function navigateFromList(listObjectId) {
	listObject = document.getElementById(listObjectId);
	productName = listObject.options[listObject.selectedIndex].value;
	if (productName != "Default") {
		navigateQnB(productName, '');
	}
	return;
}

function navigateQnB(product_name, mediaTag) {
	if (product_name == 'general-office') { product_name = 'office';}
	if (product_name == 'motor-trade') { product_name = 'motor_trader';}
	if (product_name == 'wholesale') { product_name = 'wholesaling';}
	if (product_name == 'commercial-vehicle') { product_name = 'commercial_vehicle';}
  if (qnbStatus[product_name]==1) {
    window.open('/qnb/faces/qualification.jsp?product_name='+product_name+'&mediaTag='+mediaTag,
                '',
                'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
    return false;
  }
  else {
    window.location = ('/scripts/quote.cgi?product_name='+product_name+'');
  }

}

function quickLinks(elem) {
    var destinationUrl = elem.options[elem.selectedIndex].value;
    if(destinationUrl) location.href = destinationUrl;
    return;
}

function resetAlerts(fieldinput){
    var errorNameToReset = fieldinput + '_error';
    //alert(errorNameToReset);
    if (document.getElementById(errorNameToReset)){
      document.getElementById(errorNameToReset).style.visibility = 'hidden';
    } else{
      //alert("! Tamar Debug\r\r" + "Check document errors for: " + errorNameToReset)
    }
}

function nextSection(sectionId){
    document.forms['section_form'].next_section.value = sectionId;
}

function checkForm(form){
    var error = 0;
    var arrErrors = new Array();

    for (var i in mandFields) {
      var name = 'attr_' + mandFields[i];
      var value = form.elements[name].value;
      document.getElementById(name + "_error").style.visibility = 'hidden';

      //alert(name + " " + value);

      if (value) {
        if (value == '') {
            error += 1;
            errorName = name + '_error';
            arrErrors[arrErrors.length] = errorName;
        }
      } else {
        var radioError = 1
        for (var r=0; r < form.elements[name].length; r++){
          if (form.elements[name][r].checked){
            radioError = 0;
          }
        }
        if (radioError) { 
          error += 1
          errorName = name + '_error';
          arrErrors[arrErrors.length] = errorName;
        } 
      }
    }
    
    if (error > 0) {
        showErrors(arrErrors);
        alert('Please complete all mandatory fields ');
        return false;
    }
    else {
        return true;
    }
}

function showErrors(myErrorArray){
  for (t=0; t < myErrorArray.length; t++){
    //alert("here " + t);
    myErrorName = myErrorArray[t];
    //alert(myErrorName);
    if (document.getElementById){
      //alert(myErrorName);
      document.getElementById(myErrorName).style.visibility = 'visible';
    }
  }
}
