/* Author: Dino Latoga of MAP Creative

*/

jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);
jQuery.event.add(window, "scroll", resizeFrame);

function resizeFrame() {
    var h = $(window).height(),
		hd = $(document).height(),
		w = $(window).width(),
		wd = $(document).width(),
		hf = ($('header').height() + $('footer').height() + 123);
	$("#read").height(h-hf);

}

$('#s').css( { width: '0', opacity: '0'} );
$('#s-toggle').toggle( function() {
	$('#s').animate({ width: '425px', opacity: '1'});
	return false;
}, function() {
	$('#s').animate({ width: '0', opacity: '0'});
	return false;
});

$("input#input_2_1").attr('placeholder','Please send it to my email address: myemail@email.com');
$('[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('');
		}
	})
});

$(".nav-togglr").mouseenter(function(){
    clearTimeout($(this).data('timeoutId'));
    $(this).find("ul").stop(true, true).fadeIn("fast");
	$(this).addClass('active');
}).mouseleave(function(){
    var someelement = this;
    var timeoutId = setTimeout(function(){
		$(someelement).find("ul").stop(true, true).hide();
		$(someelement).removeClass('active');
	}, 50);
    $(someelement).data('timeoutId', timeoutId); 
});


$('.slider-ctrls a').fadeTo("slow", 0.2);
$('.slider').hover(function(){
	$(this).find('a').stop(true, true).fadeTo("slow", 1);
	}, function () {
	$(this).find('a').stop(true, true).fadeTo("slow", 0.2);
});

$('.slider').cycle({
	fx: 'fade',
	timeout: 5000,
	speed: 750,
	slideExpr: 'img',
	next: '.slider-arr-next',
	prev: '.slider-arr-prev'
}); 

$('#gallery').infinitescroll({
	navSelector  : "div.navigation",            
	nextSelector : ".nav-previous a",    
	itemSelector : "div.post",
	loading		 : {
		img			: "http://new.mapmagazine.com.au/wp-content/themes/mapmagazine/images/loader.gif",
		msgText		: "",
		finishedMsg	: ""
	}
});
  
$('#dreams').infinitescroll({
	navSelector  : "div.navigation",            
	nextSelector : ".nav-previous a",    
	itemSelector : "div.dream",
	 animate      : true,
	loading		 : {
		img			: "http://new.mapmagazine.com.au/wp-content/themes/mapmagazine/images/loader.gif",
		msgText		: "",
		finishedMsg	: ""
	}
});

/* jQuery.ias({
	container 	: "#gallery,#dreams",
	item		: ".post,.dream",
	pagination	: ".navigation",
	next		: ".nav-previous a",
	loader	: "http://new.mapmagazine.com.au/wp/wp-content/themes/mapmagazine/images/loader.gif"
}); */
