var agt = navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
var is_ie = (agt.indexOf("msie") != -1) && document.all && !is_opera;
var is_ie5 = (agt.indexOf("msie 5") != -1) && document.all;

function $(s){
  return document.getElementById(s);
}
function $V(s){
  return trim(document.getElementById(s).value);
}

function $$(s){
  return document.getElementsByName(s);
}

function trim(s){
   return s.replace(/^\s+|\s+$/g,""); 
}

function isE(s){
  if(trim(s)=="") return true;
  else return false;
}

function replaceStr(s) {
  s=s.replace(/{\*o-o-o\*}/gi,"&");
  s=s.replace(/{\*o-o\*}/gi,"|");
  return s;
}


// 验证用户名  
function  CheckUserName(val,min,max)  { 
   var  len  =  val.value.length;
   for(i = 0 ;i < val.value.length;i++ )  { 
      var ch  =  val.value.charAt(i); 
      if ( (ch < "0"   ||  ch > "9" ) && (ch < "a" || ch  > "z" ) && ch!="_"){
         alert("用户名必须由小写字母、数字、下横线组成.");
		 val.focus(); 
         val.select(); 
         return  false ; 
      }  
   }
   if (len < min  ||  len > max)  { 
     alert( " 用户名长度不正确，应为 " + min + " - " + max + " 个英文字母、数字、下横线组成。 " ); 
     val.focus(); 
     val.select(); 
     return   false ; 
   }  

   var first = val.value.charAt( 0 ) 
   if (first < "a" || ch  > "z" )  { 
     alert( " 用户名必须由小写字母开头。 " ); 
     val.focus(); 
     val.select(); 
     return   false ; 
   }
   return   true ; 
}

//验证是否EMail
function isEmail(strEmail) {
    if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
       return true;
	   }
    else{ return false;}
}

function isChinese(name){ 
   if(name.length == 0)
      return  false;
   for(i = 0; i < name.length; i++){ 
      if(name.charCodeAt(i) > 128)
         return true;
   }
   return false;
}

function isNumber(num){
   if(num=='') return false;
   limitStr="0123456789";
   var s="";
   succ=true;
   for(i=0;i<num.length;i++){
     s=num.charAt(i);
	 if(limitStr.indexOf(s)<0){
       succ=false;
	   break;
	 }
   }
   return succ;
}

function isPhoneNumber(num){
   if(num==''||num.length<6) return false;
   limitStr="0123456789-()";
   var s="";
   succ=true;
   for(i=0;i<num.length;i++){
     s=num.charAt(i);
	 if(limitStr.indexOf(s)<0){
       succ=false;
	   break;
	 }
   }
   return succ;
}

function getRadioValue(ra){
 va="";
 for(i=0;i<ra.length;i++){
   if(ra[i].checked) va=ra[i].value;
 }
 return va;
}

function checkpasswd(p1,p2){
  if(trim(p1.value).length<6 || trim(p1.value).length>18){
     alert("请将密码长度设置为6-18位.");
	 p1.focus();
	 p1.select();
	 return false;
  }
  if(trim(p2.value).length<6 || trim(p2.value).length>18){
     alert("请将密码长度设置为6-18位.");
	 p2.focus();
	 p2.select();
	 return false;
  }
  if(p1.value!=p2.value){
     alert("两次输入的密码不一致，请重新输入.");
	 p1.focus();
	 p1.select();
	 return false;
  }
  
  return true;
}

var oldCN="";
function over(o){
  // alert(o.className);
   oldCN=o.className;
   o.className="leftwhite";
   o.style.cursor="pointer";
}
function out(o){
  o.className=oldCN;
  o.style.cursor="";
}

function getXY(evt){
    evt=evt?evt:(window.event?window.event:null);
    if (is_ie) { // grab the x-y pos.s if browser is IE
       tempX = evt.clientX + document.body.scrollLeft
       tempY = evt.clientY + document.body.scrollTop
    } else { // grab the x-y pos.s if browser is NS
       tempX = evt.pageX+ document.documentElement.scrollLeft
       tempY = evt.pageY+ document.documentElement.scrollTop
    }
	//   alert("document.body.scrollTop="+document.body.scrollTop+ "   document.documentElement.scrollTop="+document.documentElement.scrollTop);
    // catch possible negative values in NS4
    if (tempX < 0){tempX = 10;}
    if (tempY < 0){tempY = 10;}
	return [tempX,tempY];
}

function getXYNoScroll(evt){
    evt=evt?evt:(window.event?window.event:null);
    if (is_ie) { // grab the x-y pos.s if browser is IE
       tempX = evt.clientX ;
       tempY = evt.clientY ;
    } else { // grab the x-y pos.s if browser is NS
       tempX = evt.pageX;
       tempY = evt.pageY;
    }
	//   alert("document.body.scrollTop="+document.body.scrollTop+ "   document.documentElement.scrollTop="+document.documentElement.scrollTop);
    // catch possible negative values in NS4
    if (tempX < 0){tempX = 10;}
    if (tempY < 0){tempY = 10;}
	return [tempX,tempY];
}

function setDivBottom(o){
//   alert("w="+(o.style.width-1)+"  h="+o.style.height);
   $("ifrDIV").style.height=o.style.height;
   $("ifrDIV").style.width=o.style.width;
   $("ifrDIV").style.top=o.style.top;
   $("ifrDIV").style.left=o.style.left;
   $("ifrDIV").style.display="block";
   $("ifrDIV").style.zIndex=o.style.zIndex-1;
}
function clsDivBottom(){
	if($("ifrDIV"))
    $("ifrDIV").style.display="none";
}

function showDiv(o){
  if(!$("ifrDIV")){
    var ifr=document.createElement("iframe");
    ifr.style.position="absolute";
    ifr.style.width=0+"px";
    ifr.style.height=0+"px";
    ifr.style.top=0;
	ifr.style.display="none";
    ifr.frameBorder=0;
    ifr.id="ifrDIV";
    document.body.appendChild(ifr);
  }
  o.style.display="block";
  setDivBottom(o);
}
function hideDiv(o){
   clsDivBottom();
   o.style.display="none";
}

var pic=1;
function doFilter () { 
   if (window.ActiveXObject) { // IE 浏览器
	  document.getElementById("filterFrom").filters.item(0).Apply();
	  document.getElementById("filterFrom").filters.item(0).Transition=190;   //12,19-20 12 IS THE DISSOLVE FILTER
	 document.getElementById("filterFrom").filters.item(0).play(2);
	//  document.getElementById("filterFrom").filters[0].Play(duration=2);
   }
}

function showpic(){
//	alert("1111");
  doFilter();
 //alert(picUrl.length);
  document.getElementById("imageFrom").src=picUrl[pic-1];
  document.getElementById("showurl").href=picShowUrl[pic-1];
//alert("sssssss333");
  showtap(pic); 
//alert("444");
  if(pic==picUrl.length) pic=0;
  pic++;

  ss=window.setTimeout("showpic()",4000);

}
function showtap(t){
	//alert(t);
   for(i=1;i<=picUrl.length;i++){
     if(i==t){
       document.getElementsByName("tap")[i-1].style.background="#08af00";
	 }else{
	   document.getElementsByName("tap")[i-1].style.background="#0156AE";
	 }
   }
}
function ct(t){
  pic=t;
  doFilter();
  document.getElementById("imageFrom").src=picUrl[pic-1];
  showtap(pic); 
 // alert(t);
}
