/* swaps large image when small swatches are activated */

function changeSelect(x,image_file) {
    document.myForm.opt15.selectedIndex = x-1;
  	if (document.images)
   		document.images['SwatchSwap'].src = 'Images/'+image_file;
}

function changeSwatch(image_file)
{
  if( document.myForm.opt15.selectedIndex == 0 )
  {
  	if (document.images)
   		document.images['SwatchSwap'].src = 'Images/'+image_file;
  }
}

/* checks that dimensions are between 1 and 99
Original:  Nannette Thacker http://www.shiningstar.net  */

function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
// only allow 0-9 be entered, plus any values passed
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789" + comma + "." + hyphen;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
alertsay = "Please enter only these values \""
alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "We're sorry but the dimension you have entered exceeds the size limitation for a two panel cover.\n"
alertsay = alertsay + "Don't worry! Just call us for a great quote on a three or four panel cover for your spa.\n"
alertsay = alertsay + "Call 800.770.0292 ext. 106 (Mon-Fri, 8AM-5PM Pacific time)."
alert(alertsay);
return (false);
}
}

/* Adds Continuous Heat Seal for free when Ultra Foam is selected */

function altered(what) {

	if (what.opt16[3].checked)
	what.opt17[2].checked = true;
	
	if (what.opt16[0].checked)
	what.opt17[0].checked = true;
	
	if (what.opt16[1].checked)
	what.opt17[0].checked = true;

        } 
        

/* strips quotes and delimiters from comment box */

function jsx1() 
{ 
  var _f=document.myForm; 
  var _o=_f.custtext19; 
  var _r1= new RegExp("[\n\r]","g"); 
  _o.value=_o.value.replace(_r1,"  "); 
  var _r2= new RegExp("\"","g"); 
  _o.value=_o.value.replace(_r2,"''"); 
  var _r3= new RegExp(",","g"); 
  _o.value=_o.value.replace(_r3,"-");
}

function cover_type(type){

	switch(type)
	{
	case 'economy':
	$('#wind_straps_included').attr("disabled", true); 
	$('#heat_seal_included').attr("disabled", true);
	$('#double_wrapped_core_included').attr("disabled", true); 
	$('#heat_seal_no').attr("checked", true);
	$('#wind_straps_no').attr("checked", true);
	$('#double_wrapped_core_no').attr("checked", true); 
	
	$('#heat_seal_yes').attr("disabled", false);
	$('#double_wrapped_core_yes').attr("disabled", false);
	$('#wind_straps_yes').attr("disabled", false); 

	$('#heat_seal_no').attr("disabled", false);
	$('#double_wrapped_core_no').attr("disabled", false);
	$('#wind_straps_no').attr("disabled", false); 

	break;
	case 'standard':
	$('#wind_straps_included').attr("disabled", true); 
	$('#heat_seal_included').attr("disabled", true);
	$('#double_wrapped_core_included').attr("disabled", true); 
	$('#heat_seal_no').attr("checked", true);
	$('#wind_straps_no').attr("checked", true);
	$('#double_wrapped_core_no').attr("checked", true); 
	
	$('#heat_seal_yes').attr("disabled", false);
	$('#double_wrapped_core_yes').attr("disabled", false);
	$('#wind_straps_yes').attr("disabled", false); 

	$('#heat_seal_no').attr("disabled", false);
	$('#double_wrapped_core_no').attr("disabled", false);
	$('#wind_straps_no').attr("disabled", false); 
	break;
	case 'deluxe':
	$('#wind_straps_included').attr("disabled", true); 
	$('#heat_seal_included').attr("disabled", true);
	$('#double_wrapped_core_included').attr("disabled", true); 
	$('#heat_seal_no').attr("checked", true);
	$('#wind_straps_no').attr("checked", true);
	$('#double_wrapped_core_no').attr("checked", true); 

	$('#heat_seal_yes').attr("disabled", false);
	$('#double_wrapped_core_yes').attr("disabled", false);
	$('#wind_straps_yes').attr("disabled", false); 

	$('#heat_seal_no').attr("disabled", false);
	$('#double_wrapped_core_no').attr("disabled", false);
	$('#wind_straps_no').attr("disabled", false); 

    break;
	case 'ultra':
	$('#wind_straps_included').attr("disabled", true); 
	$('#heat_seal_included').attr("disabled", false);
	$('#double_wrapped_core_included').attr("disabled", true); 
	$('#heat_seal_included').attr("checked", true);
	$('#wind_straps_no').attr("checked", true);
	$('#double_wrapped_core_no').attr("checked", true); 

	$('#heat_seal_yes').attr("disabled", true);
	$('#double_wrapped_core_yes').attr("disabled", false);
	$('#wind_straps_yes').attr("disabled", false); 

	$('#heat_seal_no').attr("disabled", true);
	$('#double_wrapped_core_no').attr("disabled", false);
	$('#wind_straps_no').attr("disabled", false); 

    break;
	case 'theworks':
	$('#wind_straps_included').attr("disabled", false); 
	$('#heat_seal_included').attr("disabled", false);
	$('#double_wrapped_core_included').attr("disabled", false); 
	$('#heat_seal_included').attr("checked", true);
	$('#double_wrapped_core_included').attr("checked", true); 
	$('#wind_straps_included').attr("checked", true); 
	
	$('#heat_seal_yes').attr("disabled", true);
	$('#double_wrapped_core_yes').attr("disabled", true);
	$('#wind_straps_yes').attr("disabled", true); 

	$('#heat_seal_no').attr("disabled", true);
	$('#double_wrapped_core_no').attr("disabled", true);
	$('#wind_straps_no').attr("disabled", true); 

    break;
	default:
	$('#wind_straps_included').attr("disabled", true); 
	$('#heat_seal_included').attr("disabled", true);
	$('#double_wrapped_core_included').attr("disabled", true); 
	$('#heat_seal_no').attr("checked", true);
	$('#wind_straps_no').attr("checked", true);
	$('#double_wrapped_core_no').attr("checked", true); 

	}

}
