if(typeof(Frontend)=='undefined'){	
	Frontend={		
		run:function(){
			this.ActiveCategory();
			this.configDateTime();
			this.configSexyCombo();
			this.configSliderImg();
			this.configPoll();
			this.configHoverSupport();
			this.configLanguage();
			this.onchangeWeatherProvicen();
		},
		onchangeWeatherProvicen:function(){
			$('#id-select-provicen-weather').change(function(){
				var name  = $(this).val();
				$('.one-provicen-w').hide();
				if(name==''){
					name = 'sapa';
				}
				$('#' + name).show();
			});
		},
		configLanguage:function(){
			$('.change-portal-language').click(function(){
				$('.language-active').removeClass('language-active');
				$(this).addClass('language-active');
				var adminLanguage  = $(this).attr('rev');
				$.cookie('frontend-portal-language', adminLanguage,{path:'/'});
				location.href=baseURL ;
			});
			var languageValue = $.cookie('frontend-portal-language');
			languageValue = (languageValue == null)?'':languageValue;
			$('.language-active').removeClass('language-active');
			$('a[rev="'+languageValue+'"]').addClass('language-active').css({'color':'Red','font-weight':'bold'});
		},
		ActiveCategory:function(){
			if(activeRoot == '_' || activeRoot == 'home_'){
				$('#trang-chu').removeClass('normal-menu').addClass('active-menu');
			}else{
				$('#'+activeRoot).removeClass('normal-menu').addClass('active-menu');
				$('#'+activeRoot).removeClass('li-menu-main').addClass('active-menu-main');
			}
		},
		changeCaptcha:function(){
			var date = new Date();
			var captcha_time = date.getTime();
			$("#captcha-comment-image").attr({src:'/extsource/captcha/simple/create_image.php?'+captcha_time});
		},
		configDateTime:function(){
			if($('.date-train').length){
				$('.date-train').dynDateTime({
					ifFormat: "%d-%m-%Y",
					button: ".next()",
					debug:  false,
					step:1
				});
			}
		},
		configSexyCombo:function(){ 
			$("#select_train").sexyCombo();
		},
		configHoverSupport:function(){
			$('#online-ym').hover(function() {
					$("#show-content-bound-online-ym").show();
				}, function() {
					$("#show-content-bound-online-ym").hide();
				});
			$('#online-skype').hover(function() {
				$("#show-content-bound-online-skype").show();
			}, function() {
				$("#show-content-bound-online-skype").hide();
			});
			$('#online-email').hover(function() {
				$("#show-content-bound-online-email").show();
			}, function() {
				$("#show-content-bound-online-email").hide();
			});

		},
	configPoll:function(){
		this.configShowResult();
		this.configPollFormAjax();
	},
	
	configShowResult:function(){
		
	},
	
	configPollFormAjax:function(){
		var options = { 
			success:    function() { 
				$('.thickbox').click();
			} 
		}; 
		$('.from-estimate-player').ajaxForm(options);
	},
		configSliderImg:function() {
			var theInt = null;
			var $crosslink, $navthumb;
			var curclicked = 0;
			var count_booking = $('#main-photo-slider').attr('lang');
			theInterval = function(cur){
				clearInterval(theInt);
				
				if( typeof cur != 'undefined' )
					curclicked = cur;
				
				$crosslink.removeClass("active-thumb");
				$navthumb.eq(curclicked).parent().addClass("active-thumb");
					$(".stripNav ul li a").eq(curclicked).trigger('click');
				
				theInt = setInterval(function(){
					$crosslink.removeClass("active-thumb");
					$navthumb.eq(curclicked).parent().addClass("active-thumb");
					$(".stripNav ul li a").eq(curclicked).trigger('click');
					curclicked=curclicked+1;
					if( (count_booking-3) == curclicked || count_booking < curclicked ){
						curclicked = 0;
					}
					
				}, 3000);
			};
			
			$(function(){
				if($('#main-photo-slider').length){	   
					$("#main-photo-slider").codaSlider();
					
					$navthumb = $(".nav-thumb");
					$crosslink = $(".cross-link");
					
					$navthumb
					.click(function() {
						var $this = $(this);
						theInterval($this.parent().attr('href').slice(1) - 1);
						return false;
					});
					
					theInterval();
				}
			});
		}
	}
	Frontend.run();
}
