function PopUp(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
	if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

$(document).ready(function () {
    fixLinks();
    function img_mouseover() {
        this.src = getRolloverSource(this.src);
    }
    function img_mouseout() {
        this.src = this.src.replace("_on", "");
    }
    function getRolloverSource(src) {
        return src.replace(".gif", "_on.gif").replace(".jpg", "_on.jpg");
    }
    $('img.auto-rollover').each(function () {
        // only if no mouseover defined
        if (!this.onmouseover) {
            this.imgOn = new Image(img.width, img.height);
            this.imgOn.src = getRolloverSource(img.src);

            this.onmouseover = img_mouseover;
            this.onmouseout = img_mouseout;
        }
    });
});

/* buyTickets links */
$(document).ready(function () {
	var zIndex = 1000;
	$('a.buyTickets')
		.wrap('<div class="buyTicketsWrapper" class="hidden"></div>')
		.each(function () {
			var url = this.href,
				$a = $(this),
				$wrapper = $(this).parent(),
				$choosePerf = null;
			$wrapper
				.css('zIndex', --zIndex)
				.addClass( $a.is('.buttonWide') ? 'wide' : '' )
				.hoverIntent(function () {
					$('div.choosePerf').hide();
					
					$choosePerf.height(Math.min($choosePerf.height(), 263)).css('overflow', 'auto')
					$choosePerf.fadeIn("fast"); 
				},
				function () {
					$choosePerf.fadeOut("normal");
				})
				.append('<div class="choosePerf hidden"><span class="loadingText">Loading Performance Dates</span></div>');
			$choosePerf = $wrapper.find('div.choosePerf')
				.load('/Includes/Components/ChoosePerformance.aspx?url=' + url, null, function (s) {
					if (!s.match(/[a-z]/)) {
						$choosePerf.parent().hide();
					}
					else {
						$wrapper.show();
					}
				});
		});
});

function fixLinks() {
    //find mailto links, get addr from @title
    $("a.mailto").each(function () {
        var emailData = $(this).attr("title").split(",");
        var emailAddr = emailData[0] + "@" + emailData[1] + "." + emailData[2];
        $(this).attr("href", "mailto:" + emailAddr).attr("title", emailAddr);
    });
}


/* tabs */
function showTab(id, url, whichTabs, whichContent) {
    //update tab nav
    $(whichTabs + " li").removeClass("at");
    $("#" + id).addClass("at");
    //load content
    $(whichContent).load(url, null, function () { fixLinks() });
}

function initTabs(whichTabs, whichContent) {
    $(whichTabs + " li").each(function (i) {
        $(this).click(function () {
            location.hash = $(this).attr("id").substr(4);
            showTab($(this).attr("id"), $(this).find("a").attr("href"), whichTabs, whichContent);
            $(this).find("a").blur();
            return false;
        });
    });
    var hash = location.hash.replace('#', '');
    var li = null;
    $(whichTabs).find("li").each(
		        function () {
		            if (hash.indexOf(this.id.substr(4)) > -1) { // tab-
		                li = $(this);
		            }
		            $(this).removeClass("at");
		        }
            );
    if (!li) {
        li = $(whichTabs + " li:first-child");
    }
    if (li && li.length) {
        showTab(li.attr("id"), li.find("a").attr("href"), whichTabs, whichContent);
    }
}


//jquery cookie plugin
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

//clickable containers
$(document).ready(function(){
   var containerLink = $(".allClick");
   containerLink.click(function(){
      window.location = $(this).find("a:first").attr("href")
   });
   containerLink.hover(function(){
      window.status = $(this).find("a:first").attr("href")
   }, function(){
      window.status = ""
   })
});


//color box pop-up
$(document).ready(function () {
    $("a[rel='cboxPop']").colorbox({opacity:0,});
});
