
var agt = navigator.userAgent.toLowerCase(); // get browser type

var isIE4up = (document.all) ? 1 : 0;
var isIE5   = (isIE4up && navigator.appVersion.indexOf("MSIE 5") != -1) ? 1 : 0;
var isIE6   = (isIE4up && navigator.appVersion.indexOf("MSIE 6") != -1) ? 1 : 0;
var isGecko = (navigator.userAgent.indexOf("Gecko") != -1) ? 1 : 0;
var isOpera = (agt.indexOf("opera") != -1) ? 1 : 0;

function plusZero(val){
var dotpos=(''+val).indexOf(".")+1;
var res=(''+val).substr(dotpos)<10?(''+val).substr(dotpos)+'0':(''+val).substr(dotpos);
return (dotpos!=0)?(''+val).substr(0,dotpos)+res.substr(0,2):''+val+'.00';
}



function keyFilterA(e, strPattern) {  
// (c) Mauz :) 
	 var chr = (isIE4up || isIE6 || isIE6)?e.keyCode:e.which;  
	 var ch = String.fromCharCode(chr);  
	 if (chr != 13 && chr != 8) { 
		var re = new RegExp(strPattern);  
		if (ch.search(re) == -1) {  
			if(isIE4up || isIE6 || isIE6){
				e.returnValue = false;
			}else{
				e.preventDefault();
			}
		} 
	} 
}

function isEmpty(str){
	var re=new RegExp("^ *(.*) *$","gi")
	var arr = re.exec(str);
	str=RegExp.$1;
	return (str=='');
}

function calculate(){
	var total=0;
	var fL=document.getElementById('calc').elements.length;
	for(var i=0; i<fL; i++){
		if(document.getElementById('calc').elements[i].type.toUpperCase()=='TEXT' && !isNaN(document.getElementById('calc').elements[i].value) && !isNaN(document.getElementById('calc').elements[i].attributes['name'].value=='exp')){
			total+=Math.round(0+document.getElementById('calc').elements[i].value*100)/100;;
		}
	}
	if(total>0){
		document.getElementById('subtotal').innerHTML=plusZero(total);
		document.getElementById('expRefund').innerHTML = plusZero(total-(total/document.getElementById('calc').elements['vatRef'].value)) + ' ' + document.getElementById('calc').elements['curVal'].value;	
	}
}