function showPopup( content_html )
{
	$("#wrap").popup_simple({
		class_name: 'popup-window',
		top: '100px',
		width: '400px',
		levels: 8,
		content: $(".popup-contents ."+content_html).html(),
		appear_time: 1000,
		vual_opacity: 0.6
	});
	return false;
}
function show_menu(id){
	if ($("#menu").data("inmenu")){
		$("#"+id).addClass('over').prev().addClass('prev-over');
		$("#"+id).find('.pulldown').fadeIn(300);
	}
}

$(document).ready(function(){
	$("#menu").mouseenter( function(){
		$("#menu").data("inmenu", true);
		console.log("enter");
	})
	.mouseleave(function(){
		$("#menu").data("inmenu", false);
		console.log("leave");
	});

	$("#menu td")
	.mouseenter( function(){
		if ($("#menu").data("inmenu")){
			show_menu($(this).attr("id"));
		}else{
			setTimeout("show_menu('"+$(this).attr("id")+"')", 300);
			console.log("first");
		}
	})
	.mouseleave(function(){
		$(this).removeClass('over').prev().removeClass('prev-over');
		$(this).find('.pulldown').fadeOut(300);
	});


	$("#menu td:last, #body .column.left .box:last, #brand-line .box:last, #pathstring a:last").addClass('last');

	$("#menu .pulldown").find(".box:last").addClass('last');

	$("table.comparison tr").find("td:first").addClass('first');
	$("table.comparison tr").find("td:last").addClass('last');
	$("table.comparison tr.info:even").addClass('even');


	$("#section-tabs .tabs a, #unit-tabs .tabs a").each(function(){
		if( $(this).hasClass('on') )
			$("#"+$(this).attr('id')+"-content").show();
	});


	$("#section-tabs .tabs a, #unit-tabs .tabs a").wrapInner('<span>').click(function(){
		$(this).parent().find("a").removeClass('on');
		$(this).addClass('on');
		var tab = $("#"+$(this).attr('id')+"-content");
		tab.parent().find('div.tab').hide();
		tab.show();
		return false;
	});

	$("input.hint").focus(function(){
		if(!$(this).attr('backupValue'))
			$(this).attr('backupValue', $(this).attr('value'));
		$(this).attr( 'value', $(this).attr('value') == $(this).attr('backupValue') ? '' : $(this).attr('value') );
	}).blur(function(){
		$(this).attr( 'value', $(this).attr('value') == '' ? $(this).attr('backupValue') : $(this).attr('value') );
	});

	$(".button").hover(
	function(){
		if($(this).hasClass('on')){
			$(this).attr('is_on', true);
		}
		else{
			$(this).removeAttr('is_on');
			$(this).addClass('on');
		}
	},
	function(){
		if(!$(this).attr('is_on'))
			$(this).removeClass('on');
	}
	);

	$(".buttons-line input").click(function() {
		var tab = $("#"+$(this).attr('id')+"-content");
		tab.parent().find('div.tab').hide();
		tab.show();
		return false;
	})

	$("#section-tabs-more_photo-content a").click(function() {
		var count = $(this).index()+1;
		$("#unit-thumbnail div").hide();
		$("#unit-thumbnail div:eq("+count+")").show();
		//$("#unit-thumbnail img").attr("src", $(this).attr("href"));
		return false;
	})
/*
	$("select[name=count]").change(function() {
		$(this).parent().submit();
	});    

	$("input[name=show_item_isset]").click(function() {
		$(this).parent().submit();
	});
    
    $("input[name=show_only_new]").click(function() {
		$(this).parent().submit();
	});
*/    
    $("input[name=show]").click(function() {
		$(this).parent().submit();
	})
});
