
function visibleIP(){
		for (inner=1;inner<=8;inner++){
		  $("#segment"+ inner).stop().fadeTo(200, 1);
		   $("#IndustryPractice-"+ inner).stop().fadeTo(1000, 1);
		}
}

$(document).ready(function() {
		

		$(function() {

		$('#accordion3.withScrollTop').bind('accordionchange', function(event, ui) {
		  $.scrollTo( '.ui-state-active', {duration:1000}); 
		});


		$( "#accordion3.withScrollTop" ).accordion({
					autoHeight: false,
					collapsible: true,
					navigation: true,
					active: false,
					header: 'h2'
					
					});

		$( "#accordion3" ).accordion({
			autoHeight: false,
			header: 'h2'	
			});



	//	$('#accordion3 h2 a').click(function(){
	//	$.scrollTo(this);                                                 
	//	});
		
		/*submenu = '#Nav ul li.current_page_parent ul li';
		if($(submenu).hasClass('current-menu-item') == true){	
		$(submenu + " a").css("background","#5D3273");
		} */

	
	});



$('.singlecontainer .entry-content-left blockquote').append('<div class="divider_line" style="margin-top:20px"></div>');
$('.post blockquote').append('<div class="divider_line" style="margin-top:20px"></div>');

/*REMOVING THE MAIN POST NAV HIGHLIGHT */
	inbody = $('body').is('.single-post, .category');
	if(inbody == false){
		$('#Nav .menu-header ul li#menu-item-49').removeClass('current_page_parent');
	}

// MENU BAR
    $('#Nav .menu-header ul li > a').mouseover(function() {
		this_parent = $(this).parent().is('.current-menu-item,.current-menu-parent,#menu-item-180,#menu-item-181');			
		if(this_parent == false){	
         $(this).stop().animate({ color:'#FFFFFF'},500);
		}
    }).mouseout(function() {


		this_parent = $(this).parent().is('.current-menu-item,.current-menu-parent,#menu-item-180,#menu-item-181');			
		if(this_parent == false){	
		//GREY	
		$(this).stop().animate({ color:'#9F9F9F'},500);
		}


    });  

    $('#Nav .menu-header ul li#menu-item-47 > a, #Nav .menu-header ul li#menu-item-180 > a, #Nav .menu-header ul li#menu-item-181 > a').mouseover(function() {
         $(this).css("padding-bottom",'10px');
		
		id = $(this).parent().attr('id');
		//ABOUT US
		if(id == "menu-item-180"){
		$('#Nav .menu-header ul li#'+ id + " ul").css("margin-right","-645px");
		// INDUSTRY PRACTICE
		}else if(id == "menu-item-47"){
		$('#Nav .menu-header ul li#'+ id + " ul").css("margin-right","-123px");
		//SERVICE
		}else if(id == "menu-item-181"){
		$('#Nav .menu-header ul li#'+ id + " ul").css("margin-right","-273px");
		}

    }).mouseout(function() {
        $(this).css("padding-bottom",'5px');

	}); 
	
    $('#Nav .menu-header ul ul').mouseover(function() {
		getid = $(this).parent().attr('id');
		
         $("#Nav .menu-header ul li#" + getid + " > a").css("padding-bottom",'10px');
    }).mouseout(function() {
       $("#Nav .menu-header ul li#" + getid + " > a").css("padding-bottom",'5px');
    }); 



//INDUSTRY PRACTICES

/*
$('.hoverpanel').each(function(){
	id = $(this).attr("id");
		$(this).mouseover(function() {
			
			for (inner=1;inner<=8;inner++){
				if(eachIP != inner){
				//alert("i " + i + "inner " + inner);
				$("#segment" + inner).fadeTo(500, 0.2);
				$("#IndustryPractice-" + inner).delay(200).fadeTo(500, 0.2);
				}
			}
		}).mouseout(function() {
		visibleIP();
		}); 	
});
*/
//CLEAR SEARCH BOX


$('.hoverpanel').hover(
	function(){
       var hoverID = $(this).parent().attr('id');
		counter = 1;
       $('.hoverpanel').each(function(){
               
               if (hoverID != $(this).parent().attr('id'))
               {
                 $("#segment" + counter).stop().fadeTo(200, 0.3);
				$(this).parent().stop().fadeTo(200, 0.2);
               }
         counter++;      
       });   
	},
		function(){
	visibleIP();
	}
       
);
 

// FADING SLIDESHOW 
$(function(){
  setInterval("rotateImages()", 4000);  
});


    $('input[name=s]').bind("focus blur",function(){
        if ($(this).attr("value") == 'Search Wilbury Chase')
        {
            $(this).attr("value","");
        }
        else if ($(this).attr("value") == '')
        {
            $(this).attr("value","Search Wilbury Chase");
        }
    });
    
    
    //CV form functions
    
    $("form.wpcf7-form input, form.wpcf7-form textarea").focus(function(){
        var newValue = '';
        
        if ($(this).attr("name") == 'cv_name' && $(this).attr("value") == 'Name') {
                $(this).attr("value",newValue);
        }
        
        if ($(this).attr("name") == 'cv_email' && $(this).attr("value") == 'Email') {
                $(this).attr("value",newValue);
        }
        
        if ($(this).attr("name") == 'cv_comments' && $(this).attr("value") == 'Comments') {
                $(this).attr("value",newValue);
        }
        
    });

    $("form.wpcf7-form input, form.wpcf7-form textarea").blur(function(){
        if ($(this).attr("name") == 'cv_name' && $(this).attr("value") == '') {
                $(this).attr("value","Name");
        }

        if ($(this).attr("name") == 'cv_email' && $(this).attr("value") == '') {
                $(this).attr("value","Email");
        }

        if ($(this).attr("name") == 'cv_comments' && $(this).attr("value") == '') {
                $(this).attr("value","Comments");
        }
    });


})//END


function rotateImages() {
    var oCurPhoto = $('#slideshow div.current');
    var oNxtPhoto = oCurPhoto.next();
    if (oNxtPhoto.length == 0) {
        oNxtPhoto = $('#slideshow div:first');
    }

    oCurPhoto.removeClass('current').addClass('previous');
    oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity: 1.0 }, 1000,
        function() {
            oCurPhoto.removeClass('previous');
        });
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});


// FADING SLIDESHOW


