﻿function searchDate(cityFolder){
	var eventDay = document.getElementById('eventDay');
	var eventMonYear = document.getElementById('eventMonYear');
	var sDate = eventMonYear[eventMonYear.selectedIndex].value + '-' + eventDay[eventDay.selectedIndex].value;
	var myDate = new Date(sDate.replace(/-/g,"/"));
	var today = new Date();
	var folder = "theaters";
	if (cityFolder) folder = cityFolder;
	if (today > myDate){
		alert("You must choose a later date");
	} else {
		document.location.href = 'http://www.newyorkcitytheatre.com/'+folder+'/events_calendar2.php?year='+myDate.getUTCFullYear()+'&month='+(myDate.getMonth()+1)+'&day='+myDate.getDate();
	};
}	
function ajaxInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  }
}


    function goTo(x) {
        if (x != "" && x.indexOf("==") == -1 && x.indexOf("hoose") == -1) {
            var sBase = "http://www.newyorkcitytheatre.com";
            document.location = sBase + x;
            return;
        }
    }

    
    function open21() { 
       sLoc = "http://www.21club.com/web/onyc/onyc_c5a1_offers.jsp?c=websites&p=nyctheatres&cr=21_banner";
       window.open(sLoc,'_blank'); 
    } 
    
    function startTable(sHid,sQS) { 
       sLoc = "http://www.21club.com/web/onyc/table_request_restaurant.jsp?theatre=yes&c=websites&p=nyctheatres&cr=21_dining_res";
       window.open(sLoc,'_blank'); 
    } 
    
	function popupMenu() {
 
window.open('samplemenu.html','popup','height=575,width=385,left=50,top=50,scroll bars,resizable=no,status');
}

	function changeDate(strYearMonth,strEventID, strDisplayNames){
		var queryString = "";
		var arrayYearMonth = strYearMonth.split("-");
		var baseURL = document.location.href;
		baseURL = baseURL.substr(0,baseURL.lastIndexOf('/')+1);
		if (strEventID) { queryString += "&eventID=" + strEventID; }
		if (strDisplayNames) { queryString += "&displayNames=" + strDisplayNames; }
		document.location = baseURL + "tickets.php?year=" + arrayYearMonth[0] + "&month=" + arrayYearMonth[1] + queryString; 
	}


function selectDrops() {
        var sLoc = "" + document.location;
        sPage = sLoc.substring(sLoc.lastIndexOf("/")+1,sLoc.length);
        var sRE = /.html/gi;
        sPage = sPage.replace(sRE,"");
        sRE = /.htm/gi;
        sPage = sPage.replace(sRE,"");
        var bEnd = false;
        var i = 0;
        var iSet = 0;
        if (sPage.indexOf("_") > -1) {
            sPage = sPage.substring(0,sPage.indexOf("_"));
        }
        do {
            if (document.drops.theater[i]) {
                var sTheater = document.drops.theater[i].value;
                if (sTheater.indexOf(sPage) > -1) {
                    iSet = i;
                    bEnd;
                }
            } else {
                bEnd = true;
            }
            i++;
        } while (!bEnd);
        document.drops.theater.selectedIndex = iSet;
        var bEnd = false;
        var i = 0;
        var iSet = 0;
        do {
            if (document.drops.show[i]) {
                var sTheater = document.drops.show[i].value;
                if (sTheater.indexOf(sPage) > -1) {
                    iSet = i;
                    bEnd;
                }
            } else {
                bEnd = true;
            }
            i++;
        } while (!bEnd);
        document.drops.show.selectedIndex = iSet;
        return;
    }