/*
Author:Stone,Andyfoo
Homepage:Andyfoo.Net
Company:Kehu.cn
*/



 
var calendar_open = false;

function calendar(calendar_path){
	if(!calendar_open){
		if(!calendar_path)var calendar_path = "calendar/";
		document.write("<iframe width=174 height=189 name='gToday:normal:calendar_agenda.js' id='gToday:normal:calendar_agenda.js' ");
		document.write(" src='" + calendar_path + "calendar.htm' scrolling='no' frameborder='0' ");
		document.write(" style='visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;'>");
		document.write("</iframe>");
	}
	calendar_open=true;
	//document.getElementById('gToday:normal:calendar_agenda.js').src = calendar_path + "calendar.htm";
}

function set_html(id, html)
{
	document.getElementById(id).innerHTML=html;
}
function set_text(id, text)
{
	document.getElementById(id).innerTEXT=text;
}
function hide_obj(id){
	document.getElementById(id).style.display='none'
}
function show_obj(id){
	document.getElementById(id).style.display=''
}
function showhide_obj(id){
	if(document.getElementById(id).style.display==''){
		document.getElementById(id).style.display='none';
		return 'close';
	}else{ 
		document.getElementById(id).style.display='';
		return 'open';
	}
}
function set_src(id, value){
	document.getElementById(id).src=value
}
function set_background(id, value){
	document.getElementById(id).style.background=value
}
function set_class(id, value){
	document.getElementById(id).className=value
}

function select_all(form, s, sel)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.name.substring(0, sel.length) == sel)
		e.checked = s.checked;
	}
}

function select_submit(form, action)
{
	form.action = action;
	form.submit();
}


function btn_confirm(url, msg)
{
	if(confirm(msg))
		window.location=url;
	return false;
}
function set_default( form, label,value){
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		switch(e.type){
			case 'radio':
			case 'checkbox':if(e.name == label && e.value == value)e.checked = true;break;
			case 'multiple':
			case 'select':
			case 'select-one':
				if(e.name == label){
					for (var d=0; d<e.options.length; d++){
						if(e.options[d].value == value ){
							e.selectedIndex = d;
						}
					}
				}
				break;
			default:
			break;
		}			
		
	}
}
function get_value( label, t){  
	if(!label)return '';
	if(!label.length)return label.value;
	if(t == 'checkbox'){
		var v_list = new Array();
		var i=0;
		for(var j = label.length - 1; j >= 0; j--)
				if(label[j].checked)  v_list[i++] = label[j].value;
		return v_list.join(',');
	}

	for(var j = label.length - 1; j >= 0; j--)
		if(label[j].checked) return label[j].value;
	return label[0].value;


	
}
//<<+================

/***************
var pane1 = "aa";

var pane2 = "bb";

var pane3 = "Enter message here:<br><textarea cols=50 rows=6></textarea>";

var pane4 = "<table border=1><tr><td width=100><input name='cSport' type='checkbox' class='chk'>Sport</input><br><input type='checkbox' class='chk' name='cGifts'>Gifts</input><br><input type='checkbox' class='chk' name='cHealth'>Health</input><br></td><td width=100><input name='cInet' type='checkbox' class='chk'>Internet</input><br><input type='checkbox' class='chk' name='cGames'>Games</input><br><input type='checkbox' class='chk' name='cTech'>Technology</input></td><td width=100><input name='cBooks' type='checkbox' class='chk'>Books</input><br><input type='checkbox' name='cFash'>Fashion</input><br><input type='checkbox' class='chk' name='cCars'>Cars</input><br></td></tr></table>";

var pane5 = "<hr><p>This is a test of a javascript simulating a tab control<hr>";

var ts = new tabstrip();
var t1 = new tab("网站信息",pane1);
var t2 = new tab("结算帐户",pane2);
var t3 = new tab("结算周期",pane3);
var t4 = new tab("支付密码",pane4);
var t5 = new tab("返回网址",pane5);
ts.add(t1);
ts.add(t2);
ts.add(t3);
ts.add(t4);
ts.add(t5);
ts.write();
***************/
var currentPaneStyle = 0;
var currentTab = 0;
var tabNumber = 0;
// alert( readCookie("myCookie") );
function readCookie(name)
{
	var cookieValue = "";
	var search = name + "=";
	if(document.cookie.length > 0)
	{ 
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
				cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
	return cookieValue;
}
// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
	var expire = "";
	if(hours != null)
	{
		expire = new Date((new Date()).getTime() + hours * 3600000);
		expire = "; expires=" + expire.toGMTString();
	}
	document.cookie = name + "=" + escape(value) + expire;
}
function tabstrip()
{
	this.tabs = new Array();
	this.add = addTab;
	this.write = writeTabstrip;
}

function tab(caption,content)
{
	this.setId = setId;
	this.caption = caption;
	this.content = content;
	this.write = writeTab;
	this.writeContent = writePane;
}



function addTab(tab)
{
	tab.setId("tab" + this.tabs.length);
	this.tabs[this.tabs.length] = tab;
	tabNumber++;
}

function setId(id)
{
	this.id = id;
}

function initiate()
{
	var CookieTabId = readCookie("__CookieTabId__");
	if(CookieTabId != null &&  document.getElementById(CookieTabId) != null)
		var div = document.getElementById(CookieTabId);
	else
		var div = document.getElementById("tab0");
	showPane(div);
}

function showPane(div)
{
	for(i = 0; i < tabNumber; i++)
	{  
		document.getElementById("tab" + i).className = "tabs_out";
		document.getElementById("pn_tab" + i).style.display = "none";
	}
	div.className = "tabs_over";
	document.getElementById("pn_" + div.id).style.display = "block";
	writeCookie("__CookieTabId__", div.id, 24);
}

function SubmitForm()
{
	window.alert("Form submitted.  This would normally take you to another page");
	// normally, you would here check the form and submit it.
	// if the form has the name 'tabform', then it is submitted
	// with tabform.submit();
}

function writePane()
{
	document.write("<div class='tabs_pane' id='pn_" + this.id + "'>" + this.content + "</div>");
}

function writeTab()
{
	document.write("<td  class='tabs_out' id='" + this.id + "' onclick='showPane(this)'>" + this.caption + "</td>");
}

function writeTabstrip()
{
	document.write("<table border='0' cellpadding='3' cellspacing='0' class='tabs_table'><tr>");
	for(var i = 0; i < this.tabs.length; i++)
	{
		this.tabs[i].write();
	}
	document.write("</tr></table>");
	document.write("<table class='tabs_line' border='0' cellpadding='4' cellspacing='0'><tr><td height='4'></td></tr></table>");
	for(var k = 0; k < this.tabs.length; k++)
	{
		this.tabs[k].writeContent();
	}
	initiate();
}


<!--
/*=============================

	<table  width='100%' border='0' cellspacing='1' cellpadding='3' class='tpl_border_color' style='FONT-SIZE: 12px; word-break: break-all; ' id='data_table'>
	
		<tr  height='23' class='tpl_bgcolor_02'>
		<th width="50%">tt1</th>
		<th width="50%">tt2</th>
		</tr>
 
		<tr height='20' class='tpl_list_01' >
		<td align="center">d1</td>
		<td align="center">d2</td>

		</tr>
 		<tr height='20' class='tpl_list_01' >
		<td align="center">d1</td>
		<td align="center">d2</td>

		</tr>
		<tr height='20' class='tpl_list_01' >
		<td align="center">d1</td>
		<td align="center">d2</td>

		</tr>
	</table>
<script language="JavaScript">
	<!--
	tigra_tables('data_table', 1, 0, 'tpl_list_01', 'tpl_list_02', 'tpl_list_over', 'tpl_list_click');
	// -->
</script>



==========================*/


var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);
	document.write("<style type=\"text/css\">");
	document.write(".js_list_01 {BACKGROUND-COLOR: #ffffff}");
	document.write(".js_list_02 {	BACKGROUND-COLOR: #FFF0F5}");
	document.write(".js_list_over {	BACKGROUND-COLOR: #FFF68F}");
	document.write(".js_list_click {	BACKGROUND-COLOR: #EED5D2}");
	document.write("</style>");
var init_click_disable = true;
function tigra_tables (
		str_tableid, // table id (req.)
		num_header_offset, // how many rows to skip before applying effects at the begining (opt.)
		num_footer_offset, // how many rows to skip at the bottom of the table (opt.)
		str_odd_class, // background class for odd rows (opt.)
		str_even_class, // background class for even rows (opt.)
		str_mover_class, // background class for rows with mouse over (opt.)
		str_onclick_class, // background class for marked rows (opt.)
		click_disable  //click disable
	) {
		
	
	 // skip non DOM browsers
	if (ie5 || ns6){
 
		// validate required parameters
		if (!str_tableid) return alert ("No table(s) ID specified in parameters");
		var obj_tables = (document.all ? document.all[str_tableid] : document.getElementById(str_tableid));
		if (!obj_tables) return alert ("Can't find table(s) with specified ID (" + str_tableid + ")");

		// set defaults for optional parameters
		var col_config = [];
		col_config.header_offset = (num_header_offset ? num_header_offset : 0);
		col_config.footer_offset = (num_footer_offset ? num_footer_offset : 0);
		col_config.odd_class = (str_odd_class ? str_odd_class : 'js_list_01');
		col_config.even_class = (str_even_class ? str_even_class : 'js_list_02');
		col_config.mover_class = (str_mover_class ? str_mover_class : 'js_list_over');
		col_config.onclick_class = (str_onclick_class ? str_onclick_class : 'js_list_click');
		
		// init multiple tables with same ID
		init_click_disable = click_disable;
		if (obj_tables.length){
			for (var i = 0; i < obj_tables.length; i++){
				tt_init_table(obj_tables[i], col_config);
				// init single table
			}
		}else{
			tt_init_table(obj_tables, col_config);
		}
	}
}

function tt_init_table (obj_table, col_config) {
	var col_lconfig = [],
		col_trs = obj_table.rows;
	for (var i = col_config.header_offset; i < col_trs.length - col_config.footer_offset; i++) {
		col_trs[i].config = col_config; 
		col_trs[i].lconfig = col_lconfig;
		col_trs[i].set_class = tt_set_class;
		col_trs[i].onmouseover = tt_mover; 
		col_trs[i].onmouseout = tt_mout;
		col_trs[i].onmousedown = tt_onclick;
		col_trs[i].order = (i - col_config.header_offset) % 2;
		col_trs[i].onmouseout();
	}
}
function tt_set_class(str_class) {
	this.className = str_class;
}

// event handlers
function tt_mover () {
	if (this.lconfig.clicked != this)
		this.set_class(this.config.mover_class);
}
function tt_mout () {
	if (this.lconfig.clicked != this){
		this.set_class(this.order ? this.config.odd_class : this.config.even_class);
	}
}
function tt_onclick () {
	if(init_click_disable) return;
	if (this.lconfig.clicked == this) {
		this.lconfig.clicked = null;
		this.onmouseover();
	}
	else {
		var last_clicked = this.lconfig.clicked;
		this.lconfig.clicked = this;
		if (last_clicked) {
			last_clicked.onmouseout();
		}
		this.set_class(this.config.onclick_class);
	}
}
//-->



 


 

//===================>>>
var cfg_fade_switch=true;       
var cfg_xoffset=9;         
var cfg_yoffset=20;        
var cfg_mouse_follow=true;
var cfg_hide_delay=8000;    
var cfg_txt_tag='alt';
var cfg_is_show=true;

document.write("<style>.navtext_div{PADDING-RIGHT: 6px; PADDING-LEFT: 6px;PADDING-TOP: 2px; PADDING-BOTTOM: 1px; FONT-SIZE: 12px; Z-INDEX: 99; VISIBILITY: hidden; COLOR: #333333; BORDER: 1px #8899AA solid;FONT-FAMILY: Courier New,tahoma,arial; POSITION: absolute; BACKGROUND-COLOR: #FFFFCC;}</style>");
document.write('<div id="navtext_div" class="navtext_div" style="visibility:hidden; position:absolute; top:0px; left:-400px; z-index:10000; padding:3px"></div>');

function xalt_props(){
	this.w3c=(document.getElementById)?true:false;
	this.ns4=(document.layers)?true:false;
	this.ie4=(document.all && !this.w3c)?true:false;
	this.ie5=(document.all && this.w3c)?true:false;
	this.ns6=(this.w3c && navigator.appName.indexOf("Netscape")>=0 )?true:false;
	this.w_y=0;
	this.w_x=0;
	this.navtxt=null;
	this.boxheight=0;
	this.boxwidth=0;
	this.ishover=true;
	this.ieop=0;
	this.op_id=0;
	this.oktomove=true;
	this.dy=0;
}
function xalt_kill_errors() {
	return true;
}

var XALT=new xalt_props();

function xalt_set_mouse_follow(mouse_follow){//true or false
	cfg_mouse_follow=mouse_follow;
}

function xalt_set_fade_switch(fade_switch){//true or false
	cfg_fade_switch=fade_switch;
	if(!cfg_fade_switch)XALT.ieop=100;
}

function xalt_get_window_dims(){
	XALT.w_y=(XALT.ie5||XALT.ie4)?document.body.clientHeight:window.innerHeight;
	XALT.w_x=(XALT.ie5||XALT.ie4)?document.body.clientWidth:window.innerWidth;
}

function xalt_get_box_width(){
	if(XALT.ns4)XALT.boxwidth=(XALT.navtxt.document.width)? XALT.navtxt.document.width : XALT.navtxt.clip.width;
	else if(XALT.ie4)XALT.boxwidth=(XALT.navtxt.style.pixelWidth)? XALT.navtxt.style.pixelWidth : XALT.navtxt.offsetWidth;
	else XALT.boxwidth=(XALT.navtxt.style.width)? parseInt(XALT.navtxt.style.width) : parseInt(XALT.navtxt.offsetWidth);
}

function xalt_get_box_height(){
	if(XALT.ns4)XALT.boxheight=(XALT.navtxt.document.height)? XALT.navtxt.document.height : XALT.navtxt.clip.height;
	else if(XALT.ie4)XALT.boxheight=(XALT.navtxt.style.pixelHeight)? XALT.navtxt.style.pixelHeight : XALT.navtxt.offsetHeight;
	else XALT.boxheight=parseInt(XALT.navtxt.offsetHeight);
}

function xalt_move_nav_txt(x,y){
	if(XALT.ns4){
		XALT.navtxt.moveTo(x,y);
	}else{
		XALT.navtxt.style.left=x+'px';
		XALT.navtxt.style.top=y+'px';
	}
}

function xalt_get_page_scrolly(){
	if(XALT.ie5||XALT.ie4){
		if(document.documentElement.scrollTop > 0) return document.documentElement.scrollTop;
		return document.body.scrollTop;
	}else return window.pageYOffset;
}

function xalt_get_page_scrollx(){
	if(XALT.ie5||XALT.ie4){
		if(document.documentElement.scrollLeft > 0) return document.documentElement.scrollLeft;
		return document.body.scrollLeft;
	}else return window.pageXOffset;
}

function xalt_write_in_div(text){
	if(XALT.ns4){
		XALT.navtxt.document.open();
		XALT.navtxt.document.write(text);
		XALT.navtxt.document.close();
	}
	else XALT.navtxt.innerHTML=text;
}

function xalt_write_txt(text){
	if(cfg_fade_switch && (XALT.ie4||XALT.w3c))clearInterval(XALT.op_id);
	if(text!=0 && cfg_is_show ){
		if(!cfg_mouse_follow)clearTimeout(XALT.dy);
		XALT.oktomove=true;
		XALT.ishover=true;
		if(XALT.ns4)text='<div class="navtext_div">'+text+''+'</div>';
		if(XALT.w3c||XALT.ie4)XALT.navtxt.style.textAlign="left";
		xalt_write_in_div(text);
		if(XALT.ns4)XALT.navtxt.visibility="show";
		else{
			//XALT.navtxt.style.display="inline";
			XALT.navtxt.style.visibility="visible";
		}
		xalt_get_box_height();
		if((XALT.w3c||XALT.ie4) && cfg_fade_switch){
			if(XALT.ie4||XALT.ie5)XALT.navtxt.style.filter="alpha(opacity=0)";
			if(XALT.ns6)XALT.navtxt.style.MozOpacity=0;
			XALT.ieop=0;
			XALT.op_id=setInterval('xalt_do_opacity()',10);
		}
		cfg_is_show=false;
	}else{
		cfg_is_show=true;
		if(cfg_mouse_follow)xalt_hide_alt_txt();
		else XALT.dy=setTimeout('xalt_hide_alt_txt()',cfg_hide_delay);
	}
}

function xalt_hide_alt_txt(){
	if(XALT.ns4)XALT.navtxt.visibility="hide";
	else{
		//XALT.navtxt.style.display="none";
		XALT.navtxt.style.visibility="hidden";
	}
	xalt_move_nav_txt(-XALT.boxwidth-10,0);
	xalt_write_in_div('');
}

function xalt_do_opacity(){
	if(XALT.ieop<=100){
	XALT.ieop+=32;
	if(XALT.ie4||XALT.ie5)XALT.navtxt.style.filter="alpha(opacity="+XALT.ieop+")";
	if(XALT.ns6)XALT.navtxt.style.MozOpacity=XALT.ieop/100;
	}else clearInterval(XALT.op_id);
}

function xalt_move_obj(evt){
	mx=(XALT.ie5||XALT.ie4)?event.clientX:evt.pageX;
	my=(XALT.ie5||XALT.ie4)?event.clientY:evt.pageY;
	if(XALT.ishover && XALT.oktomove){
		margin=(XALT.ie4||XALT.ie5)?5:25;
		if(XALT.ns6)if(document.height+27-window.innerHeight<0)margin=15;
		if(XALT.ns4)if(document.height-window.innerHeight<0)margin=10;
		if(XALT.ns4||XALT.ns6)mx-=xalt_get_page_scrollx();
		if(XALT.ns4)my-=xalt_get_page_scrolly();
		xoff=mx+cfg_xoffset;
		yoff=(my+XALT.boxheight+cfg_yoffset-((XALT.ns6)?xalt_get_page_scrolly():0)>=XALT.w_y)? -5-XALT.boxheight-cfg_yoffset: cfg_yoffset;
		xalt_move_nav_txt( Math.min(XALT.w_x-XALT.boxwidth-margin , Math.max(2,xoff))+xalt_get_page_scrollx(), my+yoff+((!XALT.ns6)?xalt_get_page_scrolly():0));
		if(!cfg_mouse_follow)XALT.oktomove=false;
	}
}
function scanDOM(curNode) {
	while(curNode )	{
		if(curNode.nodeType == 1){
			var txt = curNode.getAttribute(cfg_txt_tag);
			if (curNode.alt) curNode.alt = "";
			if (curNode.title) curNode.title = "";
			if(txt != null && txt != ''){
				curNode.setAttribute('xalt_txt', txt);
				curNode.setAttribute(cfg_txt_tag, '');
				curNode.onmouseover = function() {
					xalt_write_txt(this.getAttribute('xalt_txt'));
					if(!cfg_mouse_follow)XALT.dy=setTimeout('xalt_hide_alt_txt()',cfg_hide_delay);
				}
				curNode.onmouseout = function() {
					xalt_write_txt(0); 
					if(!cfg_mouse_follow)clearTimeout(XALT.dy);
				}
			}
		}
		scanDOM(curNode.firstChild);
		curNode=curNode.nextSibling;
	}
}
function xalt_onload(){
	window.onerror = xalt_kill_errors;
	if (!(XALT.w3c || XALT.ns4 || XALT.ie4 || XALT.ie5 || XALT.ns6)) return;
	if(XALT.ns4||XALT.ns6){
		window.document.captureEvents(Event.MOUSEMOVE);
		window.document.addEventListener("mousemove", xalt_move_obj, true);
		window.document.addEventListener("resize", xalt_get_window_dims, true);
	}else if(XALT.ie4||XALT.ie5||XALT.w3c){
		window.document.attachEvent("onmousemove", xalt_move_obj);
		window.document.attachEvent("onresize", xalt_get_window_dims);
	}
	XALT.navtxt=(XALT.ns4)?document.layers['navtext_div']:(XALT.ie4)?document.all['navtext_div']:(XALT.w3c)?document.getElementById('navtext_div'):null;
	xalt_get_box_width();
	xalt_get_box_height();
	xalt_get_window_dims();
	if(XALT.ie4||XALT.ie5&&cfg_fade_switch)XALT.navtxt.style.filter="alpha(opacity=100)";
	scanDOM(document.body);
}

if(XALT.ns4||XALT.ns6){
	window.addEventListener("load", xalt_onload, true);
}else if(XALT.ie4||XALT.ie5||XALT.w3c){
	 window.attachEvent("onload", xalt_onload);
}
 


 /*
	autocheck 2.0
 */
 //form check
var first_error		=	"";
var check_error		=	'提示信息：';
var check_alt		=	'';
var check_alt_count	=	1;
var alert_num		=	6;
function autocheck(fm){	
	check_alt_count			=	1;
	check_alt			=	'';
	var check_rule 			=	new Array();
	check_rule['email']		=	/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;    
	check_rule['number']  		=	/^\d+$/;  
	check_rule['url']		=	/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
	check_rule['tel']		=	 /^((\(\d{2,3}\))|(\d{3}[\-]{0,1}))?(\(0\d{2,3}\)|0\d{2,3}[\-]{0,1})?[1-9]\d{6,7}([\-]{0,1}\d{1,5})?$/;
	check_rule['mobile']		=	/^((\(\d{3}\))|(\d{3}\-))?(13|15)\d{9}$/;
	check_rule['domain']		=	/^[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
	check_rule['idcard']		=	/^\d{15}(\d{2}[A-Za-z0-9])?$/;
	check_rule['money']		=	/^\d+(\.\d+)?$/;
	check_rule['zip']		=	/^[0-9]\d{5,6}$/;
	check_rule['oicq']		=	/^[0-9]\d{4,10}$/;
	check_rule['int']		=	/^[-\+]?\d+$/;
	check_rule['double']		=	/^[-\+]?\d+(\.\d+)?$/;
	check_rule['english']		=	/^[A-Za-z0-9\. ]+$/;
	check_rule['chinese']		=	/^[\u0391-\uFFE5]+$/;
	check_rule['username']		=	/^[a-z]\w{3,32}$/i;
	check_rule['password']		=	/^[A-Za-z0-9]\w{3,32}$/;
	check_rule['char']		=	/^[A-Za-z0-9_\-]+$/;


	for(var i = 0; i < fm.elements.length; i++){
		with(fm.elements[i]){ 
			var form_item	=	fm.elements[i];
			var label_model	=	form_item.getAttribute('model');
			var msg		=	form_item.getAttribute('msg');
			var area = form_item.getAttribute('area');//form_item.getAttribute('area');22-33
			var area_max = 0;
			var area_min = 0;
			if(new RegExp("^[0-9\-\.]{1,}$","g").test(area)){
				var tmp = area.match(new RegExp("^([0-9\.]*)[-]{0,1}([0-9\.]*)$"));
				area_min = parseFloat(tmp[1]);
				area_max = parseFloat(tmp[2]);
				if((form_item.type != 'checkbox' && form_item.type != 'multiple') && (area_max < form_item.value && area_max != 0 && area_max != 'NaN') || (area_min > form_item.value && area_min != 0 && area_min != 'NaN')) {
					add_error(form_item.name, msg);
					continue;
				}
			}
			var len = form_item.getAttribute('len');
			var len_max = 0;
			var len_min = 0;
			if(new RegExp("^[0-9\-]{1,}$","g").test(len)){
				var tmp = len.match(new RegExp("^([0-9]*)[-]{0,1}([0-9]*)$"));
				len_min = parseInt(tmp[1]);
				len_max = parseInt(tmp[2]);
				if(len_min == 0 && form_item.value == ''){
					continue;
				}
				if((len_max < strlen(form_item.value) && len_max != 0 && len_max != 'NaN') || (len_min > strlen(form_item.value) && len_min != 0 && len_min != 'NaN')){ 
					add_error(form_item.name, msg);
					continue;
				}
			}
			var to = form_item.getAttribute('to');
			if(typeof(label_model) != "string")  continue;
			switch(label_model){
				case 'repeat':
					if(to != null)
						if(fm.elements[to].value != form_item.value)
							add_error(form_item.name, msg);
					break;
				case 'define':
					var rule = form_item.getAttribute('rule');
					if(!new RegExp(rule,"g").test(form_item.value))
						add_error(form_item.name, msg);
					break;
				case 'select': 
					var check_label = document.getElementsByName(form_item.name);
					var checked_count = 0;
					for(var j = check_label.length - 1; j >= 0; j--){
						if(check_label[j].selected || check_label[j].value != '') checked_count = 1;
					}
					if(checked_count == 0) 
						add_error(form_item.name, msg);
					break;
				case 'multiple': 
					var check_label = document.getElementsByName(form_item.name);
					var checked_count = 0;
					for(var j = check_label.length - 1; j >= 0; j--)
						if(check_label[j].selected) checked_count++;
					if(checked_count > area_max || checked_count < area_min) 
						add_error(form_item.name, msg);
					break;
				case 'radio': 
					var check_label = document.getElementsByName(form_item.name);
					var checked_count = 0;
					for(var j = check_label.length - 1; j >= 0; j--)
						if(check_label[j].checked) checked_count = 1;
					if(checked_count == 0) 
						add_error(form_item.name, msg);
					break;
				case 'checkbox': 
					var check_label = document.getElementsByName(form_item.name);
					var checked_count = 0;
					for(var j = check_label.length - 1; j >= 0; j--)
						if(check_label[j].checked) checked_count++;
					if(checked_count > area_max || checked_count < area_min) 
						add_error(form_item.name, msg);
					break;
				case 'y-m-d h:i:s':
					var tmp = form_item.value.match(new RegExp("^([0-9]{4})[-./]{1}([0-9]{1,2})[-./]{1}([0-9]{1,2})[ ]{1}([0-9]{2})[:]{1}([0-9]{1,2})[:]{1}([0-9]{1,2})$"));
					if(tmp != null ) {//year-month-day tmp[1]-tmp[2]-tmp[3]
						if(!check_date(tmp[1], tmp[2], tmp[3]) || !check_time(tmp[4], tmp[5], tmp[6])) {
							add_error(form_item.name, msg);
						}
					}else {
						add_error(form_item.name, msg);
					}
					break;
				case 'h:i:s':
					var tmp = form_item.value.match(new RegExp("^([0-9]{2})[:]{1}([0-9]{1,2})[:]{1}([0-9]{1,2})$"));
					if(tmp != null ) {//year-month-day tmp[1]-tmp[2]-tmp[3]
						if(!check_time(tmp[1], tmp[2], tmp[3])) {
							add_error(form_item.name, msg);
						}
					}else {
						add_error(form_item.name, msg);
					}
					break;
				case 'y-m-d':
					var tmp = form_item.value.match(new RegExp("^([0-9]{4})[-./]{1}([0-9]{1,2})[-./]{1}([0-9]{1,2})$"));
					if(tmp != null ) {//year-month-day tmp[1]-tmp[2]-tmp[3]
						if(!check_date(tmp[1], tmp[2], tmp[3])) {
							add_error(form_item.name, msg);
						}
					}else {
						add_error(form_item.name, msg);
					}
					break;
				default:
					if(!check_rule[label_model] || check_rule[label_model] == 'undefined') {
						continue ;
					}else{
						if(!check_rule[label_model].test(form_item.value)){
							add_error(form_item.name, msg);
						}
					}
					break;
			}
		}
	}
	if(check_alt.length < 4) {
		for(var i = 0; i < fm.elements.length; i++){
		with(fm.elements[i]){ 
			if(fm.elements[i].type=='button' || fm.elements[i].type=='submit')
				fm.elements[i].disabled = true;
		}}
		return true;
	}
	alert(check_error + '\r\n' + check_alt);
	if(fm.elements[first_error].type != 'undefined' && fm.elements[first_error].type){
		fm.elements[first_error].focus();
	}
	first_error = "";
	return false;
}
function add_error(label, err){
	if(check_alt_count <= alert_num){
		check_alt += (check_alt_count + '.' + err + '\r\n');
		check_alt_count++;
		if(first_error.length < 1) 
			first_error = label;
	}
}
function check_date(y, m, d){
	if((y <= 0) || (m > 12 || m < 1) || (d > 31 || d < 1)) return false;
	return true;
}
function check_time(h, i, s){
	if((h > 23 || h < 1) || (i > 59 || i < 1) || (s > 59 || s < 1)) return false;
	return true;
}
function strlen(s){
	var i,str1,str2,str3,nLen;
	str1 = s;
	nLen = 0;
	for(i=1;i<=str1.length;i++){
			str2=str1.substring(i-1,i)
			str3=escape(str2);
			if(str3.length>3){
				nLen = nLen + 2;
			}else{
				nLen = nLen + 1;
			}
	}
	return nLen;
}
function set_rule(form_name, label_name, rule_str){
	var model = get_rule('model', rule_str);
	var msg = get_rule('msg', rule_str);
	var area = get_rule('area', rule_str);
	var len = get_rule('len', rule_str);
	var to = get_rule('to', rule_str);
	var rule = get_rule('rule', rule_str);
	if(document.forms[form_name] && document.forms[form_name][label_name]){
		var obj = document.forms[form_name][label_name];
		if(model) obj.setAttribute('model', model);
		if(msg) obj.setAttribute('msg', msg);
		if(area) obj.setAttribute('area', area);
		if(len) obj.setAttribute('len', len);
		if(to) obj.setAttribute('to', to);
		if(rule) obj.setAttribute('rule', rule);
	}else{
		alert( "document.forms[" + form_name + "][" + label_name + "] no defined!");
	}
}
function get_rule(attrib, rule_str){
	var preg = attrib + '=["|\']{1}([^"\']*)["|\']{1}';
	if(new RegExp(preg,"g").test(rule_str)){
		var tmp = rule_str.match(new RegExp(preg));
		return tmp[1];
	}else{
		return false;
	}
}
 

 


 


function popup(url,width,height)
{
	var popup = window.open(url, '_blank', 'width='+width+',height='+height+',scrollbars=yes,resizable=yes,status=yes');
    	if (!popup.opener) popup.opener = self;
	popup.focus();
}
 