﻿function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}
var t_id = setInterval(animate,20);
var pos=0;
var dir=2;
var len=0;

function animate()
{
var elem = document.getElementById('progress');
if(elem != null) {
if (pos==0) len += dir;
if (len>32 || pos>79) pos += dir;
if (pos>79) len -= dir;
if (pos>79 && len==0) pos=0;
elem.style.left = pos;
elem.style.width = len;
}
}
function remove_loading()
 {
	this.clearInterval(t_id);
	var targelem = document.getElementById('loader_container');
	targelem.style.display='none';
	targelem.style.visibility='hidden';
	var t_id = setInterval(animate,60);
 }
var offsetfrommouse=[15,25];
var displayduration=0;

var defaultimageheight = 40;
var defaultimagewidth = 40;

var timer;

function gettrailobj()
 {
  if (document.getElementById)
  return document.getElementById("preview_div").style
 }

function gettrailobjnostyle()
 {
	if (document.getElementById)
	return document.getElementById("preview_div")
 }


function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail(){	
	gettrailobj().display= "none";
	document.onmousemove=""
	gettrailobj().left="-500px"
	clearTimeout(timer);
}

//延迟0.2秒载入大图
function showtrail(imagename,title,content,width,height){
	i = imagename
	t = title
	c = content
	w = width
	h = height
	timer = setTimeout("show('"+i+"',t,c,w,h);",100);
}

function show(imagename,title,content,width,height){
 
    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if( (navigator.userAgent.indexOf("Konqueror")==-1  || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) && (docwidth>650 && docheight>500)) {
		( width == 0 ) ? width = defaultimagewidth: '';
		( height == 0 ) ? height = defaultimageheight: '';
		width+=30
		height+=55
		defaultimageheight = height
		defaultimagewidth = width
	
		document.onmousemove=followmouse; 
//<img onload="javascript:remove_loading();" src="' + imagename + '" border="0">height:'+ height +'px 
		newHTML = '<div class="border_preview" style="overflow: hidden; padding:0px; ">'
//		'<div id="loader_container"><div id="loader"><div align="center"></div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
//		newHTML = newHTML + '<h5>' + ' '+'sample：'+title + '</h5>'
		newHTML = newHTML + '<div class="preview_temp_load"></div>';
		newHTML = newHTML + '<span>' + ' '+ content + '</span>'
		newHTML = newHTML + '</div>'; 
		
		if(navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1 ){
			newHTML = newHTML+'';
		}		

		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="block";
	}
}


function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = e.pageX - xcoord - defaultimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < defaultimageheight + 2*offsetfrommouse[1]){
			ycoord += e.pageY - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth; 
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (defaultimageheight + 2*offsetfrommouse[1])){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}


	
function IsAlpha(cCheck)
	{
	return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
	}
function isnumber(str){
	var digits="1234567890xX";
	var i=0;
	var strlen=str.length;
	while((i<strlen)){
		var char=str.charAt(i);
		if(digits.indexOf(char)==-1)
		return false;i++;
		}
	return true;
}

function Verifyname(str){

	for (nIndex=0; nIndex<str.length; nIndex++)
		{
		cCheck = str.charAt(nIndex);


		if (isnumber(cCheck)|| IsAlpha(cCheck) || cCheck=='-' || cCheck=='_'|| cCheck==' ')
			{
			return false;
			}
		}
	return true;					
}

function Verifyusername(str){
	for (nIndex=0; nIndex<str.length; nIndex++)
		{
		cCheck = str.charAt(nIndex);
		if (!(isnumber(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' ))
			{
			return false;
			}
		}
	return true;					
}


function checkid(userID,year,month,day){
 var str;
    if (userID.value.length==15) {
str=year.value.substring(2)+month.value+day.value;
if (userID.value.substring(6,12)==str){
return true
}
else{
return false
}
   }
   if (userID.value.length==18) {
     
    
str=year.value+month.value+day.value;
if (userID.value.substring(6,14)==str){
return true
}
else{
return false
}
   }
   
   return false;
}

function nospacelong(s) 
{
  var whitespace = " \t\n\r";
  var i,l;
   l=0;
   for (i = 0; i < s.length; i++)
   {   
       var c = s.charAt(i);
       if (whitespace.indexOf(c) < 0) 
	   {
		  l=l+1;
	   }
   }
   return(l);
}
function VerifyTel(str)
{
    if (str.length>0) 
    {
	for (nIndex=0; nIndex<str.length; nIndex++)
		{
		cCheck = str.charAt(nIndex);
		if (!(isnumber(cCheck) || cCheck=='-'|| cCheck=='*'|| cCheck=='('|| cCheck==')'|| cCheck==','))
			{
			return false;
			}
	
		}
	}
	else
	return false;
	return true;					
}

function isCharsInBag(s,bag)
{  
  var i;
  for (i = 0; i < s.length; i++)
  {   
      var c = s.charAt(i);
      if (bag.indexOf(c) == -1) return false;
  }
  return true;
}
function isEmpty(s)
{  
	return ((s == null) || (s.length == 0))
}

function isWhitespace(s)
{  
  var whitespace = " \t\n\r";
  var i;
   for (i = 0; i < s.length; i++)
   {   
       var c = s.charAt(i);
       if (whitespace.indexOf(c) >= 0) 
	   {
		  return true;
	   }
   }

   return false;
}

function isEmail(s,d)
{
    if (isEmpty(s))
	{
		document.getElementById(d).innerHTML=" Please type a valid E-mail";
		return false;
	}
    if (isWhitespace(s))
	{
		document.getElementById(d).innerHTML=" The E-mail Can't include the Space";
		return false;
	}

   var i = 1;
   var len = s.length;
	pos1 = s.indexOf('@');
	pos2 = s.indexOf('.');
	pos3 = s.lastIndexOf('@');
	pos4 = s.lastIndexOf('.');
	if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len))  
	{
		document.getElementById(d).innerHTML=" Invalid E-mail Address!";
		return false;
	}
	else
	{
		if((pos1 == pos2 - 1)||(pos1 == pos2 + 1)||( pos1 != pos3 )||( pos4 < pos3 )||( pos4==len-1 ))
		{
			document.getElementById(d).innerHTML=" Invalid E-mail Address!";
			return false;
		}
	}

	if ( !isCharsInBag(s, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@"))
	{
		document.getElementById(d).innerHTML=" the E-mail can't include involid char";
		return false;
	}
	document.getElementById(d).innerHTML="Passed!"
	return true;
}
function verifypwd(pwdv,pwd,d)
{
      a=pwdv;
      b=pwd;
		if (a=='') {
		document.getElementById(d).innerHTML=" Please Type password!";
			mobj = eval(b);
    	    mobj.focus()
// 	        mobj.select()
			return false
	     }
	    if (a.length<4) {
	    document.getElementById(d).innerHTML="The length MUST BE Great Than 4 ";
	    	mobj = eval(b);
            mobj.focus()
	    	return false
	     }
	
	     if (!Verifyusername(a)) {
	     document.getElementById(d).innerHTML=" Password can only use alpha,digit,_ or - ";
	        mobj = eval(b);
            mobj.focus()
//            mobj.select()
	    	return false
       	}
	
		document.getElementById(d).innerHTML=" PASSED!";
		return true;
}
function verifyrepwd(repwdv,repwd,pwdv,d)
{
      a=repwdv;
      b=repwd;
      c=pwdv

    	if (a=='') {
   			document.getElementById(d).innerHTML=" Please retype password!";
	    	mobj = eval("b");
	        mobj.focus()
// 	        mobj.select()
			return false
		}
		if (a!=c) {
			document.getElementById(d).innerHTML=" Please retype above password!";
			mobj = eval(b);
    	    mobj.focus()
//    	    mobj.select()
			return false
		}
		document.getElementById(d).innerHTML=" PASSED!";
		return true;
}

function turnit(ss)
{
 if (ss.style.display=="none") 
 // {
  ss.style.display="";
//  if (ii.src=="images/plustop.gif")
 // {
 //  ii.src="images/minustop.gif";
 // }
 // else
 //  ii.src="images/minusmiddle.gif";

//}
 else
 // {
  ss.style.display="none"; 
  //if (ii.src=="images/minusmiddle.gif")
  // {
  // ii.src="images/plusmiddle.gif";
  // }
  //else
  //ii.src="images/plustop.gif"
 // }
}

