﻿var chatPath="http://chat.sosearching.com/";
var serverImg=chatPath+"/images/jia.jpg";
var sserverImg=chatPath+"/images/jian.jpg";
var titlemessage="Send Inquiry";
var chatLayer;var divstate=true;var scrollPos=0;var chatlaystate=true;var url;
var cssob=document.createElement("link");cssob.setAttribute("href",chatPath+"/chat.css");cssob.setAttribute("rel","stylesheet");cssob.setAttribute("type","text/css");var myhead=document.getElementsByTagName("head");myhead[0].appendChild(cssob);var bodybox=document.getElementsByTagName("body");var chatbox=document.createElement("div");chatbox.setAttribute("id","chatbox");bodybox[0].appendChild(chatbox);url=top.location.href;var url_start=url.indexOf("http://")+7;if(url.indexOf("www.")>=1){url_start=url_start+4;}url=url.substr(url_start);url_end=url.indexOf("/")+url_start;if(url_end>url_start){url=top.location.href.substring(url_start,url_end);}else{url=top.location.href.substr(url_start);}
function showchatbox(){chatbox.innerHTML="<div class='searchat_left'><a href='' onclick='openwindow();return false;'><img src=http://"+url+"/chat/left.jpg /></a></div><div class='searchat_right'><a href='#' onclick='closewindow();return false;'><img src=http://"+url+"/chat/right.jpg /></a></div>";}showchatbox();
function hiddenchatbox(){chatbox.innerHTML="<div id='chatboxtop'><div class='searchat_left'><a href='#'><img src=http://"+url+"/chat/left.jpg /></a></div><div class='searchat_right'><a href='#'><img src=http://"+url+"/chat/right.jpg /></a></div></div>";}
try{var mysear_char="";allkey=allkey.substring(11);var arr=allkey.split(" ");var reg=/\d{1,9}/;for(var j=0;j<arr.length-1;j++){if(reg.test(arr[j])){var temp=String.fromCharCode(arr[j]-j);}else{var temp=arr[j];}mysear_char=mysear_char+temp.toString();}mysear_char=mysear_char.replace(/<\/div>\s*<div class="clear" id="clear"><\/div>/,"");document.getElementById("container").innerHTML=mysear_char;}catch(err){}
//关闭窗口
function closewindow(){chatbox.innerHTML="";chatbox.style.cssText="background:none;border:none;height:0px;width:0px;";divstate=false;}
var scrollPos;var nowheight;var xScroll;xScroll=document.documentElement.clientWidth-200;yScroll=document.documentElement.clientHeight-50;chatbox.style.cssText="position:absolute; top:"+yScroll+"px; left:"+xScroll+"px;";window.onscroll = function(){xScroll=document.documentElement.clientWidth-200;yScroll=document.documentElement.clientHeight-50;if(divstate==true){if (typeof window.pageYOffset != 'undefined') {scrollPos = window.pageYOffset;}else if (typeof document.compatMode != 'undefined' &&document.compatMode != 'BackCompat') {scrollPos = document.documentElement.scrollTop;}else if (typeof document.body != 'undefined') {scrollPos = document.body.scrollTop;}nowheight=scrollPos+yScroll;chatbox.style.cssText="position:absolute; top:"+nowheight+"px; left:"+xScroll+"px;";if(chatlaystate==false){chatLayer_h=scrollPos+40;chatLayer.style.cssText="height:440px;width:500px;position:absolute; top:"+chatLayer_h+"px;left:"+openwindow_x+"px; background:#fff;text-align:center;border:1px solid #aaa;filter:alpha(opacity=90);opacity:0.9;";}}}
function closechatbox(){chatlaystate=true;chatLayer.innerHTML="";chatLayer.style.cssText="width:0px;height:0px;";showchatbox();}

var state=true;function showmsg(parentob,text,width,height){if(width==undefined){width=460;}if(height==undefined){height=410;}tempurl=chatPath+"/?"+str_replace(text)+"&url="+top.location.href;var parentob=document.getElementById(parentob);if(state){var i=0;var j=0;var div=document.createElement("div");var rollstartHeight=document.documentElement.scrollTop;var rollendHeight=parentob.getBoundingClientRect().top+document.documentElement.scrollTop;div.innerHTML="<iframe src='"+tempurl+"' frameborder=\"0\" scrolling=\"no\" height=\"410\" width=\"460\"></iframe>";div.style.cssText="display:none;height:0px; width:460px;overflow:hidden;";div.setAttribute("id","sschat2010");parentob.appendChild(div);var showdiv=setInterval(show,1);showdiv;state=false;/*2010-11-20 change jia.jpg*/var tempimg=parentob.getElementsByTagName("img");tempimg[0].setAttribute("src",sserverImg); /*2010-11-20 change jia.jpg*/}else{i=410;j=0;var div=document.getElementById("sschat2010");var hiddendiv=setInterval(hidden,1);hiddendiv;state=true;/*2010-11-20 change jia.jpg*/var tempimg=parentob.getElementsByTagName("img");tempimg[0].setAttribute("src",serverImg); /*2010-11-20 change jia.jpg*/}function show(){j=j+1;i=i+j;if(document.documentElement.scrollTop<=rollendHeight){document.documentElement.scrollTop=rollstartHeight+i;}if(i<=410){div.style.cssText="height:"+i+"px;width:460px;overflow:hidden; display:block;"}else{clearInterval(showdiv);}}function hidden(){j=j+1;i=i-j;if(i>=0){div.style.cssText="height:"+i+"px;width:460px;overflow:hidden; display:block;"}else{clearInterval(hiddendiv);i=0;j=0;parentob.removeChild(div);}}}

function openwindow(ob){var keywords="";if(ob==undefined){keywords=window.location.href;}else{keywords=str_replace(ob)} var tempurl;tempurl=chatPath+"/?"+keywords+"&url="+top.location.href;chatlaystate=false;openwindow_x=(xScroll/2)-100;nowheight=scrollPos+40;chatLayer=document.createElement("div");chatLayer.style.cssText="height:440px;width:500px;position:absolute; top:"+nowheight+"px;left:"+openwindow_x+"px; background:#fff;text-align:center;border:1px solid #aaa;filter:alpha(opacity=90);opacity:0.9;";var getframe=document.createElement("iframe");getframe.setAttribute("width","460");getframe.setAttribute("id","chatiframe");getframe.setAttribute("height","410");getframe.setAttribute("scrolling","no");getframe.setAttribute("frameBorder","0");getframe.setAttribute("src",tempurl);var closewindow=document.createElement("div");closewindow.innerHTML="<div id='searmessagesing_style'><div class='textstyle'>"+titlemessage+"</div><div class='ssleaversclosebox'><a href='' onclick='closechatbox();return false;'><img src="+chatPath+"/close.jpg /></a></div></div>";chatLayer.appendChild(closewindow);chatLayer.appendChild(getframe);document.body.appendChild(chatLayer);hiddenchatbox();}
function str_replace(str){var keywords=str.replace(/'|"|&/g," ");keywords=keywords.replace("#39;","");return keywords;}

function AddFavorite(sURL, sTitle){    try    {        window.external.addFavorite(sURL, sTitle);    }    catch (e)    {        try        {            window.sidebar.addPanel(sTitle, sURL, "");        }        catch (e)        {            alert("Fail,Add to favorite fails, please use Ctrl D");        }    }}

function SetHome(obj,vrl){
        try{
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                        }
                        catch (e) {
                                alert("Your browser doesn't support Javascript");
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
}
function changepic(bigpic,picwidth,picheight,ob){if(ob==undefined || ob==""){var setbg=document.getElementById("imgpro");}else{var setbg=document.getElementById(ob);}setbg.setAttribute("src",bigpic);if(picwidth!="" || picwidth!=null){setbg.setAttribute("width",picwidth);}if(picheight!="" || picheight!=null){setbg.setAttribute("height",picheight);}}
/*点击显示图片*/var scrollPos

