// JQuery Scripts
$(document).ready(function(){
	
	$("ul.sf-menu").superfish({ 
		pathClass:  'current',
        delay:  300
	}); 
	
	/**
	 * Image Rollover Functionality
	 */
	$(".rollover").mouseover(function(){
		imgsrc = $(this).attr("src");
		matches = imgsrc.match(/-ro/);
		// don't do the rollover if state is already ON
		if (!matches) {
			
			if(imgsrc.indexOf('.gif') > -1) {
				imgsrcON = imgsrc.replace(/.gif$/ig,"-ro.gif"); // strip off extension - Gif
			} else if(imgsrc.indexOf('.jpg') > -1) {
				imgsrcON = imgsrc.replace(/.jpg$/ig,"-ro.jpg"); // strip off extension - Jpg		
			}
			
			$(this).attr("src", imgsrcON);
		}
	});
	
	$(".rollover").mouseout(function() {
		$(this).attr("src", imgsrc);
	});

	/**
	 * Collapse Functionality on Solutions.php
	 */
    $(".client-testimonial-trigger").click(function(event) {
        if ($(".client-testimonial-trigger").is('.active')) {
            $(".client-testimonial-content").slideUp("fast", 
                function() {
                }
            );
            $(".client-testimonial-trigger").removeClass('active');
        } else {
            $(".client-testimonial-content").slideDown("fast", 
                function() {
                }
            );
            $(".client-testimonial-trigger").addClass('active');
        }
   	});
    
	/**
	* Fading Staff Pictures
	**/
	// IE6 doesn't handle the fade effect very well - so we'll stick with  
	// the default non JavaScript version if that is the user's browser.
    // we remove the active class, because of the funny things IE6 does when the user is on a page.
	if ($.browser.msie && $.browser.version < 7) {
        $('#staff a').removeClass('active');  
        return;
    }   
    
    $("#staff")  
	
	// find the a elements    
	.find('a')        

	// remove the 'highlight' class from the li therefore stripping     
	// the :hover rule   
	.removeClass("highlight")        
	
	// create our new span.hover and loop through anchor:    
	.append('<span class="hover" />').each(function () {            
	
	// cache a copy of the span, at the same time changing the opacity      
	
	// to zero in preparation of the page being loaded     
	var $span = $('> span.hover', this).css('opacity', 0);            
	
	// when the user hovers in and out of the anchor      
	$(this).hover(function () {        
	
	// on hover               
	// stop any animations currently running, and fade to opacity: 1        
	$span.stop().fadeTo(450, 1);      
	}, 
	
	function () {        
    
	// off hover                
	// again, stop any animations currently running, and fade out        
	$span.stop().fadeTo(450, 0);      
	});    
	});    

    /**
	* Switches out staff html when clicking on staff member head
	**/
    $("#staff a").click(function(event) {		
        staffName = $(this).attr('name');
        $('#staff a').removeClass('active');
        $('#staff-profile > div').css('display','none');
        $('#staff-profile #' + staffName).fadeIn();
        $('#staff a.'+staffName).addClass('active');
    }); 

});

function ValidatorClient(theForm) {
    if ((theForm.clientcode.value == 0)) {
        alert("Please enter a client code.");
        theForm.clientcode.focus();
        return (false);
    }
}


