$(document).ready(function(){
	$('#concept #content-en').fadeIn('fast');
	$("#concept img[src*='lang-cn']").click(function () {
		$('#concept #content-en').fadeOut('slow');
		$('#concept #content-cn').fadeIn('slow');
	});
	$("#concept img[src*='lang-en']").click(function () {
		$('#concept #content-cn').fadeOut('slow');
		$('#concept #content-en').fadeIn('slow');
	});
	
	$('#restaurant-info #content-csc').fadeIn('fast');
	$("#restaurant-info #switch-csc").addClass('selected');
	$("#restaurant-info #switch-oph").click(function () {
		$('#restaurant-info #content-csc').fadeOut('slow');
		$('#restaurant-info #content-oph').fadeIn('slow');
		$("#restaurant-info #switch-oph").addClass('selected');
		$("#restaurant-info #switch-csc").removeClass('selected');
		return false;
	});
	$("#restaurant-info #switch-csc").click(function () {
		$('#restaurant-info #content-oph').fadeOut('slow');
		$('#restaurant-info #content-csc').fadeIn('slow');
		$("#restaurant-info #switch-csc").addClass('selected');
		$("#restaurant-info #switch-oph").removeClass('selected');
		return false;
	});
	
	$('#promotions #content-csc').fadeIn('fast');
	$("#promotions #switch-csc").addClass('selected');
	$("#promotions #switch-oph").click(function () {
		$('#promotions #content-csc').fadeOut('slow');
		$('#promotions #content-oph').fadeIn('slow');
		$("#promotions #switch-oph").addClass('selected');
		$("#promotions #switch-csc").removeClass('selected');
		return false;
	});
	$("#promotions #switch-csc").click(function () {
		$('#promotions #content-oph').fadeOut('slow');
		$('#promotions #content-csc').fadeIn('slow');
		$("#promotions #switch-csc").addClass('selected');
		$("#promotions #switch-oph").removeClass('selected');
		return false;
	});
	
	$('.promo-content').hide();
	
	 $('.promo-title p strong').hover(function(){
    $(this).css("color","#AB1224");
    },function(){
    $(this).css("color","#7B6D35");
  });
	
	$('.promo-title').click(function(){
		$('.promo-content').hide();
		$(this).next().toggle("fast");
	});
	
	// Menu Modal Window
	var menuOpen = function(hash){
		hash.o.css('opacity', 0).show().animate({"opacity": 0.70}, "fast");
		hash.w.css('opacity', 0).show().animate({"opacity": 1});
		$('#modal-nav').load('inc/modal-nav.inc.php', null, initModalNav);
		page = getPageName(hash.t.href);
		$('a.print-friendly').attr('href', 'pdf/' + page + '.pdf');
		$('#modal-content').load(hash.t.href, null, function(){
			$('.scroll-pane', hash.w).jScrollPane({
				dragMinHeight: 0,
				dragMaxHeight: 10
			});
		});
	}
	var menuClose = function(hash) {
		$('.scroll-pane', hash.w).jScrollPaneRemove();
		hash.w.remove();
		hash.o.remove();
	}
	$('#menuDialog').jqm({trigger: 'a.showMenuDialog', toTop: true, onShow:menuOpen});
	
	// $('#logo').click(function(){ window.location = 'index.php'});
	$('#reservations #content').css('left','1000px').animate({opacity: 1.0}, 500).animate({left: '160px'}, 'slow', 'swing');
	$('#concept #content').css('top','-600px').animate({opacity: 1.0}, 500).animate({top: '0'}, 'slow', 'swing');
	
	var options = {
        beforeSubmit:  formValidate, 
        success:       formResponse
    }
	function formValidate() {
		return $("form").valid();
	}
	function formResponse(responseText, statusText) {
		$('form').html(responseText);
	}
	
	jQuery.validator.messages.required = "";
	$("#reservations form").validate({
		onkeyup: false,
		errorElement: false
	});
	$('#reservations form').ajaxForm(options);
	$("#contact-us form").validate({
		onkeyup: false,
		errorElement: false
	});
	$('#contact-us form').ajaxForm(options);
});

function menuChange(dishname) {
	$('.menu-dish').hide();
	$('#dish-' + dishname).fadeIn('slow');
}

function initModalNav () {
	var content = $('#modal-content');
	$('#modal-nav a').click(function(){
		content.empty();
		content.load($(this).attr("href"), null, initDialogScrollPane)
		page = getPageName($(this).attr("href"));
		$('a.print-friendly').attr('href', 'pdf/' + page + '.pdf');
		return false;
	});
}

function getPageName (e) {
	page = e.replace(/.*ajax\/(.*)\.html/, "$1");
	return page;
}

function initDialogScrollPane () {
	$('.scroll-pane').jScrollPane({
		dragMinHeight: 0,
		dragMaxHeight: 10
	});
}

function dialogNewContent (page) {
	$('.menu-overlay-content').empty();
	$('a.print-friendly').attr('href', 'pdf/' + page + '.pdf');
	$('.menu-overlay-content').load('ajax/' + page + '.html', null, initDialogScrollPane)
}
