
function getPrice(field,val,cost,min_price){
	re = /\s/
	c = 0
	for (a=0;a<val.length;a++){
		if (!re.test(val.charAt(a))){c += 1;}    
	}
	p = c * Number(cost);
	if (p < min_price && c > 0) {
		p = min_price;
	}
	
	var fld = document.getElementById(field);
	
	if (fld){
		fld.value = round(p,2);
  }
}
function round(val,places){
			   for (a=1;a<=places;a++){val *= 10;}
			   val = parseInt(val);
			   val = val.toString();
			   val = val.substring(0,val.length-places)+"."+val.substring(val.length-places,val.length);
			   return val;
}

function toggle_engraving_options(engraving_area){
	
	var objArea = document.getElementById("div_" + engraving_area);
	var imgArea = document.getElementById("img_" + engraving_area);
	
	if (objArea){
		 objArea.style.display = "block";		 
		 imgArea.style.display = "none";
	}
	
}

function popupWindow(url,name,w,h)
{

LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable,scrollbars=yes'
win = window.open(url,name,settings)


}