$('document').ready(function(){
	/* png fix */
	
	/* -- Fade in thumbnail images -- */

	$('div[class^="thumbnail"] ul li a').children('img').each(function() {
		// Hide the image
		$(this).hide().stop();
		
		// Create the image resource
		var $t  = $(this);
		var img = new Image();
		img.onload = function() {
			$t.fadeIn();
		}
		
		// Load the image
		img.src = $(this).attr('src');
	});

	//apply fancybox
	$('.media').fancybox({
		titlePosition	: 'over',
		easingIn 		: 'easeOutQuad',
		easingOut 		: 'easeOutQuad',
		height			:400,
		overlayColor	:'#191615',
		opacity 		: 0.8,
		autoDimensions	: false,
		autoScale		: false
	});

	$('.fancybox').fancybox({
		easingIn 		: 'easeOutQuad',
		easingOut 		: 'easeOutQuad',
		overlayColor	:'#191615',
		opacity 		: 0.8
	});
	
	//input hints
	$('input[title!=""], textarea[title!=""]').inputHint();
});

/**
 * Load a javascript or css file
 * @param filename
 * @param filetype
 * @return void
 */
function loadjscssfile(filename, filetype){
	//if filename is a external JavaScript file 
	if (filetype=="js"){ 
		var fileref=document.createElement('script')
		fileref.setAttribute("type","text/javascript")
		fileref.setAttribute("src", filename)
	 }
	 //if filename is an external CSS file
	 else if (filetype=="css"){ 
		 var fileref=document.createElement("link")
		 fileref.setAttribute("rel", "stylesheet")
		 fileref.setAttribute("type", "text/css")
		 fileref.setAttribute("href", filename)
	 }
	 if (typeof fileref!="undefined")
		 document.getElementsByTagName("head")[0].appendChild(fileref)
}
