var F= F||{};


F.$=function(id){
	return document.getElementById(id);
}
/**
String	title 
String	html,
Arrary	bts Array( Array(clickFunction,valueString),Array(clickFunction,valueString));
int	width
int	height

F.show('爱词霸短句2','<div style="padding:50px;">good</div>',[[function(){alert(5)},'关闭'],['','开始']],400,250);
**/
F.show=function(title,html,bts,width,height){	
	try{
		btstring='';
		F.$('icibaWinBotton').innerHTML='';
		for(i=0;i<bts.length;i++){
			ds= document.createElement('span');
			b= document.createElement('INPUT');			
			if( bts[i][0]!='' )b.onclick=bts[i][0];
			if( bts[i][1]!='' )b.value=bts[i][1];
			b.type = 'button';
			ds.appendChild(b);
			F.$('icibaWinBotton').appendChild(ds);
		}

	}catch(e){
		alert("初始化按钮出问题");
	}

	F.$('icibaWin').style.width= width+'px';
	if(height>0)F.$('icibaWinContW').style.height= height+'px';
	F.$('icibaWinTitle').innerHTML = title;
	F.$('icibaWinCont').innerHTML = html;
	pos=F.getPos(width,height);
	F.$('icibaWin').style.left= (pos[0])+'px';
	if(height==0){
		_top= pos[1]-200;
		if(_top<=0){_top=0;}
	}
	
	//alert(pos);	
	F.$('icibaWin').style.top= _top+'px';
	F.floatShow();
	F.$('icibaWin').style.display='block';


}
F.getPos=function(width,height){
	clX= (document.documentElement.clientWidth-parseInt(width))/2;
	clY= (document.documentElement.clientHeight-parseInt(height))/2;
	if(clX<0)clX=0;
	if(clY<0)clY=0;
	 if (document.documentElement) {
        ex = clX + document.documentElement.scrollLeft + document.body.scrollLeft;
        ey = clY + document.documentElement.scrollTop + document.body.scrollTop;
    } else {
        ex =  clX + window.scrollX;
        ey =  clY + window.scrollY;
    }
	return [ex,ey];
}
F.hide=function(){	
	F.$('icibaWin').style.display='none';
	F.$('icibaWinFloat').style.display= 'none';
	F.$('icibaWinCont').innerHTML = '';
}

F.floatShow=function(){
	//document.documentElement.scrollHeight + 'px';
	//alert(document.documentElement.clientHeight+ ':'+ document.body.clientHeight +":"+ document.body.scrollTop);
	 h=(document.documentElement)?document.documentElement.scrollHeight:document.body.scrollHeight;
	 w=(document.documentElement)?document.documentElement.scrollWidth:document.body.scrollWidth;
	 F.$('icibaWinFloat').style.width= w+'px';
	 F.$('icibaWinFloat').style.height= h+'px';
	 F.$('icibaWinFloat').style.display= 'block';
	
}
F.floatHide= function(){
	 F.$('icibaWinFloat').style.display= 'none';
}

F.w=function(str){
	document.write(str);
}


F.init=function(){
	F.w('<style>');
	F.w('#icibaWin{position:absolute;top:0px;left:5px;background-color:#ffffff;border:2px solid #bcd6ee;z-index:1005;display:none}');
	F.w('#icibaWinHead{height:27px;background:url("/v5/icibawin.png") repeat-x scroll -0px -0px;padding:0 10px 0 15px;}');
	F.w('#icibaWinHead #icibaWinTitle{float:left;font-size:12px;font-weight:bold;color:#336699;line-height:24px;font-family:"宋体"} ');
	F.w('#icibaWinHead #icibaWinClose{float:right;overflow:hidden;height:20px;width:15px;background:url("/v5/icibawin.png") no-repeat scroll -10px -35px;line-height:300px;cursor:pointer;} ');
	F.w('');
	F.w('#icibaWinContW{padding:20px;}');
	F.w('#icibaWinBotton{text-align:center;}');
	F.w('#icibaWinBotton span{margin-right:20px;margin-top:20px;border:1px solid #dfeffc}');
	F.w('#icibaWinBotton span INPUT{padding:0;margin:0;border:1px solid #bcd6ee;height:23px;cursor:pointer;');
	F.w('	background:url("/v5/icibawin.png") repeat-x scroll -0px -60px;font-size:12px;line-height:20px;padding:0 5px;');
	F.w('	color:#336699;font-family:"宋体";font-weight:bold;	');
	F.w('}');
	F.w('#icibaWinFloat{background-color:#CCCCCC;height:100%;left:0;opacity:0.7;position:absolute;top:0;width:100%;z-index:1000;');
	F.w('	filter : progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=70,finishOpacity=100);display:none');
	F.w('}');
	F.w('</style>');
	F.w('<div id="icibaWin" style="width:400px;">');
	F.w('	<div id="icibaWinHead" >');
	F.w('		   <div id="icibaWinTitle">爱词霸句库</div>');
	F.w('		   <div id="icibaWinClose">关闭</div>');
	F.w('		   <div style="clear:both"></div>');
	F.w('	</div>');
	F.w('	<div id="icibaWinContW">');
	F.w('		<div id="icibaWinCont">	</div>	');
	F.w('		<div id="icibaWinBotton">  </div>');
	F.w('	</div>');
	F.w('</div>');
	F.w('<div id="icibaWinFloat"></div>');

	F.$('icibaWinClose').onclick=F.hide ;
	//F.show('爱词霸句库','<div style="padding:50px;">good</div>',[[function(){alert(5)},'关闭'],['','开始']],400,550);
}
F.init();



//alert('456');
