$(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto();
	rollover();
	imgsize($('#item-detail dt img'), 200, 150);
	itemsize($('p.item-img img'));

	$(function() {
		var m = 0;
		$('div#recommend div').each(function() {
			if ($(this).height() > m) m = $(this).height();
		})
		.css('height', m + 10);

		$('div#recommend div img').each(function() {
			if (($(this).width() / $(this).height()) > (162 / 122)) {
				$(this).css('width', 162);
				$(this).css('height', 'auto');
			}
			else {
				$(this).css('height', 122);
				$(this).css('width', 'auto');
			}
		});
	});
});

function rollover() {
//	var path = document.URL.substr(document.URL.lastIndexOf('/')).split('#');
	var path = document.URL.split('/');
	$('.menus li a').each(function(){
		if (path[3] == 'index.php' || !path[3]) {
			path[3] = '';
		}
		if ($(this).attr('href') == '/' + path[3]) {
			$(this).attr('class', 'current');
		}
	});
	if (path[4] !== undefined) {
		$('.item-menus li a').each(function(){
			if ($(this).attr('href') == '/' + path[3] + '/' + path[4]) {
				$(this).attr('class', 'current');
			}
			if (path[5] !== undefined) {
				if ($(this).attr('href') == '/items/' + path[4] + '.php') {
					$(this).attr('class', 'current');
				}
			}
		});
		$('#sm-03 a').attr('class', 'current');
	}
}

function imgsize(elm, w, h) {
	if (elm.attr('width') > elm.attr('height')) {
		elm.attr('width', w);
	}
	else {
		elm.attr('height', h);
	}
}

function itemsize(elm) {
	elm.css('max-width', 180);
	elm.css('max-height', 130);
}

