function getUrlVars() {
	var vars = {};
	var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {

	vars[key] = value;
	});
	return vars;
}


$(function(){
	//var products_id = getUrlVars()["products_id"];
	var products_id = $('#mainproductsid').val();
	
//var countSelectMenu = $("#productAttributes .wrapperAttribsOptions select").length;

	//check if each drop down menu value is equal to "Please Select"
	var selectedString = $('.wrapperAttribsOptions select option:selected').text();
	var text = (selectedString.search(/Please Select/i));
	if(text != '-1')
	{
		$('#outputText').text('Please make your selection from above');	
	}else
	{
		doWork(products_id);
	}

	$('.wrapperAttribsOptions select').change(function() {
		//check if each drop down menu value is equal to "Please Select"
		var selectedString = $('.wrapperAttribsOptions select option:selected').text();
		var text = (selectedString.search(/Please Select/i));
		if(text != '-1')
		{
			$('#outputText').text('Please make your selection from above');
		}else
		{
			doWork(products_id);
		}
	});

});


//ajax functions

	function getHTTPObject()
	{
		if (window.ActiveXObject) 
			return new ActiveXObject("Microsoft.XMLHTTP");
		else if (window.XMLHttpRequest) 
			return new XMLHttpRequest();
		else 
		{
			alert("Your browser does not support AJAX.");
			return null;
		}
	}

	
	function doWork(product_id)
	{
		var id1 = $("#productAttributes .wrapperAttribsOptions select:eq(0)").val();
		var id2 = $("#productAttributes .wrapperAttribsOptions select:eq(1)").val();
		var id3 = $("#productAttributes .wrapperAttribsOptions select:eq(2)").val();
		var id4 = $("#productAttributes .wrapperAttribsOptions select:eq(3)").val();
		var id5 = $("#productAttributes .wrapperAttribsOptions select:eq(4)").val();

		httpObject = getHTTPObject();		
		if (httpObject != null) 
		{
			httpObject.open("GET", "index.php?main_page=change_text&value1=" + id1 + "&value2=" + id2 + "&value3=" + id3 + "&value4=" + id4 + "&value5=" + id5 + "&product_id=" + product_id , true);
			httpObject.send(null);
			httpObject.onreadystatechange = setOutput;				
		}
		
	}

	function setOutput()
	{
		if(httpObject.readyState == 4)
		{
			document.getElementById('outputText').innerHTML	= httpObject.responseText;
		}
	}

	var httpObject = null;







