// JavaScript Document
function dmxAnimate(context, cssBefore, cssTo, prefs) {//v1.8 
  jQuery.dmxAnimate.apply(this, arguments);
}
function dmxAdvLayerPopup(sTitle,sURL,sPopupName,sContent,sClass,nPositionLeft,nPositionRight,nWidth,nHeight,nAutoCloseTime,bDragable,bResizable,bOverlay,nOverlayOpacity,sIncomingEffect,sIncomingEffectEasing,nIncomingEffectDuration,bFadeIn,sOutgoingEffect,sOutgoingEffectEasing,nOutgoingEffectDuration,bFadeOut,sSlideEffect,nEffectTime,nSlideTime,bClosable,bWireframe,bgContentColor) { // v1.05
  var aURL, aSlides = sURL.split('|');
  if (aSlides && aSlides.length > 1) {
    aURL = [];
    for (var si=0;si<aSlides.length;si++) {
      var cf=aSlides[si],nW='',nH='',nS='';
      if (cf.substr(cf.length-1,1)==']') {
        var bd=cf.lastIndexOf('[');
        if(bd>0){
          var di=cf.substring(bd+1,cf.length-1);
          var da=di.split('x');
          nW=da[0];nH=da[1];
          if (da.length==3) nS=da[2];
          cf=cf.substring(0,bd)
        }   
      }      
      aURL[si] = new Object();
      aURL[si].src = cf;
      aURL[si].nWidth = (nW!=''?nW:nWidth);
      aURL[si].nHeight = (nH!=''?nH:nHeight);
      aURL[si].nDelay = (nS!=''?nS:nSlideTime);
    }  
  } else aURL = sURL;
  if (!cDMXPopupWindow) {
  	alert('The Advanced Layer Popup script is missing on your website!\nPlease upload the file ScriptLibrary/advLayerPopup.js to your live server.');
  } else {
    if (sClass == 'OS_Look') sClass = (navigator.userAgent.toLowerCase().indexOf('mac')!=-1?'dmxOSX':'dmxXP');  
    cDMXPopupWindow.buildWindow({sTitle: sTitle, sURL: aURL, sPopupName: sPopupName, sContent: sContent, sClass: sClass, aPosition: [nPositionLeft,nPositionRight], aSize: [nWidth,nHeight], nCloseDelay: nAutoCloseTime, bDragable: bDragable, bResizable: bResizable, bOverlay: bOverlay, nOverlayOpacity: nOverlayOpacity, sStartPosition: sIncomingEffect, sStartShowEffect: sIncomingEffectEasing, nIncomingEffectDuration: nIncomingEffectDuration, bFadeIn: bFadeIn, sEndPosition: sOutgoingEffect, sEndShowEffect: sOutgoingEffectEasing, nOutgoingEffectDuration: nOutgoingEffectDuration, bFadeOut: bFadeOut, sSlideEffect: sSlideEffect, nEffectTime: nEffectTime, nSlideTime: nSlideTime, bClosable: bClosable, bWireframe: bWireframe, sContentBgColor: bgContentColor });
  }  
  document.MM_returnValue = false;
}

var year = null;
var month = null;
var day = null;
var hour = null; 
var mins = null; 
var nextevent = null;
var nextgame = null;
var tz = -5;         
var lab = 'tzcd';    
var alertTimerId = null;

function startCount() 
{
	if (year == null)
		return;
	displayTZCountDown(setTZCountDown(month,day,hour,tz),lab);
}

function setTZCountDown(month,day,hour,tz)
{
  var toDate = new Date();
  if (month == '*')toDate.setMonth(toDate.getMonth() + 1);
  else if (month > 0)
  {
    if (month <= toDate.getMonth())
      toDate.setYear(toDate.getYear() + 1);
    toDate.setMonth(month-1);
  }
  if (day.substr(0,1) == '+')
  {
    var day1 = parseInt(day.substr(1));
    toDate.setDate(toDate.getDate()+day1);
  }
  else
  {
    toDate.setDate(day);
  }
  toDate.setYear(year);
  toDate.setHours(hour);
  toDate.setMinutes(mins); //toDate.setMinutes(0-(tz*60));
  toDate.setSeconds(0);
  var fromDate = new Date();
  fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());
  var diffDate = new Date(0);
  diffDate.setMilliseconds(toDate - fromDate);
  return Math.floor(diffDate.valueOf()/1000);
}
function displayTZCountDown(countdown,tzcd)
{
  if (countdown < 0)
  	$('tzcd').update();
  else 
  {  
    var secs = countdown % 60;
    if (secs < 10) secs = '0'+secs;
    var countdown1 = (countdown - secs) / 60;
    var mins = countdown1 % 60;
    if (mins < 10) mins = '0'+mins;
    countdown1 = (countdown1 - mins) / 60;
    var hours = countdown1 % 24;
    var days = (countdown1 - hours) / 24;
    var countdown_message = 'Next game in ' + days + " day" + (days == 1 ? '' : 's') + ' ' +hours+ ' hours ' +mins+ ' minutes and ' +secs+ ' seconds vs. ' ;
	$('tzcd').update(countdown_message);

    alertTimerId = setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',1000);
  }
}
function displayNextGame()
{
	if (nextevent == nextgame)
		$('nxgm').update(nextevent);
	else
	{
		var displaystring = nextgame + '(Next Event: '+ nextevent + ')';
		$('nxgm').update(displaystring);
	}
}

function getQueryValue(name) 
{
	var url = document.URL;
	i = url.indexOf(name += '=');
	j = url.indexOf('&', i);
	if(-1 == j) 
	{
		j = url.length;
	}
	if(-1 != i) 
	{
		return url.substring(i + name.length, j);
	}
}
function getaction ( ThisActionType )
{
	if (ThisActionType == '999')
	{
		alert ('This option is currently under development.');
	}
	else
	{
		document.adminform.actiontype.value = ThisActionType ;
		document.adminform.submit() ;
	}
}
function changeteam ( ThisActionType )
{
  document.adminform.actiontype.value = '100' ;
  document.adminform.t.value = ThisActionType;
  document.adminform.submit() ;
}
function getGEO ()
{
	var Street = document.adminform.address.value;
	var City = document.adminform.city.value;
	var State = document.adminform.pdState.value;
	var Zip = document.adminform.zip.value;
	var URL = "http://maps.google.com/maps/geo?q="+Street+",+"+City+"+,+"+State+" "+Zip+"&output=csv&oe=utf8&sensor=false&key=ABQIAAAAwGX_k-8hhMnIl9JP60lzMxTS-Xw2Ttbc5uUNWgC0WyT7coU8NRTkjXAmlToMk6DAZigE0lzKeQ2fGw";
	window.open(URL, "GEO Code", "location=0,status=0,scrollbars=0,width=300,height=50"); 
}
function ShowLatLong ()
{
	var Title = "Park Map to "+document.adminform.name.value;
	var LatLong = document.adminform.latlong.value;
	var URL = "http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q="+LatLong;
	window.open(URL, "Park Map", "location=0"); 
}


function flip(context, flags, backsrc, dur, easing, onend, onflip) {//v1.0
var $=jQuery,jc=$(context),f=flags,bs=$.trim(String(backsrc)),pf=parseFloat;if((
/\.(jpe?g|gif|pnga?)(\?.*)?$/i).test(bs))new Image().src=bs;jc.each(function(i,o
){var jo=$(o);if((f&32)&&jo.is(":animated"))return true;jo.stop(true,true);var c
={},r=/^[^\d\-\.\+]*/,x=pf(jo.css("scaleX").replace(r,"")),y=pf(jo.css("scaleY")
.replace(r,"")),a=180,bst;if(f&2){if(f&8)c.skewX=a*(y<1?0:1);c.scaleY=y*-1;}else
if(f&4){if(f&8)c.skewY=a*(x<1?0:1);c.scaleX=x*-1;}if(jo.is("img")){if(bs&&bs!=(o
.origsrc||jo.attr("src")))bst="img";}else try{bs=$(bs);if(bs.length>0){jo.width(
jo.width()).height(jo.height()).css({overflow:"auto"});bst="html";bs=bs.html();}
}catch(e){}if(bst){this.backsrc=bs;this.origsrc=!!this.origsrc?this.origsrc:bst
=="img"?jo.attr("src"):jo.html();this.front=!!this.front;}var sw=0;jo.animate(c,
{duration:(dur||.8)*1000,easing:easing,complete:onend,step:function(n,z){var el=
z.elem;if(z.prop=="scaleX"||z.prop=="scaleY"){if(z.state==1||z.state==0)sw=0;else
if(!sw){if(z.start>0&&z.end<0&&z.now<0){o.front=0;sw=1;if(f&16)jo.css("matrix",f&
4?[-1,0,0,1,0,0]:[1,0,0,-1,0,0]);if($.isFunction(onflip))onflip.call(o,"toback");
}if(z.start<0&&z.end>0&&z.now>0){o.front=1;sw=true;if(f&16)jo.css("matrix",[1,0,0
,1,0,0]);if($.isFunction(onflip))onflip.call(o,"tofront");}if(bst&&sw){if(bst==
"img")o.src=o.front?o.origsrc:o.backsrc;else jo.html(o.front?o.origsrc:o.backsrc);
}}}}});});}

