$(document).ready(function(){
	$("ul#nav img").hover(
		function(e){
			this.src = this.src.replace("_on","_off");
			var cur_alt = this.alt;
			$('#tooltipDiv').css({opacity:0.9, display:"none", top:52, left:e.pageX-75}).fadeIn(400).html('<p>'+cur_alt+'</p>');
			//alert(e.pageX);
		},
		function(){
			this.src = this.src.replace("_off","_on");
			$('#tooltipDiv').fadeOut(400).html('');
		}
	);
	
	$('.floating').animate({
		right: "5px", 
		bottom:"30%",
	}, 1000);
		
	$.localScroll({hash:true});

	$First = $("#services a:first");
	$First.each(function(){
$('#services li').removeClass('selected');
$(this).parent().addClass('selected');
		$("#services_content").load(this.href);
	});	
	
	$("#services a").click(function(){
$('#services li').removeClass('selected');
$(this).parent().addClass('selected');
		$("#services_content").html('<h2>loading...</h2>');
		$("#services_content").load(this.href);
		return false;
	});

	$('#contact_form').ajaxForm(function() { 
$(':input','#contact_form')
 .not(':button, :submit, :reset, :hidden')
 .val('')
 .removeAttr('checked')
 .removeAttr('selected');

         $('#response').html("Thank-you. We will respond to your message as soon as possible.<br/>").hide().fadeIn(1500).fadeOut(2500);

    }); 

	$(".services li a").hover(
		function(){$(this).parent().addClass('active');},
		function(){$(this).parent().removeClass('active');});
	
	$(".works li a").hover(
		function(){$(this).parent().addClass('active');},
		function(){$(this).parent().removeClass('active');});
    
    $("#work_page").html('<h2>loading</h2>');
	//$("#work_page").load('http://www.reload.co.za/index.php/work/C12');

	AffectCategory($("ul.works li:first a").attr('id'));
	$('.crc').cycle({ fx: 'fade',timeout: 4000 });
});

Shadowbox.init({players:["html","iframe"]});

function AffectCategory(url) {
$('.works li').removeClass('selected');
$('.works li a#'+url).parent().addClass('selected');
	if(url == "") {$("#work_page").load('http://www.reload.co.za/index.php/work/C12');  
$('.works li a#12').parent().addClass('selected');
}
	else $("#work_page").load('http://www.reload.co.za/index.php/work/C'+url);  
}
