/*function chgLang(){
	if(top.location.pathname.indexOf("/eng/") != -1){
		top.location.replace(top.location.pathname.replace(/\/eng\//,"/chi/"));
	} else if (top.location.pathname.indexOf("/chi/") != -1) {
		top.location.replace(top.location.pathname.replace(/\/chi\//,"/eng/"));
	} else if (top.location.pathname.indexOf("\\eng\\") != -1) {
		top.location.replace(top.location.pathname.replace(/\\eng\\/,"\\chi\\"));
	} else if (top.location.pathname.indexOf("\\chi\\") != -1) {
		top.location.replace(top.location.pathname.replace(/\\chi\\/,"\\eng\\"));
	}
	
function chgLang() {

       var str = window.location.href;

       if (str.indexOf("/eng/") > -1) {

              window.location.href = str.replace(/\/eng\//,"\\chi\\");

       } else {

              window.location.href = str.replace(/\/chi\//,"\\eng\\");

       }

}	
}*/

function chgLang() {

       var str = window.location.href;
       if (str.indexOf("/eng/") > -1) {
              window.location.href = str.replace("/eng/", "/chi/");
       } else {
              window.location.href = str.replace("/chi/", "/eng/");
       }
}


function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { 
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function init(obj, area) {
	obj.style.pixelTop =  area.getBoundingClientRect().bottom + Bdy.scrollTop - 1;
	obj.style.pixelLeft = area.getBoundingClientRect().right - obj.offsetWidth + Bdy.scrollLeft	- 8;
}

function checkdate() {
    var err=0;
    date=document.form.date.value;
	
    if (date.length == 0)
		err = 1;
        
	if ((date.length < 8)||(date.length > 10)) err = 1;
	
	if ((date.length > 7)||(date.length < 11)) {
		var firstSlash = date.indexOf('/');
		if(firstSlash == -1) err = 1;
		var firstPart  = date.substring(0,firstSlash);
		if(firstPart.length < 2) 
			firstPart = "0"+firstPart;
		var secondPart  = date.substring(firstSlash+1);			
		var secondSlash = secondPart.indexOf('/');
		if(secondSlash == -1) err = 1;
		secondPart  = secondPart.substring(0,secondSlash);
		if(secondPart.length < 2) 
			secondPart = "0"+secondPart;
		var thirdPart  = date.substring(firstSlash+secondSlash+2);		
		if(thirdPart.indexOf('/')!= -1) err=1;
		date = firstPart+'/'+secondPart+'/'+thirdPart;	
    }
	       
    month = parseFloat(date.substring(0, 2));
    slash1 = date.substring(2, 3)
    day = parseFloat(date.substring(3, 5));
    slash2 = date.substring(5, 6)
    year = parseFloat(date.substring(6, 10));

    if (isNaN(month)) err=1;
    if (isNaN(day)) err=1;
    if (isNaN(year)) err=1;
    
    if (month < 1 || month > 12) err = 1
    if (slash1 != '/') err = 1
    if (day<1 || day>31) err = 1
    if (slash2 != '/') err = 1
    if (year<1900 || year>2099) err = 1
    if (month==4 || month==6 || month==9 || month==11){
    if (day==31) err=1
    }
    if (month==2){
        var validYear=parseFloat(year/4)
        if (isNaN(validYear)) {
            err=1
        }
        if (day>29) err=1
        if (day==29 && ((year/4)!=parseFloat(year/4))) err=1
    }
    if (err==1) {
        alert('Please enter a valid date (mm/dd/yyyy).');
        date=document.form.date.focus();
	 return false;
    }
    return true;
}
