function dropMenu() {
	$("#nav > li:has(div)").hover(function(){
		$(">a", $(this)).addClass("selected");
		$(">a", $(this).next("li")).addClass("next");
		$("li:first", this).addClass("first");
		$(">div", this).show();
	}, function() {
		$(">a", $(this)).removeClass("selected");
		$(">a", $(this).next("li")).removeClass("next");
		$(">div", this).hide();
	});
}

function loadImage(url, callback) {
	var img = new Image();
	img.src = url;

	if (img.complete) {
		callback.call(img);
		return;
	}

	img.onload = function () {
		callback.call(img);
	};
};

//run fun
$(document).ready(function() {
	if (window.screen.availHeight <= 770) {
		$('#wrapper').css({position : 'static', margin : '0 auto', paddingTop : '74px', paddingBottom : '20px'});
	}
	//alert(window.screen.availHeight);
	if ($.browser.msie && (parseInt($.browser.version) <= 7)) {
		try {
			document.execCommand('BackgroundImageCache', false, true);
		} catch(e){}
		$('clearfix').css('zoom', 1);
	}
	if (window.navigator.userAgent.indexOf("Chrome") !== -1) {
		$('html').css('-webkit-text-size-adjust', 'none');
	}	

	$('#main').css({'-moz-border-radius-topright':'10px','-moz-border-radius-bottomleft':'20px', '-webkit-border-radius': '0 10px 0 20px', 'border-radius':'0 10px 0 20px'});
	$('.left-box').addClass('curved').css({'-moz-border-radius-bottomleft':'20px', '-webkit-border-radius': '0 0 0 20px', 'border-radius':'0 0 0 20px'});
	
	Cufon.replace(".cd", {fontFamily:"Candara", fontWeight:700});
	Cufon.replace(".cg",{fontFamily:"Century Gothic",fontWeight:400,hover:true});
	Cufon.replace(".cgi",{fontFamily:"Century Gothic",fontStyle:"italic",hover:true});
	Cufon.replace(".cgb",{fontFamily:"Century Gothic",fontWeight:700,hover:true});
	Cufon.replace(".cgib",{fontFamily:"Century Gothic",fontStyle:"italic",fontWeight:700,hover:true});
	
	$("#nav > li:first").addClass("first");
	$("#nav > li:has(div)").addClass("submenu");
	dropMenu();

	if ($('.gallery-list').length == 1 && $('.gallery-list').hasClass('do')) {
//		var imageArray = [];
//		$('.gallery-list a').each(function() {
//			loadImage($(this).attr('href'), function() { imageArray.push(this.src)});
//		});
		$('.gallery-list a.gallery-item').lightBox({containerBorderSize:0, containerResizeSpeed:1});  
	}
});
