﻿$(document).ready(
	function() {		
		$('.kwicks').kwicks({   
        	min : 60,
			max : 570,
        	//spacing : 3,    
        	sticky : true, 
			defaultKwick: Math.floor(Math.random()* $('.kwicks').children().length)
		});
		
        $('a[rel="_blank"]').click(function() {
               window.open($(this).attr('href'));
               return false;
        });

		$('.boxgrid.caption').hover(
			function(){
				var height = $('.cover', this).height();
				var top = (198 - height) + 'px';
				$('.cover', this).stop().animate({top:top},{queue:false,duration:160});
				$('a.map', this).stop().animate({top:"0px",right:"0px"},{queue:false,duration:160});
			},
			function(){
				var height = $('.cover h3', this).height();
				var top = (198 - height) + 'px';
				$('.cover', this).stop().animate({top:top},{queue:false,duration:160});
				$('a.map', this).stop().animate({top:"-44px",right:"-37px"},{queue:false,duration:160});
			}
		);
		
		/*
        $('#topnav > li[class*=topnav]').hover(
			function() {
				$(this).siblings('li[class*=topnav]').children('a').css({
					"background-position" : "left bottom"
				})
				$(this).children('a').css({"background-position" : "left top"});
				$('#topnav > li[class*=topnav] > ul').hide();
				$(this).children('ul').show();
			},
			function(){
			}
        );
		*/
		
		$('#topnav > li[class*=topnav]').click(
	        function(){
				$('#topnav > li[class*=topnav] > ul').hide();
				$(this).children('ul').show();
				$(this).siblings('li[class*=topnav]').children('a').css({
				  "background-position" : "left -33px"
				})
				$(this).children('a').css({
				  "background-position" : "left top"
				})
			}								   
		)
		
		$('#addressname').corner().css({'margin-left':(880-$('#addressname').width())/2-23 + 'px'});	
		if($('.mapinfo').length!=0){
			$('.mapinfo').css({
				top:$('.tickettypebar').offset().top + $('.tickettypebar').height() + 33 +'px',
				width:$('.mapinfo').width(),
				left:'50%',
				'margin-left':'-'+$('.mapinfo').width()/2+'px'
			}).scale9Grid({top:20,bottom:20,left:20,right:20});;	
		
			$('.mapinfo-layout').css({height:$('.mapinfo').height()}); 
		}
		
		$('.smooth').hover(
			function(){
				var time = 0;
				var dt = 50;
				$('.border1', this).stop().fadeIn(time+=dt).next('.border2').fadeIn(time+=dt).next('.border3').fadeIn(time+=dt).next('.border4').fadeIn(time+=dt).next('.border5').fadeIn(time+=dt).next('.border6').fadeIn(time+=dt).next('.border7').fadeIn(time+=dt);
			},
			function(){
				var time = 0;
				var dt = 50;
				$('.border7', this).stop().fadeOut(time+=dt).prev('.border6').fadeOut(time+=dt).prev('.border5').fadeOut(time+=dt).prev('.border4').fadeOut(time+=dt).prev('.border3').fadeOut(time+=dt).prev('.border2').fadeOut(time+=dt).prev('.border1').fadeOut(time+=dt);
			}
		);
		
		$('.printbtn').click(
		    function(){
			    window.print() (); 
				return false; 
		})
		
		if($('body.EN-US').length > 0){
			$("#ctl00_TB_Search").autocomplete(_pJSON_en_us, {matchContains: true, width:'233px'});  
		}
		else{
			$("#ctl00_TB_Search").autocomplete(_pJSON_zh_tw, {matchContains: true, width:'233px'});

        }
        
        $('.tipstool [title]').tipsy({ trigger: 'focus', gravity: 'sw' });
		$('#topbar .btn.tipstool').tipsy({ gravity: 'n'});
		$('.questionmark.tipstool').tipsy({ gravity: 'w'});
    }
	
);