var dbgcnter=0;

var BrowserDetect = {
 init: function () {
  this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
  this.version = this.searchVersion(navigator.userAgent)
   || this.searchVersion(navigator.appVersion)
   || "an unknown version";
  this.OS = this.searchString(this.dataOS) || "an unknown OS";
 },
 searchString: function (data) {
  for (var i=0;i<data.length;i++)	{
   var dataString = data[i].string;
   var dataProp = data[i].prop;
   this.versionSearchString = data[i].versionSearch || data[i].identity;
   if (dataString) {
    if (dataString.indexOf(data[i].subString) != -1)
     return data[i].identity;
   }
   else if (dataProp)
    return data[i].identity;
  }
 },
 searchVersion: function (dataString) {
  var index = dataString.indexOf(this.versionSearchString);
  if (index == -1) return;
  return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
 },
 dataBrowser: [
  {
   string: navigator.userAgent,
   subString: "Chrome",
   identity: "Chrome"
  },
  { 	string: navigator.userAgent,
   subString: "OmniWeb",
   versionSearch: "OmniWeb/",
   identity: "OmniWeb"
  },
  {
   string: navigator.vendor,
   subString: "Apple",
   identity: "Safari"
  },
  {
   prop: window.opera,
   identity: "Opera"
  },
  {
   string: navigator.vendor,
   subString: "iCab",
   identity: "iCab"
  },
  {
   string: navigator.vendor,
   subString: "KDE",
   identity: "Konqueror"
  },
  {
   string: navigator.userAgent,
   subString: "Firefox",
   identity: "Firefox"
  },
  {
   string: navigator.vendor,
   subString: "Camino",
   identity: "Camino"
  },
  { // for newer Netscapes (6+)
   string: navigator.userAgent,
   subString: "Netscape",
   identity: "Netscape"
  },
  {
   string: navigator.userAgent,
   subString: "MSIE",
   identity: "Explorer",
   versionSearch: "MSIE"
  },
  {
   string: navigator.userAgent,
   subString: "Gecko",
   identity: "Mozilla",
   versionSearch: "rv"
  },
  { // for older Netscapes (4-)
   string: navigator.userAgent,
   subString: "Mozilla",
   identity: "Netscape",
   versionSearch: "Mozilla"
  }
 ],
 dataOS : [
  {
   string: navigator.platform,
   subString: "Win",
   identity: "Windows"
  },
  {
   string: navigator.platform,
   subString: "Mac",
   identity: "Mac"
  },
  {
   string: navigator.platform,
   subString: "Linux",
   identity: "Linux"
  }
 ]
};
BrowserDetect.init();

var bd_w3c=(document.getElementById)? true: false;
var bd_ie5=(BrowserDetect.browser=='Explorer' && qfix(BrowserDetect.version)>=5);
var bd_opera=(BrowserDetect.browser=='Opera');
var bd_safari=(BrowserDetect.browser=='Safari');
var bd_chrome=(BrowserDetect.browser=='Chrome');
var bd_moz=(BrowserDetect.browser=='Mozilla' || BrowserDetect.browser=='Firefox');
var g_cursor_point=new Array(0,0);

function pu(anchorobj,popupname) {
 var pos=findpos(anchorobj);
 var minus=anchorobj.offsetHeight;
 var plus=0;
 if (popupname == 'popup_flag')	var plus=150;
 var x=pos[0]-plus;
 var y=pos[1]+minus;
 showobj(popupname);
 moveit(getobj(popupname),x,y);
 setopacity(getobj(popupname),100);//90
}

function findoptionindex(obj,matchvalue){
 for (var i=0;i<=obj.length-1;i++){
  if (obj.options[i].value==matchvalue){
   return i;
  }
 }
 return -1;
}

function autoselectlist(formfield,matchvalue){
 var obj;
 if (isobject(formfield))
  obj=formfield;
 else
  obj=eval('document.' + formfield);
 if (document.all) {
  var seli=findoptionindex(obj,matchvalue);
  if (seli>=0)
   obj.selectedIndex=seli;
  } else {
  if (obj)
   obj.value=matchvalue;
 }
}

function selectedvalue(formfield){
 if (!formfield)
  return '';
 var obj
 if (isobject(formfield))
  obj=formfield;
 else
  obj=eval('document.' + formfield);
 if (document.all) {
  if (qfix(obj.selectedIndex)==-1)
   return '';
  return obj.options[obj.selectedIndex].value;
 } else {
  return obj.value;
 }
}

function selectedtext(x){
 return x.options[x.selectedIndex].text;
}

function isobject(x){
 return (typeof x == 'object' && !!x);
}

function changetext(objectid,text) {
 var obj=getobj(objectid);
 if (obj!=null){
  obj.innerHTML=text;
 }
}

function gettext(objectid) {
 var obj=getobj(objectid);
 return obj.innerHTML;
}

function getobj(x){
 if (isobject(x)) return x;
 return document.getElementById?document.getElementById(x):document.all?document.all[x]:document.layers[x];
}

function getattr(objectid,attributename) {
 var obj=getobj(objectid);
 if (obj)
  return obj.getAttribute(attributename);
 return "";
}

function setattr(objectid,attributename,value) {
 var obj=getobj(objectid);
 if (!obj)
  return;
 obj.setAttribute(attributename,value);
}

function uc(){
 alert('Under Construction. Please try again later.');
 return false;
}

function isdefined(x){
 return typeof(x)=='undefined'?false:true;
}

var ignoreclickid=false;

function ignoreclick(){
 ignoreclickid=true; 
}

function gourl(url,clickid){
 if (!ignoreclickid)
  document.location.href=url;
 ignoreclickid=false;
}

function moveit(obj,thisx,thisy){
 obj.style.x=thisx;
 obj.style.y=thisy;
 obj.style.left=thisx+'px';
 obj.style.top=thisy+'px';
}

function findpos(obj) {
 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 hideobj(x){
 if (mt(x)) return;
 var obj=getobj(x);
 if (!isobject(obj)) return;
 if (bd_opera){
  obj.style.visibility='hidden';
  obj.style.display='none';
 }else	
  obj.style.display='none';
}

function showobj(x){
 if (mt(x)) return;
 var obj=getobj(x);
 if (!isobject(obj)) return;
 if (bd_opera){
  obj.style.visibility='visible';
  obj.style.display='block';
 } else
  obj.style.display='block';
}

function isvisible(x){
 if (mt(x)) return;
 var obj=getobj(x);
 if (!isobject(obj)) return false;
 if (bd_opera)
  return obj.style.visibility=='visible';
 else
  return obj.style.display=='block';
}

function toggleobj(x){
 var obj=getobj(x);
 if (isvisible(obj))
  hideobj(obj);
 else
  showobj(obj);
}

var windowWidth = 0, windowHeight = 0;

function getWindowSize() {
 if( typeof( window.innerWidth ) == 'number' ) {
  windowWidth = window.innerWidth;
  windowHeight = window.innerHeight;
 } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  windowWidth = document.documentElement.clientWidth;
  windowHeight = document.documentElement.clientHeight;
 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  windowWidth = document.body.clientWidth;
  windowHeight = document.body.clientHeight;
 }
}

var scrollOffsetX = 0, scrollOffsetY = 0;
var scrollbarwidth=0, scrollbarheight=0;

function getScrollXY() {
 if( typeof( window.pageYOffset ) == 'number' ) {
  scrollOffsetY = window.pageYOffset;
  scrollOffsetX = window.pageXOffset;
 } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
  scrollOffsetY = document.body.scrollTop;
  scrollOffsetX = document.body.scrollLeft;
 } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
  scrollOffsetY = document.documentElement.scrollTop;
  scrollOffsetX = document.documentElement.scrollLeft;
 }
 scrollbarwidth=20;
 scrollbarheight=20;
}

function getpagewidth() {
 return document.body.scrollWidth;
}

function getpageheight() {
 return document.body.scrollHeight;
}

function getwidth(obj){
 if (document.all)
  return obj.scrollWidth
return obj.scrollWidth
}

function getheight(obj){
 if (typeof(obj).type=='string')
  return obj.offsetHeight;
 if (document.all)
  return obj.scrollHeight
 return obj.scrollHeight
}

function hidealldropdowns(unhide){
 var ddls=document.getElementsByTagName("SELECT");
 for(i=0;i<ddls.length;i++){
  if (unhide==1)
   showobj(ddls[i]);
  else
   hideobj(ddls[i]);
 }
}

function togglecontenttohide(unhide){
 if (document.location.href.indexOf('content.planetbuzz')>=0 || document.location.href.indexOf('pagebuilder.planetbuzz')>=0 ) return;
 var obj=getstyleruleobj('contenttohide');
 if (obj) {
  if (unhide==1)
   setopacity(obj,100);
  else
   setopacity(obj,0);
 }
 if (bd_ie5)
  hidealldropdowns(unhide);
}

function getstyleruleobj(ruletext){
 if (bd_opera) return null;//no style dom for opera
 var obj=null;
 if (document.styleSheets.item) {
  if (document.styleSheets[0].cssRules)
   obj=document.styleSheets.item(0).cssRules;
  else
   obj=document.styleSheets.item(0).rules;
 } else {
  if (document.styleSheets[0].rules)
   obj=document.styleSheets[0].rules.item;
  else
   obj=document.styleSheets[0].cssRules;
 }
 if (obj) {
  for (var i=0;i<=obj.length-1;i++) {
   if (obj[i].selectorText=='.'+ruletext)
    return obj[i];
  }
 }
 return null;
}

function setopacity(obj,perc){//perc - 0 to 100
 if (bd_moz){
  obj.style.MozOpacity=perc/100;
 } else {
  if (bd_safari || bd_chrome) {
   obj.style.opacity=perc/100;
  } else {
   if(bd_ie5){
    if (perc==100)
     obj.style.filter='';
    else
     obj.style.filter='alpha(opacity='+perc+')';
   } else {
     obj.style.opacity=perc;
   }
  }
 }
}

function getopacity(obj){
 var op=0;
 if (bd_moz){
  op=obj.style.MozOpacity*100;
 } else {
  if (bd_safari || bd_chrome) {
   op=obj.style.opacity*100;
  } else {
   if(bd_ie5){
    var x=obj.style.filter;
    var pos1=x.indexOf('=');
    var pos2=x.indexOf(')');
    if(pos1<0 || pos2<0) return 0;
    op=x.substring(pos1+1,pos2);
   } else {
    //browser not supported
   }
  }
 }
 return op*1;
}

var onloadcom = new Array();

function addloadcommand(functtext){
 onloadcom[onloadcom.length]=functtext;
}

function resetloadcommands(){
 onloadcom = new Array();
}

function bodyonload(){
 for (var i=0;i<onloadcom.length;i++){
  eval(onloadcom[i]);
 }
}

function getselectradio(obj){
 if (!obj)
  return '';
 for (var i=0; i<obj.length; i++){
  if (obj[i].checked)
   return obj[i].value;
 }
 return '';
}

function selectradio(obj,v){
 for (var i=0; i<obj.length; i++){
  if(obj[i].value==v){
   obj[i].checked=true;
  }
 }
}

function safeeval(js){
 if(!mt(js))
  eval(js);
}

function preloadlist(imglist){
 //format: abc.gif;def.jpg;ghi.gif
 var imgs=new Array();
 var imgarray=imglist.split(';');
 for (var i=0;i<=imgarray.length-1;i++){
  imgs[i]=new Image(); imgs[i].src=imgarray[i];
 }
}

function isnumeric(s) {
 if (!s) return false;
 var chars = "0123456789-.";
 for (var i=0;i<s.length;i++) {
  if (chars.indexOf(s.charAt(i))==-1)
   return false;
 }
 return true;
}

function mt(x){
 if (x==null) return true;
 if (x=="") return true;
 return false;
}

function getformfieldvalue(obj){
 if (!obj) return '';
 var type=obj.type;
 if (type=='text' || type=='textarea' || type=='hidden' || type=='password') {
  return obj.value;
 }
 if (type=='radio') {
  return getselectradio(obj);
 }
 if (type=='checkbox') {
  if (obj.checked) return obj.value;
  return 0;
 }
 if (type=='select-one' || type=='select-multiple') {
  return selectedvalue(obj);
 }
}

function qfix(x){
 if (x==null)
  return 0;
 var n=x.toString().replace(RegExp('[^0-9\-.]','g'),'')*1;
 if (isNaN(n)) n=0;
 return n;
}

function trim(x){
 return x.replace(/^\s+|\s+$/g,'');
}

function popup(url) 
{
 var width  = 800;
 var height = 600;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'windowname'+(Math.floor(Math.random())), params);
 if (window.focus) {newwin.focus()}
 return false;
}

function popupfree(url) 
{
 var width  = 900;
 var height = 600;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', location=yes';
 params += ', menubar=yes';
 params += ', resizable=yes';
 params += ', scrollbars=yes';
 params += ', status=yes';
 params += ', toolbar=yes';
 newwin=window.open(url,'windowname'+(Math.floor(Math.random()*1000000)), params);
 if (window.focus) {newwin.focus()}
 return false;
}

function swap_video(div,url){
 if (div==1) {
  getobj("movie_content").innerHTML='<object width=425 height=344 type=application/x-shockwave-flash data='+url+'&hl=en&autoplay=1><param name=movie value='+url+'&hl=en&autoplay=1></object>'
 }
}

function prepjs(x){
 //Handle CR LF \ ' and "
 if (x==null) return;
 return x.replace(/\\/g,'\\\\').replace(/'/g,'\\\'').replace(/"/g,'\\\"').replace(RegExp(String.fromCharCode(10),'g'),'\n').replace(RegExp(String.fromCharCode(13),'g'),'');
}

function prephtml(x){
 if (x==null) return;
 //take non-html string and convert it to html. Handle CR LF <>     //mozilla only does 10 for lf, no cr
 return x.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(RegExp(String.fromCharCode(10),'g'),'<br\>').replace(RegExp(String.fromCharCode(13),'g'),'');
}

function deprephtml(x){
 if (x==null) return;
 return x.replace(RegExp('<br\>','ig'),String.fromCharCode(13)+String.fromCharCode(10)).replace(RegExp('&lt;','ig'),'<').replace(RegExp('&gt;','ig'),'\>').replace(RegExp('&quot;','ig'),'\>').replace(RegExp('&nbsp;','ig'),' ').replace(RegExp('&amp;','ig'),'&');
}

var zdx=100000;

function bringfront(v){
 (v).style.zIndex=++zdx;
}

var zdx2=1000;

function bringsubfront(v){
 (v).style.zIndex=++zdx2;
}

function getcookie(cookiename){
 if (document.cookie.length<=0) return "";
 var pos1=document.cookie.indexOf(cookiename + "=");
 if (pos1!=-1){ 
   pos1=pos1 + cookiename.length+1 
   pos2=document.cookie.indexOf(";",pos1)
   if (pos2==-1) pos2=document.cookie.length
   return unescape(document.cookie.substring(pos1,pos2))
 } 
}

function setcookie(cookiename,value,days){
 days=(days==null)?cookieexpiredays:days;
 var expires=new Date();
 expires.setDate(expires.getDate()+days);
 document.cookie=cookiename+ "=" +escape(value)+";expires="+expires.toGMTString();
}

function appendhtml(x){
 var newnode = document.createElement('div');
 newnode.innerHTML=x;
 document.body.appendChild(newnode);
}

var lastfocusedobj=null;
function lastfocusedobj_set(obj){
 lastfocusedobj=obj;
}

//*********** monitor speeds of javascript effects
var sd_maxstrikes=3;//if more than this per page then set cookie to never use fx on this computer
var sd_strikes=new Array(0,0);
var sd_dofx=new Array(true,true);
var sd_ccfx=new Array(false,false);
var this_ms=0;

function dofx(fxcategory){
 if (!sd_ccfx[fxcategory]){
  var doit=qfix(getcookie('sd'+fxcategory));//1||mt=do. 2=dont
  sd_dofx[fxcategory]=true;
  if (doit==2)
   sd_dofx[fxcategory]=false;
 }
 return sd_dofx[fxcategory];  
}

function setfx(ison,fxcategory){
 setcookie('sd'+fxcategory,(ison)?1:2,5);//allows another attempt 5 days later
 dofx[fxcategory]=ison;
}

function getspeeddiff(){
 var d=new Date();
 var diff=d.getTime()-this_ms;
 this_ms=d.getTime();
 return diff;
}

function handlespeeddiff(maxmilliseconds,fxcategory){
 var dif=getspeeddiff()-maxmilliseconds;
 if (dif>0){//effect was too slow
  sd_strikes[fxcategory]+=1+dif/maxmilliseconds;
  if (sd_strikes[fxcategory]>sd_maxstrikes)
   setfx(false,fxcategory);
 }
}

getspeeddiff();
//*********** 

if (typeof(jsmodsincluded)=="undefined"){
 addloadcommand('loadcommonmods()');
}
function loadcommonmods(){
 var domnshow='PlanetBuzz.com';
 var mods2load=('inc_effects.js,inc_dropdown.js,inc_border.js,inc_msgbox.js,inc_ajform.js,inc_ajform_wrapper.js,inc_aj.js').split(',');
 resetloadcommands();
 for (var m2li=0;m2li<mods2load.length;m2li++)
  injectjs('/vgfx/'+mods2load[m2li],true);//  appendhtml('<script src="/vgfx/'+mods2load[m2li]+'"></script>'); - did not work in ie7+
 setTimeout('bodyonload()',2000);
}

function getsimplehash(x){
 var h=0;
 for (var i=0;i<x.length;i++){
  h=(h+x.charCodeAt(i)*((i % 101)+1)) % 16777216;
 }
 return h;
}

function striptag(html,tagname){//todo - convert this to use regular expressions instead. AND do global strips, not just the first iteration
 var endtag='</'+tagname+'>';
 var pos1=html.indexOf('<'+tagname);
 if (pos1==-1) return html;
 var pos2=html.indexOf('\>',pos1);
 if (pos1==-1) return html;
 var pos3=html.indexOf(endtag,pos2);
 if (pos1==-1) return html;
 pos3=pos3+endtag.length;
 //pos1=pos to start removing
 //pos3=pos to start keeping
 return html.substring(0,pos1)+html.substring(pos3,html.length);
}

var scrhashes=new Array();

function gettagdata(html,tagname){
 var pos1=html.indexOf('<'+tagname);
 if (pos1==-1) return '';
 var pos2=html.indexOf('\>',pos1);
 if (pos1==-1) return '';
 var pos3=html.indexOf('</'+tagname,pos2);
 if (pos1==-1) return '';
 return html.substring(pos2+1,pos3);
}

function checkforandinjectjs(html){
 //first inject the script tag
 var s=gettagdata(html,'script');
 if (!mt(s)){
  //inject the script tag only if it hasn't been done b4
  var domaininject=true;
  var hash=getsimplehash(s);
  for (var i=0;i<scrhashes.length;i++){
   if (hash==scrhashes[i]){
    domaininject=false;
    break;
   }
  }
  if (domaininject){
   scrhashes[scrhashes.length]=hash;
   injectjs(s);
  }
 }
 //next inject any inline script
 var s=gettagdata(html,'inlinescript');
 if (!mt(s)) injectjs(s);
}

function injectjs(src,doreference){
 if (doreference==null) doreference=false;
 var s = document.createElement('script');
 s.type='text/javascript';
 if (doreference){
  s.src=src;
 } else {
  s.text=src;
 }
 var d=document.getElementsByTagName('script')[(document.getElementsByTagName('script').length-1)];
 d.parentNode.insertBefore(s, d.nextSibling );
}

function getsecondid() {//milliseconds as decimal
 var d=new Date();
 return d.getTime()/1000;
}

function HideAllObjs() {
 hideobj('popup_alpha');
 hideobj('popup_lang');
 hideobj('popup_loc');
}

function plural_es(num){
 if (num==1) return '';
  return 'es';
}

function plural_s(num){
 if (num==1) return '';
  return 's';
}

var dcs_open=false, dcs_state='';

function docatsearch(statename){
 //only open if it hasn't been opened yet
 if (dcs_open) return false;
 dcs_open=true;
 dcs_state=statename;
 loadXMLurl('/ajx_cat_selector_source.asp?km=1&r='+Math.random(10000), null, docatsearch_sub);
 return false;
}

function docatsearch_sub(htmlresponse){
 checkforandinjectjs(htmlresponse);
 msgbox_open(htmlresponse,null,3,null,'docatsearch_click()');
 ajx_cat_selector_source_runonload();
 msgbox_setcloseonclick(false);
}

function docatsearch_click(){
 if (positiveresponse()){
  //validate category selection
  if (return_selected_id>0){
   //save selection
   msgbox_close();
   dcs_open=false;
   gourl('/search_results.asp?sdc=1&sdcc='+return_selected_id+'&sdcs='+dcs_state);
  } else {
   msgbox_dialog_alert('You must first select a category or click the Cancel button.');
  }
 } else {
  msgbox_close();
  dcs_open=false;
 }
}

function browserscrollresize_init(){
 window.onresize=browserresize;
 window.onscroll=browserscroll;
}

addloadcommand('browserscrollresize_init()');

function browserscroll(){
 getWindowSize();
 getScrollXY();
 msgbox_doresize();
}

function browserresize(){
 getWindowSize();
 getScrollXY();
 msgbox_doresize();
 rsz_handler();
}

var rsz_objects=new Array();//multi-dimensional [uniqueobjname,obj,anchorobj,plusx,plusy]

function rsz_addobj(objname,obj,anchorobj,plusx,plusy){
 var i=0;
 for (i=0;i<rsz_objects.length;i++){
  if (rsz_objects[i][0]==objname){
   rsz_objects[i]=new Array(objname,obj,anchorobj,plusx,plusy);
   return;
  }
 }
 rsz_objects[i]=new Array(objname,obj,anchorobj,plusx,plusy);
}

function rsz_handler(){
 for (i=0;i<rsz_objects.length;i++){
  var thisobj=rsz_objects[i][1];
  var anchorobj=rsz_objects[i][2];
  var plusx=rsz_objects[i][3];
  var plusy=rsz_objects[i][4];
  var pos=findpos(anchorobj);
  moveit(thisobj,pos[0]+plusx,pos[1]+plusy);
 }
}

function showme_init(){
 var html='';
 for (var showmeid=1; showmeid<=qfix(g_showme_maxid); showmeid++){
  html+='<div id="showmediv'+showmeid+'" name="showmediv'+showmeid+'" style="display:none;position:absolute;"></div>';
 }
 appendhtml(html);
}

addloadcommand('showme_init()');

function showme_add(anchorobjuse,vid,showmeid,hide,plusx,plusy){
 if (showmeid==null) showmeid=1;
 var anchorobj=getobj(anchorobjuse);
 var showmedivid='showmediv'+showmeid;
 var showmeobj=getobj(showmedivid);
 if (!isobject(anchorobj)) return false;
 var html='';
 if (vid=='?'){
  html='<a href="#" onclick="msgbox_dialog_alert(\'This video tutorial will be available shortly. Please contact our support department if you need further assistance.\');return false;"><img src="/vgfx/nv_showme.gif?1.02" width="91" height="91" border="0"></a>';
 } else {
  html='<a href="#" onclick="return popup(\'/playvideo/p.asp?vid='+vid+'&f=1\')"><img src="/vgfx/nv_showme.gif?1.02" width="91" height="91" border="0"></a>';
 }
 changetext(showmeobj,html);
 plusx=qfix(plusx)-92;
 plusy=qfix(plusy)+0;
 var pos=findpos(anchorobj);
 moveit(showmeobj,pos[0]+plusx,pos[1]+plusy);
 if (qfix(hide)==0){
  setfadeslow();
  dofadein(showmedivid);
 }
 rsz_addobj(showmedivid,showmeobj,anchorobj,plusx,plusy);
}

function docasearch(cattext,areatext){
 var url='search_results.asp?flat=71&xcategory='+escape(cattext)+'&xlocation='+escape(areatext);
 document.location.href=url;
 return false;
}

function anyonmousemove(evobj){
 if (!evobj) var evobj = window.event;
 var xcoord = 0;
 var ycoord = 0;
 if (evobj.pageX || evobj.pageY) {
  xcoord = evobj.pageX;
  ycoord = evobj.pageY;
 } else if (evobj.clientX || evobj.clientY) {
   xcoord = evobj.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
   ycoord = evobj.clientY + document.body.scrollTop	+ document.documentElement.scrollTop;
 }
 return [xcoord,ycoord];
}

function bodyonmousemove(evobj){
 g_cursor_point=anyonmousemove(evobj);
}

function pointinrect(point,rect,grace){
 if (grace==null) grace=0;
 if (point[0]>=rect[0]-grace && point[0]<=rect[0]+rect[2]-1+grace)
  if (point[1]>=rect[1]-grace && point[1]<=rect[1]+rect[3]-1+grace)
   return true;
  return false;
}

if(document.body)
 if(document.body.captureEvents && Event.MOUSEMOVE ) document.body.captureEvents( Event.MOUSEMOVE );//Netscape

if (window.addEventListener){
 window.addEventListener("load", bodyonload, false);
 window.addEventListener("mousemove", bodyonmousemove, false);
} else {
 if (window.attachEvent){
  window.attachEvent("onload", bodyonload);
  document.attachEvent("onmousemove", bodyonmousemove);
 } else {
  if (document.getElementById){
   window.onload=bodyonload;
   window.onmousemove=bodyonmousemove;
  }
 }
}

function halt_if_not_signed_on(){
 if (g_signedon) return false;
 msgbox_dialog_ok('The feature that you requested requires that you have a PlanetBuzz.com account. Please sign on by clicking <a href="/signon.asp">here</a>. If you do not have an account, click <a href="/user_signup.asp">here</a>.');
 return true;
}

/***************************** Social Buzz Scripts (Begin)********************************/
function open_comments_pu(eid) {
 loadXMLurl('ajx_comment_source.asp?eid='+eid+'&'+Math.random(10000), null, open_comments_pu_sub);
 return false;
}

function open_comments_pu_sub(htmlresponse){
 checkforandinjectjs(htmlresponse);
 msgbox_open(htmlresponse,'Social Buzz',3,null,'verifyCommentSubmit()');
 msgbox_setcloseonclick(false);
}
/***************************** Social Buzz Scripts (End)********************************/

/***************************** Flagging Scripts (Begin)********************************/
function open_flag_pu(eid, flagid_type) {
 loadXMLurl('ajx_flag_source.asp?eid='+eid+'&flagid_type='+flagid_type+'&'+Math.random(10000), null, open_flag_pu_sub);
 return false;
}

function open_flag_pu_sub(htmlresponse){
 checkforandinjectjs(htmlresponse);
 msgbox_open(htmlresponse,'Flagging',3,null,'verifyFlagSubmit()');
 msgbox_setcloseonclick(false);
}
/***************************** Flagging Scripts (End)********************************/

var qs_vars=null, qs_loaded=false;
function qs_assert_load(){
 if (qs_loaded) return;
 qs_loaded=true;
 var url=window.location.href;
 var qs=window.location.search.substring(1);
 qs_vars=qs.split('&');
}
function qs_setvar(varname,varvalue){
 qs_assert_load();
 for (var i=0;i<qs_vars.length;i++){
  var nvp=qs_vars[i].split('=');
  if (nvp[0]==varname){
   if (varvalue===null){
    qs_vars.splice(i,1);
    return;
   }
   nvp[1]=Math.random(10000);
   qs_vars[i]=nvp.join('=');
   return;
  }
 }
 qs_vars[qs_vars.length]=varname+'='+varvalue;
}
function qs_getvar(varname){
 qs_assert_load();
 for (var i=0;i<qs_vars.length;i++){
  var nvp=qs_vars[i].split('=');
  if (nvp[0]==varname){
   if (nvp.length==2) return nvp[1];
  }
 }
 return '';
}
function qs_get(){
 qs_assert_load();
 return qs_vars.join('&');
}


function refreshpage(){
 var url=window.location.href;
 var pagesplit=url.split('?');
 if (pagesplit[0].indexOf('search_results.asp')>0) return;
 qs_setvar('rnd',Math.random(10000));
 qs_setvar('popfan',null);
 qs_setvar('phmt',null);
 url=pagesplit[0]+'?'+qs_get();
 document.location.href=url;
}


function common_textarea_onblur(obj,default_text,maxlen){
 if (obj.value=='') obj.value=default_text;
 common_textarea_sub(obj,default_text,maxlen);
}
function common_textarea_focus(obj,default_text,maxlen){
 if (obj.value==default_text) obj.value='';
 common_textarea_sub(obj,default_text,maxlen);
}
function common_textarea_sub(obj,default_text,maxlen) {
 if (mt(obj.value) || obj.value==default_text){
  changetext((obj.id)+'_c','');
  return;
 }
 var cleft=(maxlen - obj.value.length);
 changetext((obj.id)+'_c',cleft +' Characters Remaining');
}

function get_possessive_name(x){
 if (mt(x)) return '';
 if (x.charAt(x.length-1).toUpperCase()=='S') return x;
 return x+"'s";
}