//-----------------------------------------------------------------------------------------

function sUpdateSurveySelection( objChk, sectionLength, sectionCost ) {

var flgChecked = objChk.checked;
var divSectionCount = document.getElementById('divSectionCount');
var divSectionLength= document.getElementById('divSectionLength');
var divSectionCost = document.getElementById('divSectionCost');
var divSectionProject = document.getElementById('divSectionProject');
var divSectionProjectCost = parseFloat(divSectionProject.innerHTML);
var divSectionMinimum = document.getElementById('divSectionMinimum');
var divSectionMinimumCost = parseFloat(divSectionMinimum.innerHTML);
var divSectionTotal = document.getElementById('divSectionTotal');
var objForm = document.forms.cmsForm;

if ( flgChecked ) { 
  divSectionCount.innerHTML = parseInt(divSectionCount.innerHTML)+1; 
  objForm.sectionCount.value = parseInt(divSectionCount.innerHTML)+1;
  } 
  else 
  { 
  divSectionCount.innerHTML = parseInt(divSectionCount.innerHTML)-1; 
  objForm.sectionCount.value = parseInt(divSectionCount.innerHTML)-1;
  }


if ( flgChecked ) { 
  divSectionLength.innerHTML = parseInt(divSectionLength.innerHTML)+sectionLength; 
  objForm.sectionLength.value = parseInt(divSectionLength.innerHTML)+sectionLength; 
  } 
  else 
  { 
  divSectionLength.innerHTML = parseInt(divSectionLength.innerHTML)-sectionLength; 
  objForm.sectionLength.value = parseInt(divSectionLength.innerHTML)-sectionLength; 
  }

if ( flgChecked ) 
  { 
  divSectionCost.innerHTML = fRound(parseFloat(divSectionCost.innerHTML)+sectionCost); 
  objForm.sectionCost.value = fRound(parseFloat(divSectionCost.innerHTML)+sectionCost);
  } 
  else 
  { 
  divSectionCost.innerHTML = fRound(parseFloat(divSectionCost.innerHTML)-sectionCost); 
  objForm.sectionCost.value = fRound(parseFloat(divSectionCost.innerHTML)-sectionCost);
  }

var thisTotalCost = parseFloat(divSectionCost.innerHTML) + parseFloat(divSectionProjectCost);

if ( thisTotalCost > divSectionMinimumCost ) 
  { 
  divSectionTotal.innerHTML = fRound(thisTotalCost);
  objForm.orderValue.value = fRound(thisTotalCost);
  } 
  else 
  { 
  divSectionTotal.innerHTML = fRound(divSectionMinimumCost); 
  objForm.orderValue.value = fRound(divSectionMinimumCost)
  }


}


function fRound ( mnt ) {

mnt = Math.round ( mnt * 100 ) / 100;

return (mnt == Math.floor(mnt)) ? mnt + '.00' : ( (mnt*10 == Math.floor(mnt*10)) ? mnt + '0' : mnt);

}







//-----------------------------------------------------------------------------------------

function sLogin() {

document.getElementById("basketXml").value = objXmlBasket.xml;

document.getElementById("frmLogin").submit();

}

//-----------------------------------------------------------------------------------------

function fLogin() {

document.getElementById("frmLogin").submit();

}


//-----------------------------------------------------------------------------------------

function fConfirmOrderNotAccepted() {

window.location.href = 'showitem.cmsx?itemID=163';

}


//-----------------------------------------------------------------------------------------

function fConfirmOrderAccepted() {

window.opener.document.forms.cmsForm.submit();

window.close();


}

//-----------------------------------------------------------------------------------------

function fConfirmPlaceOrder() {

if (validateform() == false) { return false; }; 

fOpenWindow(162);

}


//-----------------------------------------------------------------------------------------

function fOpenWindow ( intItemID ) {

var strUrl = 'showitem.cmsx?itemID=' + intItemID;

if (document.all) {
   w = document.body.clientWidth;
   h = document.body.clientHeight;
}
else if (document.layers) {
   w = window.innerWidth;
   h = window.innerHeight;
}

var intLeft = ( w-490 ) / 2;
var intTop = ( h-400 ) / 2;

window.open ( strUrl, '', 'height=400, width=490, top=' + intTop + ', left=' + intLeft + ', location=no, menubar=no, resizable=no, scrollbars=1, status=no, toolbar=no' );


}


//-----------------------------------------------------------------------------------------

function fOpenWindowParent ( intItemID ) {

var strUrl = 'showitem.cmsx?itemID=' + intItemID;

window.opener.location.href = strUrl;

window.close();

}


//-----------------------------------------------------------------------------------------

function confirmDelete ( strMessage ) {

 var x = confirm(strMessage);
 if ( x == true ) { 



  document.forms.cmsForm.onsubmit = '';
  document.forms.cmsForm.DELETE.value = 'DELETE';

 }

 return x;

}


//-----------------------------------------------------------------------------------------

function fGetMultiBoxValue ( strFieldName ) {

var strValue = '';

var objField = document.getElementById(strFieldName)

for ( var i = 0; i < objField.options.length; i++ ) {

 if(objField.options(i).selected) strValue+=objField(i).value+','

 }

return String(strValue).substring(0, String(strValue).length-1);

}


//-----------------------------------------------------------------------------------------

function fSetMultiBoxValue ( strFieldName ) {

var objField = document.getElementById(strFieldName)

var testSelected = false;

for ( var i = 0; i < objField.options.length; i++ ) {

 if ( objField.options(i).selected ) testSelected = true;

 }

if ( testSelected == false ) {

for ( var i = 0; i < objField.options.length; i++ ) {

 objField.options(i).selected = true;

 }

}

return true;

}


//-----------------------------------------------------------------------------------------

function sSurveySelection ( strType, intItemID ) {

if ( intItemID == undefined ) intItemID = 33;

window.location.href = 'showitem.cmsx?itemID=' + intItemID + '&surveys=' + strType;

}


