var DDSPEED = 4;
var OPENSPEED = 5;
var CLOSESPEED = 3;
var DDTIMER = 1;
var SELECTED = '';
//var OFFSET = -2;
//var ZINT = 100;
function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  //alert(c.timer);
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    c.style.display = 'block';
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
//      c.style.left = (h.offsetWidth + OFFSET) + 'px';

      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
//    ZINT = ZINT + 1;
//    c.style.zIndex = ZINT;
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
    
  }else{
    h.timer = setTimeout(function(){ddCollapse(c)},2000);
  }
  
}
function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}
function cancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}
function ddSlide(c,d){
  var currh = c.offsetHeight;
  
  var dist;
  if(d == 1){
    dist = Math.round((c.maxh - currh) / OPENSPEED);
  }else{
    dist = Math.round(currh / CLOSESPEED);
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) - 1 + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  
  if(currh > (c.maxh - 2) && d == 1){
    clearInterval(c.timer);
  }else if(dist < 1 && d != 1){
    clearInterval(c.timer);
    c.style.display = 'none';
  }
}
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var pubUserId="";
var pubRealName="";
var pubProId="";
var pubAccount="";
var pubBranchId="";
var pubBranchName="";
var pubHostIp="";
var pubTyuserId="";


var Sys = {}; 
var ua = navigator.userAgent.toLowerCase(); 
if (window.ActiveXObject) 
Sys.ie = ua.match(/msie ([\d.]+)/)[1] 
else if (document.getBoxObjectFor) 
Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] 
else if (window.MessageEvent && !document.getBoxObjectFor) 
Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1] 
else if (window.opera) 
Sys.opera = ua.match(/opera.([\d.]+)/)[1] 
else if (window.openDatabase) 
Sys.safari = ua.match(/version\/([\d.]+)/)[1]; 

function myFlash_DoFSCommand(command, args)                {
  var myFlashObj = InternetExplorer ? myFlash : document.myFlash;
  if(args.length==0){alert("请输入搜索内容！");return ;}
  window.open("/qn_search/cxzl_ss.jsp?searchWord="+encodeURI(args));
  return ;
  
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('Sub myFlash_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call myFlash_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
}

function openHelp() {
	 window.open('/help/index.jsp');
    return ;
}

function openTrade() {
    window.open('https://trade.gtja.com/');
    return ;
}

function moveR() {
 var et = document.getElementById("et");
et.style.top=document.documentElement.scrollTop+document.documentElement.clientHeight-140+"px"; 
et.style.left=document.documentElement.scrollLeft+document.documentElement.clientWidth-300+"px";

setTimeout("moveR();",50);
}
//moveR();


var user_class = "1";//
var backParams; //



function openInvitation(obj) {
	backParams = obj;
	show();
}
// var re= getAll();
// initUser(re);    
function callExternalInterface() {

	var count = getCookie('count')==null?"":getCookie('count');
	user_class=re[7];
	thisMovie("myFlash").say(re[0],re[2],count,re[6],re[3],re[4],encodeURI(re[5]),'webcallzbwz',encodeURI(re[1]),user_class);
	
}

//
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	}
	else {
		return document[movieName]
	}
}

function accept1() {
	closeDialog();
	var url = "http://chat.gtja.com/webcall/client/client_index.jsp?param=null"+backParams;
	window.open(url,'newwindow','height=549,width=681,toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=no,status=no,top=100,left=200');
}

function encodeChange(sourceName) {
	return encodeURIComponent(sourceName);
}

function closeDialog()
		{
			document.getElementById("showDialog").style.visibility="hidden";
		}
function show()
		{
			document.getElementById("showDialog").style.visibility="visible";

		}


function initUser(reArray){

	pubUserId=reArray[0];
	pubRealName=reArray[1];
	pubProId=reArray[2];
	pubAccount=reArray[3];
	pubBranchId=reArray[4];
	pubBranchName=reArray[5];
	pubHostIp=reArray[6];
	pubTyuserId=reArray[8];
}
//if(SysET.firefox) {ck=document.getElementById("ck").contentWindow;}


var result='';
function getUser(input){
	
	switch(input){
	 	case 'userId':
	 		result=pubUserId;
	 		break;
	 	case 'realName':
	 		result=pubRealName;
	 		break;	
	 	case 'proId':
	 		result=pubProId;
	 		break;	
	 	case 'account':
	 		result=pubAccount;
	 		break;	
	 	case 'branchId':
	 		result=pubBranchId;
	 		break;	
	 	case 'branchName':
	 		result=pubBranchName;
	 		break;	
	 	case 'hostIp':
	 		result=pubHostIp;
	 		break;	
	 	case 'tyuserId':
	 		result=pubTyuserId;
	 		break;					
	 		
	 }	
	 	return result;
}

var resultAll='';
function getUserAll(input){
	var url='/share/getAllUser.jsp';
	   var paras='';
	 	 new Ajax.Request(url,{method:'post',parameters:paras,asynchronous:false,onSuccess:function(request){
	 		resultAll=request.responseText;
	 		//alert(resultAll);
	 	},onFailure:function (){}});
	 	return resultAll;
}

function getAll(){
	var allresult=getUserAll('');
	var allreults=allresult.split("|");
	if(allreults.length>0) return allreults;
}
	
/*************************************************************************************/
/****************************************************************/	
var etObj;
var etIE = window.ActiveXObject ? true : false;
  //
function showActiveX_ET(){
	if(etIE){
		return '<OBJECT id="flashwebcallET" style="width:0px;height:0px" classid="clsid:F486C5D5-5A91-43D2-B8B7-FD40A71FDB18">' +
         '<PARAM NAME="_Version" VALUE="65536"/>'+
         '<PARAM NAME="_ExtentX" VALUE="2223"/>'+
         '<PARAM NAME="_ExtentY" VALUE="550"/>'+
         '<PARAM NAME="_StockProps" VALUE="0"/>'+
         '</OBJECT>';
    }//else{
	  // return '<embed id=flashwebcallET type=application/csswebsafelogin width=75 height=18/>';
   // }
}

//
function DetectActiveX_ET(etParams){
	var hasObj = false;
	if(etIE){ try {new ActiveXObject("WebcallAtl.PrintScreenOut.1");hasObj = true;}catch(e){ }
	}//else{ hasObj = navigator.mimeTypes["application/csswebsafelogin"] ? true : false;}  
	if(hasObj){
			  document.getElementById("loginActiveX").innerHTML=showActiveX_ET();
			  etObj = document.getElementById("flashwebcallET");
			  try{
			      etValue = etObj.OpenWebCall(etParams);
			      return etValue;		
				  }catch(e){
				      return 0;
				  }
		}else{
			return 0;	  
		}
}		


var pop;		
//
function openInvestmentConsultation() {

	var url="http://chat.gtja.com/webcall/client/et_wz_index.jsp?from=webcallzbwz";//&userId="+re[0]+"&realName="+encodeURI(re[1])+"&branchName="+encodeURI(re[5])+"&branchId="+re[4]+"&formenu=tzzx&account="+re[3]+"&provinceId="+re[2]+"&userClass="+re[7]+"&customer_code="+re[9]+"&userType="+re[10];
	var etLogin = DetectActiveX_ET("null,tzzx");
	if(etLogin == 0)
		pop=window.open (url, 'newwindow', 'height=549, width=681, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no') ;
	
		/*if(!pop || pop.closed)
			pop=window.open (url, 'newwindow', 'height=549, width=681, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no') ;
		else pop.focus();*/
}

//
function openBusinessConsultation() {
//var re= getAll();
var url="http://chat.gtja.com/webcall/client/et_wz_index.jsp?from=webcallzbwz";//&userId="+re[0]+"&realName="+encodeURI(re[1])+"&branchName="+encodeURI(re[5])+"&branchId="+re[4]+"&formenu=ywzx&account="+re[3]+"&provinceId="+re[2]+"&userClass="+re[7]+"&customer_code="+re[9]+"&userType="+re[10];
	
	var etLogin = DetectActiveX_ET("null,ywzx");
	if(etLogin == 0)
		pop=window.open (url, 'newwindow', 'height=549, width=681, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no') ;

	
	/*if(!pop || pop.closed)
		pop=window.open (url, 'newwindow', 'height=549, width=681, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no') ;
	else pop.focus();*/
}

//
function openCustomerManager() {
var url="http://chat.gtja.com/webcall/client/et_wz_index.jsp?from=webcallzbwz";//&userId="+re[0]+"&realName="+encodeURI(re[1])+"&branchName="+encodeURI(re[5])+"&branchId="+re[4]+"&formenu=khjl&account="+re[3]+"&provinceId="+re[2]+"&userClass="+re[7]+"&customer_code="+re[9]+"&userType="+re[10];
	var etLogin = DetectActiveX_ET("null,khjl");
	if(etLogin == 0)
		pop=window.open (url, 'newwindow', 'height=549, width=681, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no') ;
	
	/*if(!pop || pop.closed)
		pop=window.open (url, 'newwindow', 'height=549, width=681, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no') ;
	else pop.focus();*/
}

//
function openETHelp() {
var url="http://chat.gtja.com/webcall/client/et_wz_index.jsp?from=webcallzbwz";//&userId="+re[0]+"&realName="+encodeURI(re[1])+"&branchName="+encodeURI(re[5])+"&branchId="+re[4]+"&formenu=help&account="+re[3]+"&provinceId="+re[2]+"&customer_code="+re[9]+"&userType="+re[10];
		var etLogin = DetectActiveX_ET("null,null");
		if(etLogin == 0)
			pop=window.open (url, 'newwindow', 'height=549, width=681, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no') ;
		
		/*if(!pop || pop.closed)
		  pop=window.open (url, 'newwindow', 'height=549, width=681, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no') ;
		else pop.focus();*/
}
function showLink1()
{
	if(document.getElementByName('linkList1').selectedIndex == 0)return false;
	window.open(document.getElementByName('linkList1').options[document.getElementById('linkList1').selectedIndex].value,"","");
}	
window.onload = function(){
	var mar = new Marquee("marquee");
	mar.Direction = 0;
	mar.Width = 536;
	mar.Height = 23;
	mar.Speed = 20;
	mar.Space = 1;
	mar.Tag = "p";
	MarqueeStart("marquee1",mar.Direction,mar.Width,mar.Height,mar.Speed,mar.Space,mar.Tag);
}

function Marquee(MarName)
    {
     	this.ID = document.getElementById(MarName);
        this.Speed = 30; 
        this.Direction = 0;
        this.Width = 0;
        this.Height = 0;
     this.Space = 1;
     this.Tag = "p";
     this.Start = function(){
      MarqueeStart(this,this.Direction,this.Width,this.Height,this.Speed,this.Space,this.Tag);
     }
  
     this.End = function(){
      MarqueeEnd(this);
     }
    }
function MarqueeStart(Mar,Direction,Width,Height,Speed,Space,Tag){  
     var msobj;
     if(typeof(Mar) == "string"){
      msobj = new Marquee(Mar);
     }
     if(typeof(Mar) == "object"){
      msobj = Mar;
     }
     if(!msobj.ID) return;
     msobj.ID.style.width = Width + "px";
     msobj.ID.style.height = Height + "px";
     msobj.ID.style.overflow = msobj.ID.style.overflowX = msobj.ID.style.overflowY = "hidden";
        msobj.Direction = Direction;
        msobj.Width = Width;
        msobj.Height = Height;
        msobj.Speed = Speed;
     msobj.Space = Space;
     msobj.Tag = Tag;
        msobj.InnerDiv = msobj.ID.getElementsByTagName("div")[0];
     if(!msobj.InnerDiv) return;
        msobj.InnerDiv.innerHTML += msobj.InnerDiv.innerHTML;
        msobj.Inner = msobj.ID.getElementsByTagName(Tag); 
     if(!msobj.Inner) return;
        switch(Direction)
        {    
         case 2:  
             msobj.InnerDiv.style.width = Width + "px";
       msobj.Inner[0].style.width =Width + "px";
       msobj.Inner[1].style.width =Width + "px";
          if(Height>=msobj.Inner[1].offsetHeight || msobj.Space ==1){
           msobj.Inner[0].style.paddingTop = Height + "px";
           msobj.Inner[1].style.paddingTop = Height + "px";;
          } 
          break;
         case 3:
          msobj.InnerDiv.style.width = Width + "px";
       msobj.Inner[0].style.width =Width + "px";
       msobj.Inner[1].style.width =Width + "px";   
          if(Height>=msobj.Inner[1].offsetHeight || msobj.Space ==1){
           msobj.Inner[0].style.paddingBottom = Height + "px";
           msobj.Inner[1].style.paddingBottom = Height + "px";
          }
          break;
      default:   
          msobj.InnerDiv.noWrap = true;
       if(Width >= msobj.Inner[1].offsetWidth || msobj.Space ==1){
        msobj.Inner[0].style.paddingLeft = Width + "px";
        msobj.Inner[1].style.paddingLeft = Width + "px";
       }
          break;
        }
        
        msobj.ID.onmouseover = function(){
            clearInterval(msobj.TimerID);
        }
        
        msobj.ID.onmouseout = function(){
            clearInterval(msobj.TimerID);
            msobj.TimerID = funcInterval(MarqueeScroll,msobj.Speed,msobj);
        }
        msobj.TimerID = funcInterval(MarqueeScroll,msobj.Speed,msobj);  
     
    }
function MarqueeScroll(Mar){     
        switch(Mar.Direction)
        {
            case 0: 
                if(Mar.Inner[1].offsetWidth-Mar.ID.scrollLeft<=0)
                 Mar.ID.scrollLeft-=Mar.Inner[0].offsetWidth;
                else{              
                 Mar.ID.scrollLeft++;
                }
            break;
            case 1:          
                if(Mar.ID.scrollLeft==0)
                 Mar.ID.scrollLeft=Mar.Inner[1].offsetWidth;
                else{
                 Mar.ID.scrollLeft--;
                }          
            break;
            case 2:    
                if(Mar.Inner[1].offsetHeight-Mar.ID.scrollTop<=0)
                 Mar.ID.scrollTop-=Mar.Inner[0].offsetHeight;
                else{
                 Mar.ID.scrollTop++;
                }
            break;
            case 3:          
                if(Mar.ID.scrollTop<=0)
                 Mar.ID.scrollTop = Mar.Inner[1].offsetHeight;
                else{
                 Mar.ID.scrollTop--;
                }        
            break;
        }
    }
	function MarqueeEnd(Mar){
     if(!Mar)return;
     if(typeof(Mar.TimerID) == "number") {
      clearInterval(Mar.TimerID);
      Mar = null;
     }
    }
	function funcInterval(funcName,time){
	      var args=[];
	      for(var i=2;i < arguments.length;i++){
	          args.push(arguments[i]);
	      }
	      return window.setInterval(function(){
	                funcName.apply(this,args);
	            },time);
	   }

		document.write("<div id='etObjBox'><span id='loginActiveX'></span></div>")
	
