
function SetCookie(name,value){
	
     var argv=SetCookie.arguments;
     var argc=SetCookie.arguments.length;
     var expires=(2<argc)?argv[2]:null;
     var path=(3<argc)?argv[3]:null;
     var domain=(4<argc)?argv[4]:null;
     var secure=(5<argc)?argv[5]:false;
     //domain = "hc360.com";
     //path = "/";
     //document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
     //alert("value==" + value);
     var exp="";
     var dt=new Date(); 
	 dt.setTime(dt.getTime()+(1800000)); 
	 exp="; expires="+dt.toGMTString();
     //document.cookie=name+"="+escape(value)+exp+";path=/;domain=b2b.hc360.com"; 
     /*
     var exp="";
	 var dt=new Date(); 
	 dt.setTime(dt.getTime()+1800000); 
	 exp="; expires="+dt.toGMTString();
	 document.cookie=name+"="+escape(value)+exp+";path=/;domain=hc360.com"; */
}
function GetCookie(Name) {
	
	 var m=""; 
	 if(window.RegExp){ 
		var re=new RegExp(";\\s*"+Name+"=([^;]*)","i"); 
		m=re.exec(';'+document.cookie); 
	 } 
	 return(m?unescape(m[1]):"");
	/*
     var search = Name + "=";
     var returnvalue = "";
     if (document.cookie.length > 0) {
           offset = document.cookie.indexOf(search);
           if (offset != -1) {      
                 offset += search.length;
                 end = document.cookie.indexOf(";", offset);                        
                 if (end == -1)
                       end = document.cookie.length;
                 returnvalue=unescape(document.cookie.substring(offset,end));
           }
     }
     return returnvalue; */
}

function vh(objstr){
	if(document.getElementById(objstr).style.display=="none"){
		document.getElementById(objstr).style.display="block";
	}else{
		document.getElementById(objstr).style.display="none";
	}
}
function vh2(objstr,onbj){
	if(document.getElementById(objstr).style.display=="none"){
		document.getElementById(objstr).style.display="block";
		onbj.className='st_h3_1';
	}else{
		document.getElementById(objstr).style.display="none";
		onbj.className='st_h3_2';
	}
}

//XMLHTTPREQUEST
// IE support
if (window.ActiveXObject && !window.XMLHttpRequest)
{
		window.XMLHttpRequest = function()
				{
						var msxmls = new Array('Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP');
						for (var i = 0; i < msxmls.length; i++)
						{
								try 
								{
										return new ActiveXObject(msxmls[i]);
								} 
								catch (e)
								{
								}
						}
						return null;
				};
}
 
// Gecko support
// Opera support
if (window.opera && !window.XMLHttpRequest)
{
		window.XMLHttpRequest = function()
		{
				this.readyState = 0; // 0=uninitialized,1=loading,2=loaded,3=interactive,4=complete
				this.status = 0; // HTTP status codes
				this.statusText = '';
				this._headers = [];
				this._aborted = false;
				this._async = true;
				this._defaultCharset = 'ISO-8859-1';
				this._getCharset = function() 
				{
						var charset = _defaultCharset;
						var contentType = this.getResponseHeader('Content-type').toUpperCase();
						val = contentType.indexOf('CHARSET=');
						if (val != -1) 
						{
								charset = contentType.substring(val);
						}
						val = charset.indexOf(';');
						if (val != -1)
						{
								charset = charset.substring(0, val);
						}
						val = charset.indexOf(',');
						if (val != -1)
						{
								charset = charset.substring(0, val);
						}

						return charset;
				};
 
				this.abort = function()
				{
						this._aborted = true;
				};
 
				this.getAllResponseHeaders = function()
				{
						return this.getAllResponseHeader('*');
				};
 
				this.getAllResponseHeader = function(header)
				{
						var ret = '';
						for (var i = 0; i < this._headers.length; i++)
						{
								if (header == '*' || this._headers[i].h == header)
								{
										ret += this._headers[i].h + ': ' + this._headers[i].v + 'n';
								}
						}
						return ret;
				};
 
				this.getResponseHeader = function(header)
				{
						var ret = getAllResponseHeader(header);
						var i = ret.indexOf('n');
						if (i != -1)
						{
								ret = ret.substring(0, i);
						}
						return ret;
				};
 
				this.setRequestHeader = function(header, value)
				{
						this._headers[this._headers.length] = {h:header, v:value};
				};
 
				this.open = function(method, url, async, user, password)
				{
						this.method = method;
						this.url = url;
						this._async = true;
						this._aborted = false;
						this._headers = [];
						if (arguments.length >= 3) 
						{
								this._async = async;
						}
						if (arguments.length > 3) 
						{
								opera.postError('XMLHttpRequest.open() - user/password not supported');
						}
						this.readyState = 1;
						if (this.onreadystatechange)
						{
								this.onreadystatechange();
						}
				};
 
				this.send = function(data)
				{
						if (!navigator.javaEnabled())
						{
								alert("XMLHttpRequest.send() - Java must be installed and enabled.");
								return;
						}
						if (this._async)
						{
								setTimeout(this._sendasync, 0, this, data);
						} 
						else
						{
								this._sendsync(data);
						}
				};
 
				this._sendasync = function(req, data)
				{
						if (!req._aborted)
						{
								req._sendsync(data);
						}
				};
 
				this._sendsync = function(data)
				{
						this.readyState = 2;
						if (this.onreadystatechange)
						{
								this.onreadystatechange();
						}
						var url = new java.net.URL(new java.net.URL(window.location.href), this.url);
						var conn = url.openConnection();
						for (var i = 0; i < this._headers.length; i++)
						{
								conn.setRequestProperty(this._headers[i].h, this._headers[i].v);
						}
						this._headers = [];
						if (this.method == 'POST')
						{
						// POST data
								conn.setDoOutput(true);
								var wr = new java.io.OutputStreamWriter(conn.getOutputStream(), this._getCharset());
								wr.write(data);
								wr.flush();
								wr.close();
						}
						// read response headers
						// NOTE: the getHeaderField() methods always return nulls for me :(
						var gotContentEncoding = false;
						var gotContentLength = false;
						var gotContentType = false;
						var gotDate = false;
						var gotExpiration = false;
						var gotLastModified = false;
						for (var i = 0; ; i++)
						{
								var hdrName = conn.getHeaderFieldKey(i);
								var hdrValue = conn.getHeaderField(i);
								if (hdrName == null && hdrValue == null)
								{
										break;
								}
								if (hdrName != null)
								{
										this._headers[this._headers.length] = {h:hdrName, v:hdrValue};
										switch (hdrName.toLowerCase())
										{
												case 'content-encoding': gotContentEncoding = true; break;
												case 'content-length' : gotContentLength = true; break;
												case 'content-type' : gotContentType = true; break;
												case 'date' : gotDate = true; break;
												case 'expires' : gotExpiration = true; break;
												case 'last-modified' : gotLastModified = true; break;
										}
								}
						}
						// try to fill in any missing header information
						var val;
						val = conn.getContentEncoding();
						if (val != null && !gotContentEncoding) this._headers[this._headers.length] = {h:'Content-encoding', v:val};
						val = conn.getContentLength();
						if (val != -1 && !gotContentLength) this._headers[this._headers.length] = {h:'Content-length', v:val};
						val = conn.getContentType();
						if (val != null && !gotContentType) this._headers[this._headers.length] = {h:'Content-type', v:val};
						val = conn.getDate();
						if (val != 0 && !gotDate) this._headers[this._headers.length] = {h:'Date', v:(new Date(val)).toUTCString()};
						val = conn.getExpiration();
						if (val != 0 && !gotExpiration) this._headers[this._headers.length] = {h:'Expires', v:(new Date(val)).toUTCString()};
						val = conn.getLastModified();
						if (val != 0 && !gotLastModified) this._headers[this._headers.length] = {h:'Last-modified', v:(new Date(val)).toUTCString()};
						// read response data
						var reqdata = '';
						var stream = conn.getInputStream();
						if (stream)
						{
								var reader = new java.io.BufferedReader(new java.io.InputStreamReader(stream, this._getCharset()));
								var line;
								while ((line = reader.readLine()) != null)
								{
										if (this.readyState == 2)
										{
												this.readyState = 3;
												if (this.onreadystatechange)
												{
														this.onreadystatechange();
												}
										}
										reqdata += line + '\n';
								}
								reader.close();
								this.status = 200;
								this.statusText = 'OK';
								this.responseText = reqdata;
								this.readyState = 4;
								if (this.onreadystatechange)
								{
										this.onreadystatechange();
								}
								if (this.onload)
								{
										this.onload();
								}
						}
						else
						{
								// error
								this.status = 404;
								this.statusText = 'Not Found';
								this.responseText = '';
								this.readyState = 4;
								if (this.onreadystatechange)
								{
										this.onreadystatechange();
								}
								if (this.onerror)
								{
										this.onerror();
								}
						}
				};
		};
}
 
// ActiveXObject emulation
if (!window.ActiveXObject && window.XMLHttpRequest)
{
		window.ActiveXObject = function(type)
		{
				switch (type.toLowerCase())
				{
						case 'microsoft.xmlhttp':
								case 'msxml2.xmlhttp':
								case 'msxml2.xmlhttp.3.0':
								case 'msxml2.xmlhttp.4.0':
								case 'msxml2.xmlhttp.5.0':
								return new XMLHttpRequest();
				}
				return null;
		};
}

//url 
//senddata 
//returntype xml:xmldoc,else htmltext
var http_request = false;
var responsetype = 'txt';
var whichobjid;
	function GetResponse(url,senddata,returntype,sourceobjid){
	//alert('url=='+url);
	//alert('returntype=='+returntype);
	//alert('returntype=='+sourceobjid);
	if(url){
		responsetype = returntype;
		whichobjid = sourceobjid;
		//new XMLHttpRequest
		http_request=new XMLHttpRequest();
		//Response
		if(http_request){
			http_request.onreadystatechange=getRequestResult;
			
			http_request.open('POST',url,true);

			//http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');    
			http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-1' );
			  //alert("run this is url==="+url+"    senddata==="+senddata);                             
			if(senddata==''){
				http_request.send(null);
			}
			else{
				http_request.send(senddata);
			}
		}
  }
}
function getRequestResult(){ 
//readyState 
/*
????(integer):
0 = ????
1 = ???
2 = ???
3 = ???
4 = ??
*/
	if(http_request.readyState==4){
//status
/*
????
//404 = "?????" 
//200 ="??"
*/
		if(http_request.status==200){
			var doc = null;
			if(responsetype == 'xml'){
				doc =  http_request.responseXML;
			}
			else{
				doc = http_request.responseText;
			}
			//????????
			//alert("run this is ajax doc===="+whichobjid);
			//alert(doc.getElementsByTagName("FirstCat").length);
			BusinessFunc(doc,whichobjid);
		}
		else if(http_request.status==404){
			alert('??????????????');
		}
		else {
			alert ('status = '+http_request.status);
		}
	}
}

////////////////////////////////////////////////////////////////////////////////////
// CONFIGURATION
////////////////////////////////////////////////////////////////////////////////////

// 主背景色（大区域）
// 通常使用明快的颜色（浅黄色等...）
	if (typeof fcolor == 'undefined') { var fcolor = "FFFFDD";}
	
// Border的颜色和标题栏的颜色；
// 通常的颜色深（褐色，黑色等。）
	if (typeof backcolor == 'undefined') { var backcolor = "#FFDA8C";}
	
	
// 文字的颜色
// 通常是比较深的颜色；
	if (typeof textcolor == 'undefined') { var textcolor = "#993300";}
	
// 标题的颜色
// 通常是明快的颜色；
	if (typeof capcolor == 'undefined') { var capcolor = "#FFFFFF";}
	
// "Close"的颜色
// 通常是明快的颜色；
	if (typeof closecolor == 'undefined') { var closecolor = "#9999FF";}
	
	
// 弹出的窗口的宽度；
// 100-300 pixels 合适
	if (typeof width == 'undefined') { var width = "200";}
	
// 边缘的宽度，象素。
// 1-3 pixels 合适
	if (typeof border == 'undefined') { var border = "1";}
	
	
// 弹出窗口位于鼠标左侧或者右侧的距离，象素。
// 3-12合适
	if (typeof offsetx == 'undefined') { var offsetx = 10;}
	
// 弹出窗口位于鼠标下方的距离；
// 3-12 合适
	if (typeof offsety == 'undefined') { var offsety = 10;}
	
////////////////////////////////////////////////////////////////////////////////////
// 设置结束
////////////////////////////////////////////////////////////////////////////////////

// 以下是页面中使用的公共函数；

// Simple popup right
function drs(text) {
	dts(1,text);
}


// Clears popups if appropriate
function nd() {
	if ( cnt >= 1 ) { sw = 0 };
	if ( (ns4) || (ie4) ) {
		if ( sw == 0 ) {
			snow = 0;
			hideObject(over);
		} else {
			cnt++;
		}
	}
}

// 非公共函数，被其它的函数调用；

// Simple popup
function dts(d,text) {
	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD CLASS=P1><FONT FACE=\"宋体\" COLOR=\""+textcolor+"\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp();
}



// Common calls
function disp() {
	if ( (ns4) || (ie4) ) {
		if (snow == 0) 	{
			if (dir == 2) { // Center
				moveTo(over,x+offsetx-(width/2),y+offsety);
			}
			if (dir == 1) { // Right
				moveTo(over,x+offsetx,y+offsety);
			}
			if (dir == 0) { // Left
				moveTo(over,x-offsetx-width,y+offsety);
			}
			showObject(over);
			snow = 1;
		}
	}
// Here you can make the text goto the statusbar.
}

// Moves the layer
function mouseMove(e) {
	if (ns4) {x=e.pageX; y=e.pageY;}
	if (ie4) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
	if (ie5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
	if (snow) {
		if (dir == 2) { // Center
			moveTo(over,x+offsetx-(width/2),y+offsety);
		}
		if (dir == 1) { // Right
			moveTo(over,x+offsetx,y+offsety);
		}
		if (dir == 0) { // Left
			moveTo(over,x-offsetx-width,y+offsety);
		}
	}
}

// The Close onMouseOver function for Sticky
function cClick() {
	hideObject(over);
	sw=0;
}

// Writes to a layer
function layerWrite(txt) {
        if (ns4) {
                var lyr = document.overDiv.document
                lyr.write(txt)
                lyr.close()
        }
        else if (ie4) document.all["overDiv"].innerHTML = txt
		if (tr) {  }
}

// Make an object visible
function showObject(obj) {
        if (ns4) obj.visibility = "show"
        else if (ie4) obj.visibility = "visible"
}

// Hides an object
function hideObject(obj) {
        if (ns4) obj.visibility = "hide"
        else if (ie4) obj.visibility = "hidden"
}

// Move a layer
function moveTo(obj,xL,yL) {
        obj.left = xL
        obj.top = yL
}

function VisitList(count)
{
	var pagesize = count;
	var visitinit = 0;
	
	for(i=0;i<pagesize;i++)
	{
   	var allcount = hcvisitresult[i];
	   if(allcount.length<3){
	   		allcount = "0,0"
	   	}
	 	var arrcount = allcount.split(",");
		var aa = document.getElementById('Totalvisit'+i);//总浏览次数
		var bb = document.getElementById('Todayvisit'+i);//今日浏览次数
		
		if (aa!=null){
				aa.innerText = arrcount[0];
			}
		if (bb !=null){
				//bb.innerText = arrcount[1];
			}

  }
}

function VipVisitCount(){
	var count = countStr;
	var arrcount = count.split(":");
	
	var totalvisit = document.getElementById('totalvisit');//总的访问次数
	var businvisit = document.getElementById('businvisit');//商业机会访问次数
	var provisit = document.getElementById('provisit');//产品访问次数
	var corvisit = document.getElementById('corvisit');//商铺访问次数
	var personvisit = document.getElementById('personvisit');//网络名片访问次数
		
		if(totalvisit!=null){
			totalvisit.innerText = arrcount[0];
			}
		
		if(businvisit!=null){
			businvisit.innerText = arrcount[1];
			}
		
		if(provisit!=null){
			provisit.innerText = arrcount[2];
			}
		
		if(corvisit!=null){
			corvisit.innerText = arrcount[3];
			}
		
		if(personvisit!=null){
			personvisit.innerText = arrcount[4];
			}
}

function SendData(url,objid,returntype,sourceobjid){
	var sendstr = '';	
	document.domain = "b2b.hc360.com";
	if(objid){
		var obj = document.getElementById(objid);
		//alert(obj);
		var sendstr = obj.name+'='+obj.value;
  	}
	GetResponse(url,sendstr,returntype,sourceobjid);			
}

function BusinessFunc(obj,whichobjid){
	//alert("obj=" + obj);	
	if(obj == '1' || obj == '-1') {
		//errorFlag = 0;		
		document.getElementById(whichobjid).innerText = "你输入的用户名不存在或无效！";
		document.getElementById(whichobjid).style.display = "";
	}else if(obj == '0'){
		document.getElementById(whichobjid).innerText = "";
		document.getElementById(whichobjid).style.display = "none";
		
		//alert("type="+document.getElementById('frd_operate_type').value);
		//alert("form="+document.getElementById('frd_operate_form').value);
		var op_type = document.getElementById('frd_operate_type').value;
		if(op_type == '1') {
			//提交友情操作
			var f_info_id = document.getElementById('frd_operate_infoid').value;
			var frd_operate_form = document.getElementById('frd_operate_form').value;
			if(f_info_id == ''){
				addFriendLink(3,whichobjid);
			}else {
				//alert("frd_operate_form=" + frd_operate_form);
				editFriendLink(editFriendLink, document.getElementById(frd_operate_form));
			}
			document.getElementById('frd_operate_type').value="";
			document.getElementById('frd_operate_form').value="";
			document.getElementById('frd_operate_infoid').value="";
		}
		
		
		

		//friendAddForm.action="$link.setPage("shop,async,changefriendlink.html")";
	//friendAddForm.submit();
	}	
}

//企业网站1.1新增 2009-08-14 added by weiwei
function slideLine(ul, delay, speed, lh) {
	var slideBox = (typeof ul == 'string')?document.getElementById(ul):ul;
	var delay = delay||1000, speed=speed||20, lh = lh||20;
	var tid = null, pause = false;
	var start = function() {
	tid=setInterval(slide, speed);
	}
	var slide = function() {
	if (pause) return;
	slideBox.scrollTop += 2;
	if (slideBox.scrollTop % lh == 0) {
	clearInterval(tid);
	slideBox.appendChild(slideBox.getElementsByTagName('li')[0]);
	slideBox.scrollTop = 0;
	setTimeout(start, delay);
	}
	}
	slideBox.onmouseover=function(){pause=true;}
	slideBox.onmouseout=function(){pause=false;}
	setTimeout(start, delay);
}

function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
/**
 * 设置当前位置
 */
function setCurrentLocation(current_location){
     current_location_span=document.getElementById('current_location');
     if(current_location_span!=null){
          current_location_span.innerHTML=current_location;
     }
}

/**
 * 设置订阅连接
 */
function setSubscribeLink(subscribe_link){
     subscribe_link_span=document.getElementById('subscribe_link');
     if(subscribe_link_span!=null){
          subscribe_link_span.innerHTML=subscribe_link;
     }
}
/**
商铺尾部显示十大标识时调用 begin
*/
function setTransition(){ 
if (document.all){ 
bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23); 
bannerADrotator.filters.revealTrans.apply(); 
} 
} 
function playTransition(){ 
if (document.all) 
bannerADrotator.filters.revealTrans.play() 
} 
function nextAd(){ 
if(adNum<bannerAD.length-1)adNum++ ; 
else adNum=0; 
setTransition(); 
document.images.bannerADrotator.src=bannerAD[adNum]; 
playTransition(); 
theTimer=setTimeout("nextAd()", 4000); 
} 
function displayStatusMsg() { 
status=bannerADlink[adNum]; 
document.returnValue = true; 
}
/**
商铺尾部显示十大标识时调用 end
*/
/** 商铺尾部显示十大标识用户滚动广告 begin*/
    var time = 120;
    var h = 0;
    function addCount()
    {	
	
    
        if(time>0)
        {
            time--;
            h = h+2;//展开时步长
        }
        else
        {
            return;
        }
        if(h>120)  //高度
        {
            return;
        }
        document.getElementById("ads").style.display = "";
        document.getElementById("ads").style.height = h+"px";
        setTimeout("addCount()",0); 
    }
    
    var T = 120 ;
    var hh = 120; //高度
    function noneAds()
    {
        if(T>0)
        {
            T--;
            hh = hh-2;//收起时步长
        }
        else
        {
            return;
        }
        if(hh==60)
        {
            document.getElementById("f120").style.display = "none";
			document.getElementById("f60").style.display = "block";
            return;
        }
        
        document.getElementById("ads").style.height = hh+"px";
        setTimeout("noneAds()",0); 
    }
/** 商铺尾部显示十大标识用户滚动广告 end*/
//对页面内的所以PNG图片进行处理
function correctPNG()
{
	for(var i=0; i<document.images.length; i++)
	{
	var img = document.images[i]
	var imgName = img.src.toUpperCase()
	if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	{
	var imgID = (img.id) ? "id='" + img.id + "' " : ""
	var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	var imgStyle = "display:inline-block;" + img.style.cssText
	if (img.align == "left") imgStyle = "float:left;" + imgStyle
	if (img.align == "right") imgStyle = "float:right;" + imgStyle
	if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	var strNewHTML = "<span " + imgID + imgClass + imgTitle
	+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
	img.outerHTML = strNewHTML
	i = i-1
	}
	}
}
