/*
$(document).ready(function() {
    $("#faqparent").click(function() {
    	//$("").slideToggle("fast");
    	//$("#"+).slideToggle("fast");
    	//$("#faqbullet0").css("background-image", "url('images/arrow_bottom_lightblue.png');")
    	alert(this.id);
    });
});*/

function Toggle(divID,elem) {
	var div = document.getElementById(divID);
	//var bulletImg1 = document.getElementById("arrImg");
	//var bulletImg2 = document.getElementById("arrImgDown");
	//alert(elem.getElementsByTagName("img").length);
	
	var img1 = elem.getElementsByTagName("img")[0];
	var img2 = elem.getElementsByTagName("img")[1];
	div.style.display =
	div.style.display == "" ? "none" : "";
	if ( div.style.display == "" )
	{ 
		div.parentNode.style.backgroundColor = "#ffffff";
		div.parentNode.style.fontWeight = "bold";
		div.parentNode.style.color = "#1FB4D8";
		img1.style.display = "none";
		img2.style.display = "inline"; 
	}

	if ( div.style.display == "none" )
	{ 
		div.parentNode.style.backgroundColor = "#ffffff";
		div.parentNode.style.fontWeight = "normal";
		div.parentNode.style.color = "#666666";
		img1.style.display = "inline";
		img2.style.display = "none"; 
	}
}

$(document).ready(function() {
    $(".lightbox-open.hp_video").click(function() {
    	$(".lightbox.hp_video").fadeIn("");
    	//$("").slideToggle("fast");
    	//$("#"+).slideToggle("fast");
    	//$("#faqbullet0").css("background-image", "url('images/arrow_bottom_lightblue.png');")
    });
    $(".lightbox-open.privacy").click(function() {
    	$(".lightbox.privacy").fadeIn("");
    	//$("").slideToggle("fast");
    	//$("#"+).slideToggle("fast");
    	//$("#faqbullet0").css("background-image", "url('images/arrow_bottom_lightblue.png');")
    });
    $(".lb-close").click(function () {
    	$(".lightbox").fadeOut("");
    });
});

/*** form validation ***/

function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = '#fed9ee'; 
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = '#fed9ee';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = '#fed9ee';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = '#fed9ee';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validateFormOnSubmit(theForm) {
var reason = "";

  reason += validateEmail(theForm.email);
  reason += validateEmpty(theForm.fullname);
      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}

