function extractExt(what) {
    if (what.indexOf('/') > -1)
        answer = what.substring(what.lastIndexOf('/')+1,what.length);
    else
        answer = what.substring(what.lastIndexOf('\\')+1,what.length);
    return answer;
}

function getInternetExplorerVersion()
{
  var rv = -1; // Return value assumes failure--other version
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

var msie = getInternetExplorerVersion();
 
if((msie <= 6) && (msie > 0))	
	  window.attachEvent("onload", correctPNG);

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (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:hand;" + 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='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}

formatContact = function(inDatum){
	var returnString;

	if(inDatum == "")
		returnString = inDatum;
	else
		returnString = "<b>" + inDatum + "</b><br><img src='images/email.png' style=\"vertical-align: bottom; cursor:pointer\" onclick=\"openEmailDlg('" + inDatum + "');\" />";
	
	return returnString;
}

formatLocation = function(inDatum){
	var returnString;

	if(inDatum == "TBD" || inDatum == "")
		returnString = inDatum;
	else
		returnString = "<div style='float:left'>" + inDatum + "</div>" + 
		"<img src='images/map.png' style='float:right; cursor:pointer' onclick='getMap(\"" + inDatum + "\");'>";
	
	return returnString;
}

formatDateTime = function(inDatum){
	
	if(inDatum == null || inDatum == "")
		return "";
	else{
		var dtReturn = php2JSDateTime(inDatum);
		if(dtReturn.substring(0, 8) == "0/0/0000")
			return "";
		else{
			var dateTimeArray = dtReturn.split(" ");
			dateTimeArray[0] = "<b>" + dateTimeArray[0] + "</b><br>";
			return dateTimeArray[0] + dateTimeArray[1] + " " + dateTimeArray[2];
			
			
		}
//			return dtReturn;
	}
} 

function GetXmlHttpObject()
{
	var XMLHttp=null;
	if(window.XMLHttpRequest)
  	{
  		XMLHttp=new XMLHttpRequest();
  	}
	else if (window.ActiveXObject)
  	{
  		XMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	return XMLHttp;
}

function php2JSDateTime(arrayIn){
	/*
	 * convert 2009-11-21 06:00:00 to 11/19/2009 6:00 PM 
	 */	
		var dateTimeArray = arrayIn.split(" ");
		var dateArray = dateTimeArray[0];
		var timeArray = dateTimeArray[1];
		
		dateArray = dateArray.split("-");
		dateArray = dateArray[1]+"/"+dateArray[2]+"/"+dateArray[0];
		
		timeArray = timeArray.split(":");
		if(timeArray[0] > 12){
			timeArray[2] = "PM"
			timeArray[0] = parseInt(timeArray[0]) - 12;
		}
		else
			timeArray[2] = "AM";
		
		timeArray = timeArray[0]+":"+timeArray[1]+" "+timeArray[2];

		//eliminate 0 prefixes--start at the end
		if(dateArray.charAt(3) == "0")
			dateArray = dateArray.substr(0, 3) + dateArray.substr(4);
		if(dateArray.charAt(0) == "0")
			dateArray = dateArray.substr(1);
		if(timeArray.charAt(0) == "0")
			timeArray = timeArray.substr(1);
		
		return dateArray + " " + timeArray;	
	}

function php2JSDate(dateTimeString){
//takes php date time and returns js date only	
	var dateTimeArray = dateTimeString.split(" ");
	
	var dateArray = dateTimeArray[0].split("-");
	
	return dateArray[1] + "/" + dateArray[2] + "/" + dateArray[0];  	
}


function isEven(num) {
	  return !(num % 2);
}
