<!--
// opens a prompt to bookmark the page
function bookmarkSite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}

// Launches a standard browser with full feature flags set
function launchNewBrowser(sURL, sTitle)
{
	myRemote = open(sURL, sTitle, "channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=1,resizable=yes,scrollbars=1,status=1,toolbar=1");
	if ( myRemote != null )
	{
		myRemote.focus();
	}
}

function launchPrinterFriendly(sURL)
{
	open(sURL, '', "width=650,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=1,resizable=yes,scrollbars=1,status=1,toolbar=1");
	
}

function launch(newURL, newName, newFeatures, orgName) {
	var remote = open(newURL, newName, newFeatures);
		if (remote.opener == null)
			remote.opener = window;
			remote.opener.name = orgName;
		return remote;
	}

function launchRemote(sURL, sTitle, height, width, sBAR) {
	var w = width;
	var h = height;
	var y = (screen.height-height)/2;
	var x = (screen.width-width)/2;

		switch(sBAR) {
		case "TRUE":
			myRemote = launch(sURL, sTitle, "left="+x+",top="+y+",height="+h+",width="+w+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=no,scrollbars=1,status=0,toolbar=0", "myWindow");
			break;
		case "Yahoo":
			myRemote = launch(sURL, sTitle, "left="+x+",top="+y+",height="+h+",width="+w+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=yes,scrollbars=1,status=0,toolbar=0", "myWindow");
			break;
		default :
		    myRemote = launch(sURL, sTitle, "left="+x+",top="+y+",height="+h+",width="+w+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=no,scrollbars=0,status=0,toolbar=0", "myWindow");
		}
		myRemote.focus();
	}
//javascript for popup chart "live help" link
function popNav1(url,name, features) {
	var popBox = open(url,name,features);
	if(typeof(popBox)!='underfined'&&!popBox.closed)
		{
		 popBox.focus();
		}
	else
	{
	 url = url + '&ref=' + escape(self.location);
	 popBox = window.offscreenBuffering(url,name,features);
	}
}

function clickButton(e, buttonid){ 
		
      var bt = document.getElementById(buttonid); 
      if (typeof bt == 'object'){ 
            if(navigator.appName.indexOf("Netscape")>(-1)){ 
                  if (e.keyCode == 13){ 
						e.returnValue = false;
						e.cancel = true;
                        bt.click(); 
                        return false; 
                  } 
            } 
            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
                  if (event.keyCode == 13){ 
						event.returnValue = false;
						event.cancel = true;
                        bt.click(); 
                        return false; 
                  } 
            } 
      }
} 

// purchase process, check if called from TBO in subfolder or root.
function getTicketBoxOfficeRelPath()
{
	try
	{
		if (window.location.pathname.indexOf("purchase/movietickets") >= 0)
		{
			return "../../../TicketBoxOffice.aspx";
		}
		else
		{
			return "TicketBoxOffice.aspx";
		}
	} catch (e)
	{
		return "TicketBoxOffice.aspx";
	}
}

// purchase page js
function refreshDate(ele, tmsId, movieId)
   {
   var tboDocPath = getTicketBoxOfficeRelPath();
   
      var coll = ele;
      var selectDate = coll.options[coll.selectedIndex].value;
      if (selectDate == "empty")
		return;
	
	// Add the offerchecked value to querystring only if OfferCheck box exist in the Ticketboxoffice form.	
    if (document.frmTicketQty.OfferCheck)
		{
			document.location.href = tboDocPath + "?tid=" + tmsId + "&mid=" + movieId + "&refreshdate=" + selectDate + "&offerChecked=" + document.frmTicketQty.OfferCheck.checked;
		}
	else
		{
			document.location.href = tboDocPath + "?tid=" + tmsId + "&mid=" + movieId + "&refreshdate=" + selectDate;
		}
   }
   
function refreshShowTime(ele, tmsId, movieId)
{
   var tboDocPath = getTicketBoxOfficeRelPath();

	var coll = ele;
    var perfID = coll.options[coll.selectedIndex].value;
    if (perfID == "empty")
		return;	
    
	// Add the offerchecked value to querystring only if OfferCheck box exist in the Ticketboxoffice form.	
    if (document.frmTicketQty.OfferCheck)
		{
			document.location.href= tboDocPath + "?tid=" + tmsId + "&mid=" + movieId + "&row_count=" + perfID + "&offerChecked=" + document.frmTicketQty.OfferCheck.checked;
		}
	// Add the offerchecked value to querystring only if value(offerChecked=true) exist in the location.href.	
	else if (document.location.href.toString().indexOf("offerChecked=true") > 0)
		{
			document.location.href= tboDocPath + "?tid=" + tmsId + "&mid=" + movieId + "&row_count=" + perfID + "&offerChecked=true"; 
		}
	else   
	    {
			document.location.href= tboDocPath + "?tid=" + tmsId + "&mid=" + movieId + "&row_count=" + perfID;
		}
}  

//hide from older browsers.

var seating_limitations = "none";

function checkValue (ele) {
	// make sure the user entered a correct value before moving on
		
	if (isNaN(ele.value))  {
		alert('You must enter a numeric value between 0 and 99');
		ele.value = 0;
		ele.focus();
	} else if (ele.value==''||ele.value<0||ele.value%1>0||ele.value==' '||ele.value=='  ') {
			alert('You must enter a numeric value between 0 and 99');
			ele.value=0;
			ele.focus();
	} else {
		activecheck (ele, "true");
	}
}

function checkValueWithMinMax (ele, min, max) {
	// make sure the user entered a correct value before moving on
		
	if (isNaN(ele.value))  {
		alert('You must enter a numeric value between '+min+' and '+max);
		ele.value = 0;
		ele.focus();
	} else if (ele.value==''||ele.value<0||ele.value%1>0||ele.value==' '||ele.value=='  ') {
			alert('You must enter a numeric value between '+min+' and '+max);
			ele.value=0;
			ele.focus();
	} else {
		activecheck (ele, "true");
	}
}	

function activecheck (ele, checkedValue) {
	oPrice = document.frmTicketQty.price;

	// First, check to see if we need to reset the flag
	
	var tickets_selected = false;
	
	// loop over all quantity elements, track the ones in this section.
	// if all = 0, reset seating limitations, reenable all controls
	for (i=0; i<oPrice.length-1; i++){				
		if (document.frmTicketQty.quantity[i].id == seating_limitations && document.frmTicketQty.quantity[i].value != 0) {
			tickets_selected = true;
		}
	}
	if (tickets_selected == false) {
		// user has erased all types, need to turn off the bit
		seating_limitations = "none";
	}

	
	
	if (ele.id != seating_limitations && seating_limitations != "none") {
		// user picked one type, and is now trying to pick another. Stop em.
		if (checkedValue != "true") {
			alert('You cannot purchase Reserved Seating tickets and General Admission tickets in the same order.');
		}
		ele.value = 0;
		ele.blur();
	
	} else if (seating_limitations == "none") {
		// user picking for the first time. Record the type
		seating_limitations = ele.id;
	} else if (ele.id == seating_limitations) {
		
		
	}

}	

	
function tixtotal(ele){

		var qty=0,ttlqty=0,fee,ttlprice=0,ttlfee=0;
		var oQty;
		var oPrice;
		var fee= document.frmTicketQty.fee;
		var surcharge = document.frmTicketQty.surcharge;
		var resvFee = document.frmTicketQty.resvFee;
		var i;
		var tqty;
		var count;
		var tolfee;
		var ttlResvFee
	
		oPrice = document.frmTicketQty.price;
		
		if (ele.value < 0) {
			ele.value = 0;
		}

		for (i=0; i<oPrice.length-1; i++){
			qty = parseInt(document.frmTicketQty.quantity[i].value, 10);
			if (isNaN(qty)) {
				// no value entered, assume 0
				qty = 0;
			} 
			price = qty * parseFloat(document.frmTicketQty.price[i].value);
			ttlqty = ttlqty + qty;
			ttlprice = ttlprice + price;

			
			document.frmTicketQty.inputSubtotal[i].value = formatCurrency(price);
			
		
		}
		
		if (document.frmTicketQty.inputSubtotalAll)
		{
			document.frmTicketQty.inputSubtotalAll.value = formatCurrency(ttlprice);
		}
		
			tolfee =parseFloat(fee.value) + parseFloat(surcharge.value);
			ttlfee= ttlqty * tolfee;
			ttlResvFee = ttlqty * (parseFloat(resvFee.value))
			ttlprice = ttlprice + ttlfee + ttlResvFee;

			
				document.frmTicketQty.inputTotal.value = formatCurrency(ttlprice);
				if (document.frmTicketQty.inputFeeQty!=null) {
					document.frmTicketQty.inputFeeQty.value = ttlqty;
					document.frmTicketQty.inputFeetotal.value = formatCurrency(ttlfee);
					if(document.frmTicketQty.inputResvFeeQty != null){
						document.frmTicketQty.inputResvFeeQty.value = ttlqty;
						document.frmTicketQty.inputResvFeetotal.value = formatCurrency(ttlResvFee);
					}
				}
			
		}


	function formatCurrency(num) {
		num = num.toString().replace(/\$|\,/g,'');
		if (isNaN(num)) num = "0";
		cents = Math.floor((num*100+0.5)%100);
		num = Math.floor((num*100+0.5)/100).toString();
		if (cents < 10) cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
		return ('$' + num + '.' + cents);
	}


	function UpdateDivContent(divid, newcontent) {

		//newcontent = '<span class="blk11">' + newcontent + '</span>'
		//if (document.all){ //ie4+
		  //document.all[divid].innerHTML=newcontent;
		  //}

		if (document.layers){ //ns4+
		  with (document.layers[divid].document) {
		    write(newcontent);
		    close();
				}
			}

	}

function adjustTixSel(maxTix, ticketTypes) {
	if (ticketTypes <= 0)
	{
		return;
	}

	var max, selNum, totalIndex,newMax,curVal,obj;
	var oPrices
	oPrices = document.frmTicketQty.price;
	max = maxTix
	selNum = oPrices.length - 2;

	// don't adjust anything if there are no tickets
	if ( ticketTypes < 0 )
		return;
		
	for (i=0; i <=selNum; i++) {
		//get new max val.
		obj = document.frmTicketQty.quantity[i];
		totalIndex = 0;
		for (k=0; k <= selNum; k++) { if (k !=i) { totalIndex = totalIndex + document.frmTicketQty.quantity[k].selectedIndex; }}
		newMax = max -totalIndex;
		newMax = obj.selectedIndex  > newMax ? obj.selectedIndex : newMax;
		curVal = obj.selectedIndex;

		if (obj.length -1 != newMax) {
			obj.length = 0;
			for (k=0; k<=newMax; k++) {
				obj.options[k] = new Option(k+ " ",k,0);
				if (k == curVal) { obj.selectedIndex = k; }
			} //end of for of k.
		}  //end of if.
	} // end of for of i.


		var ttlqty =0, ttlfee = 0, ttlResvFee = 0, ttlprice =0, oPrice;
		var fee= document.frmTicketQty.fee;
		var surcharge = document.frmTicketQty.surcharge;
		var resvFee = document.frmTicketQty.resvFee;

		oPrice = document.frmTicketQty.price;

		for (i=0; i<oPrice.length-1; i++){
			qty = parseInt(document.frmTicketQty.quantity[i].selectedIndex, 10);
			price = qty * parseFloat(document.frmTicketQty.price[i].value);
			ttlqty = ttlqty + qty;
			ttlprice = ttlprice + price;

			
				document.frmTicketQty.inputSubtotal[i].value = formatCurrency(price);
				
			}
			
			if (document.frmTicketQty.inputSubtotalAll)
			{
				document.frmTicketQty.inputSubtotalAll.value = formatCurrency(ttlprice);
			}

			ttlfee = ttlqty * (parseFloat(fee.value)+parseFloat(surcharge.value));
			ttlResvFee = ttlqty * (parseFloat(resvFee.value))
			ttlprice = ttlprice + ttlfee + ttlResvFee;

			
				document.frmTicketQty.inputTotal.value = formatCurrency(ttlprice);

				if (document.frmTicketQty.inputFeeQty!=null) {
					document.frmTicketQty.inputFeeQty.value = ttlqty;
					document.frmTicketQty.inputFeetotal.value = formatCurrency(ttlfee);
					if(document.frmTicketQty.inputResvFeeQty != null){
						document.frmTicketQty.inputResvFeeQty.value = ttlqty;
						document.frmTicketQty.inputResvFeetotal.value = formatCurrency(ttlResvFee);
					}
				}
			
}	// end of function


function launchWin(sURL, sTitle, height, width)
{
	var w = width;
	var h = height;
	var y = (screen.height-height)/2;
	var x = 0;

	var w = 800, h = 600;

	w = screen.availWidth;
	h = screen.availHeight;
	
	var popW = width, popH = height;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;

	if (sTitle=='Help')
	{
		var remote = open(sURL,sTitle,'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=yes,scrollbars=1,status=0,toolbar=1");
	}
	else if (sTitle == 'FullWindow')
	{
		var remote = open(sURL,sTitle,'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=1,resizable=yes,scrollbars=1,status=1,toolbar=1");
	}
	else
	{
		var remote = open(sURL,sTitle,'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=no,scrollbars=1,status=0,toolbar=0");
	}
	
	if (remote.opener == null)
	{
		remote.opener = window;
		remote.opener.name = 'myWindow';
 	}
 	remote.focus();
}

function amenInfo(url) {		
	newWin = window.open(url,'AmenWin','width=350,height=250,scrollbars=no,resizable=no');
	newWin.focus();
}

var submitted = false;

function submit_me()
{
	if(submitted != true)
	{
		submitted = true;
		return true;
    }
	return false;
}


function checkFavoritesCount( obj )
{	
	var favCount = 0;
	var MAX_FAVORITES = "10";
	
	if ( obj )
	{
		if( obj.getAttribute('theaterInFavorites') == "1" )
		{
			// since this already exists in favorites just allow a removal
			return true;
		}
	
		favCount = obj.getAttribute('favoritesCount');
		if( favCount == MAX_FAVORITES )
		{
			var retVal = confirm("You have already chosen the maximum number of favorites. To remove one of your current favorites go to the Favorites Setup Page to edit your list. \n\nDo you want to go to your Favorites Setup Page?");
			if( retVal )
			{
				//window.location="favoritesSetup.aspx?from=" + obj.getAttribute('fromUrl');
				window.location="favoritesSetup.aspx?from=" + obj.getAttribute('pageName') + obj.getAttribute('qs');
				return false;
			}
			return false;
		}
	}
	return true;
}     
		
function popUp(url, winName, h, w, l, t)
{
	var args = 'height=' + h + ',width=' + w + ',left=' + l + ',top=' + t +
			   ',toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1';
	
	window.open(url, winName, args);
}

function popUp2(url, width, height, left, top) 
{
	var WLNewWin
	WLNewWin = window.open(url,'WLNewWin',"toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
}	

function SetTixTotals()
{
	var oQty;
	var i;
	oQty = document.frmTicketQty.quantity;
	
	if (oQty)
	{
		for (i=0; i<oQty.length; i++)
		{
			tixtotal(oQty[i]);
		}
	}
}

function DropDownNav(dropdown)	
{
    document.location.href = dropdown.options[dropdown.selectedIndex].value;
}

//
// Useful when using a text area, and the input length is limited to 'maxlimit' number of chars.
//
// The function will truncate the chars in excess of maxlimit contained within the 'field' (text area).
//
// Simply pass the name of the text area and counter text field as 'document.formName.fieldName', and
// specify to call the function in the text area onKeyDown, onKeyUp, and onChange events.
//
// Unfortunately, this doesn't work with Netscape 4.x.  It isn't responsive to the onKeyDown and onKeyUp
// events.  It does however, partially support the onChange event.
//
function characterCounter(field, countfieldid, maxlimit)
{
  if(field.value.length > maxlimit)
  {
    // if too long...trim it!
    field.value = field.value.substring(0, maxlimit);
  }
  else
  {
    if (countfieldid != null)
    {
      // otherwise, update 'characters left' counter
      countfield = document.getElementById(countfieldid);
      if (countfield != null)
      {
	countfield.innerHTML = maxlimit - field.value.length;
	//countfield.value = maxlimit - field.value.length;
      }
    }
  }
} // end characterCounter

// Track a link in WSS
function InformWSS(li, lp) {
    try {
        if (hbx != null && (typeof(_hbLink) == 'function' ) ) {
	        _hbLink(li, lp);
        }
		DoWSSPageView();
    }
    catch(e) {
    }
}
// Increment a page view in WSS
function DoWSSPageView() {
    try {
        if (hbx != null && (typeof(_hbPageView) == 'function' ) )
        {
	        _hbPageView(hbx.pn, hbx.mlc);
        }
    }
    catch(e) {
    }
}

//-->

// Allows any "Read More" link to expand the hidden text span.
$(function() {
    $("a#read_more").click(function() {
        $(this).remove();
        $("span.moretext").css("display","inline");
        return false;
    });
});
$(function() {
    $("a.read_more").click(function() {
        $(this).siblings("span.moretext").css("display","inline");
        $(this).remove();
        return false;
    });
});
// toggle reply textarea on blog page
$(document).ready(function(){
    $("a.toggleReply").unbind();
    $("a.toggleReply").click(function() {
        $(this).parent().siblings('div.comment-reply').toggle();
        return false;

    });
});



// MDC - homepage Burning Question animation
$(function(){
    $("#btn-answer").click(function(){
        $("#answer").animate({marginLeft:'0px'},'normal');
        return false;
    });
    $("#btn-question").click(function(){
        $("#answer").animate({marginLeft:'301px'},'normal');
        return false;
    });
});


// Purchase - Feeding America
$(document).ready(function() {    
    $("a#about-feeding-america-toggle").click(function() {
        $("#about-feeding-america").toggle(400);
        return false;
    });
});

function fbStreamPublish(txt, linkName, linkHref, linkDesc, imgSrc, addFirstName, callback) {
	if (linkName == '' || linkHref == '') { return false; }
	FB.getLoginStatus(function(response) {
		if (response.authResponse) {
			if (addFirstName) {
				FB.api('/me', function(response) {
					var heading = response.first_name + ' commented on ' + linkName;
					FB.ui ({method:'feed',message:txt,name:heading,link:linkHref,description:linkDesc,picture:imgSrc}, function(response){callback();});
				});
			} else {
				FB.ui ({method:'feed',message:txt,name:linkName,link:linkHref,description:linkDesc,picture:imgSrc}, function(response){callback();});
			}
		}
	});
}

function applyButton(e, buttonid){ 
		
      var bt = document.getElementById(buttonid); 
      if (typeof bt == 'object'){ 
      
      	 if ((e.keyCode == 13)&&(($('#FandangoClaimCodeTextBox').val()!="") || ($('#ExibitorGiftCardTextBox').val()!="") || ($('#ExibitorGiftCardPinTextBox').val()!="")))  { 
         		e.returnValue = false;
         		e.cancel = true;
         		__doPostBack(buttonid, '');
         		return false;
         }         
      }
} 
