﻿// JavaScript Document
$(document).ready( function() {
	
	$(".PageSize_id:first").css( { "left" : $(".scott:first .PageSize").offset().left + "px" , "top" : ( $(".scott:first .PageSize").offset().top + 23 ) + "px" } );
	$(".PageSize_id:last").css( { "left" : $(".scott:last .PageSize").offset().left + "px" , "top" : ( $(".scott:last .PageSize").offset().top - 7 - $(".PageSize_id:last").attr("rel") ) + "px" } );

	$("#body").click( function() {
		if ( size_click ) {
			$(".PageSize_id").fadeOut("fast",function() { size_click = false; });
		}
	} );
	$(".scott:first .PageSize").click( function() {
		showsize("first");
	} );
	$(".scott:last .PageSize").click( function() {
		showsize("last");
	} );
	$(window).resize( function() {
		if ( size_click ) {
			$(".PageSize_id:first").css( { "left" : $(".scott:first .PageSize").offset().left + "px" , "top" : ( $(".scott:first .PageSize").offset().top + 23 ) + "px" } );
			$(".PageSize_id:last").css( { "left" : $(".scott:last .PageSize").offset().left + "px" , "top" : ( $(".scott:last .PageSize").offset().top - 7 - $(".PageSize_id:last").attr("rel") ) + "px" } );
		}
	} );
	$(".PageSize_id li").click( function() {
		$(".scott .PageSize").text($(this).text());
		$(".PageSize_id").fadeOut("fast",function() { size_click = false; $("#PageSizes_form").attr("value",parseInt($(".scott:first .PageSize").text(),10)); $("#searchForm").submit(); });
	} );

} );

var size_click = false;
function showsize(type) {
	if ( !size_click ) {
		$(".PageSize_id:" + type).fadeIn("fast",function() {
			size_click = true;
		} );
	}
}