$(document).ready(function(){
/***** Parse URL *******/

  var $seg1 = jQuery.url.segment(0);

/*****  Home Page Accordion ******/
	$('.accordion_panel').hide();
	  if($seg1 == null) {
	    $('h3#accordion_header_home').addClass('current');
	  } else {
	    $('#panel_' + $seg1 + '.accordion_panel').slideDown("slow","easeInExpo");
	    $('span#expander_' + $seg1).addClass('open');
	    $('h3#accordion_header_' + $seg1).addClass('current');
    };
	$('h3.accordion_header').click(function(){
	  $("*").removeClass('current')
		//see if the panel is open already
		if ($(this).children('span.expander').hasClass('open')) {
			return; //don't do anything
		}else{
			//close the current panel and open the panel new panel
			$('.accordion_panel').slideUp("slow","easeOutExpo");
			$('span.expander').removeClass('open');
			$(this).children('span.expander').addClass('open');
			$(this).next('.accordion_panel').slideDown("normal","easeInExpo");
			$(this).addClass('current');
		};
	});

	
});

/****** Contact Form Validation ******/
function validateNonEmpty(inputField, helpText){
	if (inputField.value.length == 0) {
	if(helpText != null){
		helpText.innerHTML = "Please enter a value.";
	}
		return false;
		} else {
			if(helpText != null){
				helpText.innerHTML = "";
			}
			return true;
		}
  };

function validateEmail(inputField, helpText){
	if(!validateNonEmpty(inputField, helpText)){
		return false;
	} else {
	return validateRegEx(/^[\w\.-_\+]+@[\w-]+(\.\w{2,4})+$/,inputField.value, helpText,"Please enter a valid email address");
	}
};
function validateRegEx(regex, inputStr, helpText, helpMessage){
	if (!regex.test(inputStr)){
		if (helpText != null){
			helpText.innerHTML = helpMessage;
		}
		return false;
	} else {
		if (helpText != null) {
			helpText.innerHTML = "";
		}
		return true;
	}
};
function submitForm(){
		document.myform.submit();
  };

/****** Google Analtyics *****
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16947654-1']);
_gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();*/
