﻿$(document).ready(function() {

	jQuery.fn.exists = function() { return jQuery(this).length>0; }



// Fancybox

			$(".fancy, #gallery a").fancybox({
				'titlePosition'	:	'over',
				'padding'			: 0,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'              : 'image',
				'changeFade'        : 0,
				'onComplete'	:	function() {
					$("#fancybox-wrap").hover(function() {
						$("#fancybox-title").show();
					}, function() {
						$("#fancybox-title").hide();
					});
				}
			});



	// Coverflow + integration with fancybox

			if($("#contentFlow").exists()) {
				var cf = new ContentFlow("contentFlow", {
					circularFlow: false,
					visibleItems: 2,
					reflectionHeight: 0.3,
					onclickActiveItem: function(item) {
						var itemOffset		= jQuery(item.element);
						var triggerDest		= $('a', itemOffset);
						$(triggerDest).trigger("click");
					}
				});

			} // end if exists




// Top menu

	$('.mainMenu li:eq(2) a, .mainMenu li:eq(3) a').attr('href', "#");

	$('.mainMenu li:eq(2) a').click(function(){
		$('.subMenu ul').fadeOut();
		$('.subMenu ul:eq(0)').fadeIn(500);
	});
	
	$('.mainMenu li:eq(3) a').click(function(){
		$('.subMenu ul').fadeOut();
		$('.subMenu ul:eq(1)').fadeIn(500);
	});



	// Flash animation

			$('.anim').flash({
		    	src: 'flash/anim.swf',
		   	 	width: 1052,
		    	height: 399,
		    	wmode: 'transparent',
		    	expressInstall: true
		    });



	// Focus border remove

			$("a").focus(function() {
				$(this).blur();
			});





	// Clear input

			clearInput = function (arg) {
				var $nam = $(arg).val();

				$(arg).focus(function() {
					if(	$(this).val() == $nam) {
						$(this).val('');
					}
				})

				$(arg).blur(function() {
					if(	$(this).val() == '') {
						$(this).val($nam);
					}
				});
			}

			clearInput("#name");
			clearInput("#email");



	// Opacity

			$.fn.opacity = function() {
				$(this).hover(
				  function () {
					$(this).css({ opacity: ".9" });
				  },
				  function () {
					$(this).css({ opacity: "1" });
				  }
				);
			}

			$(".flags a").opacity();
			$("#foot #fb img").opacity();
			$("#foot #nasi img").opacity();

			$("#gallery a").opacity();
			$("#gallery .item .printer").opacity();



	// _blank

			$(function() {
				$('.blank').click( function() {
					window.open(this.href);
					return false;
				});
			});



	// Drop down horiz menu

			$("ul.topnav li a").mouseover(function() {
				$(this).parent().find("ul.subnav").show();
				$(this).addClass("hov");

				$(this).parent().hover(function() {
				}, function(){
					$(this).find(".hov").removeClass("hov");
					$(this).parent().find("ul.subnav").hide();
				});
			});

});

