Shadowbox.loadSkin('classic', '/site/javascript/shadowbox/skin');
Shadowbox.loadLanguage('en', '/site/javascript/shadowbox/lang');
Shadowbox.loadPlayer(['flv', 'img', 'html', 'iframe', 'swf', 'mp3'], '/site/javascript/shadowbox/player');

window.onload = function(){

    Shadowbox.init();

};
function markercurrent(id){
	window.setTimeout(function() {
		$('.side ul li a').click(function() {
			$('.side ul li a').removeClass('current');
			$(this).addClass('current');
		});
	}, 510);
}
/*--- initdomscirpt ---*/
function initdomscript(){
	var line_height = 18;
	var half_line_height = line_height / 2;
	var min_margin = 2;
	var indent = "1.5em";
	$('.main-pic img').removeAttr('height').removeAttr('width');
	if($.browser.safari) {
		$('input.searchinput').addClass('safari-search');
	}
	$('a').hover(function() {
			$(this).parent().find("span").addClass('hover');
		}, function(){ 
			$(this).parent().find("span").removeClass('hover');
	});
	$('.mediapartner img').wrap('<span></span>');
	$('.mediapartner a:first-child, .mediapartner span:first-child').addClass('first');
	var mpcount = 0;
	var mpwith = $('.mediapartner').width();
	var mpspanwidth = 0;
	$('.mediapartner span').each(function(index){
	  mpspanwidth = mpspanwidth + $(this).width() + 30;
	  if(mpspanwidth > mpwith) {
	    mpcount = 0;
	    mpspanwidth = 0;
	  }
	  mpcount++;
	  $(this).addClass('index'+mpcount);
	});
	if ($.browser.msie && jQuery.browser.version.substring(0,1) === '6') {
	//	$('div.section').append('<div class="ie6clearfix"></div>');
		var _totop = '116px';
		var _fromtop = '144px';
		var ccount = 1;
		$('.pic').each(function(){
			$(this).addClass('n'+ccount);
			$('.pic.n'+ccount).parent().find('.pic-inner').addClass('n'+ccount);
			var img_w = $('.pic.n'+ccount+' .pic-inner.n'+ccount).parent().find('img').width();
			var img_h = $('.pic.n'+ccount+' .pic-inner.n'+ccount).parent().find('img').height();
			$('.pic.n'+ccount).css({'width':img_w});
			$('.pic.n'+ccount+' .pic-inner.n'+ccount).css({'width':img_w,'height':img_h});
			$('.pic.n'+ccount).find('.pic-inner-shadow-top').css({'width':img_w});
			$('.pic.n'+ccount).find('.pic-inner-shadow-bottom').css({'width':img_w});
			$('.pic.n'+ccount).find('.pic-inner-shadow-left').css({'height':img_h});
			$('.pic.n'+ccount).find('.pic-inner-shadow-right').css({'height':img_h});
			ccount++;
		});
		$("p + p").css("padding-top",line_height);
		$("p + p.indent").css("text-indent",indent);
	//	$("p.fl-r + p,p.fl-l + p,p + p.fl-r,p + p.fl-l,p + p.null").css("padding-top","0");
		$("ul.fl-l").css({'width':$("ul.fl-l li img").width()});
		$("ul.fl-r").css({'width':$("ul.fl-r li img").width()});
	} else {
		var _totop = '118px';
		var _fromtop = '144px';
		$('#sub-navigation li').hover(function() {
				$(this).next('li').addClass('none-bg');
			}, function(){ 
				$(this).next('li').removeClass('none-bg');
		});
	}
	var bbw = $('.box-base').width();
	var bw = $('.box').width();
	var cc = bbw / bw;
	var ccb = parseInt(cc) + 1;
	var count = 1;
	$('.box').each(function(){
		$(this).addClass('cc'+count);
		count++;
		if(count==ccb) count = 1;
	});
	$('.box-inner').hover(function(){
		$(".ticket", this).stop().animate({top:_totop},{queue:false,duration:160});
	}, function() {
		$(".ticket", this).stop().animate({top:_fromtop},{queue:false,duration:160});
	});
	$("ul li:first-child").addClass('first');
	$("ul li:last-child").addClass('last');
	
	$('.show-hide-value').each(function() {
    	var default_value = this.value;
	 //   $(this).css('color', '#333');
    	$(this).focus(function() {
	        if(this.value == default_value) {
    	        this.value = '';
     //   	    $(this).css('color', '#333');
	        }
    	});
	    $(this).blur(function() {
    	    if(this.value == '') {
	//			$(this).css('color', '#333');
            	this.value = default_value;
	        }
    	});
	});
	$('.infobox-links ul li.ticket').each(function(index) {
		if(!$(this).hasClass('top')) {
			$(this).addClass('t_'+index);
			$('.t_'+index+' ul.base ul li').each(function(count){
				$(this).addClass('tl_'+count);
				if($(this).width()>150) {
					$('.t_'+index+' ul.base ul li.tl_'+count).css('width','150px');
				}
			});
		}
		
		if(($('.t_'+index+' ul.base ul li').size()-4)>4){
			var lwith = $('.t_'+index+' ul.base ul li:nth-child(1)').width() + 1 +
						$('.t_'+index+' ul.base ul li:nth-child(2)').width() + 1 +
						$('.t_'+index+' ul.base ul li:nth-child(3)').width() + 1 +
						$('.t_'+index+' ul.base ul li:nth-child(4)').width();
			var ibl = lwith+1;
			var ibticket = $('.t_'+index).width();
			$('.t_'+index+' li.top').css({'width':ibl-10,'top':'70px','left':'5px','height':'1px','border-top':'1px solid #E5E5E5','background':'none'});
			$('.t_'+index+' ul.base ul li:nth-child(5)').css({'background':'none'});
			var s_top = "-184px";
			var e_top = "-169px";
			var ghe = "142px";
			var gbhe = "154px";
		} else {
			var ibl = $('.t_'+index+' ul.base ul').width()+1;
			var ibticket = $('.t_'+index).width();
			var s_top = "-103px";
			var e_top = "-88px";
			var ghe = "61px";
			var gbhe = "73px";
		}

		var ibhalv = parseInt(ibl/2);
		var ibtickethalv = parseInt(ibticket/2)+10;
		var ibhal = (ibticket-ibtickethalv)-(ibl-ibhalv);
				
		$('.t_'+index+' ul.base').css({'width':ibl,'height':gbhe,'left':ibhal,'display':'none','opacity':'0'});
		$('.t_'+index+' ul.base ul').css({'width':ibl,'height':ghe,'position':'relative'});
		$('.t_'+index+' li.bottom').css({'width':ibl});
		
		if($('.t_'+index+' ul.base').hasClass("mini")) {
			$('.t_'+index+' ul.base').css({'top':'-72px'});
			$('.t_'+index).hover(function() {
					$('.t_'+index+' ul.base').css({'display':'block'}).stop(true, true).animate({'top':'-57px','opacity':'1'},{queue:false,duration:160});
				}, function(){ 
					$('.t_'+index+' ul.base').stop().animate({'top':'-72px','opacity':'0'},{queue:false,duration:160});
					window.setTimeout(function() {
						$('.t_'+index+' ul.base').css({'display':'none'});
					}, 160);
			});
		} else {
			$('.t_'+index+' ul.base').css({'top':s_top});
			$('.t_'+index).hover(function() {
					$('.t_'+index+' ul.base').css({'display':'block'}).stop(true, true).animate({'top':e_top,'opacity':'1'},{queue:false,duration:160});
				}, function(){ 
					$('.t_'+index+' ul.base').stop().animate({'top':s_top,'opacity':'0'},{queue:false,duration:160});
					window.setTimeout(function() {
						$('.t_'+index+' ul.base').css({'display':'none'});
					}, 160);
			});
		}
	});
	
/*	$('.time-location').each(function(index){
		$(this).addClass('d_'+index);
		if($('.d_'+index).height()>24) {
			$('.d_'+index).parent('div.infobox-inner').addClass('d3lines');
		}
	});
*/	$('.box-nav').each(function(index){
		var _hold = $(this);
		var hold_w = _hold.parent().parent().width();
		var count = _hold.find('li').length;
		var _liwith = parseInt(hold_w / count)-2;
		_hold.find('span').css({'width':_liwith});
		_hold.find('li.last span').css({'width':(_liwith)+(1)});
		_hold.find('li.last span').wrapInner('<i></i>');
	//	_hold.find('em').css({'width':_liwith});
	});
	//$('.gmapslink').each(function(index){
	//	$(this).next('div').hide().addClass('s_'+index);
	//});

	$('.gmapslink').each(function(index){
		$(this).next('div').hide().addClass('s_'+index);
		$(this).click(function() {
			if($(this).hasClass("current")) {
				$('.gmapslink').removeClass('current');
				$('.slider').slideUp();
				return false;
			} else {
				$('.gmapslink').removeClass('current');
				$(this).addClass('is_'+index).addClass('current');
				window.setTimeout(function() {
					$('.slider').slideUp();
				}, 310);
				window.setTimeout(function() {
					$('.s_'+index).slideDown();
				}, 510);
			}
		});
	});
	
	$('.memberlink').each(function(index){
		if($(this).next('div').hasClass("show")) {
			$(this).next('div').addClass('s_'+index);
		} else {
			$(this).next('div').hide().addClass('s_'+index);
		}
		$(this).click(function() {
			if($(this).hasClass("current")) {
				$('.memberlink').removeClass('current');
				$('.slider').slideUp();
				return false;
			} else {
				$('.memberlink').removeClass('current');
				$(this).addClass('current');
				$('.slider').slideUp();
				$('.s_'+index).slideDown();
			}
		});
	});


}
/*--- on document ready ---*/
$(document).ready(function(){
	initdomscript();
	
	$('.jqtrans').jqTransform();
	
	$('#newsletter input').each(function() {
		if(!$('.letterslider').hasClass("show")) {
			$('.letterslider').hide();
		}
    	$(this).focus(function() {
	    	if(!$(this).hasClass("show")) {
				$('.letterslider').addClass('show').fadeIn();
				// $('html, body').animate({scrollTop:$("body").attr("scrollHeight")}, 'slow');
			}
    	});
	    $(this).blur(function() {
	    	if(!$(this).hasClass("show")) {
				$('.letterslider').addClass('show').fadeIn();
				// $('html, body').animate({scrollTop:$("body").attr("scrollHeight")}, 'slow');
			}
    	});
	});
	$('#newsletter input, .letterslider input').each(function() {
    	$(this).focus(function() {
    		if($(this).hasClass("error")) {
    			$(this).css('color', '#fff');
    		}
    	});
	    $(this).blur(function() {
    		if($(this).hasClass("error")) {
    			$(this).css('color', '#fff');
    		}
    	});
	});
	$('.xform a.close').click(function(){
		$('.letterslider').removeClass('show').fadeOut();
		return false;
	});
	
	var toggleduration = 300;
	if ($.browser.msie && jQuery.browser.version.substring(0,1) === '7') toggleduration = 2;
	
	$('.event-filter-wrapper').hide();
	$('.event-filter-toggler').bind('click',function () { 
		$('.event-filter-wrapper').slideToggle(toggleduration);
		var fullheight = 0;
		$('.box-nav-event ul').each(function(){
		  if(fullheight < $(this).height()) {
		    fullheight = $(this).height();
		  }
		}).height(fullheight);

		$(this).toggleClass("active"); 
		return false;
	});

  if($.address.parameter('searchstring') || $.address.parameter('genre') || $.address.parameter('city')
  || $.address.parameter('vip') || $.address.parameter('period')){
    $('.event-filter-toggler').addClass('active');
    $('.event-filter-wrapper').show();
  }

	//window.setTimeout(function() {
	//	myclick('1');
	//	$('.side_id0').slideDown();
	//}, 510);
	
});
