/************************************************************
*
* ENVIRONMENT 
*
************************************************************/

cgiroot       = '/cgi-bin/';
cgiscriptname = 'gunk';
cgiscript     = cgiroot + cgiscriptname;

/************************************************************
*
* getXMLHttpRequest
*
************************************************************/

function getXMLHttpRequest() {

if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
 
   xmlhttp=new XMLHttpRequest();

} else {

   if (window.ActiveXObject) { // code for IE6, IE5
      
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  } else {

      alert("Your browser cannot render this website properly. Please update or use a diferent browser. IE5+, Firefox, Safari, Chrome & Opera are all compliant browsers with this website. Thank you.");
      return;

  }

}

return xmlhttp;

}

/************************************************************
*
* popWin
*
************************************************************/

function popwin(url,winname,height,width,left,top,opstring) {

var allops = new Array("alwaysLowered", "alwaysRaised", "channelmode", "dependent", "directories", "fullscreen", "hotkeys", "location", "menubar", "resizable", "scrollbars", "status", "titlebar", "toolbar", "z-lock");

var ops = "";
var comma = "";

for (i=0;i<allops.length; i++) {

   if (opstring && opstring.substring(i,i+1) == '1') {
   
      opval = 1;    
   
   } else {
   
      opval = 0;
   
   }
   
   ops = ops + comma + allops[i] + "=" + opval;
   
   comma = ",";

}

var win = open(url,winname,"height="+height+",width="+width+",left="+left+",top="+top+","+ops,"PopUpWindow");

win.focus();

}

/************************************************************
*
* imgrot
*
************************************************************/

// See 090212 issue for call to onload in body tag and listing of /images in the doc

function imgrot(name,numimgs,timedelay,imgnum) {

for (i=0;i<numimgs;i++) {

   if (i == imgnum) {
      document.getElementById(name+'_'+i).style.display="block";
   } else {
      document.getElementById(name+'_'+i).style.display="none";
   }
}

newimgnum = (imgnum + 1) % 6;
setTimeout('imgrot("'+name+'",'+numimgs+','+timedelay+','+newimgnum+')',timedelay*1000);

}

/************************************************************
*
* clinks
*
************************************************************/

function clinks(pcid,homescreen) {

// Need random number because IE caches AJAX calls

var randomnumber=Math.floor(Math.random()*1000);

// Function parameters are not global
if (homescreen == 1) {

   cid = pcid;
   aid = pcid + "0";

} else {

   cid = pcid.substring(0,6);
   aid = pcid;
  
}

cn = new Array();

var counturl   = "/post/"+cid+"count.txt?r="+randomnumber;

// alert(counturl);

req1 = getXMLHttpRequest();

req1.onreadystatechange=LoadComCounts;
req1.open("GET",counturl,true);
req1.send(null);

}

/************************************************************
*
* LoadComCounts
*
************************************************************/


function LoadComCounts() {

if(req1.readyState==4) {

   // alert(req1.responseText);

   if (req1.responseText.match(/CLINKS/)) {

      var cn1 = new Array();
      var cn2 = new Array();

      cn1 = req1.responseText.split("|");

      for (i=1;i<cn1.length-1;i++) {

         cn2 = cn1[i].split(",");
         cncount = cn2[1].replace(/\D/g,'');
         cn[cn2[0]] = cncount;

      }

   }

   if (cn[aid] > 0) {

      count = cn[aid];

   } else {

      count = 0;

   }

   document.getElementById('clink').innerHTML = '<a href="javascript:popwin(\''+cgiscript+'?g=cs&cid='+aid+'\',\'comwin'+aid+'\',525,650,50,50,\'00000000001\')"><b><i>COMMENTS</a> about this article ('+count+')</i></b>';

}

}

/************************************************************
*
* emailpop
*
************************************************************/

function emailpop(contentid) {

return overlib('<form style=margin:0px; name=emailpop'+contentid+' method=post action='+cgiscript+'><input type=hidden name=g value=><table border=0 width=100%><tr><td colspan=3><hr></td><td align=right valign=top><img src=/images/window-close.gif onclick=nd();nd();></td></tr><tr><td></td><td valign=top><span class=syssansfont><b>Email This Listing<br></span></td></tr><tr><td align=right><span class=syssansfont><b>To:</span></td><td colspan=2><input type=text name=emailaddr size=32></td></tr><tr><td></td><td colspan=2><table width=100% cellpadding=0 cellspacing=0><tbody id=ctlwait style=display:none><tr><td height=24><span class=syssansfont>&nbsp;&nbsp;&nbsp;&nbsp;<img src=/images/waiting.gif></td></tr></tbody><tbody id=ctl0><tr><td height=24><b><span style=cursor:pointer onclick=emailsendnow('+contentid+') id=loginlink><span class=syssansfont><font color=0000ff>&nbsp;&nbsp;SEND NOW</font></span></span></td></tr></tbody><tbody id=ctl1 style=display:none><tr><td height=24><b><span class=syssansfont><span style=cursor:pointer onclick=emailsendnow('+contentid+')>&nbsp;&nbsp;SENT!&nbsp;&nbsp;<font color=0000ff>SEND AGAIN</font></span></span></td></tr></tbody></form></table></td></tr></table>',LEFT, BELOW, FGCOLOR,'#e9dfef',STICKY,WIDTH,310);

}

/************************************************************
*
* emailsendnow
*
************************************************************/

function emailsendnow(contentid) {

eval('email=document.emailpop'+contentid+'.emailaddr.value');

if (! /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {

   alert("Please Enter A Valid Email Address.");
   eval('email=document.emailpop'+contentid+'.emailaddr.focus()');

} else {

 //  document.getElementById('ctl0').style.display='none';
 //  document.getElementById('ctl1').style.display='';
//document.getElementById('ctlwait').style.display='';

   if (emreq = getXMLHttpRequest()) {

      document.getElementById('ctl0').style.display='none';
      document.getElementById('ctl1').style.display='none';
      document.getElementById('ctlwait').style.display='';
 
      emreq.onreadystatechange=function() {

      if (emreq.readyState==4) {

         if (emreq.responseText.match(/OK/)) {

         nd();
         nd();
         return;

      } else {

         document.getElementById('lmess').innerHTML=emreq.responseText;
     
         if (lf == 1) {
     
            document.getElementById('ctl0').style.display='';
	    document.getElementById('ctlwait').style.display='none';

         } else {
     
            document.getElementById('ctl1').style.display='';
	    document.getElementById('ctlwait').style.display='none';
     
         }
 
         if (emreq.responseText.match(/An email with/)) {

            document.getElementById('ctl0').style.display = 'none';
            document.getElementById('ctlwait').style.display='none';
     	    document.getElementById('dt0').style.display = 'none';
     	    document.getElementById('e0').style.display = 'none';

         }

      }

   }

   }

   var poststr = "g=maMail&ema=" + encodeURI( email ) + "&emcid=" + encodeURI( contentid );

   emreq.open("POST",cgiscript,true);
   emreq.send(poststr);

}



}

}