/*JQUERY FUNCTIONS*/
$(function(){
	/*$('.checkbox a').click(function(){
		return false;								  
	});
	$('.checkbox a').hover(function(){
		var name = $(this).attr('name');
		var path = document.location.href+'wp-content/themes/default/';
		$('#checkbox'+name).css('background-image', 'url('+path+'images/checkbox.hover.jpg)');
	},function(){
		var name = $(this).attr('name');
		var path = document.location.href+'wp-content/themes/default/';
		$('#checkbox'+name).css('background-image', 'url('+path+'images/checkbox.jpg)');
	});*/
	
	/*$('#infoList li:nth-child(1)').fadeIn(4000);
	$('#infoList li:nth-child(2)').fadeIn(5500);
	$('#infoList li:nth-child(3)').fadeIn(6500);*/
	
	/*$('.checkbox a').hover(function(e){
		var id = $(this).attr('id');
		var img = $('#'+id+'_img').attr('src');
		info = $('#'+id+'_html').html();
		var html = '<div class="info">';
		html += '<img src="'+img+'" />';
		html += info;
		html +=	'</div>';
		this.timeout = window.setTimeout(function(){
			$('body').append(html).children('.info').hide().fadeIn(400);
			$('.info').css('top', e.pageY + -200).css('left', e.pageX + 40);
		}, 450);
	},function(){
		if(this.timeout) window.clearTimeout(this.timeout);
		$('.info').remove();
	});
	
	$('.checkbox a').mousemove(function(e) {
		$('.info').css('top', e.pageY + -200).css('left', e.pageX + 40);
	});*/
	
	$('div.elim h1:nth-child(1)').show();
	/* No longer used
	setTimeout(function(){
		$('.elim').animate( {'top' : 187 }, 450, 'easeOutBack', function(){
			var i = 1;
			setInterval(function(){
				var size = $('.elim h1').size();
				$('.elim h1:nth-child('+i+')').animate( {'left' : -738 }, 900, 'easeInBack', function(){
					$(this).hide().css('left', 0);
					i++;
					if($('.elim h1:nth-child('+i+')').length > 0)
						$('.elim h1:nth-child('+i+')').css('left', 738).show().animate({'left' : 0}, 900, 'easeInOutBack');
					else
					{
						$('.elim').animate({'top' : 187}, 1650,'easeInOutBack', function(){
							$(this).remove();																
						});
					}
				});
			}, 6000);
		});
	}, 1000);*/
	setInterval(function(){
		if($('#protection').css('display') == 'none')
			$('#protection').fadeIn(6000);
		else
			$('#protection').fadeOut(6000);
	}, 2000);
	setInterval(function(){
		if($('#protection_words').css('display') == 'none')
			$('#protection_words').fadeIn(3000);
		else
			$('#protection_words').fadeOut(3000);
	}, 8000);
	
	setTimeout(function(){
		$('h1#address').fadeIn(800);
	}, 500);
	
	//Get our elements for faster access and set overlay width
	var div = $('div.graphics-bar'),
	ul = $('ul.pest-images'),
	// unordered list's left margin
	ulPadding = 15;
	
	//Get menu width
	var divWidth = div.width();
	
	//Remove scrollbars
	div.css({overflow: 'hidden'});
	
	//Find last image container
	var lastLi = ul.find('li:last-child');
	
	//When user move mouse over menu
	div.mousemove(function(e){
	
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
		
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});

	
});
