function IkbaoChat_Scroll(){
   try{
      if(document.documentElement.scrollTop>0){
   	    document.getElementById("Javascript.Ikbao_ChatMsg").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("Javascript.Ikbao_ChatMsg").offsetHeight-5)+"px";
      }else{
        document.getElementById("Javascript.Ikbao_ChatMsg").style.top=(document.body.scrollTop+document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("Javascript.Ikbao_ChatMsg").offsetHeight-5)+"px";
      }
      document.getElementById("Javascript.Ikbao_ChatMsg").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("Javascript.Ikbao_ChatMsg").offsetWidth-5)+"px";
   }catch(e){}
}

function Ikbao_ChatMsg(str){
   var jstable="";
   var pstr=str.split("<->");
   var ppstr;
   jstable="<div id=\"Javascript.Ikbao_ChatMsg\" style=\"position:absolute;border:0;font-size:12px;z-index:1000;padding-top:4px;width:220px;height:140px\">";
   jstable+="<div style=\"width:100%;\"><div style=\"width:9px;height:27px;float:left;overflow:hidden;background:url(http://img.ikbao.com/chat/chat_top_left.jpg);\"></div><div style=\"width:154px;height:27px;float:left;overflow:hidden;background:url(http://img.ikbao.com/chat/chat_top_middle.jpg);\"><div style=\"padding-top:8px;font-weight:800;\">以下代练吧有留言给你：</div></div><div style=\"width:57px;height:27px;float:right;overflow:hidden;\"><a href=\"javascript:\" onclick=\"Close_Ikbao_ChatMsg()\"><img src=\"http://img.ikbao.com/chat/chat_top_close.jpg\" border=\"0\"></a></div></div>";
   jstable+="<div style=\"width:218px;background-color:#FFFFFF;border:1px solid #CCC;border-top:0;clear:both;\">";
   jstable+="<div style=\"width:203px;height:120px;font-size:13px;text-align:left;padding:3px;margin-left:8px;overflow-y:auto;overflow-x:hidden;\">";
   for(var i=0;i<pstr.length;i++){
   	   ppstr=pstr[i].split("<>");
   	   jstable+=CreateITong(ppstr[0],ppstr[1]);
   }
   jstable+="<\/div>";
   jstable+="<\/div>";
   jstable+="<\/div>";
   document.getElementById("IkCMsg").innerHTML=jstable;
   window.onscroll=function(){IkbaoChat_Scroll();};
   window.onresize=function(){IkbaoChat_Scroll();};
   IkbaoChat_Scroll();
}

function CreateITong(id,name){
	return "<div style=\"width:100%;border-bottom:1px solid #9DB2C5;margin-top:5px;clear:both;\">"+name+"<br><img src=\"http://chat.ikbao.com/StatePic.aspx?shopid="+id+"&chatpic=line&type=gif\" onclick=\"window.open('http://www.ikbao.com/dialog.htm?shopid="+id+"&noread=1','_blank','height=490,width=730,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no')\" style=\"cursor:pointer;\"><\/div>";
}

function Close_Ikbao_ChatMsg(){
	document.getElementById("Javascript.Ikbao_ChatMsg").style.display="none";
}

var isgflashover=0;
var trygetnum=0;

function setisgetflashover(n){
  isgflashover=1;
}

function sfctodo(str){
	
}

function thisMovie(movieName) { 
  if(navigator.appName.indexOf("Microsoft") != -1){ 
     return window[movieName] 
  }else { 
     return document[movieName]; 
  }            
} 

function SetIFCookies(fname,fvalue){
  try{
     thisMovie("imflash").SetFlashCookies(fname,fvalue); 
     return true;
  }catch(e){
     return false;
  }
}

function GetIFCookies(fname){
   try{
      var results=thisMovie("imflash").GetFlashCookies(fname);
      if(isgflashover==1){
         return results;
      }
   }catch(e){
      return "nodata";
   }
}

function TryToGetIkChatNotes(){
	var resultid=GetIFCookies("ikbaokf_uid");
	if(resultid=="nodata" || isgflashover!=1){
		trygetnum++;
		if(trygetnum<=4){
		   setTimeout(TryToGetIkChatNotes,500);
		}else{
		   document.getElementById("imflashdiv").innerHTML="";
		}
	}else{
		trygetnum=0;
		document.getElementById("imflashdiv").innerHTML="";
		if(typeof(resultid)=="undefined"){resultid="";}
		try{
			var Elements = document.getElementById("imflashdiv"); 
			var oScript = document.createElement("script"); 
			oScript.setAttribute("src","http://chat.ikbao.com/UseToGetNoRead.aspx?flashuid="+resultid+"&randtime="+Getnowdaystr()); 
			oScript.setAttribute("id","gutgnrg"); 
			oScript.setAttribute("type","text/javascript"); 
			oScript.setAttribute("language","javascript"); 
			Elements.appendChild(oScript); 
		}catch(e){}
	}
}

function GetIkChatNotes(){   //进入点
    trygetnum=0;
	setTimeout(TryToGetIkChatNotes,500);
}