function paginate(ind, el) {
	return '<a href="javascript:void(0);" class="pageelem">'+(ind+1)+'</a> ';
}


function cspaginate(ind, el) {
	return '<a href="javascript:void(0);" class="pageelem"></a> ';
}


function concact_slide_nav(ind, el) {
	return '<a href="javascript:void(0);" id="tab_'+(ind)+'"></a> ';
	
}
function paginate_aboutus(ind, el) {
	return '<img src="http://one.onefuzz.com/media/bottom_line/bottom_line_static_0'+(ind)+'.png" id="img_'+(ind)+'"/>';
}







$(document).ready(function(){
	
	if(window.location.hash){
		$("#work_navigation a.reset").removeClass("selected");	
		var hash = window.location.hash.substring(1);
		
		//console.log(hash.split(","));
		
		$('[rel="' + hash + '"]').addClass("selected");
		$.post("inc/load_work.php", 
		{ 
			tag: hash,
			act: 'add'
		},
		function(data){
			$("#showreel_gallery_div").html(data);
		});
	}
	
	$("#work_navigation a.filter").click(function () { 
		$("#work_navigation a.reset").removeClass("selected");
		if ($(this).hasClass('selected')){
			window.location.replace("#");
			$(this).removeClass("selected");
			//UNSELECT BUTTON
			$.post("inc/load_work.php", 
				{ 
					tag: $(this).attr("rel"),
					act: 'remove'
				},
				function(data){
					$("#showreel_gallery_div").html(data);
				}
			);							
		} else {
			window.location.hash = $(this).attr("rel");	
			$(this).addClass("selected");
			//SELECT BUTTON
			$.post("inc/load_work.php", 
			{ 
				tag: $(this).attr("rel"),
				act: 'add'
			},
			function(data){
				$("#showreel_gallery_div").html(data);
			});			
		}
    });







   $("#work_navigation a.reset").click(function () { 
   	
   		$("#work_navigation a.reset").addClass("selected");
   		
      $("#work_navigation a.filter").each(function(index) {
		    $(this).removeClass("selected");
		  });
		  
		  //SELECT BUTTON
      			$.post("inc/load_work.php", { 
								tag: $(this).attr("rel")
								}
								,function(data){
									
									$("#showreel_gallery_div").html(data);

									}
								);
								
								
    });
    
    
    
    





function posByCoords(x, y) {
	var enter_type = "top";
	if (x < 10) {enter_type = "left"; }
	if (y < 10) {enter_type = "top"; }
	if (x > 142) {enter_type = "right"; }
	if (y > 110) {enter_type = "bottom";}
	
	return enter_type;
}	







$(function(){
	/* OLD VERSION */
	/*$(".list_element_inner").live("mouseover mouseout", function(e){
 
		if (e.type == 'mouseover') {
			var x 	= e.pageX - this.offsetLeft;
			var y 	= e.pageY - this.offsetTop;
			
			var enter_type 	= posByCoords(x, y);
			if (enter_type == "top") 	$(".elem", this).stop().animate({top:"-150px"},	{queue:false,duration:200});
			if (enter_type == "bottom") $(".elem", this).stop().animate({top:"150px"},	{queue:false,duration:200});
			if (enter_type == "left") 	$(".elem", this).stop().animate({left:"-195px"},{queue:false,duration:200});
			if (enter_type == "right") 	$(".elem", this).stop().animate({left:"195px"},	{queue:false,duration:200});		
		} else {
			var x = e.pageX - this.offsetLeft;
			var y = e.pageY - this.offsetTop;
			var enter_type = posByCoords(x, y);
			
			if (enter_type == "top") $(".elem", this).stop().css('left', '0px').css('top', '-150px').animate({top:"0px"}, {queue:false,duration:200});			
			if (enter_type == "bottom") $(".elem", this).stop().css('left', '0px').css('top', '150px').animate({top:"0px"}, {queue:false,duration:200});
			if (enter_type == "left") $(".elem", this).stop().css('left', '-195px').css('top', '0px').animate({left:"0px"}, {queue:false,duration:200});
			if (enter_type == "right") $(".elem", this).stop().css('left', '195px').css('top', '0px').animate({left:"0px"}, {queue:false,duration:200});		
		}				
				
	});*/
	
	$(".list_element").mouseenter(function(e){
		var x 	= e.pageX - this.offsetLeft;
		var y 	= e.pageY - this.offsetTop;
		var enter_type 	= posByCoords(x, y);
		
		if (enter_type == "top") 	$(".elem", this).stop().animate({top:"-150px"},	{queue:false,duration:200});
		if (enter_type == "bottom") $(".elem", this).stop().animate({top:"150px"},	{queue:false,duration:200});
		if (enter_type == "left") 	$(".elem", this).stop().animate({left:"-195px"},{queue:false,duration:200});
		if (enter_type == "right") 	$(".elem", this).stop().animate({left:"195px"},	{queue:false,duration:200});	
	}).mouseleave(function(e){
		var x 	= e.pageX - this.offsetLeft;
		var y 	= e.pageY - this.offsetTop;
		var enter_type 	= posByCoords(x, y);
		
		if (enter_type == "top") $(".elem", this).stop().css('left', '0px').css('top', '-150px').animate({top:"0px"}, {queue:false,duration:200});			
		if (enter_type == "bottom") $(".elem", this).stop().css('left', '0px').css('top', '150px').animate({top:"0px"}, {queue:false,duration:200});
		if (enter_type == "left") $(".elem", this).stop().css('left', '-195px').css('top', '0px').animate({left:"0px"}, {queue:false,duration:200});
		if (enter_type == "right") $(".elem", this).stop().css('left', '195px').css('top', '0px').animate({left:"0px"}, {queue:false,duration:200});
	});
	

});

















		
		$('#slides1').cycle({
		  pager: '#nav1',
			pagerAnchorBuilder: paginate,
			delay: 0, 
			timeout:10000,
			speed: 1000
		}).cycle("pause").hover(function() {
             $(this).cycle('pause');
       },function(){
             $(this).cycle('resume');
       });





$(function() {
    $('table#client_table a').click( function() {
        window.open(this.href);
        return false;
    });
});




		
		
});

function filterSections(sec) {
	if (sec == "all") {
		 $("ul#work-menu").find("a").parent().show('fast');
	}
	else {
	 $("ul#work-menu").find("a").parent().hide();
      $("ul#work-menu").find("a[rel="+sec+"]").parent().show('fast');
     } 
}

function filterWorkElements(sec) {
	if (sec == "all") {
		 $("ul#showreel_gallery li.list_element").each(function(){$(this).find("a").parent().show(100);});
	}
	else {
	 $("ul#showreel_gallery li.list_element a").each(
				function() {
	 				$(this).parent().hide();
	 			});
	 // $("ul#showreel_gallery li.list_element").each(function(){$(this).find("a[rel="+sec+"]").parent().show(100).delay(800);});
	 $("ul#showreel_gallery li.list_element a[rel="+sec+"]").each(
				function() {
	 				$(this).parent().show();
	 			});
     } 
}



