// JScript 文件
//var doc = document.domain;
//var loginformurl = "http://passport"+doc.substr(doc.indexOf("."));
var loginformurl = "http://passport.k8008.com";

var FBrowser=new Object();
FBrowser.isIE=((navigator.userAgent.indexOf('MSIE')==-1)?false:true);
FBrowser.isIE7=((FBrowser.isIE&&window.XMLHttpRequest)?true:false);
FBrowser.isIE6=((FBrowser.isIE&&!window.XMLHttpRequest&&window.ActiveXObject)?true:false);
FBrowser.isFirefox=((navigator.userAgent.indexOf('Firefox')==-1)?false:true);
FBrowser.isOpera=((navigator.userAgent.indexOf('Opera')==-1)?false:true);

//String.prototype.lTrim=function(){return this.replace(/^\s*/,"");}
//String.prototype.rTrim=function(){return this.replace(/\s*$/,"");}
//String.prototype.trim=function(){return this.rTrim().lTrim();}
//String.prototype.hasChinese=function(){return/[^\x00-\xff]/g.test(this);}
//String.prototype.onlyChinese=function(){return/^[\u0391-\uFFE5]+$/g.test(this);}
//String.prototype.onlyNumber=function(){return/^[1-9]\d*$/.test(this);}
//String.prototype.getLength=function(){
//return this.replace(/[^\x00-\xff]/gi,'xx').length;}

function Fid(id)
{
	return document.getElementById(id);
}

function FsetOffsetWindowPostionByRate(e,nx,ny,isID)
{
	if(isID==true)e=Fid(e);
	var s=FgetWindowSize();
	FsetOffsetWindowPostion(e,(s.width-e.offsetWidth)/nx,(s.height-e.offsetHeight)/ny);
}

function FgetWindowSize()
{
	if(FBrowser.isOpera)
	return{width:document.body.clientWidth,height:document.body.clientHeight};
	else
	return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};
}

function FgetScrollPostion()
{
	return{left:document.documentElement.scrollLeft,top:document.documentElement.scrollTop};
}

function FsetOffsetWindowPostion(e,x,y,isID)
{
	if(isID==true)e=Fid(e);
	var p=FgetScrollPostion();
	FsetPostion(e,x+p.left,y+p.top,-1,-1);
}

function FsetPostion(e,x,y,w,h,isID)
{
	if(isID==true)e=Fid(e);
	var s=e.style;
	if(s.position=="absolute"){
	s.left=x+"px";
	s.top=y+"px";}else if(s.position=="relative"){
	var p=FgetPostion(e.offsetParent);
	s.left=(x-p.x)+"px";
	s.top=(y-p.y)+"px";}
	if(w>=0)s.width=w+"px";
	if(h>=0)s.height=h+"px";
}
function Fempty(v){
if(v!=null&&(typeof(v)=='object'||typeof(v)=='function'))return false;
return((""==v||undefined==v||null==v)?true:false);}

function FunsetModal(wid){
var e=(Fempty(wid)?Fid('$_modal_$'):Fid(wid));
if(!Fempty(e))
document.body.removeChild(e);}

function FgetPageSize(){
return{width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight};}

function FgetPostion(e,isID){
if(isID==true)e=Fid(e);
var left=0,top=0,w=e.offsetWidth,h=e.offsetHeight;
do{
top+=e.offsetTop||0;
left+=e.offsetLeft||0;
e=e.offsetParent;}while(e);
return{x:left,y:top,width:w,height:h};}

function FsetModal(e,isID,wid)
{
	if(!Fempty(e)&&isID==true)e=Fid(e);
		FunsetModal(wid);
	var p=0;
	if(Fempty(e))
	{
		p=FgetPageSize();
		p.x=0,p.y=0;
	}else
	{
		p=FgetPostion(e);
	}
	if(Fempty(wid))wid="$_modal_$";
	var w=Fid(wid);
	if(Fempty(w)){
	w=document.createElement('DIV');
	w.id=wid;
	var s=w.style;
	with(s){
	position="absolute",filter="alpha(opacity=20);-moz-Opacity:0;Opacity:0;",zIndex=99,background='#666666';}
	if(FBrowser.isIE)s.background="#666666";
	if(FBrowser.isFirefox){
	s.background="#000000";
	s.opacity=0.2;}
	document.body.insertBefore(w,document.body.firstChild);}
	FsetPostion(w,p.x,p.y,p.width,p.height);
	if(FBrowser.isIE6)
	w.innerHTML='<iframe scrolling="No" style="z-index:99" border="0" frameborder="0" width="'+p.width+'" height="'+p.height+'"></iframe>';
	else if(FBrowser.isOpera)
	w.innerHTML='<img src="/image/b.gif" onMouseDown="return false;" galleryimg="no" style="z-index:99" width="'+p.width+'" height="'+p.height+'"/>';
}

function login_form()
{
	//var urlPt=/^(https?:\/\/)?([a-z]([a-z0-9\-]*\.)+qq\.com)(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&amp;]*)?)?(#[a-z][a-z0-9_]*)?$/i;
	//var args=arguments;
	//var sucUrl=(typeof args[1])=='string'?(urlPt.test(args[1])?args[1]:"http://qzone.qq.com"):window.location.href;
	//var failUrl=(typeof args[2])=='string'&&urlPt.test(args[2])?args[2]:"loginerroralert";
	//var targetWin=(typeof args[3])=='string'&&/^[^_][a-z0-9_\-]*$/i.test(args[3])?'self':"top";

	var dc = window.location.host;
	var dm = dc.substr(dc.indexOf(".")+1);
	document.domain=dm;

	//document.domain="k8008.com";
	
	var d=Fid('login_div');
	if(!d)
	{
		d=document.createElement('div');
		d.id='login_div';
		d.style.position='absolute';
		d.style.zIndex='200';
		d.innerHTML='<iframe name="login_iframe" id="login_iframe" frameborder="0" scrolling="no" width="100%" height="100%" src="about:blank"></iframe>';
		document.body.insertBefore(d,document.body.firstChild);
	}
	d.style.width='374px';
	d.style.height='285px';
	d.style.display='block';
	FsetOffsetWindowPostionByRate(d,2,3);
	FsetModal();
	Fid('login_iframe').src = loginformurl+'/login.aspx';
}

function form_close()
{
	var d=Fid('login_div');
	if(d)
	{
		d.style.display = "none";
	}
	var zj = Fid("$_modal_$");
	if(zj)
	{
		 var _parentElement = zj.parentNode;
         if(_parentElement){
                _parentElement.removeChild(zj);
         }
	}
}

