/*
Cufon.replace('.menu > ul > li', { hover: true, hoverables: { li: true }, ignore: { ul: true } } );
Cufon.replace('.sexyslider-title a', { textShadow: '#000 0 1px', hover: 'true' } );
Cufon.replace('.homepage-columns-item .title', { textShadow: '#47250f 0 1px' } );
Cufon.replace('.main-title span', { textShadow: '#560000 0 1px' } );
Cufon.replace('.menu-card-title', { textShadow: '#560000 0 1px' } );
Cufon.replace('.show-all', { textShadow: '#fff 0 1px', hover: 'true' } );
Cufon.replace('.price', { textShadow: '#a11b00 0 1px' } );
Cufon.replace('.menu-price', { hover: 'true' } );
Cufon.replace('h2, h3, h4, h5, h6', { hover: 'true' } );
Cufon.replace('.date', { hover: 'true' } );
Cufon.replace('.pages a', { hover: 'true' } );
Cufon.replace('.news-title a', { textShadow: '#fff 0 1px', hover: 'true' } );
Cufon.replace('.menu-card .item .title a', { hover: 'true' } );
Cufon.replace('blockquote', { hover: 'true' } );
Cufon.replace('.weekdays td', { hover: 'true' } );
*/

$(document).ready(function() {

	$('.updater').updater();

	/**
	 * 	Navigation hight light
	 */
	var url = window.location;
	url = url.toString();
	url = url.split('/');
	url = url[url.length - 1];
	

	switch(url) {
	case '':
		$('#nav_home').css({'background':'url(/images/menu-item-act.png) top left no-repeat', 'color':'#9c0000'});
		break;
	case 'menu':
		$('#nav_menu').css({'background':'url(/images/menu-item-act.png) top left no-repeat', 'color':'#9c0000'});
		break;
	case 'specials':
		$('#nav_specials').css({'background':'url(/images/menu-item-act.png) top left no-repeat', 'color':'#9c0000'});
		break;
	case 'reservations':
		$('#nav_reservations').css({'background':'url(/images/menu-item-act.png) top left no-repeat', 'color':'#9c0000'});
		break;
	case 'news':
		$('#nav_news').css({'background':'url(/images/menu-item-act.png) top left no-repeat', 'color':'#9c0000'});
		break;
	case 'banner':
		$('#nav_banner').css({'background':'url(/images/menu-item-act.png) top left no-repeat', 'color':'#9c0000'});
		break;
	case 'admin':
		$('#nav_home').css({'background':'url(/images/menu-item-act.png) top left no-repeat', 'color':'#9c0000'});
		break;
	case 'index.php':
		$('#nav_home').css({'background':'url(/images/menu-item-act.png) top left no-repeat', 'color':'#9c0000'});
		break;
	}
	//==========================================================================================================================
	//
	
	$('input[name=weeks_specials]').click(function() {
		if($(this).attr('checked') == true) {
			$.post('/admin/menu/ajax', {'id':$(this).attr('id'), 'specials':'1'});
		} else {
			$.post('/admin/menu/ajax', {'id':$(this).attr('id'), 'specials':'0'});
		}
	});

	$(".date").datepicker({
	//	showOn: "button",
	//	buttonImage: "/assets/images/calendar.gif",
		dateFormat: 'yy-mm-dd'
	//	buttonImageOnly: true
	});

	$('.date').live('click', function() {
		$('#ui-datepicker-div').css('z-index', 999);

	});

	$("a#single_image").fancybox();

	$("a#inline").fancybox({
		'hideOnContentClick': true
	});

	$("a#news-inline").fancybox({
		'hideOnContentClick': true
	});

	$("a#news-inline").click(function() {
		var arrText = $(this).attr('fields').split('|');
		$('.popup-news').html('');
		$('.popup-news-time').html('');
		$('.popup-news-title').html('');
		$('.popup-news-content').html('');
		$('.popup-news').append('<h2>News</h2>');
		$('.popup-news').append('<hr/>');
		$('.popup-news-time').append('<span></span>');
		$('.popup-news-time').append('<h5>' + arrText[0] + ' ' + arrText[1]  + '</h5>'); //data and time
		$('.popup-news-title').append('<h3>' + arrText[2]  + '</h3>'); //title
		$('.popup-news-content').append('<h4>' + arrText[3]  + '</h4>'); //content
	});

	$("a#inline").click(function() {
		var arrText = $(this).attr('fields').split('|');
		$('.popup-txt-wrapper').html('');
		if(arrText[7] == 'Pizze Pizzas' || arrText[7] == 'Drinks and Beverages') {
				$('.popup-txt-wrapper').append('<h3>' + arrText[0] + '</h3>'); 	//subcategory
		} else {
				$('.popup-txt-wrapper').append('<h3>' + arrText[7] + '</h3>'); 	//category
		}
		$('.popup-txt-wrapper').append('<hr/>');
		$('.popup-txt-wrapper').append('<h5>' + arrText[1] + '</h5>'); 	//title_en
		$('.popup-txt-wrapper').append('<h5>' + arrText[3] + '</h5>'); 	//description_en
		$('.popup-txt-wrapper').append('<hr/>');
		$('.popup-txt-wrapper').append('<h5>' + arrText[2] + '</h5>'); 	//title_cn
		$('.popup-txt-wrapper').append('<h5>' + arrText[4] + '</h5>'); 	//description_cn
		$('.popup-txt-wrapper').append('<hr/>');

		switch(arrText[7]) {
			//small price and medium price
			case 'Pizze(Pizzas)':
				$('.popup-txt-wrapper').append('<h5 style=text-align:right>' + 'Small(9\") Price: &yen;' + arrText[6] + '</h5>'); 	//price
				$('.popup-txt-wrapper').append('<h5 style=text-align:right>' + 'Medium(12\") Price: &yen;' + arrText[8] + '</h5>'); //medium price
				break;

			//small price and large price
			case 'Drinks and Beverages':
			case 'Sandwiches':
				if(arrText[8] == '0.00') {
					$('.popup-txt-wrapper').append('<h5 style=text-align:right>' + 'Price: &yen;' + arrText[6] + '</h5>'); 	//price
				} else {
					$('.popup-txt-wrapper').append('<h5 style=text-align:right>' + 'Price(Small): &yen;' + arrText[6] + '</h5>'); 	//price
					$('.popup-txt-wrapper').append('<h5 style=text-align:right>' + 'Price(Large): &yen;' + arrText[8] + '</h5>'); 	//large price
				}
				break;

			//small price, medium price and large price
			//case 'XXXXX XXXXX':
			//	break;

			//normal price
			default:
				$('.popup-txt-wrapper').append('<h5 style=text-align:right>' + 'Price: &yen;' + arrText[6] + '</h5>'); 	//price
				break;
		}

		$('.popup-img-wrapper').html('');
		//$('.popup-img-wrapper').append('<img height=210 width=310 src="timthumb.php?h=300&w=400&src=/images/menus/' + arrText[5] + '"/>'); 	//image
		$('.popup-img-wrapper').append('<img src="/timthumb.php?h=250&w=335&src=/images/menus/' + arrText[5] + '"/>'); 	//image
	});

	$("#homepage-slider").SexySlider({
		width      : 950,
		height     : 350,
		delay      : 3000,
		strips     : 15,
		autopause  : true,
		navigation : '#navigation',
		control    : '#control',
		effect     : 'wave', 	// curtain, zipper, wave, fountain, cascade, fade, random,
		titleStyle : 'false'
	});

	// hide #back-top first
	// $("#back-top").hide();
	
	// fade in #back-top
	$(function () {
		$(window).scroll(function () {
			if ($(this).scrollTop() > 100) {
				$('.back-top').fadeIn();
			} else {
				$('.back-top').fadeOut();
			}
		});

		// scroll body to 0px on click
		$('.back-top a').click(function () {
			$('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		});
	});

	$('a.tTip').tinyTips('title');

	$('.confirm').live("click",function() {
		return confirm("Are you sure you want to proceed?");
	});


	//login-wrapper
	$('#login').click(function() {
		$('#account').val('');
		$('#password').val('');
		$('#login-wrapper').center();
		$('#login-wrapper').show();
		$('#account').focus();
	});

	$('#login-btn').click(function() {
		if($('#account').val() == '' || $('#password').val() == '')
		{
			alert('Error: Account or Password can not be NULL');
			return false;
		} else {
		}
	});

	$('#close').click(function() {
		$('#login-wrapper').hide();
	});

	$('.admin-table tr').mouseover(function() {
		$(this).css('background', '#CCC');
	});

	$('.admin-table tr').mouseout(function() {
		$(this).css('background', '#FFF');
	});

	//edit news button action
	$('#cancel-editnews-btn').click(function(e) {
		$("form[name=edit-news-form]").attr('action', '/admin/news/cancelUpdate'); 
	});

	//edit menu button action
	$('#cancel-editmenu-btn').click(function(e) {
		$("form[name=edit-menu-form]").attr('action', '/admin/menu/cancelUpdate'); 
	});

	//edit feedback button action
	$('#cancel-editfeedback-btn').click(function(e) {
		$("form[name=edit-feedback-form]").attr('action', '/admin/feedback/cancelUpdate'); 
	});

	//edit feedback button action
	$('#cancel-editbanner-btn').click(function(e) {
		$("form[name=edit-banner-form]").attr('action', '/admin/banner/cancelUpdate'); 
	});

	//ajax getSubCategory
	$('#menu_category').change(function() {
		$.post('/admin/menu/getSubCategory', {'category':$(this).val()}, function(data) {
			if(data != '') {
				var arrText = data.split(",");
				$('#menu_subcategory').html('');
				for(var index = 0; index < arrText.length - 1; index++) {
					$('#menu_subcategory').append('<option value="' + arrText[index] + '">' + arrText[index] + '</option>');
				}
			}
		});
			
	});
});

