﻿// JScript 文件

document.write("<script language='javascript' type='text/javascript' src='/JS/CallBackObject.js'></script>");

var userId, qqNumber, backStyle, msn, headImg, myUrl;
var tel, introduce,tName,nName,eMail,post,compName,chatIsOpen,sex,trade,city;
var tmpHtml,innHtml;
document.write("<div id='UShow' style='position: absolute; padding: 12px; width: 271px; width: 300px!important;  height: 300px; background-color:White; filter: alpha(Opacity=100); text-align: justify; display:none; 264px; top: 240px;'></div>");
document.write('<link href="/css/UShow.css" rel="stylesheet" type="text/css" />');
var ev;
//获得U秀用户信息
function getUShowInfo(e,userid)
{   
    var suid;
    HidUShowMessage();
    if( GetPagePrmValue("userid")!=null && GetPagePrmValue("userid")!="" )
    {    
        suid=GetPagePrmValue("userid");   
    }
    else 
    {
        suid=userid;
    }   
    
    
    if(suid!=null)
    {  
        ev=e;        
        
        UShowMessage("加载U秀用户信息...");
        setXY("UShow");  
        var Cbo = new CallBackObject();
        Cbo.OnComplete = Cbo_UShowComplete;
        Cbo.OnError = Cbo_Error;
        Cbo.DoCallGet("/TransactRoom/RoomAjax.aspx?tp=getushow&userid="+suid);    
 
    }
    else
    {
        UShowMessage("无此用户!");
    }
}

//获得U秀模版
function getUShowPage()
{
    if(tmpHtml=="" || tmpHtml==null)
    {
        UShowMessage("加载U秀模版...");
        var Cbo = new CallBackObject();
        Cbo.OnComplete = Cbo_UShowTmpComplete;
        Cbo.OnError = Cbo_Error;
        Cbo.DoCallGet("/TransactRoom/uShowTmp.htm?"+Math.random());        
    }
    else
    {        
        setUShowInfo();        
        document.getElementById("UShow").innerHTML=innHtml;        
        document.getElementById("UShow").style.display="";      
        setXY("UShow");    
    }
}

function UShowMessage(msg)
{
    document.getElementById("UShow").innerHTML=msg;
    document.getElementById("UShow").style.display="";
}

function HidUShowMessage()
{
    if(document.getElementById("UShow")!=null)
    {
        document.getElementById("UShow").style.display="none";
    }
}

//设置U秀信息
function Cbo_UShowComplete(responseText, responseXML)
{
    if(responseText=="nouser")
    {
        UShowMessage("<a href='/TransactRoom/setUShow.aspx'><img src='/img/UShow/NoUShow_1.gif' border='0' /></a>");
    }
    else
    {
        
        var tmpUShow=responseText.split(',');
        userId=tmpUShow[0];
        backStyle=tmpUShow[1];
        headImg=tmpUShow[2];
        nName=tmpUShow[3];
        tName=tmpUShow[4];
        qqNumber=tmpUShow[5];
        msn=tmpUShow[6];
        chatIsOpen=tmpUShow[7];
        compName=tmpUShow[8];
        eMail=tmpUShow[9];
        introduce=tmpUShow[10];
        myUrl=tmpUShow[11];
        post=tmpUShow[12];
        tel= tmpUShow[13];
        
        if(tmpUShow[14]=="1")
            sex="男";
        else
            sex="女";
        
        trade= tmpUShow[15];        
        city= tmpUShow[16];
        
        getUShowPage();
    }
}

function UShowOpenChat(userid,state)
{
    state=state.toLowerCase();
    if(state=="true")
    {
        window.open("/chat/WebChatVisit.aspx?OwnerId="+userid,"","width=650,height=480,fullscreen=0,toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,resizable=0");
    }
    else
    {
        window.open('/MemberCenter/PutMessage.aspx?OwnerId='+userid,"Liuyan",'width=650,height=500,location=no,resizable=0,scrollbars=0,status=no,toolbar=no,menu=no,top=100,left=200');
    }
}

//替换模版信息
function setUShowInfo()
{
    innHtml=tmpHtml.replace("$backStyle$",backStyle);
    innHtml=innHtml.replace("$headImg$",headImg);
    innHtml=innHtml.replace("$nName$",nName);
    innHtml=innHtml.replace("$tName$",tName);
    
    if(qqNumber=="0")
    {
        innHtml=innHtml.replace("$qq$","");
    }
    else
    {        
        innHtml=innHtml.replace("$qq$","<a href=tencent://message/?uin="+qqNumber+"&Site=u1d1.com&Menu=yes><img border='0' align='absmiddle' SRC=http://wpa.qq.com/pa?p=1:"+qqNumber+":15></a>");
    }
    
    if(chatIsOpen.toLowerCase()=="true")
    {
        innHtml=innHtml.replace("$chatIsOpen$","<a href='JavaScript:UShowOpenChat("+userId+",\""+chatIsOpen+"\");' ><img src='/img/ushow/my_010.gif' border='0' width='48' height='47' /></a>");
    }
    else
    {
        innHtml=innHtml.replace("$chatIsOpen$","<a href='JavaScript:UShowOpenChat("+userId+",\""+chatIsOpen+"\");' ><img src='/img/ushow/my_010.gif' border='0' width='48' height='47' /></a>");
    }
    
    if(msn=="")
    {
         innHtml=innHtml.replace("$msn$","");
    }
    else
    {
        innHtml=innHtml.replace("$msn$","<a href='msnim:chat?contact="+msn+"'><img src='/img/ushow/my_011.gif' width='37' height='47' border='0' /></a>");
    }   
           
    innHtml=innHtml.replace("$compName$",compName);
    innHtml=innHtml.replace("$eMail$","<a href='mailto:"+eMail+"'>发邮件</a>");
    
    innHtml=innHtml.replace("$introduce$",introduce);
    innHtml=innHtml.replace("$myUrl$",myUrl);
    innHtml=innHtml.replace("$post$",post);
    innHtml=innHtml.replace("$tel$",tel);
    innHtml=innHtml.replace("$sex$",sex);
    innHtml=innHtml.replace("$trade$",trade);
    innHtml=innHtml.replace("$city$",city); 
    
}

//获得模版信息
function Cbo_UShowTmpComplete(responseText, responseXML)
{
    
    tmpHtml=responseText;
    setUShowInfo();
    document.getElementById("UShow").innerHTML=innHtml;
    document.getElementById("UShow").style.display="";
    
}

//获得页面参数
function GetPagePrmValue(prm)
{
    var url = location.href.replace('http://','').replace('#','');
    url = url.split('/');
    var index = url[url.length-1].indexOf(prm);
    
    if(index>0)
    {
        var tmpStr=url[url.length-1];
        tmpStr=tmpStr.substring(index,tmpStr.length);
        var indexEnd=tmpStr.indexOf('&');
        
        if(indexEnd==-1)
        {
            return tmpStr.substring(prm.length+1);
        }
        else
        {                
            return tmpStr.substring(prm.length+1,tmpStr.length-tmpStr.substring(indexEnd).length);
        }
    }
    else
        return "";
}

function Cbo_Error(status, statusText, responseText)
{
    document.write(responseText);
}



function setXY(obj) { 
//UShow
    try
    {
        var Ushow=document.getElementById(obj);
        //获取当前鼠标右键按下后的位置，据此定义菜单显示的位置 
      
        
        //获取当前鼠标右键按下后的位置，据此定义菜单显示的位置 
        var rightedge = document.documentElement.clientWidth-ev.clientX; 
        var bottomedge = document.documentElement.clientHeight-ev.clientY; 
        
        
        //如果从鼠标位置到窗口右边的空间小于菜单的宽度，就定位菜单的左坐标（Left）为当前鼠标位置向左一个菜单宽度 
        if (rightedge <Ushow.offsetWidth+60) 
            Ushow.style.left = document.documentElement.scrollLeft + ev.clientX - Ushow.offsetWidth-60; 
        else 
        //否则，就定位菜单的左坐标为当前鼠标位置 
            Ushow.style.left = document.documentElement.scrollLeft + ev.clientX-150;        
     
        
        //如果从鼠标位置到窗口下边的空间小于菜单的高度，就定位菜单的上坐标（Top）为当前鼠标位置向上一个菜单高度 
        if (bottomedge <Ushow.offsetHeight) 
            Ushow.style.top = document.documentElement.scrollTop + ev.clientY - Ushow.offsetHeight-50; 
        else 
        //否则，就定位菜单的上坐标为当前鼠标位置 
            Ushow.style.top = document.documentElement.scrollTop + ev.clientY+10; 
    }
    catch(e)
    {}
} 
