﻿/*000001*/
	
var fm="<style> \
.select			{position:relative;height:21px;> height:21px; margin:5px 0px;float:left; } \
.select div		{ position:absolute;height:22px;line-height:22px;padding:0 2px;overflow:hidden;white-space :nowrap;text-overflow:ellipsis;} \
.select select { position: absolute;top:0;right:0;} \
//.text						{border:1px solid #999;background:url("+path+"ScriptImages/text.gif)  repeat-x;} \
//.text						{margin:3px 0px;padding:3px 2px  3px 3px;} \
</style>"

cw(fm)

var ph; var pg;
function password(a){
			if(ph==null){
				ph = $(a).after("div",4).style("height: 5px;overflow:hidden;border: 1px solid #ccc")
			    pg = $(a).after("span",4).style("color:#999")
			}
			a = a.value;
			var i = -1; if (a.match(/[a-z]/ig)){i++;} if (a.match(/[0-9]/ig)){i++;} if (a.match(/(.[^a-z0-9])/ig)){i++;} if (a.length < 6 && i > 0){i--;}
			switch(i) {
				  case 0: ph.style("backgroundColor:#CC0000;width:30px");pg.html("&nbsp;较弱"); break;
				  case 1: ph.style("backgroundColor:#FFCC33;width:80px");pg.html("&nbsp;中"); break;
				  case 2: ph.style("backgroundColor:#66CC00;width:100px");pg.html("&nbsp;高强"); break;
				  default: ph.style("background:#CCCCCC;width:10px");pg.html("&nbsp;弱");
			} 
}
var pb = true
function checkform(a){
 
	 var check = a.check

 	var pc = true;

	checkTrim = function(check){  
          return  check.replace(/^\s*|\s*$/gi,""); 
     }  

	checkValue = function (check) {
		return $(checkTrim(check)).k("value");
	}

	checkSO =function (check){
		return $(check).parent().child(1);
	}

	checkMessage = function (check,b,c){	
		 if(c){
			if(checkSO(check).k("innerHTML").length<2){
				checkSO(check).html(b)
			}
			pc = false;
		 }else{
			 checkSO(check).html(" ")
		 }
	}
 	checkRegstr =function (check,b){
		var g=new RegExp(b);
		return !g.test(checkValue(check))
	}

	checkEmail = function (check){
		     checkMessage(check,"电子邮件",checkRegstr(check,/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/))
	}

	checkEmpty = function (check){
  		   	checkMessage(check,"*",checkValue(check)=="") 
	 }
	checkNumber = function (check){
			checkMessage(check,"数字",checkRegstr(check,/^\d+$/))
	}
	checkUrl  = function (check){
			checkMessage(check,"网址",checkRegstr(check,/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/))
	}
	checkEnglish   = function (check){
			checkMessage(check,"英文",checkRegstr(check,/^[A-Za-z]+$/))
	}
	checkChinese = function (check){
			checkMessage(check,"中文",checkRegstr(check,/^[\u0391-\uFFE5]+$/))
	}
	checkPhone = function (check){
			checkMessage(check,"电话",checkRegstr(check,/^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,8}(\-\d{1,5})?$/))
	}
	checkMobile  = function (check){
			checkMessage(check,"手机",checkRegstr(check,/^13\d{9}$/))
	}
	checkLimit  = function (check,b){

			checkMessage(check,"小于"+b+"字节",!(b>checkValue(check).replace(/[^\x00-\xff]/g,"aa").length))
	}

	checkRange  = function (check,b){
			var max = b.split("-")[1];
			var min = b.split("-")[0];
			var g =checkValue(check).length
			checkMessage(check,min+"-"+max+"位",!(g<max && g> min))
	}
	
	checkRepeat  = function (check,b){
			checkMessage(check,"与"+b.split("-")[1]+"不同",!(checkValue(check) == checkValue(b.split("-")[0])))
	}
	  
	checkSpan = function (check){
 			if(pb == true){
			 
				 $(check).after("span",4).style("color:#ff9900;padding:0px 0px 0px 2px")
			}
	 }
	 

	var g = check.split('|')
	var  h; 
	for (var n in g){
			    h = g[n].split(',')
				checkSpan(h[0])
				for(var m in h){

					 switch (h[m].split(':')[0])
					 {
						case "empty" :	 checkEmpty(h[0]) ;break; 
						case "email" :	 checkEmail(h[0]) ;break;
						case "number" :	 checkNumber(h[0]) ;break;
						case "url" :	 checkUrl(h[0]) ;break;
						case "english" : checkEnglish(h[0]) ;break;
						case "chinese" : checkChinese(h[0]) ;break;
						case "phone" :	 checkPhone(h[0]) ;break;
						case "mobile" :	 checkMobile(h[0]) ;break;
						case "range" :	 checkRange(h[0],h[m].split(':')[1]) ;break;//range:3-5
						case "repeat" :	 checkRepeat(h[0],h[m].split(':')[1]) ;break;//repeat:#repeat-message
						case "limit" :	 checkLimit(h[0],h[m].split(':')[1]) ;break;//limit:5
					 }
			   }
		
	 }
	pb = false

	if(pc==true){
		var f = $(a.form).u();
		f.action = a.action;
		f.method = a.method;
		f.submit();
	}
 }



function changeSelect(a,b){
		var g= a.u();
		a.parent().child(0).html(g.options[g.selectedIndex].text);
		$("#"+b).u().options[g.selectedIndex].selected=true;
	 
}

function formStyle(){
	function select(){
		function make(a,b){
	 
			var g = $("~"+a+">select").event("change",'command(changeSelect($(this),"'+b+'"))');
			var h = g.u();
			var i = 0
			for(var n = 0 ;n<h.length;n++){
					 j =  h.options[n].text.replace(/[^\x00-\xff]/g,"aa").length;
					if(j>i){i = j ;}
	 	    }
			i  = i*10;
			$("#"+a).cssName("select").style("width:"+i+"px");
			g.style("width:"+i+"px;clip:rect(2px "+(i+10)+"px 20px "+(i-18)+"px)");
		}
		function set(a,b,c){

            var g= a.k("innerHTML")
		    a.show();
		    a.after("div",1).outer('<div id="select'+c+'"><div>'+b.options[b.selectedIndex].text+'</div><select>'+g+'</select></div>')
			make("select"+c,b.id);
			
		}
		var g  = $("@select").u();
		if(g.tagName=="SELECT"){
			set($(g),g,1)	 	
		}
		else{
			for(var n in g){
				set($(g[n]),g[n],n)	 	 
			}
		}
	}
	select();


}
 
 


 