// Site Wide JavaScript for RD08

// used in compact search box
function search_sel(selObj){
  if((selObj.selectedIndex+1) == selObj.options.length){
    window.location = selObj.value;
  }
}

// START FUNCTIONS FOR RESIZING ARTICLE BODY TEXT
var fSize = 12;
function txtsz(step){
  max=8;
  min=1;
  b = $('article_body');
  for(var i=min;i<=max;i++){
    if(b.hasClassName('s'+i)){
      current = 's'+i;
      new_size = (i+step);
      if((new_size < min) || (new_size > max)){new_size += (step*(-1));}
      new_class = (step == 0) ? 's3' : 's'+new_size;
      b.removeClassName('s'+i);
      b.addClassName(new_class);
      //alert('changing to: '+new_class);
      break;
    }
  }
  return;
  
  alert(b.classNames());
  if(step == 0){b.setStyle({fontSize:'12px'});}
  else{
    fSize += step;
    if((fSize < 8) || (fSize > 20)){fSize += (step*(-1));}
    b.setStyle({fontSize:fSize+'px'});
  }
}

function ToggleArticleDefinitions(aObj){
  name = 'ArticleDefinitions';
  value = (getCookie(name) == 'off') ? 'on' : 'off';
  expires = new Date(new Date().getTime()+(30*86400000));
  setCookie(name,value,expires,'/');
  return true;
}

function sgt(aObj){ // "S"how "G"lossary "T"erm
 newwin=window.open(aObj.href, 'dispwin','width=450,height=410,scrollbars=1,menubar=no');
 return false;
}

// END FUNCTIONS FOR RESIZING ARTICLE BODY TEXT

// Cookie Jar Functions
function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "; path=/") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
function deleteCookie (name){
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime (cookie_date.getTime() - 1);
  setCookie(name,null,cookie_date.toGMTString());
}
// End Cookie Jar Functions


function bgWidgetFocus(obj){
  if (obj.value == obj.defaultValue){obj.value = '';}
  else{obj.select();}
  return true;
}

function bgWidgetBlur(obj){
  if (obj.value.length == 0){obj.value = obj.defaultValue;}
  return true;
}

function checkRenewForm(f){
  for(i=0; i < f.elements['service'].length; i++){
    if (f.elements['service'][i].checked == true){
      var radioValue = f.elements['service'][i].value;
      break;
    }
  }
  if(radioValue == undefined){
    alert('Please select an option.');
    return false;
  }
  f.submit();
}

/* for expanding RD08_TALL ads */
function RfidAdExpandTallLeft(id){$(id).setStyle('clip:rect(0px,240px,240px,0px);');}
function RfidAdContractTallLeft(id){$(id).setStyle('clip:rect(0px,240px,240px,120px);');}

/* for expanding RD08_WIDE ads */
function RfidAdExpandWideLeft(id){$(id).setStyle('clip:rect(0px,600px,250px,0px);');}
function RfidAdContractWideLeft(id){$(id).setStyle('clip:rect(0px,600px,250px,300px);');}
function makeExpandableTall(id){$(id).makePositioned().setStyle('position:absolute;overflow:hidden;width:240px;left:-110px;clip:rect(0px,240px,240px,120px);');}
function makeExpandableWide(id){$(id).makePositioned().setStyle('position:absolute;overflow:hidden;width:600px;left:-300px;clip:rect(0px,600px,250px,300px);');}

