﻿document.write("<style type='text/css'>"
    +".ImTable *{padding:0;margin:0;text-align:left}"
    +".ImTable{border-collapse:collapse;border:none;background:url(/en/ctrl/im/kefu/bg.gif)}"
    +".ImTable h2{font-size:14px;font-weight:bold;margin-top:5px}"
    +".ImHeader{height:39px;background:url(/en/ctrl/im/kefu/im_01.gif)}"
    +".ImRow0{background:#ffffff;margin:0 2px;height:20px;padding-left:2px;padding-top:6px}"
    +".ImRow1{background:#f2f2f2;margin:0 2px;height:20px;padding-left:2px;padding-top:6px}"
    +"a.im,a:hover.im{text-decoration:none;height:25px}"
    +".ImFooter{height:27px;background:url(/en/ctrl/im/kefu/im_04.gif)}"
    +"</style>");
var __oran_top_offset=-260;
var __oran_kf_left_offset=0;
function __oran_kf_get(elmId){return document.getElementById(elmId);}
function writeIm(textS,siteNm,topOffset){
    __oran_top_offset=topOffset;
    var textCrumbs=textS.split(',');
    if (textCrumbs.length==0)return;
    if(!siteNm)siteNm="Oran";
    var rowStr = "<div style='position:absolute;right:" + __oran_kf_left_offset + "px;width:81px;top:" + __oran_top_offset + "px;z-index:100;' id='divOranIm'><div id='kefubtn' style='text-align:right;cursor:hand;display:block' ><img alt='打开客服菜单' src='/en/ctrl/im/kefu/kf-1.gif' onclick='__oran_kf_setKf(1)'></div><div id='bodd' style='display:none'><div class='ImHeader' onclick='__oran_kf_setKf(0)' style='cursor:hand' title='隐藏客服菜单'></div><table class='ImTable' style='width:81px' border='0' cellspacing='0' cellpadding='0' width='81'>";
    var online=[0];
    var imName="qq";
    var altText;
    var imgPath;
    var classIm;
    var thisIm;
    var idCrumbs;    
    for(var i=0;i<textCrumbs.length;++i){
        classIm=textCrumbs[i].split('||');
        if(classIm[0]){
        rowStr+="<tr><td style='text-align:center' valign='middle' height='30'><h2 style='text-align:center'>"+classIm[0]+"</h2><img src='/en/ctrl/im/kefu/title.gif'></td></tr>";
        }
        idCrumbs=classIm[1].split('|');
        for(var j=0;j<idCrumbs.length;++j){
            rowStr+="<tr><td><div class='ImRow"+(j % 2)+"'><a target='_self' class='im' href='";
            if(idCrumbs[j].indexOf('@')!=-1){
                rowStr+="msnim:chat?contact=";
                imName="msn";
            }else if(idCrumbs[j].indexOf('?')!=-1){
                rowStr+="skype:";
                imName="skype";
            }else{
                rowStr+="tencent://message/?menu=yes&site="+siteNm+"&uin=";
                imName="qq";
            }
            
            thisim=idCrumbs[j].split('$');
            
            rowStr+=thisim[0];
            switch(imName){
                case "msn":altText="MSN";imgPath="/en/ctrl/im/kefu/im_msn_online.gif";break;
                case "qq":altText="QQ";imgPath="http://wpa.qq.com/pa?p=1:"+thisim[0]+":4";break;
                case "skype":altText="Skype";imgPath="/en/ctrl/im/kefu/skype.gif";break;
            }
            rowStr+="'><img src='"+imgPath+"' alt='"+altText+"' style='border:none' align='absmiddle'/> "+thisim[1]+"</a></div></td></tr>";
        }
    }
    rowStr+="</table><div class='ImFooter' onclick='__oran_kf_setKf(0)' style='cursor:hand' title='隐藏客服菜单'></div></div></div>";
    document.write(rowStr);
}

function __oran_kf_setKf(valtype){
    if(valtype==0){
        __oran_kf_get("bodd").style.display="none";
        __oran_kf_get("kefubtn").style.display="";
       // __oran_kf_setCookie("kefutype",0);
    }else{
        __oran_kf_get("bodd").style.display="";
        __oran_kf_get("kefubtn").style.display="none";
       // __oran_kf_setCookie("kefutype",1);
    }
}
function __oran_kf_getPosition(){
    var top=document.documentElement.scrollTop;
    var left=document.documentElement.scrollLeft;
    var height=document.documentElement.clientHeight;
    var width=document.documentElement.clientWidth;
    return {top:top,left:left,height:height,width:width};
}
function __oran_kf_setPostion(objID){
    var obj=__oran_kf_get(objID);
    window.onscroll=function(){
        var Position=__oran_kf_getPosition();
        obj.style.top=(Position.top) +__oran_top_offset+"px";
        obj.style.right=__oran_kf_left_offset;
    };
    var show=true;
    var cookeVal=__oran_kf_getCookie("kefutype");
    if(cookeVal==null||cookeVal=="0")show=false;
    __oran_kf_setKf(show?1:0);
}
function __oran_kf_setCookie(name,value){
    var Days=1;
    var exp=new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*10000);
    document.cookie=name+"="+escape (value)+";expires="+exp.toGMTString()+";path=/"; 
}
function __oran_kf_getCookie(name){
    var arr;
    var rgx=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    if(arr=document.cookie.match(rgx))return unescape(arr[2]);
    else return null;
}
