//recent projects page jquery initialization
$().ready(function(){
	//fix footer position
	h = $("#wrapper").height();
	w = $("#wrapper").width();
	$(".footer").css({
		position: "absolute",
		top: (h-20)+"px"
	});
	//-
	
	//dropdown menu - comment form
	$("#sendCommentForm").find(".loewDropDownMenu").loewyDropDownMenu({
		width: 150,
		slideUpSpeed: 300,
		slideDownSpeed: 400
	});
	//-
	
	//dropdown menu - work menu
	$(".recent_projects").find(".loewDropDownMenu").loewyDropDownMenu({
		width: 115,
		slideUpSpeed: 300,
		slideDownSpeed: 400
	});
	//-
	
	//dropdown menu - work menu
	$("#homenav").find(".loewDropDownMenu").loewyDropDownMenu({
		width: 115,
		slideUpSpeed: 300,
		slideDownSpeed: 400
	});
	
	//homenav
	//$(".gridMenuItem, .gridMenuContainer", $("#homenav")).find(".loewDropDownMenu").css("display","none");
	
	
	if ($.fn.jScrollPane) {
		//project list scroll
		var scroll_startUpPos = 0;
		//alert(document.referrer);
		//if (document.referrer&&document.referrer.indexOf("/work/") >= 0 ) {
			//alert("A");
			scroll_startUpPos = getCookie(scrollPaneCookie);
			if (scroll_startUpPos != "") {
				scroll_startUpPos = parseFloat(scroll_startUpPos);
			}
		//}
		$(".recent_projects").find(".project_listings").jScrollPane({
			scrollbarWidth: 8,
			dragMaxHeight: 46,
			dragMinHeight: 46,
			positionChanged:function(p) {
				setCookie(scrollPaneCookie,p,1);
			},
			startUpPos:scroll_startUpPos
		});
		//-
	}
		
	//thumbnails
	if ($.loewy.cycle) {
		$(".cycle").loewyCycle({
			width: 152,
			height: 152,
			circleSpeed: 600,
			mouseoverDelay: 2
		});
	}
	
	//-
	
	//homenav
	
	$(".homenavMenuItem","#homenav").loewyGridMenu({
		showDuration: 500,
		hideDuration: 500,
		animType: 2,
		backgroundColor: "#1A314F",
		easeShow:"easeInQuad",
		easeHide:"easeOutQuad"
	});
	
	//-
	
	//Sort by dropdown menu
	if ($.loewy.dropDownMenu) {
		$("#homenavWork").find("li.menuitem").mousedown(function(e) {
			//loadSortList($(this).attr("rel"));
			
			rel = $(this).attr("rel");
			if (rel != undefined && rel != "") {
				document.location.href = "/work/"+rel+"/";
				//document.location.replace("/work/"+rel+"/");
			}
		});
	} else {
		$("#homenavWork").find("select").find("option").click(function(e) {
			//loadSortList(this.value);
			rel = this.value
			if (rel != undefined && rel != "") {
				document.location.href = "/work/"+rel+"/";
			}
		});
	}
	//-
	
	//---------------------- project listings -------------------------
	//Sort by dropdown menu
	if ($.loewy.dropDownMenu) {
		$(".recent_projects").find("li.menuitem").mousedown(function(e) {
			rel = $(this).attr("rel");
			if (rel != undefined && rel != "") {
				document.location.href = "/work/"+rel+"/";
			}
		});
	} else {
		$(".recent_projects").find("select").find("option").click(function(e) {
			rel = this.value
			if (rel != undefined && rel != "") {
				document.location.href = "/work/"+rel+"/";
			}
		});
	}
});
