
/* POP-UP WINDOW */
function openwin(URL,theHeight,theWidth,addScroll) {
	var nXpos = (screen.availWidth - theWidth) / 2; 
	var nYpos = (screen.availHeight - theHeight) / 2; 
	var win = window.open(URL, 'popupWin', 'top=' + nYpos + ',left=' + nXpos + ',screenY=' + nYpos + ',screenX=' + nXpos + ',height=' + theHeight + ',width=' + theWidth + 'toolbar=0,scrollbars=' + addScroll + ',location=0,statusbar=0,menubar=0');
	win.focus();
}
/* ************* */


/* PRICE QUOTE */
function calculate(field,form) {

	var itemNum = field.name.split("_");
	var qty = field.value;
	var fieldTotal = itemNum[0] + '_total';
	var fieldPrice = itemNum[0] + '_price';
	fieldPrice = document.getElementById(fieldPrice).value;
	
	document.getElementById(fieldTotal).value = formatDecimal(qty * fieldPrice, 2);
	
	total();
}

function total() {
	var theForm = document.forms[0];
	var grandTotal = document.getElementById('final_total');
		tot = parseInt(theForm.item1_total.value) + <!-- Hours of coverage $265 -->
				parseInt(theForm.item2_total.value) + <!-- Non Sat or Dec. - Feb. $249 hr. -->
				parseInt(theForm.item3_total.value) + <!-- 1.25 hours -->
				parseInt(theForm.item6_total.value) + <!-- 2nd photographer -->
				parseInt(theForm.item8_total.value) + <!-- Engagement session --> 
				parseInt(theForm.item9_total.value) +  <!--Online ordering -->  
				parseInt(theForm.item10_total.value)+ <!-- Videography -->
				parseInt(theForm.item13_total.value)+  <!--Album A -->
				parseInt(theForm.item15_total.value); <!-- Album C -->

	grandTotal.value = formatDecimal(tot);
}

function formatDecimal(val, n) {
  n = n || 2;
  var str = "" + Math.round ( parseFloat(val) * Math.pow(10, n) );
  while (str.length <= n) str = "0" + str;
  var pt = str.length - n;
  return str.slice(0,pt) + "." + str.slice(pt);
}
/* ************* */
