/* 5/12/10 eh 

	intent is to capsulize some likely-to-be-needed RFTW-specific stuff into one object 
		and one namespace. 



*/
function RFTWdekiInit(){
		// give us the right url, depending on whether we're test or production --
		// 	test has a green background.
		this.geturl = function(){
			var loc = window.location.host;
			if (loc == "dev.wiki.reachforthewall.com"){
				return "72.44.46.147";
			}
			else{
				return "www.reachforthewall.com";
			}
		}
		// find the type argument, as in type of league, summer, hs, whatever. otherwise,
		//	guess based on date
		this.gettype = function(){

			if (this.getQS("type")){
				return this.getQS("type");
			}
			else{
				// no type in querystring? figure out summer or hs based on date -- if after may or before  sept, summer				
				var now = new Date();
				var tod = Date.parse(now);
				var may = Date.parse("5/1/" + now.getFullYear() );
				var sep = Date.parse("9/1/" + now.getFullYear() );
				if (now < may || now > sep ){
					return "hs";
				}
				else{
					return "summer";
				}
			}
		}
		// get a particular value of the key-value pairs in the query string.
		this.getQS =  function(key) {
			// get one value from the key-value pairs in the query string
			var qs = window.location.search.substring(1);
			var arrKV = qs.split("&");
			for (i=0;i < arrKV.length;i++) {
				var pair = arrKV[i].split("=");
				if (pair[0] == key) {
					return pair[1];
				}
			}
			return "";
		}
		this.objSeasons = {};
		this.pagelinks = {"hs": "High_Schools","high school": "High_Schools","High School": "High_Schools","summer" : "Summer_Pools", "Summer" : "Summer_Pools"};
		this.jsonurl = this.geturl();
		this.lt = this.gettype().toLowerCase();
		this.getUrlRev = function(){
			return window.location.href.split("/").reverse();
		}
}

// eventually this will be deprecated in favor of similar function within rftwdekiinit object.
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
function gup2()
{
  return window.location.href.split("/").reverse();
}

function showmessage(msg){

	var ww = $wpjQ(window).width();
	var wh = $wpjQ(window).height();
	var boxwide = $wpjQ("#rftwmsg").width();
	var boxhigh = $wpjQ("#rftwmsg").height();
	wide=ww/2 - boxwide/2;
	high= wh/2 - boxhigh/2;
	high += $wpjQ(document).scrollTop();
	$wpjQ("#rftwmsg").css("left",wide);
	$wpjQ("#rftwmsg").css("top",high);

	//$wpjQ("body").fadeTo("slow", 0.33);
	
	$wpjQ("#rftwmsg").html(msg).css("display","").fadeIn(1000).fadeOut(5000);
	
	
}


