var op_promo_code;
  //op_add_to_cart();
  function op_calc() {
	
	var price_url = "/nep_price.php";
	
	var config_sku = "MD139A-CG-40-40--Breathing Color-1.75-F0000-none-none-0-0-0-0";
	var config_array = config_sku.split("-");
	
	var op_s = config_array[1];
	var op_w = config_array[2];
	var op_h = config_array[3];
	var op_n = config_array[4];
	var op_p = config_array[5];
	var op_b = config_array[6];
	var op_f = config_array[7];
	var op_g = config_array[8];
	var op_m = config_array[9];
	var op_i = config_array[10];
	var op_c = config_array[11];
	var op_sh = config_array[12];
	var op_cc = config_array[13];
	
	var op_frame_selected = "F0000";
	var op_mat_selected = "ML000";
	var op_style_selected = "CG";
	var op_finished_width = "";
	var op_finished_height = "";
	var op_var_order_info = "";
	var op_var_order_info_to_cart = "";
	var op_var_order_info_description1 = "";
	var op_var_order_info_description2 = "";
	var op_var_order_info_item_note = "";
	var op_view_style = "1";
	var op_price_url = "";
	var op_impasto_selected = 0;
	var op_image_crop_selected = 0;
	var op_color_selected = 0;
	var op_security_selected = 0;
	var op_preview_image_url = "";
	var op_preview_image_url_pop = "";
	
    // default CF to 1.75 SB or CT to .75 SB 
	op_b = (op_s == "PL" || op_s == "PF" || op_s == "PB" || op_s == "CU") ? "none" : op_b;
	op_b = (op_s == "CF") ? "1.75" : op_b;
	op_b = (op_s == "CT") ? "0.75" : op_b;
	
	// default glazing, mat, and frame to none if certain style is selected
	op_g = (op_s == "PL" || op_s == "CU" || op_s == "CG" || op_s == "CF" || op_s == "CT") ? "none" : op_g ;
	op_m = (op_s == "PL" || op_s == "CU" || op_s == "CG" || op_s == "CF" || op_s == "CT") ? "none" : op_m ;
	op_f = (op_s == "PL" || op_s == "CU" || op_s == "CG") ? "none" : op_f ;
	
  
		  
	
	price_url += "?op_s="+op_s; // style
	price_url += "&op_w="+op_w; // width
	price_url += "&op_h="+op_h; // height
	price_url += "&op_n="+op_n; // note
	price_url += "&op_p="+op_p; // paper
	price_url += "&op_b="+op_b; // bar
	price_url += "&op_f="+op_f; // frame
	price_url += "&op_g="+op_g; // glazing
	price_url += "&op_m="+op_m; // matt
	price_url += "&op_i="+op_i; // impasto
	price_url += "&op_c="+op_c; // crop
	price_url += "&op_sh="+op_sh; // security
	price_url += "&op_cc="+op_cc; // color
	/*
	if(op_promo_code != $('promo_code').value) {
		price_url += "&coupon="+$('#promo_code').value;
	}*/
	
	op_price_url = price_url;
	
	op_p2 = $("op_paper").text;
	op_add_options = "";
	(op_i==1) ? op_add_options += "Impasto, " : 0;
	(op_c==1) ? op_add_options += "Image Crop, " : 0;
	(op_cc==1) ? op_add_options += "Color Corrected, " : 0;
	(op_sh==1) ? op_add_options += "Security Hardware" : 0;
	
	op_xmlhttpPost(price_url,op_w,op_h,op_finished_width,op_finished_height,op_s,op_p2,op_b,op_f,op_g,op_m,op_add_options,op_n);
  }
  
  function prepData(a) {
	var a_php = "";
	var total = 0;
	for (var key in a)
	{
		++ total;
		a_php = a_php + "s:" +
				String(key).length + ":\"" + String(key) + "\";s:" +
				String(a[key]).length + ":\"" + String(a[key]) + "\";";
	}
	a_php = "a:" + total + ":{" + a_php + "}";
	return a_php;  
  }
  
  function op_add_to_cart() {
	  var config_sku = "MD139A-CG-40-40--Breathing Color-1.75-F0000-none-none-0-0-0-0";
	  var config_array = config_sku.split("-");
	  var config = [];
	  config['image_code'] = config_array[0];
	  config['frame_code'] = config_array[7];
	  config['liner'] = config_array[9];
	  config['height'] = config_array[3];
	  config['width'] = config_array[2];
	  config['substrate'] = config_array[5];
	  config['stretcher'] = config_array[6];
	  config['glazing'] = config_array[8];
	  config['impasto'] = config_array[10];
	  config['cropping'] = config_array[11];
	  config['security'] = config_array[12];
	  config['correction'] = config_array[11];
	  config['mount_type'] = null;
	  config['quantity'] = 1;
	  config['sid'] = null;
	  config['artwork_media_type_id'] = config_array[1];
	  config['cart_item_description'] = null;
	  config['cart_itemdesc1'] = null;
	  config['cart_itemnote'] = null;
	  config = prepData(config);
	  alert(config);
	  jQuery.post("/test.php", config, alert("it worked... maybe."));
  }
  
  function op_styleDescribe(style) {
	  if(style == "CG") return "Canvas Gallery Wrapped";
	  if(style == "PF") return "Paper Framed";
	  if(style == "CT") return "Canvas Framed";
	  else return "Unknown";f
  }
  
  function op_xmlhttpPost(url,op_w,op_h,op_finished_width,op_finished_height,op_s,op_p2,op_b,op_f,op_g,op_m,op_add_options,op_n) {
	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest) {self.xmlHttpReq = new XMLHttpRequest();} // Mozilla/Safari
	else if (window.ActiveXObject) {self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");} // IE
		
	self.xmlHttpReq.open('GET', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	self.xmlHttpReq.onreadystatechange = function() {
	  if (self.xmlHttpReq.readyState == 4) {
		price_response = self.xmlHttpReq.responseText;
		price_response_array = price_response.split("|");
		alert(price_response);
		/*
		op_finished_width = price_response_array[1];
		op_finished_height = price_response_array[2];
		op_discount_value = price_response_array[3];
		//alert(op_discount_value);
		//op_free_shipping_limit(op_finished_width,op_finished_height);
		if(price_response_array[4]) {
			if(op_promo_code != price_response_array[4]) {
			  //$('promo_code').value = price_response_array[4];
			  //op_promo_code = price_response_array[4];
			  //alert("Your promotion code has been applied successfully.");
			} else // $('promo_code').value = op_promo_code;
			$('op_original_price').innerHTML = "$"+price_response_array[5];
			$('op_original_price').style.display = 'block';
			$('op_original_price_text').style.display = 'block';
		} else {
			$('op_original_price').style.display = 'none';
			$('op_original_price_text').style.display = 'none';
			$('promo_code').value = op_promo_code;
		}
		$("op_curr_total").innerHTML = "" + price_response_array[0];
		op_show_finish_size(op_finished_width,op_finished_height);
		op_review_selections(op_w,op_h,op_finished_width,op_finished_height,op_s,op_p2,op_b,op_f,op_g,op_m,op_add_options,op_n);
		op_hide_addtocart_btn('block');
		*/
	  }
	}
	self.xmlHttpReq.send(null);
  }