﻿/*
 *
 */
function GlobeEngine(){
	this.UID="";
	this.SID="";
	this.user="";
	this.Anx=document.all;
	this.laterRequestModule="";
	this.domain="";
	this.dm="";
	this.host=location.hostname;
	this.css="";
	this.cosnm="";
	this.address=[];
	this.composeType="";
	this.replyf="";
	this.addo=0;
	this.afterdel=0;
	this.netfdr_host="";
	this.cos_netfolder=-1;
	this.city=-1;
	this.px=-1;
	this.Adw=-1;
	this.folders=[];
	this.udid="";
	this.Avo="";
	this.time=new Date();
	this.editContent="";
	this.oLinks=null;
	this.Aua=0;
	this.fv=null;
	this.dragNav=null;
	this.kefu="";
	this.maxlist=20;
	this.pref_quota=2048;
	this.tempFrame=top.frames["template"];
	this.timeS=new Date();
	this.timeC=new Date();
	this.titles=[];
	this.network=1;
	this.addressAllInfo=[];
	this.signAllInfo=[];
	this.addressGroup=[];
}

function screenHeigh(){

	var GE = new GlobeEngine();
	
	GE.bodyHeight=document.body.scrollHeight;
	
	if(document.documentElement.scrollHeight > GE.bodyHeight){
		GE.bodyHeight=document.documentElement.scrollHeight;
	}
	
	if ( window.screen.height > GE.bodyHeight ){
		GE.bodyHeight = window.screen.height;
	}
	
	return GE.bodyHeight;
}

function screenWidth(){
	var GE = new GlobeEngine();
	
	GE.bodyWidth=document.body.scrollWidth;
	
	if(document.documentElement.scrollWidth > GE.bodyWidth){
		GE.bodyWith=document.documentElement.scrollWidth;
	}
	
	if ( window.screen.width > GE.bodyWidth ){
		GE.bodyWidth = window.screen.width;
	}
	
	return GE.bodyWidth-22;
}

//alert (document.documentElement.scrollHeight);
var t_DiglogY;
var t_DiglogX;
var t_MouseClick_Y;
var linkEl;

function AlertDialog(Title){
	ScreenConvert();
	var AJAX_LoginBody = Title;
	DialogShow("DialogMove",AJAX_LoginBody,490,250);
}

function ScreenConvert(){
	objScreen = document.createElement("div");
	objScreen.setAttribute("id","ScreenOver");
	objScreen.style.height = screenHeigh()+"px";
	objScreen.style.width = screenWidth()+"px";
//	objScreen.style.filter = "alpha(opacity=40)";
	document.body.appendChild(objScreen);
	var allselect = gname("select");
	for (var i=0; i<allselect.length; i++) 
		allselect[i].style.visibility = "hidden";
}

function DialogShow(dailogtype,showdata,ow,oh,w,h,event){
	
	var classWidth = 200;//初始化对话框的宽度
	var classHeight = 200;//初始化对话框的高度
	
	var objDialog = document.getElementById("DialogMove");//尝试获得对话框的对象
	if (!objDialog) objDialog = document.createElement("div");//如果没有得到对话框的对象时，将创建一个
	
	objDialog.id = "DialogMove";
	
	oS = objDialog.style; //设置oS变量为objDialog.style对象；
	
	oS.visibility = "hidden";// 层为隐藏层
	
	oS.display = "block";//对象的display属性为block；

	oS.position = "fixed";//将对象的位置方式设置为相对定位；
	


	oS.zIndex = "1001"; //对象的层为1001；
	
	objDialog.innerHTML = showdata;//将数据插入到对话框的位置；
	document.body.appendChild(objDialog);//对话框被插入到页面中；
	
//	objDialogWidth = objDialog.clientWidth;//取得对话框的宽度
//	objDialogHeight = objDialog.clientHeight;//取得对话框的高度
//	
//	alert("objDialogWidth:"+objDialogWidth+" objDialogHeight:"+objDialogHeight);
//	
	if (Browser.isIE && Browser.version < 7){//对IE7以下的版本进行的特殊定位处理
		oS.position = "absolute";//设置对话框的位置属性为绝对定位
		objDialogWidth = 514;//hardcode设置宽度和高度
		objDialogHeight = 104;
		g_myBodyInstance = (document.documentElement ? document.documentElement : window);
		this.scrollTo(1,1);//将scrollbar的位置返回到最高位置，以适应IE6对话框可以显示在客户眼前。
	}

	var pos = DialogLoc(event);//取得窗口的位置;
	oS.left = pos.x + "px";
	oS.top = pos.y + "px";
	oS.visibility = "visible";// 将对话框层为显现在页面中；
}

function DialogHide(){
	ScreenClean();
	var objDialog = document.getElementById("DialogMove");
	if (objDialog) objDialog.style.display = "none";
}

function gname(name){
	return document.getElementsByTagName?document.getElementsByTagName(name):new Array()
}

function DialogLoc(event){
	
	var objDialog = document.getElementById("DialogMove");//尝试获得对话框的对象
	if (!objDialog) {
		return {x:0, y:0};
	}else{	
		objDialogWidth = objDialog.clientWidth;//取得对话框的宽度
		objDialogHeight = objDialog.clientHeight;//取得对话框的高度
		
		var dde = document.documentElement;
		if (window.innerWidth){
			var ww = window.innerWidth;
			var wh = window.innerHeight;
			var bgX = window.pageXOffset;
			var bgY = window.pageYOffset;
		}else{
			var ww = dde.offsetWidth;
			var wh = dde.offsetHeight;
			var bgX = dde.scrollLeft;
			var bgY = dde.scrollTop;
		}
		
		if (Browser.isIE && Browser.version < 7){
			objDialogWidth = 514;
			objDialogHeight = 104;
		}
	
		t_DiglogX = parseInt(ww/2);
		t_DiglogY = parseInt(wh/2);
	
		
		
		leftPx = parseInt(t_DiglogX - parseInt(objDialogWidth/2));
		topPx = parseInt(t_DiglogY - parseInt(objDialogHeight/2));
		
		if (Browser.isIE && Browser.version < 7){
			t_DiglogY	
		}
		return {x:leftPx,y:topPx};
	}
}

function ScreenClean(){
	if(location.pathname.indexOf("flow.php")>-1){
		location.href = "flow.php";
	}else{
		var objScreen = document.getElementById("ScreenOver");
		if (objScreen) objScreen.parentNode.removeChild( objScreen );
		var objDialog = document.getElementById("DialogMove");
		if ( objDialog ) objDialog.parentNode.removeChild( objDialog );
		var allselect = gname("select");
		for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "visible";
	}
}

function goToShopCart(){
	//if(location.pathname.indexOf("flow.php")==-1) 
	location.href = "flow.php";
}

function showMouseDetails(event) 
{
  if (event.button == 0){
  	t_DiglogY=event.clientY;
  }
}

(document.addEventListener)?document.addEventListener("click", showMouseDetails, true):document.attachEvent("onclick",showMouseDetails);

var TextUtil = new Object();
var oData = new String();

TextUtil.isPasteEvent = function(oTextArea,event) 
{
	oData = oTextArea.value;
	if (window.event){
    	key = window.event.keyCode;
  	}else if (event){
   		key = event.which;
	}else{
		return false;
	}
	var max =  oTextArea.getAttribute("maxlength");
	var lengthis = oTextArea.value.length;
	var charcountis = max - lengthis;
	if (charcountis<0) { charcountis = 0; }
		document.getElementById('charcount').innerHTML = charcountis;
		
	if (key == 17){
		oTextArea.value = oData;
		if (window.fireEvent) {
			oTextArea.fireEvent("onkeypress");
		}else if(window.dispatchEvent){
			TextUtil.isBeyond(oTextArea);
			evt = document.createEvent("HTMLEvents");
  			evt.initEvent("blur","true","true"); 
  			oTextArea.dispatchEvent(evt);
		}
		//return false;
	}

}

TextUtil.isBeyond = function( oTextArea,event ){
	//alert ( 'isBeyond' );
	var key;
	if (window.event) key = window.event.keyCode;
	else if (event) key = event.which;
	else return true;

	if (key == null || key == 0 || key == 8 || key == 13 || key == 27 || key == 20 ||
		key == 37 || key == 38 || key == 39 || key == 40 || key == 46 || key ==17 )
    return true;
	if ( key == 9 )
		oTextArea.value = oTextArea.value + "    ";

	var max =  oTextArea.getAttribute("maxlength");
	var lengthis = oTextArea.value.length;
	
	//alert (lengthis);
	//alert (max);
	
	if (lengthis >= max){ 
		oTextArea.value = oTextArea.value.substring(0,max);
		oData = oTextArea.value;
		alert('内容必须在200字以内');
		return false;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
	}else{
		oData = oTextArea.value;
		return true;
	}
}

TextUtil.blurBeyond = function(oTextArea){
	var max =  oTextArea.getAttribute("maxlength");
	var lengthis = oTextArea.value.length;
	if (lengthis >= max){ 
		oTextArea.value = oTextArea.value.substring(0,max);
	}
}

TextUtil.blockChars = function (oTextbox, oEvent, bBlockPaste)
{
	var sInvalidChars = oTextbox.getAttribute("invaildchars");
	var sChar = String.fromCharCode(oEvent.charCode);
	
	var bIsValidChar = sInvalidChars.indexof(sChar) == -1;
	if (bBlockPaste){
		return bIsValidChar && !(oEvent.ctrlKey & sChar == 'v')
	}else{
		return bIsValidChar || oEvent.ctrlKey;
	}	
}

TextUtil.allowChars = function (oTextbox, oEvent, bBlockPaste)
{
	var sValidChars = oTextbox.getAttribute("validchars");
	var sChar = String.fromCharCode(oEvent.charCode);
	
	var bIsValidChar = sValidChars.indexof(sChar) > -1;
	
	if (bBlockPaste){
		return bIsValidChar && !(oEvent.ctrlKey & sChar == 'v')
	}else{
		return bIsValidChar || oEvent.ctrlKey;
	}	
}


TextUtil.blurBlock = function(oTextBox)
{
	var sInvalidChars = oTextbox.getAttribute("invalidchars");
	var arrInvalidChars = sInvalidChars.split("");
	
	for (var i=0; i<arrInvalidChars.length; i++){
		if (oTextBox.value.indexOf(arrInvalidChars[i]) > -1){
			alert("字符'"+ arrInvalidChars[i]+ "'不可输入" );
			oTextbox.focus();
			oTextBox.select();
			return;
		}
	} 	
}
