// JavaScript Document


function kdRfSXIvBmIivhs()
{
/* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */ 
var nniNYfXsxIbyAFk=["105","110","x66","111","x40","111","x6e","x6c","105","x6e","101","x63","x75","x72","116","97","105","110","x64","x65","115","x69","x67","x6e","46","x63","111","x2e","117","107"];
var EwrxPCSsiLdSWBh=[" "];
var ZEdjBRfkjjWYunI=["x69","x6e","102","x6f","x40","111","x6e","x6c","x69","x6e","x65","x63","x75","114","116","97","105","110","x64","101","115","105","x67","x6e","46","99","111","46","x75","x6b"];
document.write("<a href=\"&#x6d;&#x61;&#000105;&#x6c;&#x74;&#x6f;&#58;");
for (i=0; i<nniNYfXsxIbyAFk.length; i++) document.write("&#"+nniNYfXsxIbyAFk[i]+";");
for (i=0; i<EwrxPCSsiLdSWBh.length; i++) document.write(EwrxPCSsiLdSWBh[i]);
document.write("\">");
for (i=0; i<ZEdjBRfkjjWYunI.length; i++) document.write("&#"+ZEdjBRfkjjWYunI[i]+";");
document.write('</a>');
/* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */
}


	function getHumanVariantStringFormVar()
	{
//		alert("a");
		//Form a string containing selected values from each combo box		
		var objPanel = document.getElementById("panel_variants");
	//	alert(objPanel);
		var selects = objPanel.getElementsByTagName("SELECT");
		
		var text = "";

		for (var i = 0; i < selects.length; i++)
		{
			var thisSelect = selects[i];
			
//			text += "&optionTypeID[" + i + "]=" + thisSelect.options[thisSelect.selectedIndex].text + "," + "0.00" + "," + $(thisSelect).attr("humanName") + "," + thisSelect.id;
			text += "<input type='hidden' name='optionTypeID[" + i + "]' value='" + thisSelect.options[thisSelect.selectedIndex].text + "," + "0.00" + "," + $(thisSelect).attr("humanName") + "," + thisSelect.id + "' />";

		}
		
		return text;
	}

	function getVariantString()
	{
		//Form a string containing selected values from each combo box		
		var objPanel = document.getElementById("panel_variants");

		
		
		var selects = objPanel.getElementsByTagName("SELECT");
		
		text = "";
		
		for (var i = 0; i < selects.length; i++)
		{
			var thisSelect = selects[i];
			
			text += "&value[" + thisSelect.id + "]=" + thisSelect.value;
		}

		return text;
	
	}
	
	function variant_option_change()
	{
		
		text = getVariantString();
//alert("checking stock and pricing...");
//alert("variant_price.php?" + text + "&thingID=" + document.form1.thingID.value);
//		actionAjax("variant_price.php?" + text + "&thingID=" + document.form1.thingID.value, "variant_option_change_response");


			$.ajax({
				url: 'iwa/include/ajax/variant_price.php',
				data: text + "&thingID=" + document.form1.thingID.value,
				cache: false,
				async:   false,
			  
				success: function(response) 
				{


				//	alert(response);
					var panel_buy_needoptions = document.getElementById("panel_buy_needoptions");
					var panel_out_of_stock = document.getElementById("panel_buy_outofstock");
					var panel_in_stock = document.getElementById("panel_buy_instock");
					var objRRP = document.getElementById("product_rrp");
				
					panel_buy_needoptions.style.display = "none";
				
					var out_of_stock = false;
					var response = response.split(",");
		
					if (response[0] == "0" || response[1] == "0") //Out of stock
					{
						panel_out_of_stock.style.display = "block";
						panel_in_stock.style.display = "none";
					}
					else //In stock
					{
					//	alert("option is in stock");
						panel_out_of_stock.style.display = "none";
						panel_in_stock.style.display = "block";
					}
					
				//	alert(response);
					objRRP.innerHTML = "&pound;" + response[0];
					$("#rrp").val(response[0]);

					//Store options vars for buying
//					alert(getHumanVariantStringFormVar());
					$("#option_vars").html(getHumanVariantStringFormVar());

					document.form1.selectedVariantID.value = response[2];
					
					

				},
				error: function(data)
				{
					alert("Error retrieving pricing and stock availability: " + data.status);
				}
			  
			});		


	}


	
	function variant_option_change_response()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 


		}
	}
