/*marqueesHeight=160; //内容区高度
stopscroll=false; //这个变量控制是否停止滚动

with(marquees){
noWrap=false; //这句表内容区自动换行
style.width=140; //如果宽度设为0，它会被撑大
style.height=marqueesHeight;
style.overflowY="hidden"; //滚动条不可见
onmouseover=new Function("stopscroll=true"); //鼠标经过，停止滚动
onmouseout=new Function("stopscroll=false"); //鼠标离开，开始滚动
}
//这时候，内容区的高度是无法读取了。下面输出一个不可见的层"templayer"，稍后将内容复制到里面：
document.write('<div id=templayer style=position:absolute;z-index:1;visibility:hidden></div>');

function init(){ //初始化滚动内容
//多次复制原内容到"templayer"，直到"templayer"的高度大于内容区高度：
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
} //把"templayer"的内容的“两倍”复制回原内容区：
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
//设置连续超时，调用"scrollUp()"函数驱动滚动条：
setInterval("scrollUp()",30);
}
document.body.onload=init;
preTop=0; //这个变量用于判断滚动条是否已经到了尽头

function scrollUp(){ //滚动条的驱动函数
if(stopscroll==true) return; //如果变量"stopscroll"为真，则停止滚动 
preTop=marquees.scrollTop; //记录滚动前的滚动条位置
marquees.scrollTop+=1; //滚动条向下移动一个像素
//如果滚动条不动了，则向上滚动到和当前画面一样的位置
//当然不仅如此，同样还要向下滚动一个像素(+1)：
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight+1;
}
}
*/
function overTR(tr,color)
{ tr.bgColor= color; 
  tr.style.cursor="hand"; }
function outTR(tr,color)
{ tr.bgColor = color; 
  tr.style.cursor="default"; }
  
  
function doSel(Tbid,Strshow,Strhide,Otbid,Isurl)
{
 var Tbstatus=document.getElementById(Tbid).style.display;
 var arrotb
 arrotb=Otbid.split("|");
 if (Tbstatus=="none")
 {
  document.getElementById(Tbid).style.display="block";
  
  if (Isurl==0)
  {
   document.getElementById(Tbid+'t').style.backgroundColor =Strshow;
   document.getElementById(Tbid+'t').className='border3';
  }
  else
  {
   document.getElementById(Tbid+'t').style.backgroundImage='url("images/tabbg1.gif")';
  }
  for (i=1;i<=arrotb.length;i++){
   document.getElementById(arrotb[i-1]).style.display="none";
   
   if (Isurl==0)
   {
    document.getElementById(arrotb[i-1]+'t').style.backgroundColor=Strhide
    document.getElementById(arrotb[i-1]+'t').className ='border2';
   }
   else
   {
    document.getElementById(arrotb[i-1]+'t').style.backgroundImage='url("images/tabbg2.gif")';
   }
  }
 }
}

function Sel_Channel(Tbid,Strshow,Strhide,Otbid,Isurl)
{
	var funstr= "doSel('"+Tbid+"','"+Strshow+"','"+Strhide+"','"+Otbid+"',"+Isurl+")";
	//alert (funstr);
	setTimeout(funstr,200);	
}


function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_shLayers() { //v3.0
  var i,p,v,obj,args=MM_shLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

//跳转页面显示
function ShowPage(TotalPage,PageIndex,url){
document.write("<b>"+PageIndex+"/"+TotalPage+"</b>页 &nbsp; ");
if (PageIndex<6){PageLong=11-PageIndex;}
else
if (TotalPage-PageIndex<6){PageLong=10-(TotalPage-PageIndex)}
else{PageLong=5;}
for (var i=1; i <= TotalPage; i++) {
if (i < PageIndex+PageLong && i > PageIndex-PageLong || i==1 || i==TotalPage){
if (PageIndex==i){document.write("<font color=#cc0000>["+ i +"]</font>&nbsp;");}else{document.write("[<a href=?PageIndex="+i+"&"+url+">"+ i +"</a>]&nbsp;");}
}
}
document.write(" <input onblur='inPage=this.value' onkeydown=if((event.keyCode==13)&&(this.value!=''))window.location='?PageIndex='+this.value+'&"+url+"'; onkeyup=if(isNaN(this.value))this.value='' style='border:1px solid #555555;' size=3><Input type=button onclick=if(!isNaN(inPage))window.location='?PageIndex='+inPage+'&"+url+"'; value='跳转' ");
}
 
function ShowPage5(Totalcount,TotalPage,PageIndex,url){
document.write("共" +Totalcount + "条结果 <br>");
if (PageIndex<2){PageLong=5-PageIndex;}
else
if (TotalPage-PageIndex<3){PageLong=4-(TotalPage-PageIndex)}
else{PageLong=4;}
for (var i=1; i <= TotalPage; i++) {
if (i < PageIndex+PageLong && i >= PageIndex || i==1 || i==TotalPage){
if (PageIndex==i){document.write("<font color=#cc0000>["+ i +"]</font>&nbsp;");}else{document.write("[<a href=?PageIndex="+i+"&"+url+">"+ i +"</a>]&nbsp;");}
}
} 
}

//连接轮播
function scrollup(o,d,c){
	if(d==c){
		var t=o.firstChild.cloneNode(true);
		o.removeChild(o.firstChild);
		o.appendChild(t);
		t.style.marginTop=o.firstChild.style.marginTop='0px';
	}
	else{
		var s=3,c=c+s,l=(c>=d?c-d:0);
		o.firstChild.style.marginTop=-c+l+'px';
		window.setTimeout(function(){scrollup(o,d,c-l)},10);
	}
}


//搜索表单定向
 function mygoto(f)
			  {  
			     stype = f.stype.options[f.stype.selectedIndex].value;
			   //  alert(stype);
			    if(stype=="1")
			     {  f.action ="http://www.soupu.com/ChooseAddr/Result.aspx?ComName="+f.key.value;
			     }
			    else if(stype=="2")
			     {  f.action ="http://www.linkshop.com.cn/web/search.aspx?type=0";
			     }
			       else if(stype=="3")
			     {  f.action ="http://www.soupu.com/tuozhan/agentsearch.asp?comname="+f.key.value;
			     }
			     else
			      { f.action ="http://www.soupu.com/xinxi/tuijian.asp"; }
			       
			  }
			  
/************************************************** 
Description: 正确截取单字节和双字节混和字符串
String str : 要截取的字符串
Number		: 截取长度
**************************************************/
function SetString(str, len)
{
if(!str || !len) { return ''; }
//预期计数：中文2字节，英文1字节
var a = 0;
//循环计数
var i = 0;
//临时字串
var temp = '';
for (i=0;i<str.length;i++)
{
if (str.charCodeAt(i)>255)
{
//按照预期计数增加2
a+=2;
}
else
{
a++;
}
//如果增加计数后长度大于限定长度，就直接返回临时字符串
if(a > len) { return temp; }
//将当前内容加到临时字符串
temp += str.charAt(i);
}
//如果全部是单字节字符，就直接返回源字符串
return str;
}
