var bgOb,msgObj;
function sAlert(stitle,str,swidth,seight){ 
	if(!swidth)
			swidth=680;
	var msgw,msgh,bordercolor;
	msgw=400;
	msgh=100;
	titleheight=25 
	bordercolor="#336699";
	titlecolor="#99CCFF";
	 
	var sWidth,sHeight;
	sWidth=top.document.body.offsetWidth-23;
	sHeight=top.document.body.offsetHeight-5;
	bgObj=top.document.createElement("div");
	bgObj.setAttribute('id','bgDivabcd');
	bgObj.style.position="absolute";
	bgObj.style.top="0";
	bgObj.style.background="#777";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
	bgObj.style.opacity="0.6";
	bgObj.style.left="0";
	bgObj.style.width=sWidth + "px";
	bgObj.style.height=sHeight + "px";
	bgObj.style.zIndex = "10000";
	top.document.body.appendChild(bgObj);					 
	msgObj=top.document.createElement('div');			
	msgObj.setAttribute("id","msgDiv"); 
	msgObj.setAttribute("align","center");
	msgObj.style.background="white"; 
	msgObj.style.position = "absolute";
	msgObj.style.zIndex = "10001";   
	msgObj.border=1; 
	if (navigator.appName == "Microsoft Internet Explorer")
		 s='<div  style="border:1px outset #002499;position:absolute;top:0;left:0;width:20;"><div id="hdl" style="background:#333377;width:100%;height:20;color:white">';
	else
		s='<div  style="position:absolute;top:0;left:0;width:20;"><div id="hdl" style="background:#333377;width:100%;height:20;color:white">';
	s+='<table width="'+swidth+'" border="0" cellpadding="0" cellspacing="0" >  <tr >    <td  height="25"  align="left" valign="bottom" background="/images/open_win.gif" class="e pad_left_5 blue_011575 font14  pad_right_10"><img src="/images/ie_win.gif" align="absmiddle" /><span class="fb white1">'+stitle+'</span></td>    <td width="10" align="right" background="/images/open_win.gif" class="pad_top3"><img src="/images/win_close.gif" onclick="closeDlg()"  hspace="5" /></td>  </tr></table>';
	s +='</div><div style="background:#dddddd;width:100%">';
	s+=str+' </div></div>';           
	msgObj.innerHTML=s;
	top.document.body.appendChild(msgObj);  
	smWidth= 200;//msgObj.offsetWidth;
	smHeight= 300;//msgObj.offsetHeight;
	msgObj.style.left = (top.document.body.clientWidth/2 - smWidth/2 -200)+"px" ;            
	msgObj.style.top = ((top.document.body.scrollTop+top.document.body.clientHeight/2 - smHeight/2)>top.document.scrollHeight?top.document.scrollHeight-top.document.body.clientHeight/2:top.document.body.scrollTop+top.document.body.clientHeight/2 - smHeight/2+70)-100+"px";
}

var isDrag = false;
var oldX=0,oldY=0;

function init(){ 
    isDrag=true;
    oldX=event.x;
    oldY=event.y;
}

function end(){
    isDrag=false;
}

function moveIt(){
    if(isDrag){
		var x =window.event.x;
		var y = window.event.y;    
		hdl.parentNode.style.left = parseInt(hdl.parentNode.style.left.replace("px","")) + (x - oldX);
		hdl.parentNode.style.top = parseInt(hdl.parentNode.style.top.replace("px","")) + (y - oldY);    
		oldX = x;
		oldY = y;
    }
}

function closeDlg(){
    top.document.body.removeChild(top.document.getElementById("bgDivabcd"));
	top.document.body.removeChild(top.document.getElementById("msgDiv"));
}

function getNews(divId,keyWord,titleLength){
	$(divId).innerHTML = "正在加载媒体新闻,请稍候......";
	var endPoint = "/bfapp";
	var buffalo = new Buffalo(endPoint);
	buffalo.remoteCall("SPrint.getNews",[encodeURI(keyWord),titleLength,""],function(reply){
		var result=reply.getResult();
		$(divId).innerHTML = result;
	})
}  