/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address Format")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address Format")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address Format")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address Format")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address Format")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address Format")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address Format")
		    return false
		 }

 		 return true
	}

function ValidateForm(){
	var emailID=document.myform.Email

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function clearDefaultandCSS(el) {
	if (el.defaultValue==el.value) el.value = ""
	// If Dynamic Style is supported, clear the style
	if (el.style) el.style.cssText = ""
}



function pass_form ( )
{
    valid = true;
    if ( document.myform.Customer.value == "" )
    {
        alert ( "Please fill in your Name." );
        document.myform.Customer.focus();
        return false;
    }
    if ( document.myform.Email.value == "" )
    {
        alert ( "Please fill in your Email Address." );
        document.myform.Email.focus();
        return false;
    }
    if ( document.myform.Comments.value == "" )
    {
        alert ( "Please fill in the Comments field." );
        document.myform.Comments.focus();
        return false;
    }
    if ( document.myform.cap.value == "" )
    {
        alert ( "Please fill in the SPAM Guard." );
        document.myform.cap.focus();
        return false;
    }

}



function gc_form ( )
{
    valid = true;
    if ( document.form2.certto.value == "" )
    {
        alert ( "Please fill in who the gift certificate is being given to" );
        document.form2.certto.focus();
        return false;
    }
    if ( document.form2.certfrom.value == "" )
    {
        alert ( "Please fill in who the gift certificate is from" );
        document.form2.certfrom.focus();
        return false;
    }

}



function show_hide(ISID){
      // Toggle visibility between none and inline
      if ((document.getElementById(ISID).style.display == 'none'))
      {
        document.getElementById(ISID).style.display = 'inline';
      } else {
        document.getElementById(ISID).style.display = 'none';
      }
  }



function validate(chk){
  if (chk.checked == 1)
    return True;
  else
    alert("You did not check the check box agreeing to our reservation policies.")
    return false;
}



function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=450,left = 187,top = 59');");
}


function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=240,left = 187,top = 59');");
}

function resnone(){
 document.getElementById("update").innerHTML = "&nbsp;";
}

function groupon(){
 document.getElementById("update").innerHTML = "Enter Your Groupon ID# in the box below. If more than one Groupon is being redeemed, separate each with a comma. A max of 4 Groupons can be redeemed at any one time:<br><input class=inputbox type=text size=50 maxlength=100 name=grouponID><br><br>Please Note: Groupon's are valid for tandem skydives only and we require a reservation deposit of $35 per person in accordance with our Reservation Policy. This will NOT be charged to you as long as you meet the requirements of our Reservation Policy.";
}

function giftcert(){
  document.getElementById("update").innerHTML = "Enter Your Gift Certificate ID# in the box below. If more than one Gift Certificate is being redeemed, separate each with a comma. A max of 4 Gift Certificates can be redeemed at any one time:<br><input class=inputbox type=text size=50 maxlength=100 name=giftcertID><br><br>Please Note: When redeeming a Gift Certificate, we require a reservation deposit of $35 per person in accordance with our Reservation Policy. This will NOT be charged to you as long as you meet the requirements of our Reservation Policy.";
}


function validate_menu ( )
{
    valid = true;

    if ( document.diveform.divetype.value == "0")
    {
        alert ( "Please choose your reservation type from the drop down menu." );
        valid = false;
    }

    return valid;
}


function mailpage()
{
  mail_str = "mailto:?subject= RollingStar Manufacturing Custom Trailers News Article";
  mail_str += "&body= I saw this news article on the RollingStar Trailers website and thought I would recommend it to you. ";
  mail_str += "Check out the story at this link: " + location.href;
 location.href = mail_str;
}

function mailpage2()
{
  mail_str = "mailto:?subject= RollingStar Manufacturing Custom Trailers";
  mail_str += "&body= I saw this Trailer on the RollingStar Trailers website and thought I would recommend it to you. ";
  mail_str += "Check out the Trailer at the following link: " + location.href;
 location.href = mail_str;
}


