var vqqURL = "http://www.besttone.info/chat/?";
var vqqHref= vqqURL;
var win = {};
var VQQ_MinWin = null;
var VQQ_MaxWin = null;
/*****************************************************************************/
//基本兼容函数
/*****************************************************************************/
function encode(str){return window.encodeURIComponent ? encodeURIComponent(str) : escape(str);}
//========================================================================
function setCookie(n,v){
	document.cookie = n + "=" + v + ";";
}
function getCookie(n){
	var a = document.cookie;
	var search = n + '=';
	if(a.indexOf(search) == -1) return win.bbspowered;
	var startPos = a.indexOf(search) + search.length;
	if(startPos == -1)return 0;
	var endPos = a.indexOf(';', startPos);
	if(endPos < 0) endPos = a.length;
	return a.substring(startPos, endPos);
}
function getStrCookie(){
	var a = document.cookie.split(" ");
	return a.join("");
}
//create elm===============================================================
function CreateElm(pObj,obj,id,className){
	var a = document.createElement(obj);
	var p = pObj || document.body;
	p.appendChild(a);
	if(id)a.id = id;
	if(className)a.className = className ;
	return a;
}
//====================  set browser's varible  =============================
function Browser(){
	this.isIE=true;
	this.isNS=false;
	var us,s,i;
	us=navigator.userAgent;
	s="MSIE";
	if((i=us.indexOf(s))>-1){this.version=parseFloat(us.substr(i+s.length));return ;}
	s="Netscape6/";
	if((i=us.indexOf(s))>-1){this.isIE=false;this.isNS=true;this.version=parseFloat(us.substr(i+s.length));return ;}
	s="Gecko";
	if((i=us.indexOf(s))>-1){this.isIE=false;this.isNS=true;this.version=6.1;return ;}
}
var browser = new Browser();
//==========================  add or del event ===============================
function AddEvent(obj,evType,func){
	if(obj.addEventListener){
		obj.addEventListener(evType,func,true);
	}else if(obj.attachEvent){
		obj.attachEvent("on"+evType,func);
	}
}
function DelEvent(obj,evType,func){
	if(obj.removeEventListener){
		obj.removeEventListener(evType,func,true);
	}else if(obj.detachEvent){
		obj.detachEvent('on'+evType,func);
	}
}
//===========  Get Body's scrollTop at BackCompat and CSS1Compat ================
function GetBodyScrollTop(){
    if (typeof window.pageYOffset != 'undefined')return window.pageYOffset;
    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')return document.documentElement.scrollTop;
    else if (typeof document.body != 'undefined')return document.body.scrollTop;
}
//=============  Get client's height and width  ==================
function GetClientWidth(){
    if(typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') return document.documentElement.clientWidth;
    else if (typeof document.body != 'undefined')return document.body.clientWidth;
}
function GetClientHeight(){
    if(typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') return document.documentElement.clientHeight;
	else if (typeof document.body != 'undefined')return document.body.clientHeight;
}
//==============  get image's width and height  =====================
function GetImageSize(url){
	var a = new Image();
	a.src = url;
	return a;
}
/*****************************************************************************/
//元素对象拖动
/*****************************************************************************/
function VQQ_MoveInit(obj){
	for(var i = 0;i < obj.childNodes.length;i++){
		var a = obj.childNodes[i];
		if(!a)continue;
		if(a.id == 'VQQ_Top'){
			win.moveObj = a;
			AddEvent(a,"mousedown",VQQ_MoveStart);
			a.pN=obj;
		}
	}
}
function VQQ_MoveStart(event){
	if(win.isResize || win.isMax) return ;
	var a = win.moveObj;
	var target = null;
	target = event.target || window.event.srcElement;
	if(target != a)return ;
	AddEvent(document,"mousemove",VQQ_MoveDrag);
	AddEvent(document,"mouseup",VQQ_MoveEnd);
	win.isMove = true;
	win.displayH = true;
	BlockIFrame();
	a.parentNode.curX = event.clientX;
	a.parentNode.curY = event.clientY;
	if(browser.isIE)a.parentNode.setCapture();
	if(browser.isNS){
		window.captureEvents(Event.MOUSEMOVE);
		event.preventDefault();
		event.stopPropagation();
	}
}
function VQQ_MoveDrag(event){
	var a = win.moveObj;
	var DivSelect = a.pN;
	var newX = event.clientX;
	var newY = event.clientY;
	
	var newT = DivSelect.offsetTop + newY - DivSelect.curY;
	var newL = DivSelect.offsetLeft + newX - DivSelect.curX;
	if(newY > DivSelect.curY){
		win.suckTop = false;
		win.suckBottom = true;
	}else{
		win.suckTop = true;
		win.suckBottom = false;
	}
	if(newX > DivSelect.curX){
		win.suckLeft = false;
		win.suckRight = true;
	}else{
		win.suckLeft = true;
		win.suckRight = false;
	}
	DivSelect.style.left = newX<0 ? 0 : newL + "px";
	DivSelect.curX = newX;
	DivSelect.style.top = newY<0 ? 0 : newT + "px";
	DivSelect.curY = newY;
	
	win.obj.isRight = false;
	win.obj.isBottom = false;
	SetWinCurPos();
	SuckSide(event);
	PosLimit();
}
function VQQ_MoveEnd(event){
	if(browser.isIE)win.moveObj.pN.releaseCapture();
	if(browser.isNS)window.releaseEvents(Event.MOUSEMOVE);
	win.isMove = false;
	win.displayH = false;
	DelEvent(document,"mousemove",VQQ_MoveDrag);
	DelEvent(document,"mouseup",VQQ_MoveEnd);
	BlockIFrame();
}
function SuckSide(event){
	if(win.suckTop && win.obj.curTop<10){
		win.obj.style.top = parseInt(GetBodyScrollTop(),10) + "px";
	}
	if(win.suckLeft && win.obj.curLeft<10){
		win.obj.style.left = "0px";
	}
	if(win.suckBottom && win.obj.curBottom+10>GetClientHeight()){
		win.obj.style.top = GetClientHeight() - win.obj.curHeight + parseInt(GetBodyScrollTop(),10) + "px";
	}
	if(win.suckRight &&win.obj.curRight+10>GetClientWidth()){
		win.obj.style.left = GetClientWidth() - win.obj.curWidth + "px";
	}
}
/*****************************************************************************/
//    control win's big and small
/*****************************************************************************/
function ResizeInit(event){
	var target = event.target || window.event.srcElement;
	if(!target || win.isMax)return ;
	win.isResize = true;
	win.displayH = true;
	win.resizeObj = target;
	
	// Save cursor position
	win.xPosition = event.clientX;
	win.yPosition = event.clientY;
	// Save win's old l,t,w,h
	win.oldTop = win.obj.offsetTop;
	win.oldLeft = win.obj.offsetLeft;
	win.oldWidth = win.obj.offsetWidth;
	win.oldHeight = win.obj.offsetHeight;
	
	AddEvent(document, "mousemove", ResizeStart);
	AddEvent(document, "mouseup", ResizeEnd);
	//set document's capture
	if(browser.isIE)win.resizeObj.setCapture();
	if(browser.isNS){
		window.captureEvents(Event.MOUSEMOVE);
		event.preventDefault();
		event.stopPropagation();
	}
}
function ResizeStart(event){
	var obj = win.resizeObj;
	if(!obj.id){win.resizeObj=null;win.isResize=false;return ;}
	var north, east, south, west;
	north = (obj.id.indexOf("North") != -1) ? true : false;
	east = (obj.id.indexOf("East") != -1) ? true : false;
	south = (obj.id.indexOf("South") != -1) ? true : false;
	west = (obj.id.indexOf("West") != -1) ? true : false;
	
	// change cursor's position
	var dx = event.clientX - win.xPosition;
	var dy = event.clientY - win.yPosition;
	if (west) dx = -dx;
	if (north) dy = -dy;
	// Check new size.
	w = win.oldWidth  + dx;
	h = win.oldHeight + dy;
	
	//ResizeLimit();
	if ((east || west) && w > win.minWidth){
		win.obj.style.width = w +"px";
		if (west) win.obj.style.left = win.oldLeft - dx + "px";
	}
	if ((north || south) && h > win.minHeight){
		win.obj.style.height = h +"px";
		if (north) win.obj.style.top = win.oldTop - dy + "px";
	}
	win.isInit = false;
	winFrameResize();
	SetWinCurPos();
	BlockIFrame();
}
function ResizeEnd(event){
	if(browser.isIE)win.resizeObj.releaseCapture();
	if(browser.isNS)window.releaseEvents(Event.MOUSEMOVE);
	win.resizeObj = false;
	win.isResize = false;
	win.displayH = false;
	DelEvent(document, "mousemove", ResizeStart);
	DelEvent(document, "mouseup", ResizeEnd);
	BlockIFrame();
}
function ResizeLimit(){
	if(win.obj.curTop <= 0){
		win.obj.curTop = 0;
		win.obj.style.top = parseInt(GetBodyScrollTop(),10) + "px";
	}
	if(win.obj.curLeft <= 0){
		win.obj.curLeft = 0;
		win.obj.style.left = 0 +"px";
	}
	if(win.obj.curRight >= GetClientWidth()){
		win.obj.curRight = 0;
		win.obj.style.width = GetClientWidth() -win.obj.offsetWidth + "px";
	}
	if(win.obj.curBottom >= GetClientHeight()){
		win.obj.curBottom = 0;
		win.obj.style.top = GetClientHeight() + parseInt(GetBodyScrollTop(),10) - win.obj.offsetHeight + "px";
	}
}
/*****************************************************************************/
//    resize tag
/*****************************************************************************/
function SetResizeCursor(){
	if(!win.obj)return ;
	SetResizeCursor_1("NorthResize"		,"top:0px;left:0px;width:100%;height:8px;z-index:110;cursor:n-resize;");
	SetResizeCursor_1("NorthEastResize"	,"top:0px;right:0px;width:8px;height:8px;z-index:111;cursor:ne-resize;");
	SetResizeCursor_1("EastResize"		,"top:0px;right:0px;width:8px;height:100%;z-index:110;cursor:e-resize;");
	SetResizeCursor_1("SouthEastResize"	,"right:0px;bottom:0px;width:8px;height:8px;z-index:111;cursor:se-resize;background:#DADFD5;");
	SetResizeCursor_1("SouthResize"		,"left:0px;bottom:0px;width:100%;height:8px;z-index:110;cursor:s-resize;");
	SetResizeCursor_1("SouthWestResize"	,"left:0px;bottom:0px;width:8px;height:8px;z-index:111;cursor:sw-resize;");
	SetResizeCursor_1("WestResize"		,"top:0px;left:0px;width:8px;height:100%;z-index:110;cursor:w-resize;");
	SetResizeCursor_1("NorthWestResize"	,"top:0px;left:0px;width:8px;height:8px;z-index:111;cursor:nw-resize;");
}
function SetResizeCursor_1(id,css){
	var a = CreateElm(win.obj, 'div', id);
	a.style.cssText = css + 'position:absolute;overflow:hidden;';
	AddEvent(a,"mousedown",ResizeInit);
}
/*****************************************************************************/
//    resize tag
/*****************************************************************************/
function win2X(){
	var w = (win.is2X || !win.isInit)?(win.initWidth):(win.initWidth*3/2);
	var h = (win.is2X || !win.isInit)?(win.initHeight):(win.initHeight*3/2);
	win.obj.style.top = win.obj.curTop + parseInt(GetBodyScrollTop(),10) + "px";
	win.obj.style.left = win.obj.curLeft + "px";
	win.obj.style.width = w + "px";
	win.obj.style.height = h + "px";
	winFrameResize();
	
	var dr = win.obj.curLeft + win.obj.offsetWidth;
	var db = win.obj.curTop + win.obj.offsetHeight;
	if(dr>GetClientWidth())win.obj.style.left = GetClientWidth() - win.obj.offsetWidth + "px";
	if(db>GetClientHeight())win.obj.style.top = GetClientHeight() + parseInt(GetBodyScrollTop(),10) - win.obj.offsetHeight + "px";
	if(win.obj.isRight)win.obj.style.left = GetClientWidth() - win.obj.offsetWidth + "px";
	if(win.obj.isBottom)win.obj.style.top = GetClientHeight() + parseInt(GetBodyScrollTop(),10) - win.obj.offsetHeight + "px";
	SetWinCurPos();
	
	win.is2X = win.is2X?false:true;
	if(!win.isInit) win.is2X = false;
	win.isInit = win.isInit?false:true;
	win.isMin = false;
	win.isMax = false;
	win.obj.isMax = false;
	window.focus();
}
function winMin(){
	win.Open(0);
	window.focus();
	win.obj.style.display = "none";
	win.isMin = true;
	win.isMax = false;
	if(VQQ_MinWin){
		win.obj = VQQ_MinWin;
		VQQ_MinWin.style.display = "";
		SetWinPlace();
		winScroll();
	}
	else WinMinInit();
}
function winMax(){
	if(win.isMin)return ;
	if(win.isMax){winRestore();return false;}
	win.obj.style.top = GetBodyScrollTop() +"px";
	win.obj.style.left = 0 +"px";
	win.obj.style.width = GetClientWidth() + "px";
	win.obj.style.height = GetClientHeight() + "px";
	winFrameResize();
	win.isMin = false;
	win.isMax = true;
	win.obj.isMax = true;
	window.focus();
}
function winRestore(){
	window.focus();
	if(win.isMin)return ;
	win.isMax = false;
	win.obj.isMax = false;
	if(win.place == "center"){SetWinPlace();return ;}
	win.obj.style.top = win.obj.curTop + GetBodyScrollTop() + "px";
	win.obj.style.left = win.obj.curLeft + "px";
	win.obj.style.width = win.obj.curWidth + "px";
	win.obj.style.height = win.obj.curHeight + "px";
	winFrameResize();
	SetWinCurPos();
	PosLimit();
}
function winClose(){
	window.focus();
	var str = "%u786E%u5B9A%u8981%u9000%u51FA%u56F4%u5708%u5708%u5417%uFF1F%0D%0A%0A";
	if(!confirm(unescape(str)))return ;
	document.getElementById("VQQFrame").src = "about:blank";
	document.body.removeChild(win.obj);
	win.obj = null;
	win.Open(0);
}
function winFrameResize(){
	if(!win.obj || !win.frame || win.isMin){
		return ;
	}
	win.frame.style.width = "100%";
	win.frame.style.height = parseInt(win.obj.style.height,10) + "px";
	try{
		win.moveCapture.style.width = win.maxMid.offsetWidth - 15 + "px";
	}catch(e){}
}
/*****************************************************************************/
//    win on scroll or resize
/*****************************************************************************/
function winScroll(){
	if(!win.obj || (win.isMin && browser.isNS))return ;
	if(win.obj.style.position == 'fixed'){
		win.obj.style.position = 'absolute';
		return false;
	}
	win.obj.style.top = parseInt(GetBodyScrollTop(),10) + (win.isMax?0:win.obj.curTop) + "px";
}
function winResize(){
	if(!win.obj)return ;
	if(win.isMax){
		win.obj.style.top = parseInt(GetBodyScrollTop(),10) + (win.isMax?0:win.obj.curTop) + "px";
		win.obj.style.left = 0 + "px";
		win.obj.style.width = GetClientWidth() + "px";
		win.obj.style.height = GetClientHeight() + "px";
	}
	else if(win.isMin){
		if(win.place == "center"){SetWinPlace();return ;}
		if(browser.isNS)return ;
		if(win.place.indexOf("T") == -1){
			win.obj.style.top = parseInt(GetBodyScrollTop(),10) + GetClientHeight() - win.obj.offsetHeight + "px";
		}
		else if(win.place.indexOf("T") != -1){
			win.obj.style.top = parseInt(GetBodyScrollTop(),10) + "px";
		}
		win.obj.style.left = GetClientWidth() - win.obj.curWidth + "px";
	}
	else{
		if(win.obj.offsetTop<0)win.obj.style.top = 0 + "px";
		if(win.obj.offsetLeft<0)win.obj.style.left = 0 + "px";
		if(win.obj.isRight)win.obj.style.left = GetClientWidth() - win.obj.offsetWidth + "px";
		if(win.obj.isBottom)win.obj.style.top = GetClientHeight() - win.obj.offsetHeight + "px";
	}
	winFrameResize();
	PosLimit();
}
//========================================================
function BlockIFrame(){
	if(win.displayH){win.maxH.style.display = '';}
	else {win.maxH.style.display = 'none';}
	win.maxH.style.top = win.maxMid.offsetTop + "px";
	win.maxH.style.left = win.maxMid.offsetLeft + "px";
	win.maxH.style.width = win.maxMid.offsetWidth + "px";
	win.maxH.style.height = win.maxMid.offsetHeight + "px";
}
/*****************************************************************************/
//   init
/*****************************************************************************/
function VQQInit(){
	win.frame							= null;
	win.moveCapture						= null;
	win.image							= null;
	win.RoomID							= null;
	win.moveObj							= null;
	win.resizeObj						= null;
	win.obj								= null;
	win.maxMid							= null;
	win.encode							= 0;
	win.everyPage						= 0;
	win.place							= "RB";
	win.Css								= 2;
	win.initWidth						= 360;
	win.initHeight						= 240;
	win.minWidth						= 330;
	win.minHeight						= 220;
	win.isMin							= true;
	win.isMax							= false;
 	win.is2X							= false;
 	win.isMove							= false;
	win.isResize						= false;
	win.isLoaded						= false;
	win.isMaxOpened						= false;
	win.CssLoaded						= false;
	win.suckTop 						= false;
	win.suckLeft	 					= false;
	win.suckRight 						= false;
	win.suckBottom 						= false;
	win.listHidden						= 1;
	win.isInit							= true;
	win.displayH						= false;
	
	win.cursor							= (browser.isIE && browser.version < 6) ? "hand" : "pointer";
	win.docModel						= (document.compatMode == 'BackCompat') ? true : false;
	
	GetRoomInfo();
	VQQInit2();
	//定义吸边
	window.onresize = winResize;
}
function VQQInit2(){
	if(!win.RoomID){return ;}
	if(!win.isLoaded && !win.CssLoaded){
		var timer,i;
		timer = setInterval(function(){if(i>10)clearInterval(timer);},200);
		return ;
	}
	WinMinInit();
	window.onscroll = winScroll;
}
/*****************************************************************************/
function GetRoomInfo(){
	try{win.RoomID = g_vqq_roomid}catch(e){win.RoomID = 1}
	try{win.image = g_vqq_image}catch(e){win.image = 0}
	try{win.openmaxwin = g_vqq_openmaxwin}catch(e){win.openmaxwin = 0}
	try{win.uniteurl = g_vqq_uniteurl}catch(e){win.uniteurl = 0}
	if(document.compatMode == "BackCompat" && browser.isIE) win.initWidth += 12;
	
	win.listHidden = 0;
//	win.isMin = true;
	if(win.isMin)win.isTime = 0;
	win.isLoaded = true;
	set_max_host();
	//postme();
	//timeoutCurUser(0);
}
/*****************************************************************************/
function set_max_host(){
	var notMinHost = new Array('www.vqq.com','www.whuu.com','www.51.vc');
	for(var i = 0 ; i < notMinHost.length ; i++){
		var a = notMinHost[i];
		if(a.indexOf(window.location.host) > -1)win.isMin = false;
	}
}
/*****************************************************************************/
function getUniteCookie(){
	var strCookies = getStrCookie();
	try{win.cookie = encode(strCookies)}catch(e){win.cookie = 0}
	return win.cookie;
}
/*****************************************************************************/
function WinMinInit(){
	if(win.openmaxwin == 2){WinMaxInit();return;}
	if(win.getOpen() == 1 || (!win.isMin && !win.isTime)){ WinMaxInit(); return ;}
	if(!VQQ_MinWin){
		VQQ_MinWin = CreateElm(null, "div");
		//SetWinPlace(VQQ_MinWin);
		VQQ_MinWin.style.cssText = "position:absolute;margin:0px;padding:0px;overflow:hidden;z-index:100;";
		VQQ_MinWin.style.cursor = win.cursor;
		var image,a;
		if(win.image){image = win.image;}
		else image = "http://www.besttone.info/chat/images/chat"+ win.Css +".gif";
		
		if(browser.isIE){
			a = GetImageSize(image);
			VQQ_MinWin.style.width = a.width + "px";
			VQQ_MinWin.style.height = a.height + "px";
			VQQ_MinWin.style.background = "url("+ image +") no-repeat 0 0";
			VQQ_MinWin.innerHTML = "<span style='visibility:hidden'>信息圈（VQQ）</span>";
		}else{
			VQQ_MinWin.style.position = 'fixed';
			VQQ_MinWin.innerHTML = "<img src='"+ image +"'>";
		}
	}
	
	win.obj = VQQ_MinWin;
	win.isMin = true;
	SetWinPlace();
	SetWinCurPos();
	winScroll();
	if(!win.isMin && win.isTime){setTimeout("WinMaxInit()", win.isTime*1000);return ;}
	AddEvent(VQQ_MinWin, "click", ClickMinWin);
}
function ClickMinWin(event){
	if(win.openmaxwin){
		win.PopOut(win.openmaxwin);
	}else{
		WinMaxInit();
	}
}
//===========   set loading's div to hidden  =============================
var vqqFrameLoadCount = 0;
function set_loaded(){
	vqqFrameLoadCount++ ;
	try{
		win.obj.removeChild(win.loaded);win.loaded=null;
	}catch(e){}
}
function WinMaxInit(){
	win.Open(1);
	if(win.obj)win.obj.style.display = "none";
	if(VQQ_MaxWin){
		win.obj = VQQ_MaxWin;
		VQQ_MaxWin.style.top = parseInt(GetBodyScrollTop(),10) + (win.isMax?0:VQQ_MaxWin.curTop) + "px";
		VQQ_MaxWin.style.display = "";
		if(win.obj.isMax){win.isMax = false;win.isMin = false;winMax();}
	}
	win.isMin = false;
	if(!VQQ_MaxWin){
		VQQ_MaxWin = CreateElm(null, 'div');
		win.obj = VQQ_MaxWin;
		VQQ_MaxWin.style.cssText = "position:absolute;overflow:visible;text-align:left;margin:0px;padding:0px;z-index:100;";
		VQQ_MaxWin.style.width = win.initWidth + "px";
		VQQ_MaxWin.style.height = win.initHeight + "px";
		if(browser.isNS)VQQ_MaxWin.style.position = 'fixed';
		//set VQQ_MaxWin's current place
		win.loaded = CreateElm(VQQ_MaxWin, 'div');
		win.loaded.style.cssText = "position:absolute;z-index:1000;text-align:center;background:#fff;"
				+"font-family:Arial, Helvetica, sans-serif;font-size:12px;border:3px solid #DADFD5";
		
		win.loaded.style.top = '0px';
		win.loaded.style.left = '0px';
		win.loaded.style.width = win.initWidth - (win.docModel ? 0 : 6) + 'px';
		win.loaded.style.height = win.initHeight - (win.docModel ? 0 : 6) + 'px';
		win.loaded.innerHTML = '<div style="background:url(http://www.besttone.info/chat/images/loading.gif) no-repeat 0 0;'
			+'padding:6px 0 0 40px;margin:'+(win.initHeight/2 -16)+'px auto 0;width:90px;height:32px;">'
			+'<span> Loading ... </span></div>';
		
		var VQQ_MaxTop = CreateElm(VQQ_MaxWin, 'div', 'VQQ_Top');
		VQQ_MaxTop.style.cssText = "position:absolute;cursor:move;text-align:right;left:4px;z-index:115;top:4px;";
		VQQ_MaxTop.innerHTML+="<span style='visibility:hidden'>信息圈</span>";
		VQQ_MaxTop.innerHTML+="<img src='http://www.besttone.info/chat/images/buttons_mini.gif' usemap='#VQQ_Map' style='cursor:"+win.cursor+";border:0;'>";
		VQQ_MaxTop.innerHTML+="<map name='VQQ_Map' id='VQQ_Map'>"
			+"<area shape='rect' coords='0,0,15,15' onclick='winMin();return false;' href='#' title='最小化' />"
			+"<area shape='rect' coords='16,0,30,15' onclick='win2X();return false;' href='#' title='2倍放大/还原' />"
			+"<area shape='rect' coords='31,0,45,13' onclick='win.PopOut();return false;' href='#' title='以新窗口打开' />"
			+"<area shape='rect' coords='46,0,62,13' onclick='winClose();return false;' href='#' title='关闭/退出' />"
			+"</map>";
		AddEvent(VQQ_MaxTop, 'dblclick', winMax);
		
		win.maxH = CreateElm(VQQ_MaxWin, 'div');
		win.maxH.style.cssText = "margin:0;padding:0;clear:both;position:absolute;display:none;background-color:#999;z-index:105;";
		win.maxH.style.opacity = 0.5;
		win.maxH.style.filter = "alpha(opacity=50)";
		
		win.maxMid = CreateElm(VQQ_MaxWin, 'div');
		win.maxMid.style.cssText = "clear:both;margin:0;padding:0;";
		win.maxMid.innerHTML = "<iframe name='VQQFrame' id='VQQFrame' src='' width='100%' height='"+win.initHeight+"' frameborder='0' scrolling='no' style='overflow:hidden;margin:0;' onload='set_loaded()'></iframe>";
		
		win.frame = document.getElementById("VQQFrame");
		win.frame.style.width = win.maxMid.offsetWidth + "px";
		win.moveCapture = VQQ_MaxTop;
		win.moveCapture.style.width = win.maxMid.offsetWidth - 8 + "px";
		win.frame.src = vqqHref + "target=1&rid="+ win.RoomID +"&cookie="+ getUniteCookie();
		
		VQQ_MoveInit(VQQ_MaxWin);
		SetResizeCursor(VQQ_MaxWin);
		SetWinPlace();
		SetWinCurPos();
		win.isMaxOpened = true;
		winScroll();
	}
}
/*****************************************************************************/
//
/*****************************************************************************/
function SetWinPlace(obj){
	if(win.isMax)return ;
	if(obj)win.obj = obj;
	if(win.place.toLowerCase() == "center"){
		var top = GetClientHeight()/2 - win.obj.offsetHeight/2;
		var left = GetClientWidth()/2 - win.obj.offsetWidth/2;
		win.obj.style.top = ((top < 0) ? 0 : top) + "px";
		win.obj.style.left = ((left < 0) ? 0 : left) + "px";
	}else if(win.place.toUpperCase() == "LT"){
		win.obj.style.top = parseInt(GetBodyScrollTop(), 10) +"px";
		win.obj.style.left = 0 + "px";
	}else if(win.place.toUpperCase() == "RT"){
		win.obj.style.top = parseInt(GetBodyScrollTop(), 10) + "px";
		win.obj.style.right = 0 + "px";
		win.obj.isRight = true;
	}else if(win.place.toUpperCase() == "LB"){
		win.obj.style.left = 0 + "px";
		win.obj.style.bottom = 0 + "px";
		win.obj.isBottom = true;
	}else if(win.place.toUpperCase() == "RB"){
		win.obj.style.right = 0 + "px";
		win.obj.style.bottom = 0 + "px";
		win.obj.isRight = true;
		win.obj.isBottom = true;
	}
}
function SetWinCurPos(){
	win.obj.curTop = win.obj.offsetTop - parseInt(GetBodyScrollTop(),10);
	win.obj.curLeft = win.obj.offsetLeft;
	win.obj.curWidth = win.obj.offsetWidth;
	win.obj.curHeight = win.obj.offsetHeight;
	
	win.obj.curRight = win.obj.curLeft + win.obj.offsetWidth;
	win.obj.curBottom = win.obj.curTop + win.obj.offsetHeight;
	win.obj.curClientWidth = GetClientWidth();
	win.obj.curClientHeight = GetClientHeight();
}
function PosLimit(){
	if(win.isMin){ SetWinCurPos(); return ; }
	if(win.obj.curTop<=0){
		win.obj.curTop = 0;
		win.obj.style.top = parseInt(GetBodyScrollTop(),10) + "px";
	}
	if(win.obj.curLeft<=0){
		win.obj.curLeft = 0;
		win.obj.style.left = 0 +"px";
	}
	if(win.obj.curRight >= GetClientWidth()){
		win.obj.curRight = 0;
		win.obj.style.left = GetClientWidth() -win.obj.offsetWidth + "px";
		win.obj.isRight = true;
	}
	if(win.obj.curBottom >= GetClientHeight()){
		win.obj.curBottom = 0;
		win.obj.style.top = GetClientHeight() + parseInt(GetBodyScrollTop(), 10) - win.obj.offsetHeight + "px";
		win.obj.isBottom = true;
	}
	if(!win.isMax)SetWinCurPos();
}
/*****************************************************************************/
//
/*****************************************************************************/
win.Open = function(n){return ;
	setCookie('open', n);
}
win.getOpen = function(){return getCookie('open')}
win.PopOut = function(t){
	if(t == 1 || !win.uniteurl){
		var url = vqqHref + "target=0&rid="+ win.RoomID +"&cookie="+ getUniteCookie();
	}else if(t == 2 && win.uniteurl){
		var url = win.uniteurl;
		url += win.uniteurl.indexOf('?') > -1 ? '&' : '?';
		url += 'url='+ encode(vqqHref + "target=0&rid="+ win.RoomID +"&cookie=");
	}else{
		var url = vqqURL + 'joinroom.php?rid='+ win.RoomID;
	}
	var bar = "toolbar=no,location=no,directories=no,menubar=no,titlebar=no,scrollbars=no,resizable=yes,width=800,height=600";
	window.open(url, "VQQ_xiaox", bar);
	try{win.frame.src = "about:blank";}catch(e){}
	document.body.removeChild(win.obj);
	win.Open(0);
}
win.UnLoaded = function(){
	document.getElementById("VQQFrame").src = "about:blank";
	document.body.removeChild(win.obj);
	win.obj = null;
	win.Open(0);
}



/*****************************************************************************/
//
/*****************************************************************************/
AddEvent(window,"load",VQQInit);
