/* Author smarru */

$(document).ready(function() {

	// disable on click event for comments box
	$(".greybox").attr('onclick', '');

	var GB_ANIMATION = true;
	// Call grey box for featured work
	$(".greybox").live('click', function(e) {
		e.preventDefault();
		var t = this.title || $(this).text() || this.href;
		$('#GB_window').css( {
			'display' : 'block'
		});
		GB_show(t, this.href, 930, 980);

		$('#GB_frame').addClass('autoHeight');
		doIframe();
		return false;
	});

	// Call slider for featured work
	$("#slider").easySlider( {
		auto : true,
		continuous : true,
		numeric : true,
		pause : 10000
	});

	/*
	 * //hide other feature works $('.newmar').hide();
	 * $('.sokolove').hide();
	 */

	/* $('div.first div.sub-title, div.first div.desc').hide(); */

	/* $('#controls1 a').trigger('click'); */

	// Call pagination for slider for featured work
	$('.prev').live('click', function() {
		max = 3;
		if ($('#controls .current a').html() == 1) {
			$("#controls" + max + " a").trigger('click');
		} else {
			i = $("#controls .current a").html();
			$("#controls" + (i - 1) + "  a").trigger('click');
		}
	});

	$('.next').live('click', function() {
		max = 3;
		if ($('#controls .current a').html() == max) {
			$("#controls1 a").trigger('click');
		} else {
			i = $("#controls .current a").html();
			i = parseInt(i) + 1;
			$("#controls" + i + "  a").trigger('click');
		}
	});

	$("#controls1 a, #controls2 a, #controls3 a").click(
			function() {
				$('div.first div.sub-title, div.first div.desc').hide();
				var current = $('div.first ol#controls li').index(
						$('div.first ol#controls li.current'));
				$('div.first div.sub-title:eq(' + current + ')').show();
				$('div.first div.desc:eq(' + current + ')').show();
			});

	// Twitter link should go to new external pages
	$(".twitter-link").attr('target', '_blank');
	$(".twitter-user").attr('target', '_blank');

	$('li.twitter-item').each(function(index) {
		$(this).prepend("<span class='twitter-timestamp-new'></span>");

		// date format
		timestamp = $(this).find('abbr').attr('title');

		$(this).find(".twitter-timestamp-new").prepend(
				$(this).find('abbr').attr('title'));
		$(this).find(".twitter-timestamp").remove();
	});

	// big target call
	$("#work ul li a").bigTarget();

	// comment page submit button

	$(".commentbtn").hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});

});
