function toggleEmailAFriend()
{
	var element = document.getElementById('Email-A-Friend');

	if (element.style.display == 'none') { 
		element.style.display = 'inline';
	} else {
		element.style.display = 'none';
	}
}

function togglePayment() {
	var paymentForm = document.getElementById('checkOutPaymentForm');
	var extraInfo = document.getElementById('extraPayByCheckInfo');
			
	if (paymentForm.style.display == 'inline') {
		paymentForm.style.display = 'none';		
		extraInfo.style.display = 'inline';
		extraInfo.style.width = "280px";
	} else {
		paymentForm.style.display = 'inline';
		extraInfo.style.display = 'none';
	}	
}

function gallon_calculator() {
	blength = $F('boat_long');
	bbeam = $F('boat_beam');
	
	if (blength == '') { blength = 0; }
	if (bbeam == '') { bbeam = 0; }
	
	gallons = (blength * bbeam) / 300 * 3.5;
	
	if (blength > 0 && bbeam > 0) {			
		$('gallon_answer').innerHTML = "You will need <h1>" + gallons.toFixed(2) + " Gallons</h1>" + 
			"This assumes 3 coats of paint plus an extra coat at the waterline and other high impact areas such as the bow.<br /><br />" +
			"<a href=\"javascript:void(0)\" onclick=\"$('gallon_answer').toggle();$('gallon_form').toggle();\" class=\"calclink\">New Calculation</a><br /><br />";
		$('gallon_form').toggle();
		$('gallon_answer').toggle();
	} else {
		alert("You must provide a valid boat length and beam.");
	}
}

var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 600,
      height: 500,
      name:"_blank",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"yes",
      scrollbars:"yes",
      resizable:"yes",
      left:"",
      top:"",
      normal:false
    }
    Object.extend(this.options, options || {});

    if (this.options.normal){
        this.options.menubar = "yes";
        this.options.status = "yes";
        this.options.toolbar = "yes";
        this.options.location = "yes";
    }

    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    window.open(this.options.url, this.options.name,openoptions );
    return false;
  }
}

function calculator_popup(o) {
	return Popup.open({url: o.href, width: 400, height: 300});
}

function survey_use_dd(o) {								
	if (o.value == 'Recreational' || o.value == 'Commercial') {
		$('survey_o1').show();
		$('survey_o1').options.length = 0;
		$('survey_o2').options.length = 0;
		$('survey_o2').hide();				
	} else {
		$('survey_o1').hide();
		$('survey_o2').hide();
		
		if (o.value != '') {
			$('survey_submit').show();
		}
	}
						
	
	switch(o.value) {
		case '':
			$('survey_o1').hide();
			$('survey_o2').hide();	
			$('survey_submit').hide();
		break;
	
		case 'Recreational':
			$('survey_o1').options[0] = new Option('Cruising','Cruising');
			$('survey_o1').options[1] = new Option('Racing','Racing');
			$('survey_submit').show();
		break;
				
		case 'Commercial':
			$('survey_o1').options[0] = new Option('Aluminum, Fiberglass or Wood','Aluminum, Fiberglass or Wood');
			$('survey_o2').show();
			$('survey_o2').options.length = 0;			
			$('survey_o2').options[0] = new Option('Cruise speed less than 15 knots', 'Cruise speed less than 15 knots');
			$('survey_o2').options[1] = new Option('Cruise speed 15 - 30 knots', 'Cruise speed 15 - 30 knots');		
			
			$('survey_o2').options[2] = new Option('Cruise speed over 30 knots', 'Cruise speed over 30 knots');		
			$('survey_submit').show();
		break;
	}
}
		
function survey_find_paint() {
	var survey_use = $('survey_use').value;
	var option1 = $('survey_o1').value;
	var option2 = $('survey_o2').value;
			
	if (survey_use == '') {
		return false;
	}
			
	switch(survey_use) {
		case 'Commercial':
			if (option2 == 'Cruise speed 15 - 30 knots') {
				//alert('You need SN-1');
				window.location.href = '/categories/13';
			} else if (option2 == 'Cruise speed over 30 knots') {
				//alert('You need SN-1 HP');
				window.location.href = '/categories/14';
			} else {
				alert('Please contact your E Paint Representative for a specific recommendation tailored to your boating use.');
			}
		break;
				
		case 'Recreational':
			if (option1 == 'Racing') {
				//alert('You need EP ZO HP');
				window.location.href = '/categories/11';
			} else {
				//alert('You need EP ZO');
				window.location.href = '/categories/12';
			}
		break;
				
		default:
			//alert('You need EP 2000');
			window.location.href = '/categories/15';
		break;
	}	
}