//程序[TL网点]版权所有 http://www.tlweb.net

//右键提示函数，TL编制
//参数：提示文本
function mouseright(text)
{ text_title=text;
  document.onmousedown=function(){if(event.button>=2){alert(text_title);return false;}else return true;}
}

//得到随机整数函数，TL编制
//参数：随机整数上限
function getrandom(n)
{
var m;
m=Math.floor(Math.random()*(n+1));
if(m>n) m=n; else if(m<0) m=0;
return m.toString();
}

//网页标题闪烁函数，TL编制
//参数：标题名
function flash_title(pagename)
{
var tl_now=new Date();
if(tl_now.getSeconds()%2==0)
 document.title=pagename+" ";
 else
 document.title=" "+pagename;
delete tl_now;
setTimeout("flash_title(\""+pagename+"\")",1000);
}

//彩色文本函数，TL编制
//参数：文本,色彩("r"--红,"g"--绿,"b"--蓝,"w"--白,缺省时为白),方向("|"--纵向,"-"--横向,缺剩时为横向)
function colortext(text,textcolor,hv)
{
var l,i,r,c1,c2,c3;
if(typeof(hv)=='undefined') hv="-";
if(typeof(textcolor)=='undefined') textcolor="w"; else textcolor=textcolor.toLowerCase();
if(textcolor=="w"||textcolor=="r"||textcolor=="g"||textcolor=="b")
 {
   r=Math.random()*50;
   l=text.length;
   for(i=0;i < l;i++)
    {
      switch (textcolor)
       {
        case "w":
           c1=c2=c3=Math.floor((l-i)/l*40+215);
           break;
        case "r":
           c1=255; c2=Math.floor(r*Math.sin(i/l)); c3=Math.floor(i/l*r);
           break;
        case "g":
           c2=255; c3=Math.floor(r*Math.sin(i/l)); c1=Math.floor(i/l*r);
           break;
        case "b":
           c3=255; c1=Math.floor(r*Math.sin(i/l)); c2=Math.floor(i/l*r);
           break;
       } 
      document.write(text.substring(i,i+1).fontcolor("#"+I_to_C(c1)+I_to_C(c2)+I_to_C(c3)));
      if(hv=="|") document.write("<BR>");
    }
 }
 else
   document.write(text.fontcolor(textcolor));
}

function I_to_C(I)
{ var c1=Math.floor(I/16),c2=I%16;
  return String.fromCharCode(c1>9?55+c1:48+c1,c2>9?55+c2:48+c2);
}

//无刷新请求服务器节点数据函数，TL编制
//参数：请求ASP文件名,节点名
//返回值:发送到客户端文本
function guestsend_nodedata(aspfile,node_data)
{ var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  xmlhttp.Open("POST",aspfile,false);
  xmlhttp.Send("<NODE>"+escape(node_data)+"</NODE>");
  return unescape(xmlhttp.responseText);
}

//视频播放函数，TL编制
//参数：请求URL文件位置,播放器宽度
//返回值:HTML
function playtv(url,tv_width)
{ var tv_width_=Math.floor(tv_width).toString(),tv_height_=Math.floor(tv_width*0.75+66).toString(),wh;
  if(tv_width>0)
    wh='width="'+tv_width_+'" height="'+tv_height_+'"';
   else
    wh='';
  return '<object '+wh+' classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6">  <param name="URL" value="'+url+'">  <param name="rate" value="1">  <param name="balance" value="0">  <param name="currentPosition" value="0">  <param name="defaultFrame" value="">  <param name="playCount" value="1">  <param name="autoStart" value="-1">  <param name="currentMarker" value="-1">  <param name="invokeURLs" value="0">  <param name="baseURL" value="">  <param name="volume" value="80">  <param name="mute" value="0">  <param name="uiMode" value="full">  <param name="stretchToFit" value="0">  <param name="windowlessVideo" value="0">  <param name="enabled" value="-1">  <param name="enableContextMenu" value="0">  <param name="fullScreen" value="0">  <param name="SAMIStyle" value="">  <param name="SAMILang" value="">  <param name="SAMIFilename" value="">  <param name="captioningID" value="">  </object>';
}

//重新调整父框架尺寸函数，TL编制
//参数：调整的宽度(正数为固定文本宽度、负数为最小文本宽度),调整的高度(正数为固定文本高度、负数为最小为文本高度)
function resize(w,h)
{ var doc=document,p=window,frames,frame;
  while(p=p.parent)
   { frames=p.frames;
     frame=frames[1];
     if(frame.document==doc)
      { with(frame.frameElement.style)
         { height=(h<0?Math.max(parseInt(doc.body.scrollHeight),-h):h).toString();
           width=(w<0?Math.max(parseInt(doc.body.scrollWidth),-w):w).toString();
           doc=p.document;
         }
        break;
      }
     if(p==top) break;
   }
}

//客户端得到Cookie编码值函数（中间函数），TL编制
//参数：位置
function getCookieVal_(offset)
{ var endstr=document.cookie.indexOf(";",offset);
  if(endstr==-1) endstr=document.cookie.length;
  return document.cookie.substring(offset,endstr);
}

//客户端得到Cookie编码值函数（中间函数），TL编制
//参数：Cookie名
function getCookie_(name)
{ var arg=name.toUpperCase()+"=",alen=arg.length,clen=document.cookie.length,i=0,j;
  while(i<clen)
   { j=i+alen;
     if(document.cookie.substring(i,j).toUpperCase()==arg) return getCookieVal_(j); 
     i=document.cookie.indexOf(" ",i)+1; 
     if(i==0) break; 
   } 
  return null; 
}

//客户端得到Cookie值函数，TL编制
//参数：Cookie名
function getCookie(name)
{ var c=getCookie_(name);
  if(c==null)
     return c;
   else
     return unescape(c);
}

//客户端得到子Cookie值函数，TL编制
//参数：Cookie名,子Cookie名
function getSubCookie(name,subname)
{ var i,j,c,c0=subname.toUpperCase(),s=getCookie_(name).split("&");
  for(i=0;i<s.length;i++)
   { c=s[i].split("=")
     if(c[0].toUpperCase()==c0) return unescape(c[1]);
   }
  return null;
}
