/* main.js */
// Preload images
$.preloadCssImages();
/* setCookie */
function setCookie(sName, sValue) {
	document.cookie = sName+ "=" + escape(sValue);
}
/* getCookie */
function getCookie(sName) {
	var sResults = document.cookie.match('(^|;) ?' + sName + '=([^;]*)(;|$)');
	if (sResults) {
		return (unescape(sResults[2]));
	} else {
		return null;
	}
}
/* $(document).ready */
$(document).ready(function(){
	// Clear field
	$('.clear-field').one("focus", function() {
		$(this).val("");
	});
	// Hide comments
	$(".comment").css("display", "none");
	$(".show").css("display", "block");
	// Toggle comments
	$(".toggle").bind("click", function(e){
		$(this).next(".comment").toggle("normal"); 
	});
	// Set scroll position
	$('.scroll').click(function () { 
		var nOffset = $(window).scrollTop();
		setCookie('cOffset', nOffset);
	});
	// Get scroll position 
	$(window).scrollTop(getCookie('cOffset'));
	// Reset scroll offset
	setCookie('cOffset', 0);
});