function bookmark(title,url) {
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} else if(document.all) { // ie
		window.external.AddFavorite(url, title);
	} else {
		alert('Please press Control-D (for Windows, Linux) or Command-D (for Apple) to bookmark this page');
	}
}
function emailPage(uid) {
	window.open("/Email-Page?UID="+uid,"pop","width=775,height=327,toolbars=0,scrollbars=0");
}
function printPage() {
	window.print();
}
function showEvents(type) {
	document.getElementById('display').value=type;
	document.getElementById('refineSearch').submit();
}
function buy(i) {
	top.window.location.href = "/Cart/Add?ItemType=TT&ItemID="+i+"&Quantity="+document.getElementById('s'+i).value
}
function buyFg(i) {
	top.window.location.href = "/Cart/Add?tpl=Fgs&ItemType=TT&ItemID="+i+"&Quantity="+document.getElementById('s'+i).value
}
function buyCustom(i) {
	quantity = document.getElementById('s'+i).value;
	if (!quantity) {
		alert('Please select a quantity');
		return;
	}
	top.window.location.href = "/Cart/Add?ItemType=CT&ItemID="+i+"&Quantity="+quantity;
}
function notes(id) {
	note = document.getElementById('notes'+id);
	if (note.className == 'hide') note.className='show';
	else note.className='hide';
}
function addItemToCart(i) {
	top.location.href = '/Cart/Add/Items/'+i+'/'+document.getElementById('item'+i).value
}
function changeItemQuantity(i) {
	top.location.href = '/Cart/Items/Quantity/'+i+'/'+document.getElementById('item'+i).value
}
function changeTTQuantity(i) {
	top.location.href = '/Cart/Tickets/Quantity/'+i+'/'+document.getElementById('tt'+i).value
}
function colHeight() {
	try {
		var bottomPos = findPosY(document.getElementById('bottomNav1'));
	} catch (e) {}
	try {
		var leftbar = document.getElementById('leftbar');
		if (leftbar) {
			var newHeight = bottomPos - findPosY(leftbar);
			if (newHeight > leftbar.clientHeight) leftbar.style.height = newHeight+'px';
		}
		var rightbar = document.getElementById('rightbar');
		if (rightbar) {
			var newHeight = bottomPos - findPosY(rightbar);
			if (newHeight > rightbar.clientHeight) rightbar.style.height = newHeight+'px';
		}
	} catch (e) {}
}
function findPosY(obj) {
	try {
		var curtop = 0;
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y) {
			curtop += obj.y;
		}
	}
	catch (e) { }
	return curtop;
}
function Float(id, sy, minY, startMoveAt, stopMoveAt, bumper) {
        var objFloat = document.getElementById(id);
        var refObj = document.getElementById(bumper);

        var agt=navigator.userAgent.toLowerCase();
        if (agt.indexOf("msie 6.") != -1) isIE6 = true;
        else isIE6 = false;

        objFloat.cy = objFloat.sy = sy;

        window[id + "_obj"] = objFloat;

        objFloat.doFloat=function() {
                var currentScrollTop = getScroll().top;
                var containingElementTop = getY(refObj);
                var containingElementHeight = refObj.offsetHeight;
                var floatElementHeight = this.offsetHeight;
                var bodyHeight = document.body.clientWidth;
                var fullHeight = document.body.offsetHeight;
                this.newLocation = 0;
                if (currentScrollTop >= startMoveAt && (fullHeight - currentScrollTop) > stopMoveAt) {
                        if (isIE6) {
                                this.style.position = "absolute";
                                this.style.top = currentScrollTop;
                        } else {
                                this.style.position = "fixed";
                                this.style.top = "0px";
                        }
                } else if ((fullHeight - currentScrollTop) <= stopMoveAt) {
                        this.style.position = "absolute";
                        this.style.top = (fullHeight - stopMoveAt-180) + "px";
                } else {
                        this.style.position = "absolute";
                        this.style.top = minY + "px";
                }
        setTimeout(this.id + "_obj.doFloat()", 250);
        }
        objFloat.doFloat();

        return objFloat;
}
getScroll = function () {
  var top = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  var left = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
  return { 
    top: top, 
    left: left, 
    offset:{ x: left, y: top }  //  note the change, NOT an Array with added properties. 
  };  //  object
} 
function getY(oElement) {
        var iReturnValue = 0;
        while( oElement != null ) {
                iReturnValue += oElement.offsetTop;
                oElement = oElement.offsetParent;
        }
        return iReturnValue;
}
getBorderBox = function (node) {
  return { width: node.offsetWidth, height: node.offsetHeight };  //  object
}
/*
function togglePassword() {
	if (document.getElementById('CheckReturning').checked) {
		document.getElementById('PasswordDiv').style.display = '';
		document.getElementById('Password').disabled = false;
	} else {
		document.getElementById('PasswordDiv').style.display = 'none';
		document.getElementById('Password').disabled = true;
	}
}
*/
spotlightId = 0;
spotlightTags = Array();
function startSpotlight(json) {
	var list = eval(json);
	for (i = 0; i < list.length; i++) {
		image = new Image();
		image.src=list[i]['Image'];
		image.alt=list[i]['Name'];
		image.border=0;
		spotlightTags[i] = document.createElement('a');
		spotlightTags[i].setAttribute('href', list[i]['URL']);
		spotlightTags[i].setAttribute('title', list[i]['Name']);
		spotlightTags[i].appendChild(image);
	}
	spotlight();
}
function spotlight() {
	if (!document.getElementById('spotlightImage')) document.write('<div id="spotlightImage"></div>');
	div = document.getElementById('spotlightImage');
	if (!spotlightTags[spotlightId]) spotlightId = 0;
	try {id=spotlightId-1;if (id < 0) id = spotlightTags.length-1;div.removeChild(spotlightTags[id]);}catch(e){}
	div.innerHTML = '';
	div.appendChild(spotlightTags[spotlightId++]);
	setTimeout("spotlight()",7000);
}
function findValue(li) {
	if( li == null ) return false;
	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];
	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;
	return sValue;
}
function selectItem(li) {
	v = findValue(li);
	if (v != false) {
		top.location.href = '/atbs/json/redirecthid.php?q='+v;
	}
}
/* JavaScript for Footer: Hover Over Images
Giancarlo Colfer - Tuesday, June 16, 2009 */
function mouseOver_ssl() {
    document.getElementById("ssl").src = "/content/images/godaddy-SSL-mini.png"
}
function mouseOver_bbb() {
    document.getElementById("bbb").src = "/content/images/bbb-better-business-bureau.png"
}
function mouseOver_fcr() {
    document.getElementById("fcr").src = "/content/images/weekly-best-fairfield-county-readers-poll-2005-2008.jpg"
}
function mouseOver_bcw() {
    document.getElementById("bcw").src = "/content/images/the-business-council-of-westchester.jpg"
}
function mouseOver_gc() {
    document.getElementById("gc").src = "/content/images/greenwich-chamber.jpg"
}
function mouseOver_mbn() {
    document.getElementById("mbn").src = "/content/images/metropolitan-business-network.jpg"
}
function mouseOver_natb() {
    document.getElementById("natb").src = "/content/images/national-association-of-ticket-brokers.png"
}

function mouseOut_ssl() {
    document.getElementById("ssl").src = "/content/images/bw-godaddy-SSL-mini.gif"
}
function mouseOut_bbb() {
    document.getElementById("bbb").src = "/content/images/bw-bbb-better-business-bureau.gif"
}
function mouseOut_fcr() {
    document.getElementById("fcr").src = "/content/images/weekly-best-fairfield-county-readers-poll-2005-2008.jpg"
}
function mouseOut_bcw() {
    document.getElementById("bcw").src = "/content/images/bw-the-business-council-of-westchester.jpg"
}
function mouseOut_gc() {
    document.getElementById("gc").src = "/content/images/bw-greenwich-chamber.jpg"
}
function mouseOut_mbn() {
    document.getElementById("mbn").src = "/content/images/bw-metropolitan-business-network.jpg"
}
function mouseOut_natb() {
    document.getElementById("natb").src = "/content/images/bw-national-association-of-ticket-brokers.jpg"
} 
/* Better Tool Tip */ 
$(document).ready(function(){
	$('.tTip').betterTooltip({speed: 150, delay: 300});
}); 
/* Hide / Show */ 
function change(id){
     ID = document.getElementById(id);
    
     if(ID.style.display == "")
          ID.style.display = "none";
     else
          ID.style.display = "";
      }; 
	  
//var CORE = CORE||{};
if (typeof CORE == 'undefined') {
  CORE = {};
}	  
/*******************************************************************************
 * Install Firefox custom search plugin.
 *
 * @link http://mycroft.mozdev.org/deepdocs/installing.html
 * @param string name
 * @param string ext
 * @param string cat
 * @param string type
 */
CORE.addEngine = function(name, ext, cat, type) {
  if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addSearchEngine == 'function')) {
    window.sidebar.addSearchEngine(
      'http://allshows.com/content/downloads/plugins/mozilla-search/' + name + '.src',
      'http://allshows.com/content/downloads/plugins/mozilla-search/' + name + '.' + ext,
      name,
      cat );
  } else {
      alert('Netscape 6 or Mozilla is needed to install the search plugin');
  }
};

/* 
* Hot Searches Hack by Giancarlo Colfer http://giancarlocolfer.com/ 
* 
*/ 
$(function () {
        // basic version is: $('div.searches marquee').marquee() 
        
        $('div.search-trending marquee').marquee('pointer').mouseover(function () {
            $(this).trigger('stop');
        }).mouseout(function () {
            $(this).trigger('start');
        }).mousemove(function (event) {
            if ($(this).data('drag') == true) {
                this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
            }
        }).mousedown(function (event) {
            $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
        }).mouseup(function () {
            $(this).data('drag', false);
        });
    });
