﻿
/******************************************
*
* 本文件为本站所有js文件的父文件
* Power By LiShilin@Gmail.com	2008-04-30
*
* Code Rework By LiShilin@Gmail.com  2008-06-25
*
******************************************/

/************************
	获取页面对象
************************/
//根据id获取页面对象
function $(objID)
{
	return document.getElementById(objID);
}
//根据name获取页面对象数组
function $Name(objsName)
{
	return document.getElementsByName(objsName);
}
//根据tagname获取页面对象数组
function $TagName(objsTagName)
{
	return document.getElementsByTagName(objsTagName);
}
//获取下拉控件select的当前选定项的值
function $DropGetValue(objID)
{
	var obj = $(objID);
	return obj.options[obj.selectedIndex].value;
}
//获取下拉控件select的当前选定项的文本
function $DropGetText(objID)
{
	var obj = $(objID);
	return obj.options[obj.selectedIndex].text;
}
//按值设置下拉控件select的当前选定项
function $DropSetByValue(dropID,value)
{
	var dropobj = $(dropID);
	var list = dropobj.options;
	for(var i=0;i<list.length;i++)
	{
		dropobj[i].selected = (dropobj[i].value.toLowerCase() == value.toLowerCase()) ? true : false;
	}
}
//按文本设置下拉控件select的当前选定项
function $DropSetByText(dropID,text)
{
	var dropObj = $(dropID);
	var list = dropObj.options;
	for(var i=0;i<list.length;i++)
	{
		dropObj[i].selected = (dropObj[i].text.toLowerCase() == text.toLowerCase()) ? true : false;
	}
}
//获取radio的选定项的值
function $RadioGetValue(rdoName,value)
{
	var rdo = $Name(rdoName);
	for(var i=0;i<rdo.length;i++)
	{
		if(rdo[i].checked)return rdo[i].value;
	}
	return value;
}
//设置radio的选定项
function $RadioSetValue(rdoName,value)
{
	var rdo = $Name(rdoName);
	for(var i=0;i<rdo.length;i++)
	{
		rdo[i].checked = (rdo[i].value == value);
	}
}
//兼容ff的获取event对象
var myevt=new Function('e','if (!e) e = window.event;return e');
/*****************************************
	字符串去除头尾空格
*****************************************/
String.prototype.Trim = function() 
{ 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.LTrim = function() 
{ 
	return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.RTrim = function() 
{ 
	return this.replace(/(\s*$)/g, ""); 
} 
/*******************************
   限制键盘输入
*******************************/
//限制不允许输入除0～9之外的所有字符
function KeyPress(objTR)
{	
	var txtval=objTR.value;		
	
	var key = event.keyCode;

	if((key < 48||key > 57)&&key != 46)
	{		
		event.keyCode = 0;
	}
	else
	{
		if(key == 46)
		{
			event.keyCode = 0;
		}
	}
}
//限制只允许输入0~9及小数点
function KeyPressPoint(objTR)
{	
	var txtval=objTR.value;		
	
	var key = event.keyCode;

	if((key < 48||key > 57)&&key != 46)
	{		
		event.keyCode = 0;
	}
	else
	{
		if(key == 46)
		{
			if((objTR.value.length == 0) || (objTR.value.indexOf('.') >= 1))
			{
				event.keyCode = 0;
			}
		}
	}
}
//限制只能输入数字和横线(-)
function KeyPressLine(objTR)
{	
	var txtval=objTR.value;
	
	var key = event.keyCode;

	if((key < 48||key > 57)&&(key != 45))
	{		
		event.keyCode = 0;
	}
}

//限制不允许输入'和"
function KeyPressYin(objTR)
{
	var key = event.keyCode;
	
	if(key == 34||key == 39)
	{		
		event.keyCode = 0;
	}
}
/**********************************************
	页面跳转
**********************************************/
//跳到本页并且去除url参数
function RefreshMe()
{
	location.href =location.pathname;
}
//跳转到本页，不去除参数
function LocationToMe()
{
	location.href=location.href;
}
//跳转到本页，并删除指定的参数
//参数：param:应为匹配指定参数的js正则表达式字符串
function RefreshMeDelParam(param)
{
	var url = location.href;
	var reg = new RegExp(param,"ig");
	var x = url.replace(reg,"");
	LocationTo(x);
}
//跳到指定页
function LocationTo(url)
{
	location.href=url;
}
//顶部窗口跳转
function TopLocationTo(url)
{
	top.location.href=url;
}
//跳转到本页，并添加参数
function LocationToMeParam(param)
{
	location.href =SetUrlAddParam(location.href,param);
}
//提交页面
function SubmitToMeParam(url)
{
	document.forms[0].action = url;
	document.forms[0].submit();
}

//打开窗口的js类，默认打开空页面
function NewWindow()
{
	this.Url = "about:blank";
	this.Name = "_blank";
	this.Height = Math.round(window.screen.height / 2);
	this.Width = Math.round(window.screen.width / 2);
	this.ToolBar = "yes";
	this.MenuBar = "yes";
	this.ScrollBars = "yes";
	this.Location = "yes";
	this.Status = "yes";
	this.Resizable = "yes";
	this.Left = Math.round(((window.screen.availWidth-this.Width)/2)/2);
	this.Top = Math.round(((window.screen.availHeight-this.Height)/2)/2);
}
NewWindow.prototype.Open = function()
{
	window.open(this.Url,this.Name,'height='+this.Height+',width='+this.Width+',toolbar=' + this.ToolBar + ',menubar=' + this.MenuBar + ',scrollbars=' + this.ScrollBars + ',resizable=' + this.Resizable + ',location=' + this.Location + ',status=' + this.Status + ',left='+ this.Left +',top='+ this.Top +'');
}
//打开一个没有任何限制的窗口
function OpenUrl(url)
{
	var win = new NewWindow();
	win.Url = url;
	win.Open();
}
//打开一个所有操作工具条都没有的窗口
function OpenUrlNotAll(url,width,height)
{
	if(url == null || url == "")
		url = "/";
	if(width == null || width == 0)
		width = Math.round(window.screen.width / 2);
	if(height == null || height == 0)
		height = Math.round(window.screen.height / 2);
		
	var win = new NewWindow();
	win.Url = url;
	win.Height=height;
	win.Width = width;
	win.ToolBar="no";
	win.MenuBar = "no";
	win.ScrollBars = "auto";
	win.Location = "no";
	win.Status = "no";
	win.Resizable = "yes";
	win.Left = Math.round((window.screen.availWidth-win.Width)/2);
	win.Top = Math.round((window.screen.availHeight-win.Height)/2);
	win.Open();
}
/***************************************
	异步操作
***************************************/
function XmlHttp()
{
	this.CreateXmlHttpRequest = function(){
		try
		{
			return new XMLHttpRequest();
		}
		catch(x)
		{
			try
			{
				return new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(xx)
			{
				try
				{
					return new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(xxx)
				{
					return null;
				}
			}
		}
	};
	//xmlhttprequest对象
	this.xmlHttpObj = this.CreateXmlHttpRequest();
	//要获取数据的地址
	this.url = "";
	//处理数据的函数名
	this.handler = null;
};
XmlHttp.prototype.GetXMLData = function(){
	if(this.xmlHttpObj == null)return "error";
	if(this.url == "") return "error";
	if(this.handler == null) return "error";
	this.url = SetUrlAddParam(this.url,"x=" + Math.random());
	try
	{
		this.xmlHttpObj.open("get",this.url,true);
		this.xmlHttpObj.setRequestHeader("Content-Type","text/xml");
		this.xmlHttpObj.onreadystatechange = this.handler;
		this.xmlHttpObj.send(null);
	}
	catch(x)
	{
		return "error";
	}
}
/**********************************************
	url操作
**********************************************/
//获取url中一个指定的参数值
function GetRequest(paramName,defaultValue)
{
	var search = paramName + "=";
	var FieldValue="";
	var URL=location.href;
	var offset = URL.indexOf(search);
	if (offset != -1)
	{ 
	  offset += search.length;
	  var end = URL.indexOf("&", offset);
	  if (end == -1)
	  { 
		FieldValue=URL.substring(offset);
	  }
	  else
	  {
		FieldValue=URL.substring(offset,end);
	  }
	}
	if(FieldValue == "")
	{
		FieldValue = defaultValue;
	}
	return FieldValue.toLowerCase();
}
//为url添加参数，自动判断是更新还是添加
//参数格式：如：page=1的形式，不能是“page=1&params=1”的形式，即一次只能添加一个参数
function SetUrlAddParam(url,param)
{
	var interrogation = url.indexOf("?");

	if (interrogation == -1)
	{
		url+="?"+param;
	}
	else
	{
		//3\如果?后面有查询字符串,则检测有没有该字段，如果有，则重新付值
		var fp = param.split("=");
		var search = fp[0] + "=";
		var offset = url.indexOf(search);
		if (offset != -1)
		{ 
		  offset += search.length;
		  end = url.indexOf("&", offset);
		  if (end == -1)
		  { 
		  	url=url.substring(0,offset)+fp[1];
		  }
		  else
		  {
		  	url=url.substring(0,offset)+fp[1]+url.substring(end);
		  }
		}
		else
		{
			url=url+"&"+param;
		}
	}
	return url;
}
/**************************************************
	可用于显示页面进度条的隐藏层操作
**************************************************/
//创建一个浮动的div，未指定宽高度及位置，指定部分样式
var timer = null;
function CreateStateDiv(divID)
{
	var div = document.createElement("div");
	div.id = divID;
	div.style.display = "none";
	div.style.position = "absolute";
	div.style.zIndex = "100000";
	div.style.border = "1px solid #cccccc";
	div.style.backgroundColor = "#ffffff";
	return div;
}
//进度条操作：关闭
function HiddenState(divID)
{
	if($(divID)!= null)
		$(divID).style.display = "none";
	if(timer != null)window.clearTimeout(timer);
}
//进度条操作：显示信息，并延时关闭
var timer = null;
function ShowMsg(divID,text,time)
{
	$(divID).innerHTML = text;
	$(divID).style.top = (document.documentElement.scrollTop+(document.documentElement.clientHeight-$(divID).offsetHeight)/2)+"px";
	$(divID).style.left = (document.documentElement.scrollLeft+(document.documentElement.clientWidth-$(divID).offsetWidth)/2)+"px";
	timer = window.setTimeout("HiddenState('"+divID+"')",time);
}
//延时将某个对象的显示设置为不显示
function HiddenObjTimer(objid,time)
{
	if($(objid) != null)
		timer = window.setTimeout("$('" + objid + "').style.display='none';if(timer!=null)window.clearTimeout(timer);",time);
}
//扩展：创建一个定义好样式的层，用于显示网页提示信息
function CreateMessageLayer(text,width)
{
	var state = $("Tranning");
	if(state == null)
	{
		state = CreateStateDiv("Tranning");
		if(document.readyState == "complete")
		{
			document.documentElement.getElementsByTagName("body")[0].appendChild(state);
		}
		else
		{
			timer = window.setTimeout(function(){document.documentElement.getElementsByTagName("body")[0].appendChild(state);window.clearTimeout(timer);},1000);
		}
	}
	state.innerHTML = "";
	
	var swidth = (width == null || width == "" || width == 0) ? 234 : width;
	
	state.style.filter = "progid:DXImageTransform.Microsoft.DropShadow(color=#c8f2ff,offx=3,offy=3,positive=2)";
	//state.onmouseover=new Function("MoustMoveOBJ('Tranning')");
	
	var content = '<div style="cursor:move;background-color:#c8f2ff; height:22px; color:#000000;width:'+ swidth + 'px;" onmouseover="MoustMoveOBJ(\'Tranning\');">';
	content += '<div style="display:inline; font-size: 14px; vertical-align:middle; padding-left:2px;">网页对话框</div>';
	content += '<div title="关闭" style="position: absolute; width: 12px; height: 9px; z-index: 100003; left: '+ (swidth - 23) + 'px; top: 1px; font-size: 14px; font-weight: bold; cursor: pointer;" onmouseover="this.style.border=\'1px solid #c8f2ff\';" onmouseout="this.style.border=\'0px\';" onclick="HiddenState(\'Tranning\');">×</div>';
	content += '</div>';
	content += '<div style="MARGIN-TOP: 8px! important; MARGIN-BOTTOM: 5px; MARGIN-LEFT: 11px; WIDTH: '+ (swidth - 23) + 'px">';
	content += text;
	content += '</div>';
	
	state.innerHTML = content;
	state.style.display = "inline";
	state.style.top = (document.documentElement.scrollTop+(document.documentElement.clientHeight-state.offsetHeight)/2)+"px";
	state.style.left = (document.documentElement.scrollLeft+(document.documentElement.clientWidth-state.offsetWidth)/2)+"px";
}
//扩展：创建一个没有标题栏的状态显示条
function CreateStateLayer(text,width)
{
	var state = $("State");
	if(state == null)
	{
		state = CreateStateDiv("State");
		if(document.readyState == "complete")
		{
			document.documentElement.getElementsByTagName("body")[0].appendChild(state);
		}
		else
		{
			timer = window.setTimeout(function(){document.documentElement.getElementsByTagName("body")[0].appendChild(state);window.clearTimeout(timer);},1000);
		}
	}
	state.innerHTML = "";
	
	var swidth = (width == null || width == "" || width == 0) ? 234 : width;
	
	state.style.filter = "progid:DXImageTransform.Microsoft.DropShadow(color=#c8f2ff,offx=3,offy=3,positive=2)";

	var content = '<div style="cursor:move;MARGIN-TOP: 8px! important; MARGIN-BOTTOM: 5px; MARGIN-LEFT: 11px; WIDTH: '+ swidth + 'px" onmouseover="MoustMoveOBJ(\'State\');">';
	content += text;
	content += '</div>';
	
	state.innerHTML = content;
	state.style.display = "inline";
	state.style.top = (document.documentElement.scrollTop+(document.documentElement.clientHeight-state.offsetHeight)/2)+"px";
	state.style.left = (document.documentElement.scrollLeft+(document.documentElement.clientWidth-state.offsetWidth)/2)+"px";
}
//扩展：层的移动
var drag_ = false;
function MoustMoveOBJ(objID){
	var x,y;
	$(objID).onmousedown=function(e){
		drag_=true;
		with(this){
			style.position="absolute";var temp1=offsetLeft;var temp2=offsetTop;
			x=myevt(e).clientX;y=myevt(e).clientY;
			document.onmousemove=function(e){
				if(!drag_)return false;
				with(this){
					style.left=temp1+myevt(e).clientX-x+"px";
					style.top=temp2+myevt(e).clientY-y+"px";
				}
			}
		}
		document.onmouseup=new Function("drag_=false;");
	}
}
/*************************************************
	获取某个元素在页面上的坐标
*************************************************/
//获取元素的纵坐标 
//e:要获取的元素
function GetTop(e)
{
	var offset=e.offsetTop; 
	if(e.offsetParent!=null) 
		offset+=GetTop(e.offsetParent); 
	return offset; 
} 
//获取元素的横坐标 
//e:要获取的元素
function GetLeft(e)
{
	var offset=e.offsetLeft; 
	if(e.offsetParent!=null)
		offset+=GetLeft(e.offsetParent); 
	return offset; 
}
/********************************
	分页控件所用的按页索引跳转
********************************/
//显示为下拉框时的跳转
function ANP_goToPage(boxEl)
{
	if(boxEl!=null)
	{
		var pi;
		if(boxEl.tagName=="SELECT")
		{
			pi=boxEl.options[boxEl.selectedIndex].value;
		}
		else
		{
			pi=boxEl.value;
		}
		LocationToMeParam("page=" + pi)
	}
}
//页索引输入检测
function ANP_checkInput(bid,mv)
{
	var el=document.getElementById(bid);
	var r=new RegExp("^\\s*(\\d+)\\s*$");
	if(r.test(el.value))
	{
		if(RegExp.$1<1||RegExp.$1>mv)
		{
			alert("页索引超出范围！");
			el.focus();
			el.select();
			return false;
		}
		return true;
	}
	alert("页索引不是有效的数值！");
	el.focus();
	el.select();
	return false;
}
//页索引输入框限制
function ANP_keydown(e,btnId)
{
	var kcode;
	if(window.event)
	{
		kcode=e.keyCode;
	}
	else if(e.which)
	{
		kcode=e.which;
	}
	var validKey=(kcode==8||kcode==46||kcode==37||kcode==39||(kcode>=48&&kcode<=57)||(kcode>=96&&kcode<=105));
	if(!validKey)
	{
		if(kcode==13)
			document.getElementById(btnId).click();
		if(e.preventDefault)
			e.preventDefault();
		else
		{
			event.returnValue=false;
		}
	}
}

/************************************************************
	设为主页和添加收藏
************************************************************/
//加入浏览器收藏
function AddFavorite(title,url)
{
   if (document.all)
   {
	  window.external.addFavorite(url,title);
   }
   else if (window.sidebar)
   {
	  window.sidebar.addPanel(title,url,  "");
   }
}
//设为主页
function SetHomePage()
{
	if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(location.href);
    }
	else if(window.sidebar)
	{
		if(window.netscape)
		{
			try
			{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
			}   
			catch (e)
			{
				alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值改为true" );
			}
		} 
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
		prefs.setCharPref('browser.startup.homepage',location.href); 
	}
}
//复制信息到剪贴板
function CopyToClipboard(str)
{
	//var str = "我在" + sitename + "网站上看到的这个" + proname+"，蛮好的，你也看看吧，地址是：" + url;
	if(window.clipboardData)
	{
		 window.clipboardData.clearData();
		 window.clipboardData.setData("Text",str);
		 alert("本页信息复制成功，您可以粘贴到QQ、MSN或邮箱中，发送给您的好友。");
     }
     else if (window.netscape)
     {
          try
          {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          }catch(e)
          {
			alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
          }    
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
          if (!clip)
               return;
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
          if (!trans)
               return;
          trans.addDataFlavor('text/unicode');
          var len = new Object();
          var str2 = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          var copytext = str;
          str2.data = copytext;
          trans.setTransferData("text/unicode",str2,copytext.length*2);
          var clipid = Components.interfaces.nsIClipboard;
          if (!clip)
               return false;
          clip.setData(trans,null,clipid.kGlobalClipboard);
          alert("本页信息复制成功，您可以粘贴到QQ、MSN或邮箱中，发送给您的好友。");
     }
}
//复制信息到剪贴板，无题示
function CopyToClipboardNonAlert(str)
{
	if(window.clipboardData)
	{
		 window.clipboardData.clearData();
		 window.clipboardData.setData("Text",str);
     }
     else if (window.netscape)
     {
          try
          {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          }catch(e)
          {
          }    
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
          if (!clip)
               return;
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
          if (!trans)
               return;
          trans.addDataFlavor('text/unicode');
          var len = new Object();
          var str2 = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          var copytext = str;
          str2.data = copytext;
          trans.setTransferData("text/unicode",str2,copytext.length*2);
          var clipid = Components.interfaces.nsIClipboard;
          if (!clip)
               return false;
          clip.setData(trans,null,clipid.kGlobalClipboard);
     }
}
/***************************************************************
	tab式选项卡效果切换
***************************************************************/
var SELECTED_TAB = "footer_top_index_left_b_a Lfloat font14 fontB";
var NONFOCUS_TAB = "footer_top_index_left_b_b Lfloat";
function TabbedActionInit(tabParentID,menuID,listPostfix)
{
	var divall = $(tabParentID);
	var list = divall.getElementsByTagName("DIV");
	//setting all
	for(var i=0;i<list.length;i++){
		if(list[i].className != "clear"){
			list[i].className = (list[i].id == menuID) ? SELECTED_TAB : NONFOCUS_TAB;
			list[i].onmouseover = function(){
				TabbedAction(tabParentID,this.id,listPostfix);
			}
			if(list[i].className == SELECTED_TAB){
				TabbedContentAction(list.length,list[i].id,listPostfix);
			}
		}
	}
}

function TabbedAction(tabParentID,menuID,listPostfix){
	var divall = $(tabParentID);
	var list = divall.getElementsByTagName("DIV");
	//setting all
	for(var i=0;i<list.length;i++){
		if(list[i].className != "clear"){
		
			list[i].className = (list[i].id == menuID) ? SELECTED_TAB : NONFOCUS_TAB;
			
			if(list[i].className == SELECTED_TAB){
				TabbedContentAction(list.length,list[i].id,listPostfix);
			}
		}
	}
}
function TabbedContentAction(listCount,menuID,listPostfix)
{
	menuPrefix = menuID.substring(0,menuID.length - 1);
	for(var i=0;i<listCount;i++){
		var tmp = menuPrefix + i.toString();
		if($(tmp + listPostfix))
			$(tmp + listPostfix).style.display = (tmp == menuID) ? "block" : "none";
	}
}


/*****************************************************
	简单验证
*****************************************************/
function CK_HtmlControl()
{
	this.Message = "";//错误信息容器
	this.Postfix = "<br />";//错误信息后缀
	//验证不能为空，可加长度限制
	//参数：obj:要验证的对象; objTitle:要显示的错误信息前缀; maxlength:要限制的字符串长度最大值，为-1表示不限制；minLength:要限制的字符串长度最小值，为-1表示不限制
	//返回：true:表示验证成功，false:表示发生错误
	this.Required_TextBox = function(obj,objTitle,maxLength,minLength)
	{
		if(obj)
		{
			var tmp = obj.value.Trim();
			if(tmp == "")
			{
				this.Message += objTitle+"不能留空"+this.Postfix;
				return false;
			}
			else
			{
				if(maxLength > -1 && minLength > -1){//两种长度同时限制
					if(!((tmp.length <= maxLength)&&(tmp.length >= minLength)))
					{
						this.Message += objTitle+"长度应在" + minLength + "～" + maxLength + "个字之间"+this.Postfix;
						return false;
					}
					return true;
				}
				else if(maxLength > -1 && minLength <= -1){//限制最大长度
					if(!(tmp.length <= maxLength))
					{
						this.Message += objTitle+"长度应小于" + maxLength + "个字"+this.Postfix;
						return false;
					}
					return true;
				}
				else if(maxLength <= -1 && minLength > -1){//限制最小长度
					if(!(tmp.length >= minLength))
					{
						this.Message += objTitle+"长度应大于" + minLength + "个字"+this.Postfix;
						return false;
					}
					return true;
				}
				return true;
			}
		}
		this.Message = "内部错误：对象不存在。";
		return false;
    }
    //验证数字字符串不能为空，只能输入数字，并带有数字范围验证
    this.Required_Number_TextBox=function(obj, objTitle, maxValue, minValue) {
        if(obj)
        {
            var tmp=obj.value.Trim();
            if(tmp=="")
            {
                this.Message+=objTitle+"不能留空"+this.Postfix;
                return false;
            }
            else if(isNaN(tmp))
            {
                this.Message+=objTitle+"只能输入数字"+this.Postfix;
                return false;
            }
            else
            {
                var value=parseInt(tmp);
                if(value>maxValue||value<minValue)
                {
                    this.Message+=objTitle+"必须在"+minValue.toString()+"和"+maxValue.toString()+"之间"+this.Postfix;
                    return false;
                }
                return true;
            }
        }
        this.Message="内部错误：对象不存在。";
        return false;
    }
	//验证字符串格式
	//参数：reg:要匹配的正则模式
	this.Regular_TextBox = function(obj,objTitle,reg)
	{
		if(obj)
		{
			var tmp = obj.value.Trim();
			if(tmp.match(reg) == null)
			{
				this.Message += objTitle + "格式不正确" + this.Postfix;
				return false;
			}
			return true;
		}
		this.Message = "内部错误：对象不存在";
		return false;
	}
	//验证两个字符串相等
	this.CompareEquals = function(str1,str2,mess)
	{
		if(str1 == str2)return true;
		this.Message += mess;
		return false;
	}
	//验证两个字符串不相等
	this.CompareNotEquals = function(str1,str2,mess)
	{
		if(str1 != str2)return true;
		this.Message += mess;
		return false;
	}
}
/*****************************************************
	页面顶部用户登录框动作
*****************************************************/
var ERROR_MSG_ICON="<img src='/Images/System/smallerror.gif' align='absmiddle' width='32' height='32' />&nbsp;";
var LOADING_ICON="<img src='/Images/System/smallloading.gif' align='absmiddle' width='32' height='32' />&nbsp;";
var INFO_MSG_ICON="<img src='/Images/System/no.jpg' align='absmiddle' width='32' height='32' />&nbsp;";
var SUCCESS_MSG_ICON = "<img src='/Images/System/ORB_Icons_by_014.png' align='absmiddle' width='32' height='32' />&nbsp;";
var ajaxObj = null;
//登录动作
function HeadLoginBarAction()
{
	var ck = new CK_HtmlControl();
	ck.Postfix = "</li>";
	//ck.Message = "";
	if(ck.Required_TextBox($("txtHLBLoginName"),"<li style='color:red;'>--用户名",20,2) && ck.Required_TextBox($("txtHLBPassword"),"<li style='color:red;'>--登录密码",60,6))
	{
		var ajax = new XmlHttp();
		ajaxObj = ajax.xmlHttpObj;
		var un = encodeURI($("txtHLBLoginName").value.Trim());
		var ps = $("txtHLBPassword").value.Trim();
		var type = $RadioGetValue("logintype","0");
		CreateStateLayer(LOADING_ICON + "正在登录，请稍候...",0);
		ajax.url = "/Users/UserForm.aspx?action=login&un=" + un + "&pwd=" + ps + "&type=" + type;
		ajax.handler = TranHeadLoginBar;
		if(ajax.GetXMLData() == "error")
		{
			HiddenState("State");
			CreateMessageLayer(ERROR_MSG_ICON + "网络出现故障，请稍候重试",0);
		}
	}
	else
	{
		var error = '<strong>您的输入有以下错误：</strong><br /><ol>';
		error += ck.Message + "</ol>";
		CreateMessageLayer(ERROR_MSG_ICON + error,0);
	}
}
//处理登录框返回的数据
function TranHeadLoginBar()
{
	if(ajaxObj.readyState == 4)
	{
		var root = ajaxObj.responseXML;
		if(root == null)
		{
			HiddenState("State");
			CreateMessageLayer(ERROR_MSG_ICON + "网络出现故障，请稍候重试",0);
		}
		else
		{
			var result = root.getElementsByTagName("result")[0].childNodes[0].nodeValue;
			if(result == "0")
			{
				HiddenState("State");
				CreateMessageLayer(ERROR_MSG_ICON + "用户名或密码错误",0);
			}
			else if(result == "1")
			{
				//输出登录信息
				var username = root.getElementsByTagName("UserName")[0].childNodes[0].nodeValue;
				var usertype = parseInt(root.getElementsByTagName("UserType")[0].childNodes[0].nodeValue);
				$("HeadLoginBar").innerHTML = WriteHeadLoginedInfo(username,usertype);
				HiddenState("State");
			}
			else if(result == "2")
			{
				HiddenState("State");
				CreateMessageLayer(ERROR_MSG_ICON + "验证码错误",0);
			}
		}
	}
}
	var toplogincontent = '用户名：<input class="login_input" type="text" name="txtHLBLoginName" id="txtHLBLoginName" size="18" maxlength="25" />&nbsp;'+
	'密码：<input class="login_input" type="password" name="txtHLBPassword" id="txtHLBPassword" size="18" maxlength="60" />&nbsp;&nbsp;'+
	'<input type="submit" style="background-image:url(/Images/btn_01.gif); width:36px;height:19px; border:0px;" value="" onclick="HeadLoginBarAction()" align="absmiddle" />&nbsp;'+
	'<input type="button" style="background-image:url(/Images/btn_02.gif); width:36px;height:19px; border:0px;" value="" onclick="LocationTo(\'/Register.aspx\');" align="absmiddle" />'+
	'&nbsp;&nbsp;';
//输出登录框
function CreateHeadLoginBar()
{
	var ajax = new XmlHttp();
	ajaxObj = ajax.xmlHttpObj;
	ajax.url = "/Users/UserForm.aspx?action=checklogined&x=" + Math.random();
	ajax.handler = CHLBHandler;
	if(ajax.GetXMLData() == "error")
	{
		$("HeadLoginBar").innerHTML = toplogincontent;
	}
	//$("spanTopUserLoginState").innerHtml = toplogincontent;
}
function CHLBHandler()
{
	if(ajaxObj.readyState == 4)
	{
		var root = ajaxObj.responseXML;
		if(root == null)
		{
			$("HeadLoginBar").innerHTML = toplogincontent;
		}
		else
		{
			var result = root.getElementsByTagName("Error")[0].childNodes[0].nodeValue;
			if(result == "1")
			{
				$("HeadLoginBar").innerHTML = toplogincontent;
			}
			else if(result == "0")
			{
				//输出登录信息
				var username = root.getElementsByTagName("UserName")[0].childNodes[0].nodeValue;
				var usertype = parseInt(root.getElementsByTagName("Type")[0].childNodes[0].nodeValue);
				$("HeadLoginBar").innerHTML = WriteHeadLoginedInfo(username,usertype);
			}
		}
	}
}
//输出已登录信息
function WriteHeadLoginedInfo(un,type)
{
	switch(type)
	{
		case 0://普通会员
			return un + '，欢迎您！<a href="/Users/" title="进入会员中心" target="_blank">会员中心</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/Users/NewsList.aspx?params=3" target="_blank" title="非常资讯">非常资讯</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/Users/UserForm.aspx?action=logout&redirect=' + encodeURI(location.href) + '" title="退出登录">退出登录</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/Users/Lottery.aspx" target="_blank" title="时尚抽奖">时尚抽奖</a>';
			break;
		case 1://加盟商
			return un + '，欢迎您！<a href="/Users/" title="进入加盟商中心" target="_blank">加盟商服务</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/Users/Bulletin.aspx" target="_blank" title="加盟商资讯">加盟商资讯</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/Users/UserForm.aspx?action=logout&redirect=' + encodeURI(location.href) + '" title="退出登录">退出登录</a>';
			break;
		case 2://代理商
			return un + '，欢迎您！<a href="/Users/" title="进入代理商中心" target="_blank">代理商服务</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/Users/Bulletin.aspx" target="_blank" title="代理商资讯">代理商资讯</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/Users/UserForm.aspx?action=logout&redirect=' + encodeURI(location.href) + '" title="退出登录">退出登录</a>';
			break;
		default://游客
			return toplogincontent;
			break;
	}
}

/***************************************************
	首页投资成本计算
***************************************************/
//暂时无铺效果
function NotStoreChecked(cbxObj)
{
	if(cbxObj.checked)
	{
		$("txtDsf").disabled = true;
		$("txtRent").disabled = true;
	}
	else
	{
		$("txtDsf").disabled = false;
		$("txtRent").disabled = false;
	}
}
//验证选项
function CheckInvestCost()
{
//ck.CompareNotEquals($DropGetValue("selCity"),"none","<li style='color:red;'>-请选择您所在的城市级别。</li>")&&
	var ck = new CK_HtmlControl();
	ck.Postfix = "</li>";
	if(
		ck.CompareNotEquals($DropGetValue("selSales"),"none","<li style='color:red;'>-请选择您的店铺所在的商圈级别。</li>")&&
		ck.Required_Number_TextBox($("txtStoreArea"),"<li style='color:red;'>-店铺面积",100,20)
	)
	{
		return true;
	}
	else
	{
		var error = '<strong>您的输入有以下错误：</strong><br /><ol>';
		error += ck.Message + "</ol>";
		CreateMessageLayer(ERROR_MSG_ICON + error,0);
		return false;
	}
}
//计算
function ComputeInvestCost()
{
	var zxObj = $("txtZhuangXiu");
	var zx = 0;
	if(zxObj.value.Trim() != "")zx = parseInt(zxObj.value.Trim())*1250;
	var sp = parseInt($("ShouPi").innerText);
	var pp = parseInt($("PinPai").innerText);
	var xy = parseInt($("XinYong").innerText);
	//var by = parseInt($("BeiYong").innerText);
	var shebei = parseInt($("SheBei").innerText);
	var gz = parseInt($DropGetValue("GongZi"));
	var sd = parseInt($("ShuiDian").innerText);
	var ld = parseInt($("LiuDong").innerText);
	var zj = parseInt(((zx + shebei)/3).toString());
	var dsfObj = $("Dsf").innerText;
	var dsf = 0;
	if(dsfObj != "")dsf = parseInt(dsfObj);
	var rentObj = $("Rent").innerText;
	var rent = 0;
	if(rentObj != "")rent = parseInt(rentObj);
	var resultAll = $("All");
	var resultMonth = $("Month");
	
	//resultAll.innerText ="￥" +( zx + shebei + sp + pp + xy + by + dsf + rent + ld) + "元";
	resultAll.innerText ="￥" +( zx + shebei + sp + pp + xy + dsf + rent + ld) + "元";
	resultMonth.innerText = "￥" + parseFloat(((dsf + zx + shebei) /36) + rent + sd + gz).toFixed(2) + "元";
	$("ZheJiu").innerText = zj + "元";
}
/************************************************************
	首页滚动的图片
************************************************************/

function MarqueeControl(ContainID,Directions,LeftBtn,RightBtn)
{
	var marquee1 = new Marquee(ContainID)
	marquee1.Direction = Directions;
	marquee1.Step = 2;
	marquee1.Width = 398;
	marquee1.Height = 132;
	marquee1.Timer = 30;
	marquee1.DelayTime = 0;
	marquee1.WaitTime = 0;
	marquee1.ScrollStep = -1;
	$(LeftBtn).onclick = function(){marquee1.Direction=2;};
	$(RightBtn).onclick = function(){marquee1.Direction=3;};
	marquee1.Start();
}