jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

jQuery.fn.switchClass = function(class1,class2) { 
    if (this.hasClass(class1)) { 
        this.removeClass(class1).addClass(class2); 
    } else { 
        this.removeClass(class2).addClass(class1); 
    } 

};

common_bg = 'top right no-repeat'
list = '<h3>Contact Me</h3>\
		<ul>\
		<li class="aim">aim: dndesakuaim</li>\
		<li class="gtalk">gtalk: <a href="mailto:davidnuongm@gmail.com">davidnuongm@gmail.com</a></li>\
		<li class="msn">live: davidnuongm@gmail.com</li>\
		<li class="yahoo">yh: davidnuonyh</li>\
		<li class="blellow">blellow: <a href="http://www.blellow.com/davidnuon">davidnuon</a></li>\
		<li class="twitter">twitter: @<a href="http://twitter.com/dn_desaku">dn_desaku</a></li>\
		</ul>'

data = {
	'web' : ['latest: 3 x Wavers', {'background-image' : 'url(img/stings/web-dev-3xwavers.png)'}],
	'id'  : ['latest: Neo-Beastie', {'background-image' : 'url(img/stings/identity.png)'} ],
	'graphic' : ['latest: Venture Aviation Flyer', {'background-image' : 'url(img/stings/graphic.png)'}],
	'apps' : [5, {'background' : 'purple'}],
	'contact' : [ list, {'background-image' : 'url(img/stings/contact.png)'}],
	'normal' : ['Hover over the navigation to see the latest.', 
				{'background-image' : 'url(img/stings/default.png)'}]
}

$("document").ready( function(){
	$(".a-context").hover( 
		function() { 
			$("#context").html( data[$(this).attr("rel")][0]);
			$("#image-sting").css( data[$(this).attr("rel")][1]);
		},  
		function() { 
		}
		);

$("#js-check").hide();
	
	/* View */
	
	$('.navi-toggle a').click( 
		function () { 
			$('#slider').slideToggle(); 
			$('.navi-toggle a').switchClass('up', 'down');
		} );
	
	first_item = $($('#entry-navi').find("li")[0])
	fi_data = [$(first_item.find("span")[2]).html(),
					$(first_item.find("span")[3]).html(),
					$(first_item.find("span")[0]).html(),
					$(first_item.find("span")[1]).html()]
	gallery_r(fi_data[0], fi_data[1], fi_data[2], fi_data[3])
	
	$('#entry-navi li').click(
		function () {
			data = [$($(this).find("span")[2]).html(),
					$($(this).find("span")[3]).html(),
					$($(this).find("span")[0]).html(),
					$($(this).find("span")[1]).html()]
			gallery_r(data[0], data[1], data[2], data[3])
		}	
	);
	
	$('#entry-navi li').each(
		function () {
			data = [$($(this).find("span")[2]).html(),
				$($(this).find("span")[3]).html(),
				$($(this).find("span")[0]).html(),
				$($(this).find("span")[1]).html()]
			$(this).qtip({
				content : { text: data[2]},
				show : 'mouseover',
				hide : { fixed: true },
				   position: { corner: { target: 'bottomMiddle', tooltip: 'topMiddle' } }
			})
			}
		)
})

function gallery_r(image, tech, title, info) {
	$('#entry-view').html( image );
	$('#entry-info .one-third .b-content .tech').html( tech );
	$('#entry-info .two-third .b-content .title').html( title );
	$('#entry-info .two-third .b-content .info').html( info );	
}