function mainmenu(){
$("#topnav ul, ul#nav ul ").css({display: "none"}); // Opera Fix
$("ul#nav li, #topnav li").hover(function(){
$(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(300);
},function(){
$(this).find('ul:first').css({visibility: "hidden"});
});
}

$(function() {
	mainmenu();
	
	$('#header .menu ul li:last-child').css({"marginRight":"0px", "border":"none"});
	
	var bannerid = 0; 
	var numberofslides = $('#banner ul.slides li').size();
	setInterval(function() {
		bannerid++;
		if(bannerid == numberofslides) { bannerid = 0; }
		$('#banner ul.slides li').fadeOut(1000);
		$('#banner ul.slides li').eq(bannerid).fadeIn(1000);
	}, 5000);
	
	var captchaText = "Enter characters on left to prevent SPAM";
	jQuery("input[name='captcha-875']").val(captchaText);
	jQuery("input[name='captcha-875']").addClass("greytext");
	
	
	$("input[name='captcha-875']").focus(function() {
			var value=$(this).val();
			if(value==captchaText) {
				$(this).val("");
				$(this).removeClass("greytext");
			}
	});
	
	$("input[name='captcha-875']").blur(function() {
			if($(this).val()=="") {
				$(this).val(captchaText);
				$(this).addClass("greytext");
			}
	});
	
	var captchaText2 = "separate by commas";
	jQuery("input#mlstext").val(captchaText2);
	jQuery("input#mlstext").addClass("greytext");
	$("input#mlstext").focus(function() {
			var value2=$(this).val();
			if(value2==captchaText2) {
				$(this).val("");
				$(this).removeClass("greytext");
			}
	});
	$("input#mlstext").blur(function() {
			if($(this).val()=="") {
				$(this).val(captchaText2);
				$(this).addClass("greytext");
			}
	});

	var mq1 = 0; var mq2 = 0; var mq3 = 0;
	
	$("#as-link1").click(function(event){
		event.preventDefault(); $(".as-tab").hide(); $("#as-tab1").show();
		$(".as-link").removeClass("active"); $(this).addClass("active");
		if(mq1==0) document.getElementById('mqmap1').src = document.getElementById('mqmap1').src;
		mq1++;
	});
	
	$("#as-link2").click(function(event){
		event.preventDefault(); $(".as-tab").hide(); $("#as-tab2").show();
		$(".as-link").removeClass("active"); $(this).addClass("active");
		if(mq2==0) document.getElementById('mqmap2').src = document.getElementById('mqmap2').src;
		mq2++;
	});
	
	$("#as-link3").click(function(event){
		event.preventDefault(); $(".as-tab").hide(); $("#as-tab3").show();
		$(".as-link").removeClass("active"); $(this).addClass("active");
		if(mq3==0) document.getElementById('mqmap3').src = document.getElementById('mqmap3').src;
		mq3++;
	});
	
	$("#as-link4").click(function(event){
		event.preventDefault(); $(".as-tab").hide(); $("#as-tab4").show();
		$(".as-link").removeClass("active"); $(this).addClass("active");
	});
	
	$("#as-link5").click(function(event){
		event.preventDefault(); $(".as-tab").hide(); $("#as-tab5").show();
		$(".as-link").removeClass("active"); $(this).addClass("active");
	});
	
	$("#as-link6").click(function(event){
		event.preventDefault(); $(".as-tab").hide(); $("#as-tab6").show();
		$(".as-link").removeClass("active"); $(this).addClass("active");
	});
	
	$("#as-link7").click(function(event){
		event.preventDefault(); $(".as-tab").hide(); $("#as-tab7").show();
		$(".as-link").removeClass("active"); $(this).addClass("active");
	});
	
	$('#asf :checkbox').click(function () {
		var v = $(this).val();
    	if(v!="All") $("#asf .defaultchecked").removeAttr("checked");
    	if(v=="All") { $("#asf :checkbox").removeAttr("checked"); $('#asf .defaultchecked').attr('checked','checked'); }
    	if($("#asf input[type=checkbox]:checked").length==0) $('#asf .defaultchecked').attr('checked','checked');
	});
	
	$('#asf2 :checkbox').click(function () {
		var v = $(this).val();
    	if(v!="All") $("#asf2 .defaultchecked").removeAttr("checked");
    	if(v=="All") { $("#asf2 :checkbox").removeAttr("checked"); $('#asf2 .defaultchecked').attr('checked','checked'); }
    	if($("#asf2 input[type=checkbox]:checked").length==0) $('#asf2 .defaultchecked').attr('checked','checked');
	});
	
	$('#asf4 :checkbox').click(function () {
		var v = $(this).val();
    	if(v!="All") $("#asf4 .defaultchecked").removeAttr("checked");
    	if(v=="All") { $("#asf4 :checkbox").removeAttr("checked"); $('#asf4 .defaultchecked').attr('checked','checked'); }
    	if($("#asf4 input[type=checkbox]:checked").length==0) $('#asf4 .defaultchecked').attr('checked','checked');
	});
	
});
