var dec_places=2;
var n=1;
for(i=0;i<dec_places;i++){
	n=n*10;
}
//function for rounding on 4 decimal places
function round_price(price){
	return (Math.round(n*price))/n;
}

//function for checking decimal value
function check_number(obj){
	re = /[^0-9.]/;
	var test_val=parseFloat(obj.value);
	
	if(isNaN(test_val)){
		
		obj.value=0;
		
	}else{
		obj.value=parseFloat(obj.value);
		
	}
	//obj.val=parseFloat(obj.value);
	if(re.test(obj.value)){
		alert("Valid characters for this field are:0-9 and '.' for decimal point.");
		obj.focus();
		
	}
		
	
	
}
//function for checking integer value 
function check_int(obj){
	re = /[^0-9\-]/;
	
	var test_val=parseFloat(obj.value);
	
	if(isNaN(test_val)){
		
		obj.value=0;
	}else{
		obj.value=parseFloat(obj.value);
	}
	
	if(re.test(obj.value)){
		alert("Valid characters for this field are:0-9 and '-' for negative values.");
		obj.focus();
		return false;
	}else{
		return true;
	}
	
}

function check_pint(obj){
	re = /[^0-9]/;
	
	var test_val=parseFloat(obj.value);
	
	if(isNaN(test_val)){
		
		obj.value=0;
		
	}else{
		obj.value=parseFloat(obj.value);
	}
	if(re.test(obj.value)){
		alert("Valid characters for this field are:0-9");
		obj.focus();
		return false;
	}else{
		return true;
	}
	
	
}

function check_nrstr(obj,chr_no){
	//re = /\d{chr_no}/;
	re = /[^0-9]/;
	//re=/\d/;
	/*
	var test_val=parseFloat(obj.value);
	
	if(isNaN(test_val)){
		
		obj.value=0;
		
	}else{
		obj.value=parseFloat(obj.value);
	}*/
	//alert(re.test(obj.value));
	if(re.test(obj.value)){
		alert("Valid characters for this field are:0-9");
		obj.value="0";
		obj.focus();
		return false;
	}else{
		//return true;
	}
	//alert(obj.value.length);
	if(obj.value.length<chr_no){
		alert("Field is not in valid format!");
		obj.focus();
		return false;
	}
	return true;
}





//function for checking length of string
function check_str(obj){
	re=/\s/g;
	var temp_val=obj.value.replace(re,"");
	if(temp_val.length==0){
		
		return false;
		
	}else{
		return true;
	}
}


function check_valid_str(obj){
	
	//re=/[^(0-9a-zA-z\-.\/)]/;
	re=/[^(\w\s\/\-\#)]/;
	if(re.test(obj.value)){
		alert("Valid characters are: a-z, A-Z, 0-9, '_', '#', '-', '.', '/' and space.\nPlease correct this order number.");
		obj.focus();
		return;
	}
	
	
	
	
	
}


function check_email(obj){
	//re=/\w{0,}[\-\.]?\w{1,}\@\w{1,}[\-\.]?\w{0,}\.\w{2,}/;
	re=/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
	answ=re.test(obj.value);
	if(!answ){
		alert("E-mail you've entered doesn't seems to be OK!");
		return false;
	}else{
		return true;
	}
	
}

function format_price(str){
	//re0=/\.\d{4}/;
	//re1=/\.\d{3}/;
	re2=/\.\d{2}/;
	re3=/\.\d{1}/;
	
	//if(re0.test(str)){
	//	return(str);
	//}else if(re1.test(str)){
	//	return(str+"0");
	//}else 
	if(re2.test(str)){
		return str;
		return(str+"00");
	}else if(re3.test(str)){
		return(str+"0");
	}else{
		return(str+".00");
	}
	
}



function calc_discount(prc){
	
	var new_price=0.025*prc;
	
	return round_price(new_price);
}
//part for layers and old browsers
if(document.all && !document.getElementById) {
    document.getElementById = function(id) {
         return document.all[id];
    }
}

function style_change(obj,val){
	//obj.className=val;
	obj.style.backgroundColor=document.style[val].backgroundColor;
	//alert(obj.className);
	alert(obj.style.backgroundColor);
		/*
		if(val=="in"){
			var stl="solid 1px #c0c0c0"
			var bgc="A2988c";//#7b90a6";//#565656";
		}else{
			var stl="solid 1px #565656";
			var bgc="#000000";
			var bgc="";
		}
		obj.style.border=stl;
		obj.style.backgroundColor=bgc;*/
	}
//function for switching divs on and off 
function toggle(id) {
	
	
	if (document.all) {
		if(document.all[id]){
			if (document.all[id].style.display == 'none') {
				document.all[id].style.display = '';
			} else {
			
				document.all[id].style.display = 'none';
			}
		}
		
	} else if (document.getElementById) {
		if(document.getElementById(id)){
			
			if (document.getElementById(id).style.display == 'none') {
				document.getElementById(id).style.display = 'block';			
			} else {
				document.getElementById(id).style.display = 'none';
			}
		}
	}
}