var xmlhttp;
var oid;
var oids;
var value;
var opt='';
var output='';



function getAttributevalues(optionid, optionvalueid, productid, optionids)
{
oid = optionid;
oids = optionids;
value=optionvalueid;
//mysoft
if(value==1188)//38
{
	if(document.getElementById(37))
	{
		document.getElementById(37).style.display='none';
	}
	
	if(document.getElementById(36))
	{
		document.getElementById(36).style.display='none';
	}
   if(document.getElementById('option27'))
	{
		document.getElementById('option27').value=0;
	}
	  if(document.getElementById('option37'))
	{
		document.getElementById('option37').value=0;
	}
	if(document.getElementById('option38'))
	{
		document.getElementById('option38').value=0;
	}
	
	
	document.getElementById('img_color').src='';
	
    
	var aryTest = optionids.split('.');
	for (i=1;i<(aryTest.length-2);i++)
	{
		document.getElementById('price'+aryTest[i]).value='';
	}
	//document.getElementById('calctotal').value=document.getElementById('price_base').value;
	
	
	if(document.getElementById(38).style.display=='none')
	{
	document.getElementById(38).style.display='';	
	}
	document.getElementById("option35")[2].selected="selected";	
	document.getElementById("option28")[2].selected="selected";
	document.getElementById("attribute_included_"+35).innerHTML = "<strong>UV Protection Is Included For FREE!</strong>";	
	document.getElementById("attribute_included_"+28).innerHTML = "<strong>Scratch Resistant Is Included For FREE!</strong>";	

	
}
if(value==1186)//36
{

	
	if(document.getElementById(37))
	{
		document.getElementById(37).style.display='none';
	}
	if(document.getElementById(38))
	{
		document.getElementById(38).style.display='none';
	}
	if(document.getElementById('option27'))
	{
		document.getElementById('option27').value=0;
	}
	if(document.getElementById('option27'))
	{
		document.getElementById('option27').value=0;
	}
	
		  if(document.getElementById('option37'))
	{
		document.getElementById('option37').value=0;
	}
	if(document.getElementById('option38'))
	{
		document.getElementById('option38').value=0;
	}
	
	document.getElementById('img_color').src='';
	document.getElementById('option35').value=0;
	document.getElementById('option28').value=0;
	
	var aryTest = optionids.split('.');
	for (i=1;i<(aryTest.length-2);i++)
	{
		document.getElementById('price'+aryTest[i]).value='';
	}
	document.getElementById("attribute_included_"+35).innerHTML = "";	
	document.getElementById("attribute_included_"+28).innerHTML = "";
	if(document.getElementById(36).style.display=='none')
	{
	document.getElementById(36).style.display='';	
	}
}
if(value==1187)//37
{
	
	
	if(document.getElementById(36))
	{
		document.getElementById(36).style.display='none';
	}
	if(document.getElementById(38))
	{
		document.getElementById(38).style.display='none';
	}
	document.getElementById('img_color').src='';
		  if(document.getElementById('option37'))
	{
		document.getElementById('option37').value=0;
	}
	if(document.getElementById('option38'))
	{
		document.getElementById('option38').value=0;
	}
	var aryTest = optionids.split('.');
	for (i=1;i<(aryTest.length-2);i++)
	{
		document.getElementById('price'+aryTest[i]).value='';
	}
	if(document.getElementById(37).style.display=='none')
	{
	document.getElementById(37).style.display='';	
	}
	document.getElementById("option35")[2].selected="selected";	
	document.getElementById("option28")[2].selected="selected";	
	
	document.getElementById("attribute_included_"+35).innerHTML = "<strong>UV Protection Is Included For FREE!</strong>";	
	document.getElementById("attribute_included_"+28).innerHTML = "<strong>Scratch Resistant Is Included For FREE!</strong>";	

}
//mysoft
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="getattributevalues.php";
url=url+"?optionid="+optionid+"&optionvalueid="+optionvalueid+"&productid="+productid;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{ 
if (xmlhttp.readyState==4)
{
	
	str = xmlhttp.responseText;
	//alert(str);
	response = str.split('*sib*');
	//replace image;
	
	// New Ajax code by Joey@GooseRockDesign.com 5/3/10
	if (response[0] != '') {
        $('#swap_container'+oid).html("<img src=\"images/"+output[0]+"\" />");
		$('#swap_container'+oid).show();
	} else { 
		$('#swap_container'+oid).hide();
	} 
	
	if ( oid == 35 && ($('#option31').val() == '1187' || $('#option31').val() == '1188')) {
	    $('#price'+oid).val('0');
	    if ($('#option35').val() == '1201') { alert("This option is included"); }
	} else if( oid == 28 && ($('#option31').val() == '1187' || $('#option31').val() == '1188')) {
		if ($('#option28').val() == '1205') { alert("This option is included"); }
	} else {
	    $('#price'+oid).val(response[1]);
	}
	
	$('#attribute_help_'+oid).html('');

	opt = oids.split('.'); 
	
	//price_base = document.getElementById('price_base').value;

	var price = parseFloat($('#price_base').val());
	
    for (i=0; i<opt.length-1; i++) {
		if(opt[i] !=34) {
			if($('#price'+opt[i]).val() != '') {
			    //alert('here '+price);
                price = parseFloat(price) + parseFloat($("#price"+opt[i]).val());
			}
			
		}
	}
	$('#calctotal').val(price);
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}