// JavaScript Document
function dollarformat(num){
	if(num.length>6){
		rem=num.length-6;
		numform=num.substr(0,rem)+','+num.substr(rem);
	}else{
		numform=num;
	}
	return numform;
}

//function update_option(what_pic,opt_sku,opt_image_small,opt_image_large){
//	//alert(opt_image_small);
//	//alert(opt_image_small);
//	
//	if(opt_image_large != '' && opt_image_large != 'x' && opt_image_large != '*'){
//		document.images["large_pic" + what_pic].src =imagepath + opt_image_large;
//	}
//	
//	//squ
//	if(opt_sku != '' && opt_sku != 'x' && opt_sku != '*'){
//		sku_name = 'sku' + what_pic;	
//		document.getElementById(sku_name).innerHTML = opt_sku;
//	}
//}
	
//function format_price(y,num1){
//	//num1=0;
//	//can_price=0;
//	base_cost = document['form_'+y]['current_price'+y].value; //this is the product price with no options
//	can_price = 0;
//	
//	//add all the options on the page togethet + the product price
//	var num2 = 0;
//	//alert(num1);
//	for (var i=0; i < document['form_'+y].length; i++){
//		if(document['form_'+y].elements[i].name.search(/option_/) != '-1'){
//			f = document['form_'+y].elements[i].value.split( "," );
//			num2 = Number(num2) + Number(f[2]);
//			//alert(num2);
//		}
//	}
//	//alert();
//	the_sum = Number(base_cost)+num2;//Number(base_cost) + Number(num2)
//	//alert(the_sum);
//	num = parseFloat(the_sum);//opt price
//	price_name = 'price' + y;
//	
//	if(num==0){
//		//num == '0' && cents == '00'
//		//
//		document.getElementById(price_name).innerHTML = 'Please Select an option to see Price';
//	} else {
//		num_c = 0;
//		num_c =0;
//		
//		if(!document['form_'+y]['list'+y]){
//			for(a=0;a<document['form_'+y].length;a++){
//				if(document['form_'+y][a].name.match("option_")){
//					listtemp=document['form_'+y][a].value.split(',');
//					listprice=0;
//					//alert(listprice);
//					break;
//				}
//			}
//		}else{
//			listprice=document['form_'+y]['list'+y].value;
//		}
//		listprice=parseFloat(listprice).toFixed(2);
//		listprice=Number(listprice)+Number(num2);
//		listout="";
//		if(Number(listprice)>Number(num)){
//			dif=(Number(listprice)-Number(num)).toFixed(2);
//			listout='<span style="text-decoration:line-through">List: $'+dollarformat(listprice.toFixed(2))+'</span><br>';
//			listout=listout+"<b>You save : $"+dollarformat(dif)+"</b><br>";
//		}
//		
//
//		can_pri=0;
//		document.getElementById(price_name).innerHTML = listout+'Price: $' + dollarformat(num.toFixed(2));
//
//
//	}
//	
//}

// function update_price(x,y){
//	//add it up or just update the price displayed based on if the option is default or not
//	alert(x); 
//	//alert(y);
//	
//	var x_arr = x.split( "," );
//	
//	//define the vars we will be using
//	var option_id = x_arr[0];
//	var option_choice = x_arr[1];
//	var option_price = x_arr[2];
//	var weight = x_arr[3];
//	var sku = x_arr[4];
//	var quantity = x_arr[5];
//	var small_image = x_arr[6];
//	var large_image = x_arr[7];
//	var op_type = x_arr[8];
//	
//	//var quant_procedure_backorder = <!--- #allow_zero_order# --->;
//	var quant_procedure_backorder = false;
//	if(quantity == 0 && quant_procedure_backorder == false && option_id != 'option_error' && option_id != 'no_option_selected'){
//		price_name = 'price' + y;
//		butt_name = 'butts' + y;
//		document.getElementById(price_name).innerHTML = backorder_message;
//		document.getElementById(butt_name).style.display = 'none'; 
//	} else {
//		butt_name = 'butts' + y;
//		document.getElementById(butt_name).style.display = ''; 
//		if(option_id == 'option_error' || option_id == 'no_option_selected'){
//			format_price(y,0)
//			
//			if(quantity != 'x'){
//				quant_name = 'quantity' + y;	
//				document.getElementById(quant_name).innerHTML = quantity;
//			}
//			
//			//pic and sku
//			if(op_type == 'c'){update_option(y,sku,large_image);};
//		}else if(op_type == 'd'){
//			//default option, only update price
//			format_price(y,option_price);
//			update_option(y,sku,small_image,large_image);
//			
//		}
//		else if(op_type == 'c'){
//			//custom option, update price sku image quantity
//			format_price(y,option_price)
//			
//			//now we will call a function on the product_line or detail page that will, update the image and the sku
//			update_option(y,sku,small_image,large_image);
//		}
//	}
//}
	
// 	function update_price(x,y){
//		//add it up or just update the price displayed based on if the option is default or not
//		alert(x); 
//		//alert(y);
//		var x_arr = x.split( "," );
//		
//		//define the vars we will be using
//		var option_id = x_arr[0];
//		var option_choice = x_arr[1];
//		var option_price = x_arr[2];
//		var weight = x_arr[3];
//		var sku = x_arr[4];
//		var quantity = x_arr[5];
//		var small_image = x_arr[6];
//		var large_image = x_arr[7];
//		var op_type = x_arr[8];
//		
//		//if it is 0 quant then you cant have it
//		var quant_procedure_backorder = #allow_zero_order#;
//		if(quantity == 0 && quant_procedure_backorder == false && option_id != 'option_error' && option_id != 'no_option_selected'){
//			//alert('nono');
//			price_name = 'price' + y;
//			butt_name = 'butts' + y;
//			document.getElementById(price_name).innerHTML = '#backorder_message#';
//			//get rid of quant and order button
//            document.getElementById(butt_name).style.display = 'none'; 
//		} else {
//			butt_name = 'butts' + y;
//			document.getElementById(butt_name).style.display = ''; 
//			if(option_id == 'option_error' || option_id == 'no_option_selected'){
//				format_price(y,0)
//				
//				if(quantity != 'x'){
//					quant_name = 'quantity' + y;	
//					document.getElementById(quant_name).innerHTML = quantity;
//				}
//				
//				//pic and sku
//				if(op_type == 'c'){update_option(y,sku,large_image);};
//			}else if(op_type == 'd'){
//				//default option, only update price
//				format_price(y,option_price)
//				update_option(y,sku,small_image,large_image);
//			}
//			else if(op_type == 'c'){
//				//custome option, update price sku image quantity
//				format_price(y,option_price)
//				
//				//now we need to update the quantity (if displayed)	
//				if(quantity != 'x'){
//					quant_name = 'quantity' + y;	
//					//document.getElementById(quant_name).innerHTML = quantity;
//				}
//				
//				//now we will call a function on the product_line or detail page that will, update the image and the sku
//				update_option(y,sku,small_image,large_image);
//			}
//		}
//	}
	function openWin( windowURL, windowName, windowFeatures ) { 
		return window.open( windowURL, windowName, windowFeatures ); 
	}
