$(document).ready(function() {

   $('a.lightbox').lightBox();

	$.fn.disableTextSelect = function() {
		return this.each(function(){
			if($.browser.mozilla){//Firefox
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){//IE
				$(this).bind('selectstart',function(){return false;});
			}else{//Opera, etc.
				$(this).mousedown(function(){return false;});
			}
		});
	}
	//$("#brand").click(function(){$(".tmenu").slideToggle();});

	if (!($('.map').length > 0)) scroller();
	resizer();

	$("#cclose").click(function(){$("#cdiv").hide();});
	$("#pclose").click(function(){$("#pdiv").hide();});
});

$(window).bind('resize', function() {
	resizer();
});
function resizer() {
	//if ($(window).height() < 780) {
	//	$(".wrapper").css("backgroundPosition", "center "+(-218)+"px !important");		
	//} else {
	//	$(".wrapper").css("backgroundPosition", "center bottom");
	//}
	

	var mt = parseInt(($(".wrapper").height()-$(".bmenu").height()))-235;
	if (mt < 0) mt = 0;
	$(".bmenu").css({marginTop: mt+"px"});
	var mt = parseInt(($(".wrapper").height()-$(".mbg").height()))-235;
	if (mt < 0) mt = 0;
	$(".mbg").css({marginTop: mt+"px"});

	mt = parseInt(($(".wrapper").height()-$(".cbg").height())/2)-50;
	if (mt < 0) mt = 0;
	$(".cbg").css({marginTop: mt+"px"});
	if ($(".pbg").hasClass("video")) {
		mt = parseInt(($(".wrapper").height()-445)/2)-50;   //firefox problem
		if (mt < 0) mt = 0;
		$(".pbg").css({marginTop: mt+"px"});	
	} else {
		mt = parseInt(($(".wrapper").height()-$(".pbg").height())/2)-50;
		if ($(".pbg").hasClass("shops")) mt -= 50; 
		if (mt < 0) mt = 0;
		$(".pbg").css({marginTop: mt+"px"});
	}
}

function scroller() {
	var w=46, h=58;
	if ($('.wrapper').hasClass('man')) {w=62;h=40;}
	$('.slist').jScrollPane({
		scrollbarWidth: w,
		dragMinHeight: h,
		dragMaxHeight: h
	});
}