var http = createHttpObj();
var CALENDAR_AJAXIN = false;
var TIMO_CALENDAR_AJAXIN;

function switchCalendarMonth(month,year)
{
	if (! CALENDAR_AJAXIN) //guard mozilla from buggin' out when a user is clickin' 1000x per second
	{
		CALENDAR_AJAXIN = true;
		try
		{
			http.open('GET', 'calendar.php?AJAXED=true&month='+month+'&year='+year, true);
			http.onreadystatechange = handleHttpResponse_switchCalendarMonth;
			http.send(null);
		}
		catch (e)
		{
			TIMO_CALENDAR_AJAXIN = setTimeout('switchCalendarMonth('+month+','+year+')',500);
		}
	}
}

function handleHttpResponse_switchCalendarMonth()
{
	if (http.readyState == 4)
	{
		docObj('calendar').innerHTML = http.responseText;
		CALENDAR_AJAXIN = false;
	}
}

function openPlayaInNewWin()
{
	var left = parseInt((screen.availWidth/2)-160);
	var top  = parseInt((screen.availHeight/2)-200);
	var winProps = 'status=0,menubar=0,toolbar=0,resizeable=0,scrollbars=0,height=400,width=320,left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var win = window.open('external_player.php', 'SermonPlayer', winProps);
	win.focus();
}

function docObj(id)
{
    return document.getElementById(id);
}

function createHttpObj()
{
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
  {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}


function InitIE6_PngFix()
{
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);

    if ( (version >= 5.5 && version < 7) && document.body.filters)
    {
       for(var i=0; i<document.images.length; i++)
       {
          var img = document.images[i]
          var imgName = img.src.toUpperCase()
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
          {
             var imgID = (img.id) ? "id='" + img.id + "' " : ""
             var imgClass = (img.className) ? "class='" + img.className + "' " : ""
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
             var imgStyle = "display:inline-block;" + img.style.cssText 
             if (img.align == "left") imgStyle = "float:left;" + imgStyle
             if (img.align == "right") imgStyle = "float:right;" + imgStyle
             if (img.parentElement.href) imgStyle = "cursor:pointer;" + imgStyle
             var strNewHTML = "<span " + imgID + imgClass + imgTitle
             + " style=\"" + "width:" + img.width + "px;  height:" + img.height + "px;" + imgStyle + ";"
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
             + "(src=\'" + img.src + "\', sizingMethod='image');\"></span>" 
             img.outerHTML = strNewHTML;
             i = i-1;
          }
       }
    }
}
