function isValid(type, str) {
	if (type.toLowerCase() == "email") {
		if ((str == null) || (str == "")) return false;
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1) return false;
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
		if (str.indexOf(at,(lat+1))!=-1) return false;
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
		if (str.indexOf(dot,(lat+2))==-1) return false;
		if (str.indexOf(" ")!=-1) return false;
		return true;
	}
};

jQuery.fn.simpleAccordion = function() {
	return this.each(function() {
		var height = 0;
		$(this).find("span").each(function() {
			if($(this).height() > height) height = $(this).height();
		});
		$(this).find("span").height(height);
		$(this).find(".drawer").hide();
		$(this).find("a.topic").fadeTo("fast", 0.5);
		if($(this).find("li.active").size() > 0) $(this).find("li.active div.drawer").show().parent().find("a.topic").fadeTo("fast", 1.0);
		else $(this).find("li:first div.drawer").show().parent().find("a.topic").fadeTo("fast", 1.0);
		var $$ = $(this);
		$(this).find("li a").click(
			function() {
				var checkElement = $(this).next(".drawer");
				if((checkElement.is("div")) && (checkElement.is(":visible"))) {
					return false;
				}
				if((checkElement.is("div")) && (!checkElement.is(":visible"))) {
					$$.find("li.active").removeClass("active").find("a.topic").fadeTo("fast", 0.5);
					$$.find("div.drawer:visible").slideUp("normal");
					checkElement.parent("li").addClass("active").find("a.topic").fadeTo("fast", 1.0);
					checkElement.slideDown("normal");
					return false;
				}
			}
		);
	});
};

(function($) {
	$(document).ready(function() {
		$("input[type=text][title]").each(function() { $(this).val($(this).attr("title")); if($.trim($(this).val()) == "") $(this).val($(this).attr("title")); $(this).focus(function() { if($(this).val() == $(this).attr("title")) $(this).val(""); }).blur(function() { if($.trim($(this).val()) == "") $(this).val($(this).attr("title")); }); });
		$("a[href][rel*=external]").attr("target", "_blank");
		$(".lo").hoverIntent(function() { $(this).removeClass("lo").addClass("hi"); }, function() { $(this).removeClass("hi").addClass("lo"); });
		
		$("#faq-nav").simpleAccordion();
	});
})(jQuery);

