/* jquery scripting for UI barloworld */		
/* written by Red Dot Interactive */

			Cufon.replace('#nav a', {hover: 'true'});
			Cufon.replace('#contentBlock H2');
			//Cufon.replace('#contentBlock p');
			//Cufon.replace('.col-2 page li');
			//Cufon.replace('.col-1 li');
			//Cufon.replace('.post-summary');
			Cufon.replace('#footer-copy H2',  {hover: 'true'});
			//Cufon.replace('#footer-copy p');
			Cufon.replace('#socialLinks h2');
			Cufon.replace('#.button a');
			Cufon.replace('#product-title H3');
			Cufon.replace('#panel-content H3');
			Cufon.replace('#panel-content H4');
			Cufon.replace('.col-2 H1');
			Cufon.replace('.col-2 H2');
			//Cufon.replace('.col-2 p');
			Cufon.replace('#leftMenu h2');
			
			
			$(document).ready(function() { 
				
				//When page loads...
				$(".tab_content").hide(); //Hide all content
				$("#footer-nav li:first").addClass("active").show(); //Activate first tab
				$(".tab_content:first").show(); //Show first tab content
				
				if ( !$("#panel-wrapper").is(':animated') ) {
						$("#panel-wrapper").animate({
							marginLeft: 0
						}, 300);			
					}

				// initialise superfish plugin
				$('#nav').supersubs({ 
						minWidth:    9,   // minimum width of sub-menus in em units 
						maxWidth:    27,   // maximum width of sub-menus in em units 
						extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
										   // due to slight rounding differences and font-family 
					}).superfish({
						 delay:       800,
						 animation:   {opacity:'show'},
						 speed:       'fast',
						 autoArrows:  false			 
					});
					
 
			 // Toggle top contact slider
				$("#nav-wrapper div.button").click(function(){
					$("#contact-wrapper div.panel").slideToggle(400);
					$(this).toggleClass("button-active");
					return false;
				});
				
				
				// Toggle side login slider
				$("div#panel-wrapper a.button, div#panel-wrapper a.button2").click(function(e) {
      				
					e.preventDefault();
					var slidepx=$("#panel-wrapper").width() - 28;
					
						if (parseInt($("#panel-wrapper").css('marginLeft'), 10) < slidepx) {
							$("#panel-wrapper a.button").addClass('open');
							margin = "+=" + slidepx;
			
						} else {
							$("#panel-wrapper a.button").removeClass('open');
							margin = "-=" + slidepx;
					}
					if ( !$("#panel-wrapper").is(':animated') ) {
						$("#panel-wrapper").animate({
							marginLeft: margin
						}, 300);			
					}
					return false;
				});
				
				
				
				// Search input focus highlighting
				 
			    $('input[jqid="searchPhrase"]').addClass("textIdle2");
			    $('input[jqid="searchButton"]').addClass("btnIdle2"); 
			      
			    $('input[jqid="searchPhrase"]').focus(function() {  
			        $(this).removeClass("textIdle").addClass("textFocus");
			        
	 
			        if (this.value == this.defaultValue){  
			            this.value = '';
			        }   
			        if(this.value != this.defaultValue){  
			            this.select();  
			        } 
			        $('input[jqid="searchButton"]').removeClass("btnIdle").addClass("btnFocus"); 
			        
			    });
			    
			    $('input[jqid="searchPhrase"]').blur(function() {  
			        $(this).removeClass("textFocus").addClass("textIdle"); 
			        $('input[jqid="searchButton"]').removeClass("btnFocus").addClass("btnIdle");

			         
			        if ($.trim(this.value === '')){  
			            this.value = (this.defaultValue ? this.defaultValue : '');  
			        }
			    });
			    
			    //jquery for tabbed news feeds
			
				//On Click Event
				$("#footer-nav li").click(function(e) {
				    e.preventDefault();
			
					$("#footer-nav li").removeClass("active"); //Remove any "active" class
					$(this).addClass("active"); //Add "active" class to selected tab
					$("div.tab_content").hide(); //Hide all tab content
			
					var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
					$(activeTab).fadeIn(); //Fade in the active ID content
					return false;
				});
				
				
				//jquery pretty photo

					$("span[class^='PrettyPhoto'] a, a[rel^='PrettyPhoto']").prettyPhoto({
						animationSpeed: 'normal', /* fast/slow/normal */
						opacity: 0.80, /* Value between 0 and 1 */
						showTitle: true, /* true/false */
						allowresize: true, /* true/false */
						default_width: 500,
						default_height: 344,
						counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
						theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
						hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
						wmode: 'opaque', /* Set the flash wmode attribute */
						autoplay: true, /* Automatically start videos: True/False */
						modal: false /* If set to true, only the close button will close the window */
					});
					

					
					//toggle posts
					
					  $('div.col-2:eq(0)> div.dir-excerpt').hide();  
					  $('div.col-2:eq(0)> div.dir-content div.profileHead').click(function() {
						$(this).next().slideToggle('fast');
					  });
					  
					  //fix the fixed position scrolling in ie6 fo login slider
				if($.browser.msie && parseFloat($.browser.version) < 7){
			
					 $("div#panel-wrapper").css("position", "absolute");
					 
					 $("div#panel-wrapper a.button, div#panel-wrapper a.button2").click(function(e) {
      				
					e.preventDefault();
					var slidepx=$("#panel-wrapper").width() - 28;
					
						if (parseInt($("#panel-wrapper").css('left'), 10) < slidepx) {
							$("#panel-wrapper a.button").addClass('open');
							margin = "+=" + slidepx;
			
						} else {
							$("#panel-wrapper a.button").removeClass('open');
							margin = "-=" + slidepx;
					}
					if ( !$("#panel-wrapper").is(':animated') ) {
						$("#panel-wrapper").animate({
							marginLeft: margin
						}, 300);			
					}
					return false;
				});
				
				return;
				}
					  			  

});  

$(window).scroll(function() {

	//fix the fixed position scrolling in ie6

	if($.browser.msie && parseFloat($.browser.version) < 7){
	
		$("div#panel-wrapper").css("top", $(window).scrollTop() + 150 + "px");
	
	return;
	}

    
});
