// JavaScript Document
/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);




$(document).ready(function(){
	

	$.ajax({
	url: "../jQuery/jquery.cycle.all.js",
	dataType: "script",
	async: false,
	success: function(js){if(jQuery.browser.safari){eval(js);}}
});
	
	/*$(function(){
	positionFooter(); 
	function positionFooter(){
		$("#footerWrapper").css({position: "absolute",top:($(window).scrollTop()+$(window).height()-$("#footerWrapper").height())+"px"})	
	}
 
	$(window)
		.scroll(positionFooter)
		.resize(positionFooter)
	});*/
	
	$('#mainBanner').cycle({ 
    	fx:      'fade', 
   	 	speed:    750, 
    	timeout:  7500 
	});
 
	/*$(function() {
		 $('#mainBanner').cycle();
	});*/
	
	//CONTROLS SPACING OF BANNERS ON INTERIOR PAGES
		$("#midContent > .bannerWrapper > .intMainBanner:last-child").css({"margin-right":'0'});
	  
	//	THIS SETS THE HEIGHT OF THE MAIN CONTENT SECTION EQUAL TO THE HEIGHT OF THE LEFT NAV AND VICE VERSA
			
			//var windowHite = $(window -200).height();
			var divHite = $('#topWrapper').height();
			$("#top").height(divHite);
			
			var footerHite = $('#footerWrapper').height();
			//$("#midWrapper").height(footerHite)
			
			//	THIS SETS THE HEIGHT OF THE TRANSPARENT BACKGROUND EQUAL TO THAT OF THE PARENT CONTAINER
				var featureHite = $('#news_events').height();
				$("#news_events > .grad").height(featureHite+5);
				
				var featureWide = $('#news_events').width();
				$("#news_events > .grad").width(featureWide);
				
				
				var featureHite = $('#legislative_advisories').height();
				$("#legislative_advisories > .grad").height(featureHite +5);
				
				var featureWide = $('#legislative_advisories').width();
				$("#legislative_advisories > .grad").width(featureWide);
				
				var featureHite = $('#member_spotlight').height();
				$("#member_spotlight > .grad").height(featureHite +5);
				
				var featureWide = $('#member_spotlight').width();
				$("#member_spotlight > .grad").width(featureWide);
				
				var featureHite = $('#penntrux_magazine').height();
				$("#penntrux_magazine > .grad").height(featureHite+5);
				
				var featureWide = $('#penntrux_magazine').width();
				$("#penntrux_magazine > .grad").width(featureWide);
				
				
				var featureHite = $('#current_events').height();
				$("#current_events > .grad").height(featureHite+5);
				
				var featureWide = $('#current_events').width();
				$("#current_events > .grad").width(featureWide);
				
				var midContentHite = $('#midContent').height();
				
				var SNHite = $('#sideNav').height();
				
				var productWrapperHite = $('#midContent > #text > #productWrapper').height();
				
				var textHite = $("#midContent > #text").height();
				
				var offListHite = $("#listOfficers").height();
				
				
				
				
					/*if(midContentHite < offListHite){
						$("#midContent > #text").height(offListHite +25);
					}
					else{
						$("#midContent > #text").height(midContentHite -20);
					};
					
					
					if(textHite < SNHite){
						$("#midContent > #text").height(SNHite);
						//$("#sideNav").height(productWrapperHite);
					}
					else{
						$("#midContent > #text").height(midContentHite -20);
					};
					
					
					if(textHite < productWrapperHite){
						$("#midContent > #text").height(productWrapperHite);
						$("#sideNav").height(productWrapperHite);
					}
					else{
						$("#midContent > #text").height(midContentHite -20);
					};*/
					
					
					
				
				
	
	$('input[id = "submitMemberEdit"]').addClass("button");
	$('input[id = "Username"]').addClass("field");	
	$('input[id = "Password"]').addClass("field");
	$('input[id = "mail_to"]').addClass("field");
	$('input[type = "submit"]').addClass("submit");
	
	
		$('input[type = "submit"]').hover(function() {
			$(this).css({"background-color":"#FFF"});
			$(this).css({"color":"#9E2B28"});
			  }, function() {
				$(this).css({"background-color":"#681614"});
				$(this).css({"color":"#FFF"});
	    });
		
		
		$("#memberLoginBox").hover(function() {
			$(this).children(".welcome > a").css({"color":"#fff"});
			$(this).children(".forgotPassword > a").css({"color":"#fff"});
			  }, function() {
				$(this).children(".welcome > a").css({"color":"#ccc"});
			$(this).children(".forgotPassword > a").css({"color":"#ccc"});
	    });
		
		
	
	$("#top").css({"opacity": ".9"});
	//$("#midWrapper").css({"opacity": ".95"});
	$("#footerWrapper").css({"opacity": ".75"});
	//$("#navWrapper").css({"opacity": "1"});
	$("#rightBox > .button").css({"opacity": "0.9"});
	$(".featureBox > .grad").css({"opacity": "0.6"});
	$(".featureBox > .currentEvents:last-child").css({"margin-right": "0px"});
	$(".featureBox > .grad").css({"opacity": "0.3"});    
	 $(".featureBox > .headline > img").pngfix();
	 $("#midWrapper").pngfix();
	 $("#top > img").pngfix();
		    $("#midWrapper > img").pngfix();
		    $("#footerWrapper > img").pngfix();
		    $("#header > #pmta_logo > img").pngfix();
		    $("#becomeMember > img").pngfix();
		    $("#pmtaStore > img").pngfix();
		    $(".grad > img").pngfix();
	    
	    
	   
			
	   $("#pmta_logo").css({"cursor": "default", "z-index":"1000"});
	    
	 
	//THIS CONTROLS THE CHAPTERS BUTTON SUBNAV
	//$('#foo').slideUp(300).delay(800).fadeIn(400);
	
		$("#secNav > .snButtons").hover(function() {
			$(this).children(".subNav").slideDown();
			  }, function() {
				  $(this).children(".subNav").slideUp();
	    });
		
	//THIS CONTROLS THE CHAPTERS BUTTON SUBNAV LINK ROLLOVERS	
		$("#secNav > .snButtons > .subNav > ul >li").hover(function() {
			$(this).addClass("hover");
			$(this).children("a").css({"color":"#B84C16"});
			  }, function() {
				  $(this).removeClass("hover");
				  $(this).children("a").css({"color":"#FFF"});
	    });
		
		$("#secNav > .snButtons").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
		
		
		
		$("#memberLoginBox > .forgotPassword").click(function() {
			$("#passwordDrop").slideDown("fast");
			$("#rightBox > #memberLoginBox > #loginDrop").slideUp("fast");
			  }, function() {
				  $("#passwordDrop").slideUp("fast");
	    });
		
	
	
		$('#loginDiv').click(function() {
			$("#rightBox > #memberLoginBox > #loginDrop").slideDown("fast");
			$("#passwordDrop").slideUp("fast");
	    });
		
		
		$("#rightBox > .button").hover(function() {
			$(this).addClass("hover");
			$(this).children("a").css({"color":"#333"});
			$(this).children(".welcome").css({"color":"#fff"});

			  }, function() {
				  $(this).removeClass("hover");
				  $(this).children("a").css({"color":"#fff"});
				  $(this).children(".welcome").css({"color":"#ccc"});
	    });
		
		
		
		
		// MAIN NAV FUNCTIONS
		
		var menu = $("#navWrapper > #navBar > #nav > ul > li");
		
			$(menu).hoverIntent({
				sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
				interval: 200,   // number = milliseconds for onMouseOver polling interval
				over: show,     // function = onMouseOver callback (required)
				timeout: 300,   // number = milliseconds delay before onMouseOut
				out: hide       // function = onMouseOut callback (required)
			});
		
		
			function show() {
				$(this).children("ul").slideDown();
				}
			function hide() { 
				$(this).children("ul").slideUp();
			}
		
			$(menu).hover(function() {
				$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
		});



		/*$("#navWrapper > #navBar > #nav > ul > li").hover(function() {
			$(this).addClass("hover");
			$(this).children("ul").delay(1250).slideDown("fast");
			  }, function() {
				  $(this).removeClass("hover");
				  $(this).children("ul").slideUp("fast");
	    });*/
		
	//NTH CHILD of MAIN NAV DROP DOWN ---MAKES MEMBERSHIP APP LINK HAVE MARGIN BELOW
		//$('#navWrapper > #navBar > #nav > ul > li > ul > li> a[id = "membershipApp"]').parent().css({'margin-bottom':'5px'});
		//$('#navWrapper > #navBar > #nav > ul > li > ul > li> a[id = "membershipApp"]').css({'font-weight':'bold', 'color':'#530D0A'});
		//$('#navWrapper > #navBar > #nav > ul > li > ul > li> a[id = "adOpps"]').parents().css({'margin-top':'10px'});
		
		
		$("#navWrapper > #navBar > #nav > ul > li > ul > li").hover(function() {
			$(this).addClass("hover");
			$(this).children("a").css({"color":"#fff"});
			  }, function() {
				 $(this).removeClass("hover");
				 $(this).children("a").css({"color":"#333"});
	    });
		
		
	
	// SIDE NAV FUNCTIONS
	$("#sideNav > .section > ul > li").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
	
	//NTH CHILD of SIDE NAV ---MAKES MEMBERSHIP APP LINK HAVE MARGIN BELOW
	$('#sideNav > .section > ul > li > a[id = "membershipApp"]').parent().css({'margin-bottom':'10px'});
	$('#sideNav > .section > ul > li > a[id = "membershipApp"]').css({'font-weight':'bold', 'color':'#530D0A'});
	$('#sideNav > .section > ul > li > a[id = "adOpps"]').css({'font-weight':'bold', 'color':'#530D0A'});
	$('#sideNav > .section > ul > li > a[id = "adOpps"]').parent().css({'margin-top':'15px'});
	$('#sideNav > .section > ul > li[id = "advDownloads"]').css({'font-weight':'bold', 'color':'#530D0A'});
	
	
	
	
	
	$("#sideNav > .section > ul > li").hover(function() {
			$("#sideNav > .section > .sectionName a").css({"color":"#681614"});
			  }, function() {
				  $("#sideNav > .section > .sectionName a").css({"color":"#333"});
	    });
	
	
	$("#sideNav > .section > .sectionName a").hover(function() {
			$(this).css({"color":"#681614"});
			  }, function() {
				  $(this).css({"color":"#333"});
	    });
	
	
	
	$("#midContent > #text > .adminAdd a").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
	
	// THIS IS FOR showing the chapter officers
	$("#chapterOfficers").click(function() {
			$("#listOfficers").slideToggle("slow");
			e.preventDefault();
			$(this).css({"cursor":"pointer"});
	    });
	
	
	$("#listOfficers > .officersListing > p").hover(function() {
			$(this).css({"background-color":"#F5F5F5"});
			  }, function() {
				  $(this).css({"background-color":"#fff"});
	    });
	
	
	
	
	// THIS IS FOR THE GOOGLE MAP ON THE DIRECTIONS PAGE
	$("#viewGoogle").click(function() {
			$("#pmtaDirections").slideDown();
			  }, function() {
				 $("#pmtaDirections").slideUp();
	    });
	
	//THIS IS FOR THE HOVER ON THE BOARD MEMBERS
	$(".board").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
	
	
	//THIS IS FOR THE LETTER NAV ON THE SUPPLIER DIRECTORY PAGE
	$("#letterNav > a").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
	
	
	//THIS IS FOR THE HOVER ON THE STAFF MEMBERS
	$(".staff").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
	
	
		
	
	// THIS IS FOR THE STORE PAGES
		$("#productWrapper > .product").hover(function() {
			$(this).addClass("hover");
			$(this).children(".viewProduct").addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
				  $(this).children(".viewProduct").removeClass("hover");
				
	    });
		
		
	// THIS IS FOR THE STORE PAGES	
		$(".bigProduct > .buyNow").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
		
		
	// THIS IS FOR THE NEWS PAGES	
		$("#newsNav").hover(function() {
			$(this).addClass("hover");
			$(this).children("a").addClass("hover");
			$(this).children(".sub").slideDown("hover");
			  }, function() {
				  $(this).removeClass("hover");
				  $(this).children("a").removeClass("hover");
				  $(this).children(".sub").slideUp("hover");
	    });
		
		$("#newsNav > .sub > a").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
		
		$('.newsSection > .entry:last-child').before("<h3>").css({"border":"none"});
		$('.newsSection > div:last-child').css({"border":"none"});
		
		$(".newsSection > .entry:last-child").css({"border":"none"});
		
		
	
	//ADMIN SECTION
	$(".adminSection > .adminRow:last-child").css({"border": "none"});
	
	$(".adminRow").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
	
	//THIS SHOWS CHAPTER EVENTS ON THE SUCCESSFUL LOGIN PAGE
		$("#chapterEventsClick").click(function() {
			$("#chapterEvents").slideDown();
			  }, function() {
				  $("#chapterEvents").slideUp();
	    });
		
		
		//THIS SHOWS PROFILE THE SUCCESSFUL LOGIN PAGE
		$("#profileClick").click(function() {
			$("#profile").slideDown();
			  }, function() {
				  $("#profile").slideUp();
	    });
		
	
	//THIS IS FOR THE FOOTER NAVIGATION
		$("#footer > a").hover(function() {
			$(this).addClass("hover");
			  }, function() {
				  $(this).removeClass("hover");
	    });
		

		
	
	});
	
	
	
