
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MenuHidden()
{
menu.style.visibility="hidden";
}

function MenuShow()
{
menu.style.visibility="visible";
}

function ChangeColor()
{
}

function MM_showHideLayers() { //v6.0
  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 getLength(str){
  return eval(str.replace(/[^\x00-\xff]/g,"**").length);
}

function chkSpecialLetter(str){
  var pattern = /([%'])+/;
  if (pattern.test(str))
    return true;
  else
    return false;	
}

function getErrorMsg(errormsg,msg){
  var error_msg="";
  
  if(errormsg.length<=0)
    error_msg = msg;
  else
    error_msg = errormsg + "\n"+msg;
  
  return error_msg;	
}

function isChinese(str){    
  var pattern = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0])*$/gi;
  if (pattern.test(str))
    return true;
  else
    return false;
}

function validEmail(str){
  var pattern = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/gi;
  if(pattern.test(str))
    return true;
  else
    return false;
}

function isDigital(str){
  var pattern=/(\D)+/;     
  if(pattern.test(str))
    return false;
  else
    return true;     
}	

function chgImage(imgObj,w,h){
  var temp_img = new Image();
  temp_img.src = imgObj.src;

  
  if(temp_img.width<=0 && temp_img.height<= 0){
    if(imgObj.width>0)
    	temp_img.width=imgObj.width;
    else	
    	temp_img.width=w;
    if(imgObj.height>0)
    	temp_img.height=imgObj.height; 
  }
  
  
  factorX = 1.00;
  factorY = 1.00;
  factorX = w / temp_img.width;
  if (factorX > 1) factorX = 1;
  factorY = h / temp_img.height;
  if (factorY > 1) factorY = 1;
  if (factorX < factorY) {
    factorY = factorX;
  } else {
    factorX = factorY;
  }
  newW = Math.floor(factorX * temp_img.width);
  newH = Math.floor(factorY * temp_img.height);
  imgObj.width=parseInt(newW);
  imgObj.height=parseInt(newH);
}

function ochgImage(imgObj,w,h){
  var temp_img = new Image();       
  temp_img.src = imgObj.src; 
  if(temp_img.width>=temp_img.height){
    if(temp_img.width>=w){
      imgObj.width=w;  
      imgObj.height=temp_img.height*(w/temp_img.width);
    }else if(temp_img.width!=0 && temp_img.height!=0){
      imgObj.width=temp_img.width;
      imgObj.height=temp_img.height;
    } 
  }else{
    if(temp_img.height>=h){
      imgObj.height=h;        
      imgObj.width=temp_img.width*(h/temp_img.height);
    }else if(temp_img.width!=0 && temp_img.height!=0){
      imgObj.width=temp_img.width;
      imgObj.height=temp_img.height;
    } 
  }    
}

    function getHTTPXMLrequest(){

        var http_request = null;

        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {            
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {                
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        return http_request;          
    }
                    
    function doGet(s_url,s_param,callbackfunction){
    	var http_request = getHTTPXMLrequest();
    	var o_return = null;
    	
    	if(http_request){
    	  if( typeof(callbackfunction) == 'function' ){
    	    http_request.onreadystatechange = function(){
	      if ( http_request.readyState == 4 ){
	      	if(http_request.status == 200)
		  callbackfunction(http_request.responseText);
		else
		  callbackfunction("http error: "+http_request.status);	        
	      }else if(this.readyState == 1){	      
	        window.status = "loading";
	      }else if(this.readyState == 2){
	        window.status = "loaded";
	      }else if(this.readyState == 3){
	        window.status = "interactive";
	      }else if(this.readyState == 0){
	        window.status = "uninitialized";
	      }  
	    }
            http_request.open('GET', s_url+'?'+s_param, true);
            http_request.send(s_param);  
          }else{
            http_request.open('GET', s_url+'?'+s_param, false);            
            http_request.send(s_param);  
            if(http_request.status == 200)
              o_return = http_request.responseText;
            else
		  o_return = "http error: "+http_request.status;
          }
        }
        return o_return;
    }

var picWindow;
/*
function openPicWin(img){
  var temp_img = new Image();
  temp_img.src = img.src;
  
  var url = temp_img.src;
  var w = temp_img.width;
  var h = temp_img.height;
  var s = "yes";
  
  //var w = eval(w);
  //var h = eval(h);
  
  
  if(h>=w && h>768){
    w=w*(768/h);
    h=768;  	
  }else if(w>h && w>1024){
    h=h*(1024/w);
    w=1024;  	
  }
  
  w=w+40;
  h=h+30;
  	 
  if(typeof(picWindow)=="undefined" || picWindow.closed){  	
    picWindow = window.open (url, "picWindow", "height="+h+", width="+w+", toolbar =no, menubar=no, scrollbars="+s+", resizable="+s+", location=no, status=no");
    picWindow.focus();
  }else if(!picWindow.closed){
    picWindow.close();
    picWindow = window.open (url, "picWindow", "height="+h+", width="+w+", toolbar =no, menubar=no, scrollbars="+s+", resizable="+s+", location=no, status=no");	
    picWindow.focus();
  }else {  	
    picWindow = window.open (url, "picWindow", "height="+h+", width="+w+", toolbar =no, menubar=no, scrollbars="+s+", resizable="+s+", location=no, status=no");	
    picWindow.focus();
  }    
}
*/

function openPicWin(img){
  var s_url = img.src;	  
  var s_hostname = window.location.hostname;
//alert(s_url);
//alert(s_hostname);  
  if(s_url && s_url.indexOf(s_hostname)>=0 && s_url.indexOf("media")>0 && s_url.indexOf("/gallery/m")>0){
  	s_url = s_url.replace("/gallery/m","/gallery/");
  }
  
  var temp_img = new Image();
  temp_img.src = s_url;
    
  var w = temp_img.width;
  var h = temp_img.height;
  var s = "yes";
  /*
  var w = eval(w);
  var h = eval(h);
  */
  
  if(h>=w && h>768){
    w=w*(768/h);
    h=768;  	
  }else if(w>h && w>1024){
    h=h*(1024/w);
    w=1024;  	
  }
  
  w=w+40;
  h=h+30;
  	 
  if(typeof(picWindow)=="undefined" || picWindow.closed){  	
    picWindow = window.open (s_url, "picWindow", "height="+h+", width="+w+", toolbar =no, menubar=no, scrollbars="+s+", resizable="+s+", location=no, status=no");
    picWindow.focus();
  }else if(!picWindow.closed){
    picWindow.close();
    picWindow = window.open (s_url, "picWindow", "height="+h+", width="+w+", toolbar =no, menubar=no, scrollbars="+s+", resizable="+s+", location=no, status=no");	
    picWindow.focus();
  }else {  	
    picWindow = window.open (s_url, "picWindow", "height="+h+", width="+w+", toolbar =no, menubar=no, scrollbars="+s+", resizable="+s+", location=no, status=no");	
    picWindow.focus();
  }    
}

function chgImageSrc(img){
  var s_url = img.src;	  
  var s_hostname = window.location.hostname;
  var s_port = window.location.port;

  if(s_url && s_url.indexOf(s_hostname)>=0 && s_url.indexOf("media")>0 && s_url.indexOf("/gallery/m")>0){
  	s_url = s_url.replace("/gallery/m","/gallery/");
  }else
  	s_url = "http://"+s_hostname+":"+s_port+"/twlog/_img/nopic.gif";
  
  img.alt = img.src;  
  img.src = s_url;  
}
