jQuery(document).ready(function() {
								  
	// Homepage Slideshow
	jQuery('#my-carousel-1').carousel({
		itemsPerPage: 'auto',
		itemsPerTransition: 1,
		orientation: 'horizontal',
		noOfRows: 1,
		pagination: true,
		nextPrevActions: false,
		speed: 'normal',
		autoScroll: true,
		pause: 6000
	});
	
	// Simple Image Rotator
	jQuery('.slide1, .slide2').simplestSlideShow({
		'timeOut': 5000,
		'speed': 1000
	});

	// FAQ expand-collapse
	jQuery('.ans').hide();
	jQuery('.qstn').click(function(){
		jQuery(this).next('.ans').slideToggle(2);
	});
	
	jQuery('.eqh').equalHeight();
	
	jQuery('#tab_head_w').tabs();                                                                   // This is for the header tabs
	jQuery('.srch div.srch_opt').dropDownFr();                                                      // Dropdown in Search Header block
	//$('.scroll-pane').jScrollPane();                                                              // FitchWire Homepage List
	jQuery('.jScrollbar, .jScrollbar2, .jScrollbar3, .jScrollbar4, .jScrollbar5').jScrollbar();     // FitchWire Homepage List
	
	/* Hiding and showing username and password text on mouse click */
	jQuery('.act_out #pass_clear').show();
	jQuery('.act_out #pass_fill').hide();
	
	jQuery('.act_out #pass_clear').focus(function() {
		jQuery('.act_out #pass_clear').hide();
		jQuery('.act_out #pass_fill').show();
		jQuery('.act_out #pass_fill').focus();
	});
	jQuery('.act_out #pass_fill').blur(function() {
		if(jQuery('.act_out #pass_fill').val() == '') {
			jQuery('.act_out #pass_fill').hide();
			jQuery('.act_out #pass_clear').show();
		}
	});
	jQuery('.field_swap').each(function() {
	    var default_value = this.value;
		jQuery(this).addClass('idleField');
	    jQuery(this).focus(function() {
	        if(this.value == default_value) {
	            this.value = '';
				jQuery(this).removeClass('idleField').addClass('focusField');
	        }
			if(this.value != this.defaultValue){
				this.select();
			}
	    });
	    jQuery(this).blur(function() {
	        if(this.value == '') {
				jQuery(this).removeClass('focusField').addClass('idleField');
	            this.value = default_value;
	        }
	    });
	});
	
});

if(jQuery) (function($){
					 
	/* Set equal heights for a group of divs */
	$.fn.equalHeight = function(params){
		var conf = $.extend({
			elements: '.mid'
		}, params);
		return this.each(function(){
			var o=$(this),c=conf,r=o.find(c.elements),h=0,lh=0;
			r.each(function(){if($(this).height()>h){h=$(this).height()}});
			lh=h;
			r.each(function(){$(this).height(h);})
		});
	};
	
	/* Simple Slideshow */
	$.fn.simplestSlideShow = function(settings){
		var config = {
			'timeOut': 3000,
			'speed': 'normal'
		};
		if (settings) $.extend(config, settings);
		this.each(function(){
			var $elem = $(this);
			$elem.children(':gt(0)').hide();
			setInterval(function(){
				$elem.children().eq(0).fadeOut(config['speed'])
				.next().fadeIn(config['speed'])
				.end().appendTo($elem);
			}, config['timeOut']);
		});
		return this;
	};
	
	/* Function for Dropdown in Search Header block */
	$.fn.dropDownFr = function(params){
		var conf = $.extend({
			headerBlock:'a', contentBlock:'ul, div', hoverClass:'itemHover'
		}, params);
		return this.each(function(){
			var o=$(this),c=conf,h=o.children(c.headerBlock),w=o.children(c.contentBlock);
			if(w.html() != null){
				w.css({display:'none'});
				mouse_is_inside=false;
				h.bind('click',function(){w.css({display:'block'}); h.addClass(c.hoverClass); return false});
				//h.bind('mouseleave',function(){w.css({display:'none'}); h.removeClass(c.hoverClass)});
				w.bind('mouseenter',function(){ mouse_is_inside=true; h.addClass(c.hoverClass)});
				w.bind('mouseleave',function(){ mouse_is_inside=false; });
				$("body").mouseup(function(){ 
					if(! mouse_is_inside){w.css({display:'none'}); h.removeClass(c.hoverClass)};
				});
			}
		});
	};
	$.fn.dropMenuFr = function(params){
		var conf = $.extend({
			headerBlock:'a', contentBlock:'ul', hoverClass:'itemHover', hoverSubClass:'itemSubHover'
		}, params);
		return this.each(function(){
			var o=$(this),c=conf,h=o.children(c.headerBlock),w=o.children(c.contentBlock);
			if(w.html() != null){
				w.css({display:'none'});
				o.bind('mouseenter',function(){w.css({display:'block'}); o.addClass(c.hoverSubClass)});
				o.bind('mouseleave',function(){w.css({display:'none'}); o.removeClass(c.hoverSubClass)});
			}else{
				o.hover(
					function(){o.addClass(c.hoverClass)},
					function(){o.removeClass(c.hoverClass)}
				)
			}
		});
	};
	
})(jQuery)
