// JavaScript Document

$(document).ready(function() { 
	var browser = '';
	var version = '';
	
	// Cufon test
	Cufon.replace('h1');
	Cufon.replace('h3');
	Cufon.replace('#mainNav li a');
	Cufon.replace('#slogan');
	Cufon.replace('.sliderSpan');
	var flyoutOpen = 0;
	
	$.each($.browser, function(i, val) {
		if(i=='version'){version = val;}
		if (i=='msie' && version == 6.0){browser='msie6';}
		if (i=='msie' && version == 7.0){browser='msie7';}
	});
	
	if(popLevel > 100) {
		$().bubbles({total:4,imgroot:imgroot,popPoint:popLevel});
	}
	
	if (browser != 'msie6' && browser != 'msie7'){
		
		$(".l-img").lazyload();
	
		$(window).bind("load", function() { 
			 var timeout = setTimeout(function() {$(".l-img").trigger("sporty")}, 5000);
		}); 
	
	}
	
	$('#headerNav ul#mainNav li a:first').css({width:128});
	$('#headerNav ul#mainNav li:last').css({marginRight:0});
	
	$(".slider1,.slider2").hover(
		function () {
			$(".sliderBody", this).slideToggle('slow');
		},
		function () {
			// do nothing
		}
	);
	
	//$(".slider1:first").css({'marginTop':'20px'});
	
	var tabContainers = $('.listingDetailTab');
    
    /* listing blue tabs */
	$('#l-tabHolder a').click(function () {
        $('#l-tabHolder a').removeClass('tab-on');
		$('#l-tabHolder a').removeClass('tab-off');
		$('#l-tabHolder a').addClass('tab-off');
        $(this).removeClass('tab-off');
		$(this).addClass('tab-on');
		
		tabContainers.hide().filter(this.hash).fadeIn('slow');
        
        return false;
    });//.filter(':first').click();
	
	/* flyout tabs */
	$('#flyTabHolder a').click(function () {
		if(flyoutOpen == 0){
			$('#flyoutHolder').animate({ right: 0}, 1000);	
			flyoutOpen = 1;
		}
		$('#flyTabHolder a').removeClass('sel');
		$(this).addClass('sel');
		$('.flyPage').hide().filter(this.hash).fadeIn('slow');
        
        return false;
    }); //.filter(':first').click()
	
	/*$('#flyoutHolder').mouseout(function(){
		if(flyoutOpen == 1){
			$('#flyoutHolder').animate({ right: -274}, 1500);
			flyoutOpen = 0;
		}
	});*/
	
	$('#flyoutHolder').bind("mouseleave",function(){
		if(flyoutOpen == 1){
			$('#flyoutHolder').animate({ right: -274}, 1500);
			flyoutOpen = 0;
		}
	});
	
	$(".flyPageContent p").css("margin-top",0)
	
	$('a.eventBlogTabs').click(function () {
		$('a.eventBlogTabs').removeClass('sel');
		$(this).addClass('sel');
		$('.eventBlogContent').hide().filter(this.hash).fadeIn('slow');
        
        return false;
    }).filter(':first').click();
	
	$('a.wctTabs').click(function () {
		$('a.wctTabs').removeClass('sel');
		$(this).addClass('sel');
		$('.wctContent').hide().filter(this.hash).fadeIn('slow');
        
        return false;
    }).filter(':first').click();
	
	$('#l-listingImages')
		.before('<div id="picsnav">')
	.cycle({
		fx:     'fade', 
		timeout: 6000, 
		delay:  -2000, 
		pager:  '#picsnav',
		fit: 1
		
	});
	
	$('a#advancedSearchBtn').click( function(){
		$('#lSearchAdvanced').slideToggle("slow");
	});
	
	
	/*$('#flyoutHolder').hover(function () {
		$(this).animate({ right: 0}, 1000);
     }, function () {
	   	$(this).animate({ right: -274}, 1500);
     });*/
	
	
/*	
	var camContainers = $('.camWindow');
    
	$('.centerBlock2 a:not(a.otherWebcam)').click(function () {
		$("#camWindowHolder").show();
		camContainers.hide().filter(this.hash).fadeIn('slow');
        
        return false;
    });
*/

	$("h5.darkOrange,h5.orange").hover(
      function () {
        $(this).css("color","#0172c1");
      }, 
      function () {
        $(this).css("color","#f08833");
      }
    );
	
	$("h5.blue").hover(
      function () {
        $(this).css("color","#f08833");
      }, 
      function () {
        $(this).css("color","#0172c1");
      }
    );
	
	// check for IE6 to add pngFIx to pngs that were missed
	/*if (browser = 'msie6'){
		//$("img[src*='.png']").addClass("pngFix");
		$("img[src*='.png']").css({'behavior' : 'url("/includes/css/iepngfix.htc")'});	
	}*/
});