var Browser=new Object();
Browser.isMozilla=(typeof document.implementation!='undefined')&&(typeof document.implementation.createDocument!='undefined')&&(typeof HTMLDocument!='undefined');
Browser.isIE=window.ActiveXObject?true:false;
Browser.isGecko=navigator.userAgent.indexOf("Gecko")!=-1;
Browser.isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);

if(Browser.isMozilla&&!Browser.isOpera)
{
	HTMLElement.prototype.removeNode=function(){this.parentNode.removeChild(this);}
	if(window.Event)
    {
        extendEventObject();
    }

	emulateAttachEvent();
	var eventArr=["click","dblclick","mouseover","mouseout","mousedown","mouseup","mousemove","keydown","keypress","keyup"];
	emulateEventHandlers(eventArr);
	emulateCurrentStyle();
	Event.LEFT=0;Event.MIDDLE=1;Event.RIGHT=2;
}
else
{
	Event={};
	Event.LEFT=1;Event.MIDDLE=4;Event.RIGHT=2;
}
function extendEventObject()
{
    Event.prototype.__defineGetter__("srcElement",
                                        function()
                                        {
                                            //alert(this.target);
                                            var node=this.target;
                                            while(node.nodeType!=1)node=node.parentNode;
                                            return node;
                                        }
                                    );
}
function emulateAttachEvent()
{
    HTMLDocument.prototype.attachEvent=HTMLElement.prototype.attachEvent=function(sType,fHandler){
                                                                                                    var shortTypeName=sType.replace(/on/,"");
                                                                                                    fHandler._ieEmuEventHandler=function(e){window.event=e;return fHandler();};this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);};HTMLDocument.prototype.detachEvent=HTMLElement.prototype.detachEvent=function(sType,fHandler){var shortTypeName=sType.replace(/on/,"");if(typeof fHandler._ieEmuEventHandler=="function")
this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);else
this.removeEventListener(shortTypeName,fHandler,true);};}
function emulateEventHandlers(eventNames)
{
    for(var i=0;i<eventNames.length;i++)
    {
        document.addEventListener(eventNames[i],function(e){window.event=e;},false);
    }
}
function emulateAllModel(){var allGetter=function(){var a=this.getElementsByTagName("*");var node=this;a.tags=function(sTagName){return node.getElementsByTagName(sTagName);};return a;};HTMLDocument.prototype.__defineGetter__("all",allGetter);HTMLElement.prototype.__defineGetter__("all",allGetter);}
function extendElementModel(){HTMLElement.prototype.__defineGetter__("parentElement",function(){if(this.parentNode==this.ownerDocument)return null;return this.parentNode;});HTMLElement.prototype.__defineGetter__("children",function(){var tmp=[];var j=0;var n;for(var i=0;i<this.childNodes.length;i++){n=this.childNodes[i];if(n.nodeType==1){tmp[j++]=n;if(n.name){if(!tmp[n.name])
tmp[n.name]=[];tmp[n.name][tmp[n.name].length]=n;}
if(n.id)
tmp[n.id]=n}}
return tmp;});HTMLElement.prototype.contains=function(oEl){if(oEl==this)return true;if(oEl==null)return false;return this.contains(oEl.parentNode);};}
function emulateCurrentStyle()
{
    HTMLElement.prototype.__defineGetter__("currentStyle",function(){return this.ownerDocument.defaultView.getComputedStyle(this,null);});
}




 $=function(A){
    return document.getElementById(A);
 }
 
function trim(temp) 
{
	return temp.replace(/(^\s*)|(\s*$)/g, "");
}

function insertFlash(elm, url,Id, w, h,wmodeValue,fVars)
{
    if (!document.getElementById(elm)) return;
    var str = '';
    str += '<object id="'+Id+'" width="'+ w +'" height="'+ h +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
    str += '<param name="movie" value="'+ url +'" />';
    str += '<param name="wmode" value="'+wmodeValue+'" />';//transparent|Opaque
    str += '<param name="quality" value="High" />';
    str += '<param name="FlashVars" value="'+fVars+'" />';
    str += '<embed name="'+Id+'" swliveconnect="true" width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="High" wmode="'+wmodeValue+'" FlashVars="'+fVars+'" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
    str += '</object>';
    document.getElementById(elm).innerHTML = str;
}



var xmlHttp=null;
var StallDocument=null;
creRequest=function()
{
	msxml_progid=['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
	try
	{
		xmlHttp=new XMLHttpRequest();
		
	}
	catch(e)
	{
		for(var i=0;i<msxml_progid.length;++i)
		{
			try
			{
				xmlHttp=new ActiveXObject(msxml_progid[i]);
				break;
			}
			catch(e)
			{
			    return false;
			}
		}
	}
	 return true;
}

startRequest=function(method,requestType,urlstr,postDatastr,callback)
{
	    var url="";var poststr="";
	    if(method=='GET')
	    {
		    url=urlstr+"?"+postDatastr;
		    poststr=null;
	    }
	    else if(method=='POST')
	    {
		    url=urlstr;poststr=postDatastr;
	    }
	    xmlHttp.onreadystatechange=function()
	    {
		    if(xmlHttp.readyState==4&&xmlHttp.status==200)
		    {
			   if(requestType=="requestext")
			   {    
			        if(callback)
			        {
			            callback(xmlHttp.responseText);
			        }
			        else
			        {
			            alert(xmlHttp.responseText);
			        }
			   }
			   else
			   {
			        if(callback)callback(xmlHttp.responseXML);
			   }  
		    }
		    else if(xmlHttp.readyState==1)
		    {
		        ;//if(callback)callback("已建立但还没有发出请求.....请等待....");
		    }
		    else if(xmlHttp.readyState==2)
		    {
		        
		        ;//if(callback)callback("正在处理数据.....请等待....");
		    }
		    else
		    {
		        ;//if(callback)callback("服务器没有完成响应,请－刷新....");
		    }
	    }
		xmlHttp.open(method,url,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.send(poststr);
}


function getscrollHeight()
{
	if(document.body.scrollHeight>document.documentElement.clientHeight)
	{
		return document.body.scrollHeight
	}
	else
	{
		return document.documentElement.clientHeight
	}
}


var bigDiv=null;
var movDiv=null;//可移动DIV
var dirInfoDiv=null;

var detlaX,detlaY,ooo;
var Old_x,Old_y;
var moveBoxLeft,moveBoxTop;

function beginDrag(){
	var thisDiv,evt;
	thisDiv=document.getElementById("moveBox");
	evt=thisDiv.event;
	e = evt || window.event;
	ooo = thisDiv;
	document.onmousemove = move;
	document.onmouseup = up;
	if(Browser.isMozilla)
	{
	    window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
	}
	else
	{
	    thisDiv.setCapture();   
	}
	Old_x=e.clientX;
	Old_y=e.clientY;
	
}
function move(evt){
    
		e = evt || window.event;
		
		moveBoxLeft=parseInt(document.getElementById("moveBox").style.left);
		moveBoxTop=parseInt(document.getElementById("moveBox").style.top);
		if(isNaN(moveBoxLeft))
		{
		    moveBoxLeft=0;
		}
		if(isNaN(moveBoxTop))
		{
		    moveBoxTop=0;
		}
		
		
		document.getElementById("moveBox").style.left = (moveBoxLeft+e.clientX-Old_x)+"px";
		document.getElementById("moveBox").style.top = (moveBoxTop+e.clientY-Old_y)+"px";
		Old_x=e.clientX;
		Old_y=e.clientY;
}
function up(){
	document.onmousemove = null;
	document.onmouseup = null;
	if(Browser.isMozilla)
	{
	   
	    window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
	}
	else
	{
	    ooo.releaseCapture();
	}
}



function closebiDiv()
{
    if(dirInfoDiv!=null)
    {
        dirInfoDiv.style.display="none";
    }
	if(movDiv!=null)
	{
	    document.body.removeChild(movDiv);
	    movDiv=null;
	}   
    if(bigDiv==null)
    {
        return;
    }
    else
    {
        document.body.removeChild(bigDiv);
	    bigDiv=null;
    }
}

function hideDiv(obj,currId)
{
    var myTradListId=unescape(getUserCookie("MyTradList_00"));
    var newMyTradList="";
    var arrTradListId= new Array();
    var arrLen=0;
    if(myTradListId!="")
    {
        arrTradListId=myTradListId.split(","); 
        arrLen=arrTradListId.length;
    }
    if(arrLen<=1)
    {
        alert('系统必须保留一个行业,所以这个行业不能被关闭!!');
    }
    else
    {
        document.getElementById(obj).style.display="none";
        for(var i=0;i<arrLen;i++)
        {
            if(currId!=arrTradListId[i])
            {
                if(newMyTradList=="")
                {
                    newMyTradList=arrTradListId[i];
                }
                else
                {
                    newMyTradList+=(","+arrTradListId[i]);
                }
            }
        }
        delCookie("MyTradList_00");
        setCookie("MyTradList_00",newMyTradList);
    }
    
}

function showmask()//制作透明DIV
{
	if(bigDiv==null||!bigDiv)
	{
		bigDiv=document.createElement("DIV");
		bigDiv.attachEvent('onclick',closebiDiv);
		bigDiv.style.cssText="position:absolute;top:0px;left:0px;background-color:#000;";
	if(Browser.isMozilla)
	{
		bigDiv.style.cssText="position:absolute;top:0px;left:0px;background-color:#000;opacity:.7; z-index:999;";
	}
	else
	{
		bigDiv.style.cssText="position:absolute;top:0px;left:0px;background-color:#000;filter:alpha(opacity=70); z-index:999;";
	}
		bigDiv.style.height=getscrollHeight()+"px";
		bigDiv.style.width=document.body.clientWidth+"px";
		document.body.appendChild(bigDiv);
	}
}


function createMovDiv(TitleTxt,MovDivWidht,setItem)//创建可移动Div
{
    if(movDiv==null)
    {
        movDiv=document.createElement("div");//创建大的容器
        movDiv.id="moveBox"
	    movDiv.style.cssText="width:"+MovDivWidht+"px";
        movDiv.style.left=5+"px";
        movDiv.style.top=0+"px";
    }
	
    var titleDiv=document.createElement("div");//创建标题
    titleDiv.id="movTitle";
    //titleDiv.innerHTML=TitleTxt;
    titleDiv.attachEvent('onmousedown',beginDrag);
    var txtDiv=document.createElement("div");//标题文字
    txtDiv.className="TitleTxt";
    txtDiv.innerHTML=TitleTxt;
    
    var divClose=document.createElement("div");
	divClose.className="Close";
	divClose.attachEvent('onmousedown',closebiDiv);
	
	var contentDiv=document.createElement("div");//创建内容
	contentDiv.id="setContent";
	contentDiv.innerHTML=setItem;
	
	titleDiv.appendChild(txtDiv);
	titleDiv.appendChild(divClose);
		
    movDiv.appendChild(titleDiv);
    movDiv.appendChild(contentDiv);
    
    document.body.appendChild(movDiv);
}

function msnoperate(action, msn) {
	var actionArray = new Array();
	actionArray = {
		'reghotmail' : 'http://go.discuz.com/?app=msn&linkid=1',
		'reglivemail' : 'http://go.discuz.com/?app=msn&linkid=2',
		'regliveid' : 'http://go.discuz.com/?app=msn&linkid=3',
		'download' : 'http://go.discuz.com/?app=msn&linkid=4',
		'add' : 'http://go.discuz.com/?app=msn&linkid=5&msn=' + msn,
		'chat' : 'http://go.discuz.com/?app=msn&linkid=6&msn=' + msn
	}

	if(messengerInstalled()) {
		window.open(actionArray[action]);
	} else {
		window.open('http://go.discuz.com/msn/msn.html','_blank','width=571, height=498');
	}
}

function messengerInstalled() {
      try {
            new ActiveXObject("MSNMessenger.P4QuickLaunch");
            return true;
      }
      catch (e) {
            return false;
      }
}