/*首页最新供应、求购信息，每5分钟刷新一次*/

$=function(id){
	return document.getElementById(id);
}

function clickTime()
{
var thistime = new Date();
var years	 = thistime.getYear();
var days	 = thistime.getDay();
var hours	 = thistime.getHours();
var minutes  = thistime.getMinutes();
var seconds  = thistime.getSeconds();
var lastDate = new Date(thistime.getYear(), thistime.getMonth(), thistime.getDate(),hours,5*parseInt(minutes/5));
if(hours>17||hours<9){
document.getElementById("mainbody").parentNode.className="row1_";
if(hours>=18){
document.getElementById("mainbody").innerHTML = "下次更新时间是明日9:00";
}else{
document.getElementById("mainbody").innerHTML = "下次更新时间是今日9:00";
}
document.getElementById("lastTime").innerHTML="上次更新时间18:00";
}else{
document.getElementById("mainbody").parentNode.className="row1";
minutes = 4 - minutes % 5;
seconds = 59 - seconds;
var smin = lastDate.getMinutes();
if(smin<10)smin="0"+smin;
document.getElementById("lastTime").innerHTML="上次更新时间"+(lastDate.getHours())+":"+smin;
if(minutes == 0 && seconds == 0){
//window.location.reload();
document.getElementById('timeIframe').src='searchhomepage.asp';
}else{
if(minutes<10)minutes="0"+minutes;
if(seconds<10)seconds="0"+seconds;
thistime = minutes + ":" + seconds;
document.getElementById("mainbody").innerHTML = thistime;
}
}
setTimeout("clickTime()",1000);
}
/*
*以下函数从chinajs_v1.js文件中拷贝过来
*2008-12-15 wjh
*/
function MM_findObj(n, d) { //v4.01
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 && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.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 tp_search(o){
var v = o.keywords.value;
var _d=$("ss_dl")
if(v.length > 100){
alert("您输入的关键字过长！");
return false;
}
if(v == ""  || v.substring(0,3) =="请输入") {
alert("请输入关键字！");
return false;
}
}

function sr_onfocus(o){
var v = o.value;
if(v.substring(0,3) =="请输入")o.value = ""
o.style.color="#000";
}

function sr_ra_1(o){
if(k=$("sr_keyw")){
if(""==k.value || "请输入"==k.value.substring(0,3)){
k.value = o.title
k.style.color = "#AAB7C7"
}

//$("sel_ra").value = o.title
//var a = o.value.split("||")
$("sr_fm").action = o.value;
//$("sr_fm").tracelog.value = a[1]
}
}

function getCookie(sName) {
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
return null;
}

function getCookieEr(cookie_name,_name) {

var allcookies = document.cookie;
var cookie_pos = allcookies.indexOf(cookie_name);

// 如果找到了索引，就代表cookie存在， 反之，就说明不存在。

if (cookie_pos != -1)
{
// 把cookie_pos放在值的开始，只要给值加1即可。
cookie_pos += cookie_name.length + 1;
var cookie_end = allcookies.indexOf(";", cookie_pos);

if (cookie_end == -1)
{
	cookie_end = allcookies.length;
}

var value = unescape(allcookies.substring(cookie_pos, cookie_end));
	if (value.indexOf("&")>0)
	{
		_arr=value.split("&");
		for (var i=0; i<_arr.length ; i++ )
		{
			_arr2=_arr[i].split("=");
			if (_arr2[0] == _name)
			{
				_value = _arr2[1];
			}
		}
		return _value;
	}
	else
	{
		var _arr = value.split("=");
		if (_arr[0] == _name)
		{
			return _arr[1];
		}
	}
}
}


/*
*以下函数从buz.js文件中拷贝过来
*2008-12-16 wjh
*/
Namespace = new Object();
Namespace.register = function(namespace){
	var nsArray = namespace.split('.');
	var sEval = "";
    var sNS = "";
	for (var i = 0; i < nsArray.length; i++){
        if (i != 0) sNS += ".";
        sNS += nsArray[i];
        sEval += "if (typeof(" + sNS + ") == 'undefined') " + sNS + " = new Object();"
    }
    if (sEval != "") eval(sEval);
}
Namespace.register("Hc.util.setDiv");
Namespace.register("Hc.util.showDiv");
(function(){
	var initheight,totalheight;
	Hc.util.setDiv = {
		init:function(el,con,nums,overclassname,outclassname,speed,maxheight){
			var arg = new Array();
			for(i=0;i<arguments.length;i++){
				arg[i] = arguments[i];
			}
			for(j=1;j<=parseInt(arg[2]);j++){
				tagBox = $(arg[0] + j);
				hidBox = $(arg[1] + j);
				tagBox.m = j;
				hidBox.m = j;
				tagBox.onmouseover=function(){Hc.util.showDiv.slideshow(arg,this.m);};
				tagBox.onmouseout=function(){Hc.util.showDiv.slideshow(arg,this.m);};
				hidBox.onmouseover=function(){Hc.util.showDiv.slideshow(arg,this.m);};

			}
			Hc.util.showDiv.slideshow(arg,1);
		},
	
		build:function(el,className,targetName,cookiename){
			totalheight = 0;
			var mb_arr = new Array();
			var childtag = el.getElementsByTagName(targetName);
			for(i=0;i<childtag.length;i++){
				if(childtag[i].className==className){
					with(childtag[i].style){
						position = "absolute";
						top = totalheight + "px";
					}
					totalheight = totalheight + childtag[i].scrollHeight ;
					mb_arr[mb_arr.length] = childtag[i].id;
				}
			}
			el.style.height = totalheight + "px";
			Hc.util.move.init(el,mb_arr,cookiename);
		},
	
		rebuild:function(movebox,cookieValue,cookiename){
			totalheight = 0;
			var mb_arr = cookieValue.split("&");
			for(var i=0;i<mb_arr.length;i++){
				$(mb_arr[i]).style.position = "absolute";
				$(mb_arr[i]).style.top = totalheight + "px";
				totalheight = totalheight + $(mb_arr[i]).scrollHeight ;
			}
			movebox.style.height = totalheight + "px";
			Hc.util.move.init(movebox,mb_arr,cookiename);
		},

	
		tabDivinit:function(nums,tab,con,curClassName,speed,oEvent){
			var t = oEvent;
			var arg = new Array;
			for(i=0;i<arguments.length;i++){
				arg[i] = arguments[i];
			}
			for(var j=0;j<arg[0];j++){
				var curtab = $(arg[1] + j);
				curtab.n = j;
				switch(t){
					case 'click':
						curtab.onclick = function(){Hc.util.showDiv.show(arg,this.n);};
						break;
					default:
						curtab.onmouseover = function(){Hc.util.showDiv.show(arg,this.n);};
						break;
				}
			}
			return arg;
		}
	};
})();


(function(){
	var pos;
	var showpos;
	Hc.util.showDiv = {
	
		show:function(arg,id){
			var curtab,curobj;
			curobj = this;
			var useArg = new Array;
			for(j=0;j<arg.length;j++){
				useArg[j] = arg[j];
			}
			for(var i=0;i<useArg[0];i++){
				curtab = $(useArg[1] +i);
				if(i==id){ 
					curtab.className = useArg[3];
					$(useArg[2]+i).style.display = "block";
				}else{
					curtab.className = '';
					$(useArg[2]+i).style.display = "none";
				}
			}	
		},

	
		autoshow:function(arg){
			var time1,curobj,curtab,curnum,bpos;
			curnum = 1;
			curobj = this;
			bpos = 0;
			var useArg = new Array;
			for(j=0;j<arg.length;j++){
				useArg[j] = arg[j];
			}
			this.show(useArg,0);
			function ctrl(){
				time1 = setInterval(function(){
					if(curnum>=useArg[0]) curnum=0;
					bpos = curnum;
					curobj.show(useArg,curnum);
					curnum++;
				},useArg[4])
			}
			ctrl();
			for(var i=0;i<useArg[0];i++){
				curtab = $(useArg[1] +i);
				switch(useArg[5]){
					case 'click':
						curtab.onclick = function(){curobj.show(useArg,this.n);};
						curtab.onmouseover = function(){clearInterval(time1);bpos=this.n;}
						break;
					default:
						curtab.onmouseover = function(){clearInterval(time1);curobj.show(useArg,this.n);bpos=this.n;};
						break;
				}
				$(useArg[2] +i).onmouseover = function(){clearInterval(time1);bpos++;}
				$(useArg[2] +i).onmouseout = function(){

					curnum = bpos;
					ctrl();
				}
				curtab.onmouseout = function(){

					curnum = bpos;
					ctrl();
				}
			}
		},
	
		slideshow:function(arg,id){
			var curobj = new Array();
			for(j=0;j<arg.length;j++){
				curobj[j] = arg[j];
			}
			var tagBox,hidBox;
			var ctrl = 0;
			if((id!=pos)||(pos==null)){
				for(i=1;i<=parseInt(curobj[2]);i++){
					tagBox = $(curobj[0] + i);
					hidBox = $(curobj[1] + i);
					if(i==id){
						pos=id;
						tagBox.className = curobj[3];
						hidBox.style.display = "block";
	
						hidBox.style.height = curobj[6] + "px";
					}else{
							hidBox.style.height = "0px";
							tagBox.className = curobj[4];
							hidBox.style.display = "none";
					}
				}
			}
		}
		
	}
})();
/*end*/

/*
*以下函数从hcmarquee.js文件中拷贝过来
*实现顶部三个图片的滚动效果
*2008-12-16 wjh
*/
// Useage: HCmarquee(滚动对象id, 可见范围宽度, 可见范围高度, 滚动条数, 可见条数, 滚动速度, 停留时间, 方向); 方向有left和up两种
function HCmarquee(id,mw,mh,mr,sr,ms,pause){
	
	var obj=document.getElementById(id);
	obj.ss=false; //stop tag
	obj.mr=mr; //marquee rows
	obj.sr=sr; //marquee display rows
	obj.mw=mw; //marquee width
	obj.mh=mh; //marquee height
	obj.ms=ms; //marquee speed
	obj.pause=pause; //pause time
	obj.pt=0; //pre top
	obj.st=0; //stop time
	obj.mul=1;
	obj.con="";
	with(obj){
		style.width=mw+"px";
		style.height=mh+"px";
		noWrap=false;
		onmouseover=stopm;
		onmouseout=startm;
		scrollTop=0+"px";
		scrollLeft=0+"px";
	}

	if(obj.mr!=1){
				obj.tt=mh*mr/sr;
				obj.ct=mh; //current top
				obj.innerHTML+=obj.innerHTML;
				setInterval(scrollUp,obj.ms);
	}
	function scrollUp(){
		if(obj.ss==true) return;
		obj.ct+=1;
		if(obj.ct==obj.mh+1){
			obj.st+=1; obj.ct-=1;
			if(obj.st==(obj.pause*obj.mul)){
				obj.ct=0; obj.st=0;
				if(obj.mul==1) obj.mul = 1;
				else obj.mul = 1;
			}
		}else {
			obj.pt=(++obj.scrollTop);
			if(obj.pt==obj.tt){obj.scrollTop=0;}
		}
	}

	function stopm(){obj.ss=true;}
	function startm(){obj.ss=false;}
	
}
/*end*/


//]]>


