// =============================================
// DeniseYardy.com jQuery Functions
// Author: Mark Garity
// =============================================

	// Cufon custom h1 fonts
	Cufon.replace('h1');
	
jQuery(function( $ ){	
	
	// Check for obsolete browsers 
	// (Compatable with Ie6+, Ff, Sf, Op)
	if ($.browser.msie && $.browser.version < 6) return;
	
	// JavaScript Easing - borrowed from jQuery easing plugin
	// http://gsgd.co.uk/sandbox/jquery.easing.php
	$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};
	
	// Logo fade on mouseover
 	$('#logo')
  	.removeClass('glow')
    .find('a')
    .append('<span class="hover" />').each(function () {
     	var $span = $('> span.hover', this).css('opacity', 0);
      	$(this).hover(function () {
        	$span.stop().fadeTo(400, 1);
      	}, function () {
        	$span.stop().fadeTo(400, 0);
      	});
    });
	
	// Navigation dropdowns
	$(document).ready(function(){
							   
		$('#buying-dropdown').hover(
		  function () {
			$('#buying-dropdown ul').slideDown(200, function(){ $('#buying-dropdown ul').addClass('dropped'); });
			$('#buying-dropdown ul').removeClass('hidden');
		  },
		  function () {
			$('#buying-dropdown ul').removeClass('dropped');
			$('#buying-dropdown ul').slideUp(0);
		  }
		);
		$('#buying-dropdown ul').hover(
		  function () {
			$('#buying-dropdown a').addClass('dropped');
		  },
		  function () {
			$('#buying-dropdown a').removeClass('dropped');
		  }
		);
		
		$('#selling-dropdown').hover(
		  function () {
			$('#selling-dropdown ul').slideDown(200, function(){ $('#selling-dropdown ul').addClass('dropped'); });
			$('#selling-dropdown ul').removeClass('hidden');
		  },
		  function () {
			$('#selling-dropdown ul').removeClass('dropped');
			$('#selling-dropdown ul').slideUp(0);
		  }
		);
		$('#selling-dropdown ul').hover(
		  function () {
			$('#selling-dropdown a').addClass('dropped');
		  },
		  function () {
			$('#selling-dropdown a').removeClass('dropped');
		  }
		);
		
	});
	
	// Homepage highlight scrolling
	var HLTarget = $('#highlights');
	var slideRotate = 1;
	$.scrollTo.defaults.axis = 'x'; 
	HLTarget.stop().scrollTo( '0px', 0 );
	
	function HlSlide (item) {
		if (item==1){
			HLTarget.stop().scrollTo( '0px', 1000 );
			$('a#hltab1').addClass('active');
			$('a#hltab2').removeClass('active');
			$('a#hltab3').removeClass('active');
			$('a#hltab4').removeClass('active');
			slideRotate = 1;
		}else if (item==2){
			HLTarget.stop().scrollTo( '641px', 1000 );
			$('a#hltab2').addClass('active');
			$('a#hltab1').removeClass('active');
			$('a#hltab3').removeClass('active');
			$('a#hltab4').removeClass('active');
			slideRotate = 2;
		}else if (item==3){
			HLTarget.stop().scrollTo( '1282px', 1000 );
			$('a#hltab3').addClass('active');
			$('a#hltab1').removeClass('active');
			$('a#hltab2').removeClass('active');
			$('a#hltab4').removeClass('active');
			slideRotate = 3;
		}else if (item==4){
			HLTarget.stop().scrollTo( '1923px', 1000 );
			$('a#hltab4').addClass('active');
			$('a#hltab1').removeClass('active');
			$('a#hltab2').removeClass('active');
			$('a#hltab3').removeClass('active');
			slideRotate = 4;
			}
	}
	
	$('a#hltab1').click(function(){
			HlSlide(1);
			slideRotate = 2;
			return false;
	});
	$('a#hltab2').click(function(){
			HlSlide(2);
			slideRotate = 3;
			return false;
	});
	$('a#hltab3').click(function(){
			HlSlide(3);
			slideRotate = 4;
			return false;
	});
	$('a#hltab4').click(function(){
			HlSlide(4);
			slideRotate = 1;
			return false;
	});
	
	$(document).ready(function(){
		setInterval( function() {
			if (slideRotate==1){
				HlSlide(2);
			}else if (slideRotate==2){
				HlSlide(3);
			}else if (slideRotate==3){
				HlSlide(4);
			}else if (slideRotate==4){
				HlSlide(1);
			}
			
		}, 10000);
	});
	
	
	jQuery(function($){	
	$("a.fancybox").fancybox({'transitionIn':'elastic', 'transitionOut': 'elastic','easingIn':'swing','easingOut':'swing'}); 
});
	
});