$(document).ready(function() {
	// Placeholder hack
    // http://webdesignerwall.com/tutorials/cross-browser-html5-placeholder-text
    if(!Modernizr.input.placeholder){
        $('[placeholder]').focus(function() {
          var input = $(this);
          if (input.val() == input.attr('placeholder')) {
                input.val('');
                input.removeClass('placeholder');
          }
        }).blur(function() {
          var input = $(this);
          if (input.val() == '' || input.val() == input.attr('placeholder')) {
                input.addClass('placeholder');
                input.val(input.attr('placeholder'));
          }
        }).blur();
        $('[placeholder]').parents('form').submit(function() {
          $(this).find('[placeholder]').each(function() {
                var input = $(this);
                if (input.val() == input.attr('placeholder')) {
                  input.val('');
                }
          })
        });
    }
	
	// Slider initialization
	if ($('#slider').length > 0) {
		$('#slider').nivoSlider({
			effect:'random', //Specify sets like: 'fold,fade,sliceDown'
			slices:15,
			animSpeed:500,
			pauseTime:3000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:true, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:true, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:true, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){} //Triggers after all slides have been shown
		});
	}
	
	// Dropdown Menu Init
	ddsmoothmenu.init({
		mainmenuid: "mainMenu",
		orientation: 'h',
		classname: 'ddsmoothmenu',
		contentsource: "markup"
	});

	// Add specifi class for item which has
	// submenu
	$("#mainMenu .sub-menu").each(function() {
		$(this).parent().addClass('addSubMenu');
	});
	
	// PrettyPhoto init
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	// Share links
	$('#shareLinks a.share').click(function() {
		if ($("#shareLinks #icons").is(":hidden")) {
			$('#shareLinks').animate({width: "625"}, 500 );
			$('#shareLinks #icons').fadeIn();
			$(this).text('[-] Share & Bookmark');
			return false;
		} else {
			$('#shareLinks').animate({width: "130"}, 500 );
			$('#shareLinks #icons').fadeOut();
			$(this).text('[+] Share & Bookmark');
			return false;	
		}
	});
	
	/**
	 * Top search with animation
	 * Inactive
	$('#s').focus(function() {
			$(this).animate({width: "215"}, 300 );	
			$(this).val('')
	});
	$('#s').blur(function() {
			$(this).animate({width: "100"}, 300 );
	});
	 */
});
