// JavaScript Document
var i=0;  // initial count for the table row for Prospect List

$(document).ready(function() {

	$(".iframe").fancybox();
	
	//Default Action
	
	// Reset the Menu's Current Position relative to their height in order to allow dynamic expansion
	
	/****************************     Navigation Pop Out    ****************************/
	$("#nav li").hover(function() {
		//If there is a child for the li that was clicked on
		if($("#" + $(this).attr("id") + "Child").length > 0){
			//Hide any visible menus
			$(".dropdownMenu").not("#" + $(this).attr("id") + "Child").hide();
			//Show the menu for the one that was clicked on
			$("#" + $(this).attr("id") + "Child").show();
			// Add the button show / hide to the child to determine if the mouse is on the drop down or not
			$("#" + $(this).attr("id") + "Child").attr("button", "show");
			
			
		}
	}, function() {
		// Add the button show / hide to the child to determine if the mouse is on the drop down or not
		$("#" + $(this).attr("id") + "Child").attr("button", "hide");
		
		
		if($("#" + $(this).attr("id") + "Child").length > 0){
			// Add a on class the the current tab that's highlighted.
			$(this).find("a").addClass("on");
		}
		
		//  Add delay to the drop down menu when mouse hover out
		setTimeout("hideMenu('" + $(this).attr("id") + "Child" + "');", 100);
		
		
	});
	
	$(".dropdownMenu").hover(function() {
		// Add the menu show / hide to the child to determine if the mouse is on the drop down or not
		$(this).attr("menu", "show");
	}, function() {
		// Add the menu show / hide to the child to determine if the mouse is on the drop down or not
		$(this).attr("menu", "hide");
		//  Add delay to the drop down menu when mouse hover out
		setTimeout("hideMenu('" + $(this).attr("id") + "');", 100);
	});
	/****************************     Navigation Pop Out    ****************************/
	
	
	
	/****************************    TAB    ****************************/

	//Tab Switch
	$('.tabs a').click(function(){
		switch_tabs($(this));
		return false;
	});
 
	switch_tabs($('.defaulttab'));
	
	/****************************    TAB END    ****************************/
	
	/****************************   Accordion   ****************************/
	
	$('#accordion dd').hide();
	// show the fist tab
	$('#accordion dd#first').show();
    $('#accordion dt a').click(function(){
		   $('#accordion dd').slideUp();
		   $(this).parent().next().slideDown();
		   return false;
    });

	/****************************   Accordion   ****************************/
	
	
	
	
	/********************** Make the grayscale effect ***********************/
	
	$(".personHolder img").hover(
		function() { if(!$(this).hasClass("active")) grayscale.reset($(this)); } ,
		function() { if(!$(this).hasClass("active")) grayscale($(this)); }
	);
	if($(".personHolder img").not(".active").length > 0 && !$.browser.safari)
		grayscale($(".personHolder a img").not(".active"));
	if($.browser.safari)
		$(".personHolder img").not(".active").load( function() { grayscale($(this)); $(this).unbind("load"); } );
		
    //Add the event to change the content
	$("#featured-person .personHolder a").click( function() {
										 
	/*	alert("hi");								 
		
		//var pos = parseInt($(this).find("img").attr("id").replace("img", ""));
		
		//Reset the grayscale
		grayscale($(".personHolder a .active"));
		grayscale.reset($(this).find("img"));
		$(".personHolder a img.active").removeClass("active");
		$(this).find("img").addClass("active");
		
		$("#testimonial div").hide();
		$("#" + $(this).attr("rel")).fadeIn(1000);*/
		
		return false;
	});
	
	
	
	/********************** Add Alternative Row color to Prospect List ***********************/
	
   $(".listTable tr").each(function() {          
	 if (i%2 == 0){
	   $(this).addClass("row1");
	   i++;
	 } else {
	   $(this).addClass("row2");
	   i++;
	 }
   }); 
	
	
	
	
	

});


/**************************** Custom Functions  ****************************/

//Switch tab function
function switch_tabs(obj)
{
	$('.tab-content').hide();
	$('.tabs a').removeClass("selected");
	var id = obj.attr("rel");
 
	$('#'+id).show();
	obj.addClass("selected");
}


//hide drop down menu
function hideMenu(id){
	// Check if the child menu's attribute has menu show or hide and button has show or hide or not, if the condition is true then move the drop down menu up.
	if($("#" + id).attr("menu") != "show" && $("#" + id).attr("button") != "show"){
		$("#" + id).hide(); 
		$("#nav li a").removeClass("on");			
		

	};
		
};



// Slide Show


$(function(){
    $('#quoteSlide p:gt(0)').hide();
    setInterval(function(){
      $('#quoteSlide p:first-child').fadeOut()
         .next('p').fadeIn()
         .end().appendTo('#quoteSlide');}, 
      11000);
});


