
// JQuery
$(document).ready(function(){
	Cufon.replace('#menu');
	if ( $(".default").length > 0 ) {
		Cufon.replace('h1');
		Cufon.replace('#content h2');
		Cufon.replace('#content h3');
		Cufon.replace('#content h4');
		Cufon.replace('#content h5');
		Cufon.replace('#content h6');
	}
	// DEFAULT
	// Window identification & lng
	$(".sharethis").click( function() {
		if ( $("#win_lng").is(":visible") ) {
			$("#win_lng").fadeOut(300);
		}
		$(this).prev(".win").slideToggle(300);
		return false;
	});
	$(".lngs").click( function() {
		if ( $("#win_sharethis").is(":visible") ) {
			$("#win_sharethis").fadeOut(300);
		}
		$(this).prev(".win").slideToggle(300);
		return false;
	});
	// Win Close
	$(".win .close").click( function() {
		$(this).parent().parent(".win").fadeOut(300);
		return false;
	});
	$("#menu li.ht").hover(
		  function () {
			$(this).children("a").css('background-color','#171717');
			$(this).children("ul").show();
		  },
		  function () {
			$(this).children("a").css('background-color','transparent');
			$(this).children("ul").hide();
	});
	
	// WIDNOWS RESIZE
	$(window).resize(function(){
		// Body OFF
		if ( $("#body_off").length > 0 ) {
			$("#body_off").css({'width': $(window).width()});
			$("#body_off").css({'height': $(document).height()});	
		}
	});
	
	//SLIDESHOW
	if ( $("#slideshow .slides").length > 0 ) {
		$('#slideshow').slides({
			container: 'slides',
			paginationClass: 'buttons',
			generateNextPrev: false,
			effect: 'fade',
			crossfade: true,
			preload: true,
			preloadImage: '../i/df_loading1.gif',
			play: 5000,
			pause: 2500,
			hoverPause: true
		});
	}		
	//Init
	// Body OFF
	if ( $("#body_off").length > 0 ) {
		$("#body_off").css({'width': $(window).width()});
		$("#body_off").css({'height': $(document).height()});	
	}
	//Gallery
	$("a[rel='gallery1']").colorbox();
	$("a[rel='gallery2']").colorbox();
	$(".video1").colorbox({iframe:true, innerWidth:640, innerHeight:390});
	$(".video2").colorbox({iframe:true, innerWidth:640, innerHeight:390});							
});
//For loading events
function addEvent(elm, evType, fn) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, false);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent("on" + evType, fn);
		return r;
	} else {
		elm["on" + evType] = fn;
	}
}
