WSTOA_Map = {
  ResizeDuration : 1,
  Version: '0.0.beta0',
  WebService: 'ws.php?'+new Date(),
  WSMethod: 'GetTeams',
  LoadingImage: 'images/loading.gif',
  ContainerDiv: 'mapDetail',
  beginHeight: 125,
  beginWidth : 125,
  endWidth: '',
  endHeight: '',
  curText :'',
  init : function ()
  {
  
  },
  
  loadRegion: function(regionNum)
  {
	  activate("ViewWindow");
	  oDiv = $(this.ContainerDiv);
	  oDiv.innerHTML = '<img src="' + this.LoadingImage + '" alt="loading">';
	  params = "METHOD=" + this.WSMethod + "&RegionId=" + regionNum;
	  new Ajax.Request(this.WebService, {
			 onSuccess : this.on_RegionLoadCallBack,
			 parameters : params,
			 method: 'get'
			});
  },
  
  on_RegionLoad : function(res)
  {
  	this.curText = res.responseText;
//  	$(this.ContainerDiv).innerHTML = "<button onclick='WSTOA_Map.close(\"\")'>Close Popup</button><br />" + res.responseText + "<br /><button onclick='WSTOA_Map.close(\"\")'>Close Popup</button>";
//	this.endWidth =  window.f_width() - 100;
//	this.endHeight =  this.windowSize("height")- 300;
	if ( document.all )
	{
	if ( this.endHeight == "")
		this.endHeight =  this.windowSize("height")* .90;
	} else {
	this.endHeight =  this.windowSize("height")- 300;
	}
	this.endWidth = 400;
	
//	alert(window.f_height());
	$(this.ContainerDiv).style.height = this.beginHeight;
	$(this.ContainerDiv).style.width = this.beginWidth;
	
	yScale = ( this.endHeight / this.beginHeight) * 100;
    xScale = ( this.endWidth / this.beginWidth) * 100;

  	hDiff = (this.beginHeight - this.endHeight );
  	wDiff = (this.beginWidth - this.endWidth);
  	
  //	new Effect.ReSize($(this.ContainerDiv), {delay:0, direction:'vert', toSize:this.endHeight, originalSize:this.beginHeight, duration: this.ResizeDuration, queue: 'front'});
//  	new Effect.ReSize($(this.ContainerDiv), {direction:'horiz', toSize:this.endWidth,originalSize:this.beginWidth, afterFinish: this.onFinishTimeToSetCallBack, delay: this.ResizeDuration, duration: this.ResizeDuration});
  	
  	if(!( hDiff == 0)){ new Effect.Scale(this.ContainerDiv, yScale, {scaleX: false, duration: this.ResizeDuration, queue: 'front', scaleContent:false}); }
	if(!( wDiff == 0)){ new Effect.Scale(this.ContainerDiv, xScale, {afterFinish: this.onFinishTimeToSetCallBack, scaleY: false, delay: this.ResizeDuration, duration: this.ResizeDuration, scaleContent:false}); }  

  },

onFinishTimeToSet :function(effect)
{
  	$(this.ContainerDiv).innerHTML = "<button onclick='WSTOA_Map.close(\"\")'>Close Popup</button><br />" + this.curText+ "<br /><button onclick='WSTOA_Map.close(\"\")'>Close Popup</button>";
	
},
onFinishTimeToSetCallBack:function (effect)
{
WSTOA_Map.onFinishTimeToSet(effect);
},

  
  on_RegionLoadCallBack : function(res)
  {
  	WSTOA_Map.on_RegionLoad(res);
  },
  
  close : function()
  {
  	$(this.ContainerDiv).innerHTML = this.curText;
  	yScale = ( this.beginHeight / this.endHeight) * 100;
    xScale = ( this.beginWidth / this.endWidth) * 100;

  	hDiff = (this.endHeight - this.beginHeight);
  	wDiff = (this.endWidth - this.beginWidth);
  	
//  	new Effect.ReSize($(this.ContainerDiv), {delay:0, direction:'vert', originalSize:this.endHeight, toSize:this.beginHeight, duration: this.ResizeDuration, queue: 'front'});
 // 	new Effect.ReSize($(this.ContainerDiv), {direction:'horiz', originalSize:this.endWidth, toSize:this.beginWidth,afterFinish: this.onFinishTimeToCloseCallBack, delay: this.ResizeDuration, duration: this.ResizeDuration});
  	
  	if(!( hDiff == 0)){ new Effect.Scale(this.ContainerDiv, yScale, {delay:0,scaleX: false, duration: 1, queue: 'front',scaleContent:false}); }
	if(!( wDiff == 0)){ new Effect.Scale(this.ContainerDiv, xScale, {afterFinish: this.onFinishTimeToCloseCallBack, scaleY: false, scaleContent:false,delay: 1, duration: 1}); }  
  },
  onFinishTimeToCloseCallBack: function (effect)
  {
  WSTOA_Map.onFinishTimeToClose(effect);
  },
  onFinishTimeToClose : function (effect)
  {
  	
  	 oDiv = $(this.ContainerDiv);
  	 oDiv.style.width = this.beginWidth;
  	 oDiv.style.height = this.beginHeight;
  oDiv.innerHTML = '<img src="' + this.LoadingImage + '" alt="loading">';
	deactivate("");
  }
  
  ,
  
  windowSize: function(sHeight) {
  var myWidth = 0;
   myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  switch ( sHeight.toUpperCase() )
  {
 	case "HEIGHT" : 
 		return myHeight;
 		break;
 	default : 
 		return myWidth;
 		break;
  }
}
};

 Event.observe(window, 'load',
    function() { WSTOA_Map.init(); }
  );

  function MapEntry(regionNum)
  {
  	WSTOA_Map.loadRegion(regionNum);
  }
  
  window.f_height = function() { return([window.innerHeight ?
 window.innerHeight : null, document.documentElement ?
 document.documentElement.clientHeight : null, document.body ?
 document.body.clientHeight : null].compact().first()); }

window.f_width = function() { return([window.innerWidth ?
 window.innerWidth : null, document.documentElement ?
 document.documentElement.clientWidth : null, document.body ?
 document.body.clientWidth : null].compact().first()); }
