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 fieldClear(obj, color) {
	if(obj.Val) {
		if (obj.value == '') { 
			obj.style.color = color;
			obj.value = obj.Val;
			obj.Val = null;
			obj.first = null;
		} else {
			obj.Val = null;
		}
	} else if (!obj.first) {
		obj.style.color = '#000';
		obj.Val = obj.value;
		obj.value = ''; 
		obj.first = 'true';
	} 
}

function emailPage(uid) {
	window.open("/Email-Page?UID="+uid,"pop","width=300,height=250,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 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 Pager(containingDiv, itemsPerPage, pagerName, pageNavElement) {
	this.containingDiv = containingDiv;
	this.itemsPerPage = itemsPerPage;
	this.pagerName = pagerName;
	this.pageNavElement = pageNavElement;
	this.currentPage = 1;
	this.pages = 0;
	this.inited = false;
	childNodes = document.getElementById(containingDiv).childNodes;
	var goodNodes = [];
	var k = 0;
	for (i = 0; i < childNodes.length; i++) {
		if (childNodes[i].nodeType == 1) {
			goodNodes[k++] = childNodes[i];
			childNodes[i].style.display = 'none';
		}
	}
	this.children = goodNodes;

	this.showRecords = function(from, to) {
		for (var i = from; i <= to && i < this.children.length; i++) this.children[i].style.display = '';
	}
	this.hideRecords = function(from, to) {
		for (var i = from; i <= to && i < this.children.length; i++) this.children[i].style.display = 'none';
	}
	this.showPage = function(pageNumber) {
		if (!this.inited) {
			alert('not inited');
			return;
		}
		var oldfrom = (this.currentPage - 1) * itemsPerPage;
		var oldto = oldfrom + itemsPerPage - 1;
		this.hideRecords(oldfrom, oldto);
		this.currentPage = pageNumber;
		var from = (pageNumber - 1) * itemsPerPage;
		var to = from + itemsPerPage - 1;
		this.showRecords(from, to);
		this.showPageNav();
	}
	
	this.prev = function() {
		if (this.currentPage > 1) this.showPage(this.currentPage - 1);
	}
	this.next = function() {
		if (this.currentPage < this.pages) this.showPage(this.currentPage + 1);
	}
	this.init = function() {
		var records = (this.children.length - 1);
		this.pages = Math.ceil(records / itemsPerPage);
		if (this.pages == 0) this.pages = 1;
		this.inited = true;
	}
	this.showPageNav = function() {
		if (!this.inited) {
			alert('not inited');
			return;
		}
		var element = document.getElementById(pageNavElement);
		var pagerHtml = '<div style="float:right"><div style="float:left;"><a href="javascript:' + this.pagerName + '.prev();"><img src="/content/template_images/prev.gif" alt="Previous" /></a></div>';
		pagerHtml += '<div style="float:left;margin-left: 5px;margin-top:5px"> Pg. '+this.currentPage+" of "+this.pages +  ' </div>';
        pagerHtml += '&nbsp;<a href="javascript:'+this.pagerName+'.next();"><img src="/content/template_images/next.gif" alt="" /></a></div></div>';
        element.innerHTML = pagerHtml;
	}
}
var first = false;
function flashText() {
	ft = document.getElementById('flashText');
	if (first) ft.innerHTML = 'No Service Fees';
	else ft.innerHTML = 'Free 2-day shipping';
	first = !first;
	setTimeout('flashText()',3000);
}
