     $(function() {
                $('#navigation a').stop().animate({'marginLeft':'-80px'},1000);

                $('#navigation > li').hover(
                    function () {
                        $('a',$(this)).stop().animate({'marginLeft':'-10px'},200);
                    },
                    function () {
                        $('a',$(this)).stop().animate({'marginLeft':'-85px'},200);
                    }
                );
            });
     $(window).load(function() {
        $('#slider').nivoSlider();
    });
	$(document).ready(function() {

			
			$("a#example1").fancybox();

			$("a#example2").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

			$("a#example3").fancybox({
				'transitionIn'	: 'none',
				'transitionOut'	: 'none'	
			});

			$("a#example4").fancybox({
				'opacity'		: true,
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'none'
			});

			$("a#example5").fancybox();

			$("a#example6").fancybox({
				'titlePosition'		: 'outside',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9
			});

			$("a#example7").fancybox({
				'titlePosition'	: 'inside'
			});

			$("a#example8").fancybox({
				'titlePosition'	: 'over'
			});

			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image. ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
		});


$(document).ready(function() {
	
	//if submit button is clicked
	$('#submit').click(function () {		
		
		//Get the data from all the fields
		var name = $('input[name=name]');
		var email = $('input[name=email]');
		var website = $('input[name=website]');
		var comment = $('textarea[name=comment]');


		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name.val()=='') {
			name.addClass('hightlight');
			return false;
		} else name.removeClass('hightlight');
		
		if (email.val()=='') {
			email.addClass('hightlight');
			return false;
		} else email.removeClass('hightlight');
		
		if (comment.val()=='') {
			comment.addClass('hightlight');
			return false;
		} else comment.removeClass('hightlight');
		
		//organize the data properly
		var data = 'name=' + name.val() + '&email=' + email.val() + '&website=' + 
		website.val() + '&comment='  + encodeURIComponent(comment.val());
		
		//disabled all the text fields
		$('.text').attr('disabled','true');
		
		//show the loading sign
		$('.loading').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "process.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
					$('.form').fadeOut('slow');					
					
					//show the success message
					$('.done').fadeIn('slow');
					
				//if process.php returned 0/false (send mail failed)
				} else alert('technology sucks this time. please email me directly at info@djejr.com.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	
});	

var o = {
	init: function(){
		this.portfolio.init();
	},
	portfolio: {
		data: {
		},
		init: function(){
			$('#portfolio').portfolio(o.portfolio.data);
		}
	}
}

$(function(){ o.init(); });

(function($){
    $.fn.portfolio = function(options) {
		var d = {
				image: {
					width: 600,
					height: 400,
					margin: 20
				},
				path: {
					width: 10,
					height: 10,
					marginTop: 5,
					marginLeft: 5
				},
				animationSpeed: 400
		}; // default settings
		
		var s = $.extend({}, d, options); 
		
        return this.each(function(){
			var $t = $(this),
				plugin = {
					init: function(){
						this.set.position();
						this.paths.draw();
						this.paths.go();
						this.animate.item();
					},
					set: {
						position: function(){
							$t.find('.item').each(function(i){
								var t = $(this);
								t.css({ left: (s.image.width+s.image.margin)*i+'px' });
								t.find('div').each(function(j){
									var t = $(this);
									t.css({ top: (s.image.height+s.image.margin)*j+'px' });
								});
							});
						}
					},
					paths: {
						draw: function(){
							$t.append($('<div />').addClass('paths'));
							var path = $t.find('.paths'),
								items = $t.find('.item');
							items.each(function(i){
								var t = $(this), div = t.find('div');
								path.append($('<div />').addClass('path'+i).css({
										width: s.path.width+'px', 
										left: (s.path.width+s.path.marginLeft)*i+'px' 
									})
								);
								div.each(function(j){
									$('<a />').attr({ href: '#', rel: j }).css({ 
										width: s.path.width+'px',
										height: s.path.height+'px',
										top: (s.path.height+s.path.marginTop)*j+'px'  
									}).appendTo(path.find('.path'+i))
								});
							});
							path.find('.path0').find('a').eq(0).addClass('active');
						},
						go: function(){
							$t.find('.paths').find('a').click(function(){
								var t = $(this), all = $t.find('.paths').find('a'), column = t.parent('div').attr('class').split('path')[1], row = t.attr('rel'), 
									inside = $t.find('.inside'),
									top = row*(s.image.height+s.image.margin),
									left = column*(s.image.width+s.image.margin);
								inside.animate({
									top: -top+'px',
									left: -left+'px'
								}, s.animationSpeed, function(){
									plugin.position.get(inside);
								});	
								return false;
							});
						},
						classes: function(column, row){
							var anchors = $t.find('.paths').find('a'), anchor = anchors.filter(function(){
								var t = $(this),
									col = t.parent('div').attr('class').split('path')[1], 
									r = t.attr('rel');
								return col == column && r == row;
							});
							anchors.removeClass('active');
							anchor.addClass('active');
						}
					},
					animate: {
						item: function(){
							var down = { top: '-='+(s.image.height+s.image.margin)+'px' },
								up = { top: '+='+(s.image.height+s.image.margin)+'px' },
								next = { top: 0, left: '-='+(s.image.width+s.image.margin)+'px' },
								prev = { top: 0, left: '+='+(s.image.width+s.image.margin)+'px' }
							plugin.animate.img('.down', down, 40);
							plugin.animate.img('.up', up, 38);
							plugin.animate.img('.next', next, 39);
							plugin.animate.img('.prev', prev, 37);
						},
						img: function(element, object, key){
							var inside = $t.find('.inside'), type = $.browser.mozilla ? '' : '';
							$(element).click(function(){
								var t = $(this);
								if (!t.hasClass('active')){
									inside.animate(object, s.animationSpeed, function(){
										plugin.position.get(inside);
										t.removeClass('active');
									});	
								}
								t.addClass('active');
								return false;
							});
							$(document).bind(type, function(e) {
						        var code = e.keyCode ? e.keyCode : e.which;
								if(code == key && $(element).is(':visible')) { 
									if (!inside.is(':animated')) {
										inside.animate(object, s.animationSpeed, function(){
											plugin.position.get(inside);
										});
									}
								}
								return false;
							});	
						
						}
					},
					position: {
						get: function(element){
							var top = element.position().top,
								left = element.position().left;
							plugin.position.check(top, left);
						},
						check: function(top, left){
							top = ($.browser.msie && parseInt($.browser.version) == 8 && top != 0) ? top-1 : top;
							var items = $t.find('.item'),
								size_left = items.length-1,
								max_left = -size_left*(s.image.width+s.image.margin),
								column = left*size_left/max_left,
								current = items.filter(function(){
									return parseInt($(this).css('left')) == -left;
								}),
								size_top = current.find('div').length-1,
								max_top = -size_top*(s.image.height+s.image.margin),
								row = top*size_top/max_top,
								arrows = $t.find('.arrows'), 
								up = arrows.find('.up'), down = arrows.find('.down'),
								next = arrows.find('.next'), prev = arrows.find('.prev');
							if (left==max_left){ next.hide(); } else { next.show(); }
							if (left<0) { prev.show(); } else { prev.hide(); }
							if (top==max_top){ down.hide(); } else { down.show(); }
							if (top<0) { up.show(); } else { up.hide(); }
							plugin.paths.classes(column, row);
						}
					}
				}
			plugin.init();
        });
    };
}(jQuery));

var jqb_vCurrent = 0;
var jqb_vTotal = 0;
var jqb_vDuration = 5000;
var jqb_intInterval = 0;
var jqb_vGo = 1;
var jqb_vIsPause = false;
var jqb_tmp = 20;
var jqb_title;
var jqb_imgW = 560;
var jqb_imgH = 350;

jQuery(document).ready(function() {	
	jqb_vTotal = $(".jqb_slides").children().size() -1;
	$(".jqb_info").text($(".jqb_slide").attr("title"));	
	jqb_intInterval = setInterval(jqb_fnLoop, jqb_vDuration);
			
	//Horizontal
	$("#jqb_object").find(".jqb_slide").each(function(i) { 
		jqb_tmp = ((i - 1)*jqb_imgW) - ((jqb_vCurrent -1)*jqb_imgW);
		$(this).animate({"left": jqb_tmp+"px"}, 500);
	});
	
	/*
	//Vertical
	$("#jqb_object").find(".jqb_slide").each(function(i) { 
		jqb_tmp = ((i - 1)*jqb_imgH) - ((jqb_vCurrent -1)*jqb_imgH);
		$(this).animate({"top": jqb_tmp+"px"}, 500);
	});
	*/
	
	$("#btn_pauseplay").click(function() {
		if(jqb_vIsPause){
			jqb_fnChange();
			jqb_vIsPause = false;
			$("#btn_pauseplay").removeClass("jqb_btn_play");
			$("#btn_pauseplay").addClass("jqb_btn_pause");
		} else {
			clearInterval(jqb_intInterval);
			jqb_vIsPause = true;
			$("#btn_pauseplay").removeClass("jqb_btn_pause");
			$("#btn_pauseplay").addClass("jqb_btn_play");
		}
	});
	$("#btn_prev").click(function() {
		jqb_vGo = -1;
		jqb_fnChange();
	});
		
	$("#btn_next").click(function() {
		jqb_vGo = 1;
		jqb_fnChange();
	});
});

function jqb_fnChange(){
	clearInterval(jqb_intInterval);
	jqb_intInterval = setInterval(jqb_fnLoop, jqb_vDuration);
	jqb_fnLoop();
}

function jqb_fnLoop(){
	if(jqb_vGo == 1){
		jqb_vCurrent == jqb_vTotal ? jqb_vCurrent = 0 : jqb_vCurrent++;
	} else {
		jqb_vCurrent == 0 ? jqb_vCurrent = jqb_vTotal : jqb_vCurrent--;
	}
	
			
	$("#jqb_object").find(".jqb_slide").each(function(i) { 
		if(i == jqb_vCurrent){
			jqb_title = $(this).attr("title");
			$(".jqb_info").animate({ opacity: 'hide', "left": "-50px"}, 250,function(){
				$(".jqb_info").text(jqb_title).animate({ opacity: 'show', "left": "0px"}, 500);
			});
		} 
			
			
		//Horizontal Scrolling
		jqb_tmp = ((i - 1)*jqb_imgW) - ((jqb_vCurrent -1)*jqb_imgW);
		$(this).animate({"left": jqb_tmp+"px"}, 500);
		
		
		/*
		//Vertical Scrolling
		jqb_tmp = ((i - 1)*jqb_imgH) - ((jqb_vCurrent -1)*jqb_imgH);
		$(this).animate({"top": jqb_tmp+"px"}, 500);
		*/
		
		/*
		//Fade In & Fade Out
		if(i == jqb_vCurrent){
			$(".jqb_info").text($(this).attr("title"));
			$(this).animate({ opacity: 'show', height: 'show' }, 500);
		} else {
			$(this).animate({ opacity: 'hide', height: 'hide' }, 500);
		}
		*/
		
	});


}


