
//--------------------------------------------------------------------------------
//¡¹¡¹¡¹¡¹¡¹¥»µ{¦¡¥¼¨Ó¥i¯à·|³Q¨ä¥¦µ{¦¡¤Þ¥Î¡A½Ð¤Å·h°£¡¹¡¹¡¹¡¹¡¹
//
//¨ú±o¦r¦êªº ¸ô®|,ÀÉ®×¦WºÙ,¥DÀÉ¦W¦WºÙ,°ÆÀÉ¦W¦WºÙ
//v1.0 -- ¥¿¦¡ª©¥»
//
//ex.
//    get_name( 'c:\image\verygood\2002.05.01\¤j¶H.123.gif' , type=0 )  //c:\image\verygood\2002.05.01\
//    get_name( 'c:\image\verygood\2002.05.01\¤j¶H.123.gif' , type=1 )  //¤j¶H.123.gif
//    get_name( 'c:\image\verygood\2002.05.01\¤j¶H.123.gif' , type=2 )  //¤j¶H.123
//    get_name( 'c:\image\verygood\2002.05.01\¤j¶H.123.gif' , type=3 )  //gif
//--------------------------------------------------------------------------------
function get_name( url , type )
{
    var tmp='';
    var buffer='';
    var data0=''; //¦s¸ô®|
    var data1=''; //¦sÀÉ¦W
    var data2=''; //¦s¥DÀÉ¦W
    var data3=''; //¦s°ÆÀÉ¦W

    //­Y¨S¦³³]©wªº¸Ü´Nµ¹¹w³]­È
    if(typeof(url)=="undefined")   return '';

    //­Y¨S¦³³]©wªº¸Ü´Nµ¹¹w³]­È, ¤£¬O¼Æ­È´Nµ¹¤©³]­È, ¿ù»~ªº¼Æ­È´NªÈ¥¿
    if(typeof(type)=="undefined")  type=1;
    if(typeof(type)!="number")     type=1;
    if(type<0)                     type=1;
    if(type>3)                     type=1;

    //¨ú±o³Ì«á¤@­Ó \ ²Å¸¹«e­±ªº©Ò¦³¦r¤¸
    data0=url;
    buffer='';
    while( true )
    {
        tmp=data0.indexOf('\\');
        if(tmp==-1) break;
        buffer+=data0.substr(0,(tmp+1));
        data0=data0.substr((tmp+1),data0.length);
    }
    data0=buffer;

    //¨ú±oÀÉ®×¦WºÙ
    data1=url.substr( data0.length );

    //¥ýÀË¬d¦³¨S¦³°ÆÀÉ¦W
    if( data1.indexOf('.')==-1 )
        data3='';
    else
    {
        //¥h°£©Ò¦³ . «e­±ªº¥ô¦ó¦r¤¸, ¨ú±o°ÆÀÉ¦W
        //¥»¨Ó¥H¤Uªº tmp ¨ú±oµ{¦¡­n©ñ¦b while ¸Ì­±,¦ý¬O¤×©ó¨ú¨ì ¹s ªº®É­Ô, while ·|»{¬°¬O false ¦Ó¸õ¥X
        //©Ò¥H©ñ¨ì¸Ì­±¥h
        data3=data1;
        while( true )
        {
            tmp=data3.indexOf('.');
            if(tmp==-1) break;
            data3=data3.substr((tmp+1));
        }
    }

    //ºâ¥X¥DÀÉ¦W
    data2=data1.substr( 0,(data1.length-data3.length-1) )

    //debug
    //alert(url+'\n'+data0+'\n'+data1+'\n'+data2+'\n'+data3);
    if(type==0)      return data0;
    else if(type==1) return data1;
    else if(type==2) return data2;
    else if(type==3) return data3;
    else             return '';
}





/*
OpenPopup
v0.2  -  ¤U¤È 12:10 2007/5/29
ºô§}©Î¹Ï¤ù , ¦W¦r , ÄÝ©Ê , ¬O§_©~¤¤ , ¼e , ªø 
openpopup('test.htm','test','scrollbars=0',true,'100','100');    //µL±²°Ê©T©wµøµ¡
openpopup('test.jpg','test','scrollbars=0',true,'100','100');    //¹Ï¤ùµøµ¡
openpopup('test.jpg','test','scrollbars=0',true);                //¹Ï¤ùµøµ¡¦Û°Ê°w´ú (opera·|¨Ó¤£«æ¤ÏÀ³)
openpopup('test.htm','test','fullscreen',false,'100','100');     //full screen
openpopup('test.htm','test','scrollbars,status,location,resizable',true,'300','100')  //center screen/scrollbars/statusbar/location/resizable
openpopup('test.htm','test','directories,menubar,location,toolbar',true,'300','100')  //center screen/directories/menubar/location/toolbar
*/
function openpopup(url,name,w,h,props,center){

    var l=42;
    var t=42;
    if(center){l=(screen.availWidth-w)/2;t=(screen.availHeight-h)/2}
    url=url.replace(/[ ]/g,'%20');

    // is image ?
    var is_image = /\.jpg$|\.jpeg$|\.gif$|\.png$|\.bmp$/.test(url.toLowerCase()) ;
    if(is_image==true) {
        var img = new Image();
        img.src=url;    //¨ì¦æµ²§ô¬°¤î, opera ·|¨Ó¤£«æ¨ú±o img ¥¿½Tªº width , height
        if( ( !w && !h ) || ( w=='' && h=='' ) || ( typeof w =='undefined' || typeof h =='undefined' )  ) {
            w = (img.width+42);
            h = (img.height+42);
        } else {
            //nothing
        }
    }

    popup=window.open(url,name,'left='+l+',top='+t+',width='+w+',height='+h+',scrollbars=1'+((props)?','+props:''));
    props=props||'';
    if(props.indexOf('fullscreen')!=-1){popup.moveTo(0,0);popup.resizeTo(screen.width,screen.height)}
    popup.focus();

}


