function toggletext(whichcontent,helpCount,hightlightRow){
  cross_el=document.getElementById(helpCount);
  row_el = document.getElementById('tr_'+helpCount);
  if(hightlightRow){
  	cp_row = document.getElementById('cp_'+helpCount);
  }
  
  if (cross_el.innerHTML=="") {
    cross_el.innerHTML="<span class='small'>"+whichcontent+"</span>";
    row_el.style.display="";
    if(cp_row!=undefined){
    	cp_row.className = 'subhead bottom-dotted-border';
    }
  } else {
    cross_el.innerHTML="";
    row_el.style.display="none";
    if(cp_row!=undefined) cp_row.className = '';
  }
}

function confirmLink(theLink, theMsg, editUrl) {
  editUrl = typeof(editUrl) != 'undefined' ? editUrl : true;
  var is_confirmed = confirm(theMsg);
  if (is_confirmed && editUrl) {
    theLink.href += '&is_js_confirmed=1';
  }
  return is_confirmed;
}

function getDocumentSize() {
  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;
  }
  return [ myWidth, myHeight ];
}

function getScrollXY(){
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function XYwin(v){
	var scrollArray = getScrollXY();
	if (document.all){
		z = Array(document.body.clientWidth,document.body.clientHeight);
	}else{
		z = Array(window.innerWidth,window.innerHeight);
	}
	return(isset(v)?z[v]:z);
}
function findPos(obj) {
	if(obj==null) return false;
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}

function SetJsCookie(cookieName,cookieValue,nDays,domain,path,secure){
 	today = new Date();
 	expire = new Date();
 	expStr = '';
	if(nDays){
		expires = nDays*1000*60*60*24;
		expires_date = new Date( today.getTime() + (expires) );
 		expStr = expires_date.toGMTString();
	}
	ckStr = cookieName+'='+escape(cookieValue) + ((expStr) ? ';expires='+expStr : '')+ ((domain) ? ';domain=' + domain : '') + ((path) ? ';path=' + path : '') + ((secure)?";secure" : "" );
 	document.cookie = ckStr;
}

function getCookie(c_name){
	if(document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if(c_start!=-1){ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
    		return unescape(document.cookie.substring(c_start,c_end));
    	} 
  	}
	return "";
}

function delCookie(cookieName,domain,path,session){
	ndays = (session) ? 0 : -10;
	SetJsCookie(cookieName,'2',ndays,domain,path);
}

function pageScrollToElement(elementId,timeStep,pixStep){
	if($jq('#'+elementId).length <= 0 ) return false;
	var vardocScroll = getScrollXY();
	vardocScroll = vardocScroll[1];
	if($jq('#'+elementId).css('display') !='none'){
		scrtobj = document.getElementById(elementId);
		var elPos = findPos(scrtobj);
		if(vardocScroll < elPos[1] && vardocScroll- elPos[1] < -pixStep){ //scroll down
			if((vardocScroll+pixStep) < elPos[1]){
				window.scrollBy(0,pixStep); // horizontal and vertical scroll increments
				var vardocScroll2 = getScrollXY();
				vardocScroll2 = vardocScroll2[1];
				if(vardocScroll2 != vardocScroll){ //can scroll more
		   			scrolldelay = setTimeout('pageScrollToElement(\''+elementId+'\','+timeStep+','+pixStep+')',timeStep); // scrolls every 'timeStep' milliseconds
				}else{
					window.scrollBy(0,10);
				}
			}
		}else if(vardocScroll > elPos[1] && vardocScroll- elPos[1] > pixStep){ //scroll up
			if((vardocScroll-pixStep) > elPos[1]){
				window.scrollBy(0,-pixStep); // horizontal and vertical scroll increments
				var vardocScroll2 = getScrollXY();
				vardocScroll2 = vardocScroll2[1];
				if(vardocScroll2 != vardocScroll){ //can scroll more
		   			scrolldelay = setTimeout('pageScrollToElement(\''+elementId+'\','+timeStep+','+pixStep+')',timeStep); // scrolls every 'timeStep' milliseconds
				}else{
					window.scrollBy(0,-10);
				}
			}
		}
	}
}
//activateActiveX_onload.js
//trap onload event
window.onload = function () {
	//Determine browser, we only need this for Internet Explorer
	if (navigator.appName == "Microsoft Internet Explorer") {
		
		//Array of elements to be replaced
		var arrElements = new Array(3);
		arrElements[0] = "object";
		arrElements[1] = "embed";
		arrElements[2] = "applet";
	
		
		//Loop over element types
		for (n = 0; n < arrElements.length; n++) {
		
			//set object for brevity
			replaceObj = document.getElementsByTagName(arrElements[n]);
			
			//loop over element objects returned
			for (i = 0; i < replaceObj.length; i++ ) {
			
				//set parent object for brevity
				parentObj = replaceObj[i].parentNode;
				
				//grab the html inside of the element before removing it from the DOM
				newHTML = parentObj.innerHTML;
				
				//remove element from the DOM
				parentObj.removeChild(replaceObj[i]);
				
				//stick the element right back in, but as a new object
				parentObj.innerHTML = newHTML;
			
			}
		}
	}
};
var cms_font_size = 10;
function adjustTextSize(updown){
	fontsize_cms = $jq('div#container-fullcontent').css('fontSize');
	length = fontsize_cms.length;
	cms_font_size = fontsize_cms.substr(0,parseInt(length,10) - 2);
	if(updown=='up')
		cms_font_size = (cms_font_size*1) + 0.5;
	else if (updown=='down')
		cms_font_size = (cms_font_size*1) - 0.5;
	$jq('div#container-fullcontent').css({ fontSize: cms_font_size + 'px'});
	fontsize_cms = $jq('div#container-fullcontent').css('fontSize');
	SetJsCookie('WMCMSTextSize',fontsize_cms,0,'','/');
}

function roundedLinkRollOver(id,state){
	if(state=='over'){
		$jq('div#rlink-right-' + id).css({backgroundImage:"url(/assets/img/rounded-orange-right.gif)"});
		$jq('div#rlink-left-' + id).css({backgroundImage:"url(/assets/img/rounded-orange-left.gif)"});
		$jq('div#rlink-center').css({backgroundImage:"url(/assets/img/rounded-orange-bg.gif)"});
	}else if(state=='out'){
		$jq('div#rlink-right-' + id).css({backgroundImage:"url(/assets/img/rounded-grey-right.gif)"});
		$jq('div#rlink-left-' + id).css({backgroundImage:"url(/assets/img/rounded-grey-left.gif)"});
		$jq('div#rlink-center').css({backgroundImage:"url(/assets/img/rounded-grey-bg.gif)"});
	}
}

function onEnterSubmit(e, form){
	var characterCode;
	if( e.which ) 
		characterCode = e.which;
	else if( e.keyCode ) 
		characterCode = e.keyCode;
	
	if(characterCode == 13)
	{ 
		$jq(form).submit();
		return false;
	}else{
		return true;
	}
}

function enterPressed(e){
	var keynum;
	if(window.event){ // IE
		keynum = e.keyCode;
	}else if(e.which){ // Netscape/Firefox/Opera
		keynum = e.which;
	}
	return keynum==13 ? true : false;
}

function inArray(thearray,value) {
	var i;
	for (i=0; i < thearray.length; i++) {
		if (thearray[i] === value) {
			return true;
		}
	}
	return false;
};


//This prototype is provided by the Mozilla foundation and
//is distributed under the MIT license.
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license

if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}

// Internet explorer detection
var isIE = false;
var isIE6 = false;
if ($jq.browser.msie) {
	isIE = true;
	if ($.browser.version.substr(0,1)<7) {
		isIE6 = true;
	}
}

function toggle_loginbox(){
	$('#signIn-menu').slideToggle('normal',
		function(){
			if($('#vemail').val()) $('#vpasswd').focus(); else $('#vemail').focus();
		}
	);
}

function getAnObject(v){
	return(document.getElementById(v)); 
}
function objectStyle(v){
	return(getAnObject(v).style); 
}
function agent(v){
	return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0));
}
function isset(v){
	return((typeof(v)=='undefined' || v.length==0)?false:true);
}

function loginTog(){
	document.onclick=function(){
		hideLoginBox();
	};
}
var vardocScroll = getScrollXY();
vardocScroll = vardocScroll[1];

function checkValues(emailAlert,passAlert){
	if($jq('#vemail').val() && $jq('#vpasswd').val()){
		return true;
	}else if($jq('#vemail').val()){
		$jq('#vemail').removeClass('input-error');
		$jq('#vpasswd').addClass('input-error');
		$jq('#login_error_row').css('display','block');
		$jq('#login_error_row').html(passAlert);
		return false;
	}else{
		$jq('#vpasswd').removeClass('input-error');
		$jq('#vemail').addClass('input-error');
		$jq('#login_error_row').css('display','block');
		$jq('#login_error_row').html(emailAlert);
		return false;
	}
}

// toggle.js
function switchMenu(obj){
	var el = document.getElementById(obj);
	el.style.display = el.style.display != "none" ? 'none' : '';
}

//Sweet titles
Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}else {
		obj["on"+type] = obj["e"+type+fn];
	}
}
	
var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();
addEvent(window,'unload',EventCache.flush);
/*
Sweet Titles (c) Creative Commons 2005
http://creativecommons.org/licenses/by-sa/2.5/
Author: Dustin Diaz | http://www.dustindiaz.com
*/
var sweetTitles = { 
	xCord : 0,									// @Number: x pixel value of current cursor position
	yCord : 0,									// @Number: y pixel value of current cursor position
	tipElements : ['a','abbr','acronym','img', 'tr','div', 'span'],	// @Array: Allowable elements that can have the toolTip
	obj : Object,								// @Element: That of which you're hovering over
	tip : Object,								// @Element: The actual toolTip itself
	active : 0,									// @Number: 0: Not Active || 1: Active
	init : function() {
		if ( !document.getElementById ||
			!document.createElement ||
			!document.getElementsByTagName ) {
			return;
		}
		var i,j;
		
		if(document.getElementById('toolTip')){
			this.tip = document.getElementById('toolTip');
			sweetTitles.tip = this.tip;
		}else{
			this.tip = document.createElement('div');
			this.tip.id = 'toolTip';
			document.getElementsByTagName('body')[0].appendChild(this.tip);
			document.getElementById('toolTip').style.top = '0';
			document.getElementById('toolTip').style.visibility = 'hidden';
			document.getElementById('toolTip').style.display = 'none';
			document.getElementById('toolTip').style.zindex = 9999;
		}
		
		var tipLen = this.tipElements.length;
		for ( i=0; i<tipLen; i++ ) {
			var current = document.getElementsByTagName(this.tipElements[i]);
			var curLen = current.length;
			for ( j=0; j<curLen; j++ ) {
				if(current[j].getAttribute('title') != null && current[j].getAttribute('title') != ''){
					addEvent(current[j],'mouseover',this.tipOver);
					addEvent(current[j],'mouseout',this.tipOut);
					current[j].setAttribute('tip',current[j].title);
					current[j].removeAttribute('title');
				}
			}
		}
	},
	updateXY : function(e) {
		if ( document.captureEvents ) {
			sweetTitles.xCord = e.pageX;
			sweetTitles.yCord = e.pageY;
		} else if ( window.event.clientX ) {
			sweetTitles.xCord = window.event.clientX+document.documentElement.scrollLeft;
			sweetTitles.yCord = window.event.clientY+document.documentElement.scrollTop;
		}
	},
	tipOut: function() {
		if ( window.tID ) {
			clearTimeout(tID);
		}
		if ( window.opacityID ) {
			clearTimeout(opacityID);
		}
		document.getElementById('toolTip').style.visibility = 'hidden';
		document.getElementById('toolTip').style.display = 'none';
	},
	checkNode : function() {
		var trueObj = this.obj;
		if (trueObj.nodeName && this.tipElements.inArray(trueObj.nodeName.toLowerCase()) ) {
			return trueObj;
		} else {
			return trueObj.parentNode;
		}
	},
	tipOver : function(e) {
		sweetTitles.obj = this;
		if(this.getAttribute('tip')){
			tID = window.setTimeout("sweetTitles.tipShow()",500);
		}
		sweetTitles.updateXY(e);
	},
	tipShow : function() {		
		var scrX = Number(this.xCord);
		var scrY = Number(this.yCord);
		var tp = parseInt(scrY+15,10);
		var lt = parseInt(scrX+10,10);
		var anch = this.checkNode();
		var addy = '';
		var access = '';
		var largeText = false;
		if(anch && anch.nodeName){

			document.getElementById('toolTip').innerHTML = "<p>"+anch.getAttribute('tip')+"<em>"+access+addy+"</em></p>";
			if ( parseInt(document.documentElement.clientWidth+document.documentElement.scrollLeft,10) < parseInt(document.getElementById('toolTip').offsetWidth+lt,10) ){
				document.getElementById('toolTip').style.left = parseInt(lt-(document.getElementById('toolTip').offsetWidth+10),10)+'px';
			}else{
				document.getElementById('toolTip').style.left = lt+'px';
			}
			if(largeText==false && (parseInt(document.documentElement.clientHeight+document.documentElement.scrollTop,10) < parseInt(document.getElementById('toolTip').offsetHeight+tp,10) )){
				document.getElementById('toolTip').style.top = parseInt(tp-(document.getElementById('toolTip').offsetHeight+10),10)+'px';
			}else{
				document.getElementById('toolTip').style.top = tp+'px';
			}
			document.getElementById('toolTip').style.visibility = 'visible';
			document.getElementById('toolTip').style.display = 'block';
			document.getElementById('toolTip').style.opacity = '.1';
			this.tipFade(10);
		}
	},
	tipFade: function(opac) {
		var passed = parseInt(opac,10);
		var newOpac = parseInt(passed+10,10);
		if ( newOpac < 80 ) {
			document.getElementById('toolTip').style.opacity = '.'+newOpac;
			document.getElementById('toolTip').style.filter = "alpha(opacity:"+newOpac+")";
			opacityID = window.setTimeout("sweetTitles.tipFade('"+newOpac+"')",20);
		}
		else { 
			document.getElementById('toolTip').style.opacity = '.80';
			document.getElementById('toolTip').style.filter = "alpha(opacity:80)";
		}
	}
};
function pageLoader() {
	sweetTitles.init();
}
addEvent(window,'load',pageLoader);

function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}

function stripslashes(str){
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}


function setSelectedInMenu(value,element){
	var $kids = $jq('#'+element).children();
	if($kids.length){
		$kids.each(function(i){
		if($jq($kids[i]).val() == value){
			$jq($kids[i]).attr("selected", true);
			return false;
		}
      });
	}
}

function appendToMenu(value,label,element){
	var $kids = $jq('#'+element).children();
	var found = false;
	if($kids.length){
		$kids.each(function(i){
		if($jq($kids[i]).val() == value){
			found = true;
			$jq($kids[i]).attr("selected", true);
			return false;
		}
      });
	}
	if(found == false){
		$jq('#'+element).prepend('<option value="' + value + '">' + label + '</option>');
	}	
}

function removeFromMenu(value, selector){
	var $kids = $jq('#'+selector).children();
	var found = false;
	if($kids.length){
		$kids.each(function(i){
		if($jq($kids[i]).val() == value){
			found = true;
			$jq($kids[i]).remove();
			return true;
		}
      });
	}
	return false;
}

(function($){
  $.fn.vCenter = function(options) {
	var pos = {
	  sTop : function() {
		return window.pageYOffset || document.documentElement && document.documentElement.scrollTop ||	document.body.scrollTop; 
	  },
	  wHeight : function() { 
		return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body.clientHeight;
	  },
	  wWidth : function() { 
		return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body.clientWidth;
	  }
	};
	return this.each(function(index) {
	  if (index == 0) {
		var $this = $(this);
		var elHeight = $this.height();
		var elWidth = $this.width();
			var elTop = pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2);
			var elLeft = (pos.wWidth() / 2) - (elWidth / 2);
		$this.css({
		  position: 'absolute',
		  marginTop: '0',
		  top: elTop ,
		  left: elLeft
		});
	  }
	});
  };
})(jQuery);

var WMjsonp = function (url, params, callback) {
	  var script = this.document.createElement("script");
	  url += "?"+params;
	  url += (url.indexOf('?') > -1)? '&': '?';
	  url += "callback="+callback+"&_="+Math.floor(Math.random()*999999);
	  url = WMAPIURL+url;
	  script.setAttribute("src", url);
	  script.setAttribute("type", "text/javascript");
	  try{
		  this.document.body.appendChild(script);
	  } catch(err) {
		  console.log('error json call');
	  }
	  
};

var refreshAPIKeyCallback = function() {
	$('#nkey_refresh').fadeOut();
	setTimeout('refreshAPIKey()',300000);
};

var refreshAPIKey = function () {
	if(getCookie('nkey').length>0) {
		$('#nkey_refresh').fadeIn();
		WMjsonp('acct_noop.php','','refreshAPIKeyCallback');
	}
};
function plupperPopup(url){
	if(typeof(plupper_popup)=='undefined' || plupper_popup.closed){
		var width  = 600;
		var height = 320;
		var left   = (screen.width  - width)/2;
		var top    = (screen.height - height)/2;
		var params = 'width='+width+', height='+height+', top='+top+', left='+left;
		params += ', directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=yes, toolbar=no';
		plupper_popup = window.open(url,'plupperpop', params);	
	}
	plupper_popup.focus(); 
	return false;
};
