$(document).ready(function(){    

	$('body').removeClass('no-js'); 

if (screen.availWidth>=480) {
	// SlideToggle for Membership Info
	var dues = $(".page-id-246 .dues");	
	dues.hide();
	$(".page-id-246 .article h3").after("<p class='pricing'><a class='a-button' href='#'>View Plan Details &rarr;</a></p>");

    $(".pricing a").click(function(event){
       $(this).parents(".plan").find(".dues").slideToggle();
       event.preventDefault();
    });
     
    // SlideToggle for Golf Groups    
	$(".page-id-449 .article ul").hide();
	$(".page-id-449 .article h3").prepend("<a class='a-button' href='#'>&#43;</a>");
	$(".page-id-449 h3 + p").addClass('description');
   
    $(".page-id-449 h3").click(function(event){
       $(this).next("p.description").next("ul").slideToggle();
       event.preventDefault();
    });
}	

	$(".page-id-732").find("#member-number").attr("disabled","disabled");
	$('img').each(function(){ // remove inline height and width for images for liquid layout
        $(this).removeAttr('width')
        $(this).removeAttr('height');
    });
	    
    $('.wp-caption').each(function(){
    	$(this).removeAttr('style');
	});
	 	
// full browser drop down
//	$(".nav ul li:has(ul)").find("a:first").append(" &raquo; ");
		$(".nav ul li:has(ul)").find("a:first").after("<span class='menu-select'></span>");
		$(".nav ul ul li:has(ul)").find("span").removeClass("menu-select");
		
// click drop down 		

	$(".nav li span.menu-select").click(function() { //When trigger is clicked...

		$(this).parent().find("ul.children").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.children").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});
	});	
		
/* hover drop down - usability issue
    $(".nav ul li:has(ul)").hover(function(){
    
    $(this).addClass("hover");
    
    $('ul:first',this).stop(true, true).animate({
    opacity: 'show',height: 'toggle'
    }, 220);

    }, function(){
    
    $(this).removeClass("hover");
    $('ul:first',this).stop(true, true).slideUp(0);   
    });
*/

    
	// add first-child tag to target ie

	$('.page-template-default').find('.article p:first').addClass('first-child');
	$('.page-template-default.parent-pageid-543').find('.article p:first').removeClass('first-child');
	$('.page-template-default..page-id-543').find('.article p:first').removeClass('first-child');  
    $('.more-link').before('<br />');
    
	// add unicode arrow to member directory     
    
    $('.tern_members_sort li.tern_members_sorted_d a').prepend('<span>&#9660;</span>');

    // Mobile Nav

	$(".page-id-397").find("#content iframe").attr("width", "100%");	


if (screen.availWidth<=480) {
//if (window.innerWidth<=480) { // just for testing with safari
			
	$(".nav").hide();
    $(".nav").before("<a id='mobile-nav' href='#'>Menu</a>");
	$(".nav ul li:has(ul)").append("<span class='m-button'>&raquo;</span> ");
				
	$("#mobile-nav").click(function(e) {
		$(".nav").slideToggle('fast');
		$(".nav ul li:has(ul)").unbind();  	//unbind hover drop down
		e.preventDefault();    		
	});
    	
   	// mobile menu 2nd level
   	
   	var dropButton = $(".nav li span");
	
		dropButton.click(function(e) {
		var childMenu = $(this).parent("li").find("ul.children"); 		
		var grandDaddy = $(this).closest("li");
		var isClosed = grandDaddy.find("ul.children:first");

		childMenu.slideUp('fast');
		grandDaddy.siblings().find("ul.children").slideUp('fast');
		dropButton.removeClass("active");
		
		if ( isClosed.is(':hidden') == true ) {
			$(this).addClass('active');
			childMenu.slideDown('fast');
		}
		e.preventDefault();
	});	
	// add sign-in and phone number	
	$("#masthead").append($(".tel"));
	$("#masthead").append($("#sign-in-link"));
	//$("#masthead").append("<a href='http://skylinecountryclub.com/?page_id=838'>Directions &raquo;</a>");	
				
	// power up and hide a few things
	$("#featured").find("img").removeAttr("src");
	$(".attachment").find(".navigation img").removeAttr("src");	
	$("#course-nav").find("a").addClass("button");	
	$("#featured").hide();
	$(".page-id-397 #content iframe").before("<a href='http://www.google.com/calendar/embed?src=execsec%40skylinecountryclub.com&ctz=America/Phoenix'>View Calendar &raquo;</a>");
	$(".page-id-397 #content iframe").hide();
	$(".page-id-688 #content iframe").before("<a href=http://www.google.com/calendar/embed?src=humpn2j9ijltuis2ulch3ogmu0%40group.calendar.google.com&ctz=America/Phoenix'>View Calendar &raquo;</a>");
	$(".page-id-688 #content iframe").hide();
}


	// slideshow settings
	$('#slideshow').innerfade({
		animationtype: 'fade',
		speed: 500,
		timeout: 5000,
		type: 'sequence'
	});
	// add class to center buttons
	var prev_para = $('.home .section.primary p.postmetadata').prev('p') ;
		
	prev_para.addClass('button-para');
	prev_para.children('a').addClass('button');
});
