function GetCookie (name) {  
  var arg = name + "=";  
  var alen = arg.length;  
  var clen = document.cookie.length;  
  var i = 0;  
  while (i < clen) {
     var j = i + alen;    
     if (document.cookie.substring(i, j) == arg)      
         return getCookieVal (j);    
     i = document.cookie.indexOf(" ", i) + 1;    
     if (i == 0) break;   
  }  
  return null;
}

function SetCookie (name, value) {  
  var argv = SetCookie.arguments;  
  var argc = SetCookie.arguments.length;  
  var expires = (argc > 2) ? argv[2] : null;  
  var path = (argc > 3) ? argv[3] : null;  
  var domain = (argc > 4) ? argv[4] : null;  
  var secure = (argc > 5) ? argv[5] : false;  
  document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) +  ((domain == null) ? "" : ("; domain=" + domain)) +  ((secure == true) ? "; secure" : "");
}

function SetCookie_php(name,value) {
  return true;
}
function DeleteCookie (name) {  
  var exp = new Date();  
  exp.setTime (exp.getTime() - 1);   
  var cval = GetCookie (name);  
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function keyDownAction(e)
{
    if (!e) {
        e = window.event;
    }
    var key = e.keyCode;
    try {
        eval("keyDownAction_"+key+"();");
    }
    catch(err) {
        return;
    }
}

function keyDownAction_37()
{
    self.location.href = document.getElementById("l_arrow").href;
}

function keyDownAction_39()
{
    self.location.href = document.getElementById("r_arrow").href;
}

function keyDownAction_32() {
    keyDownAction_39();
}

/*
function rightIconView(all_width, br) {
    var h=window.innerHeight;
    if (h == undefined) { 
        var h=window.document.body.clientHeight; 
    }
    alert(mainBody.offsetLeft+'x'+mainBody.offsetTop);
    alert(mainBody.offsetWidth+'x'+mainBody.offsetHeight);

    var w=window.innerWidth;
    if (w == undefined) { 
        var w=window.document.body.clientWidth; 
    }
    if (br == 'IE') {
        w=w;
    } else if (br == 'Safari') {
        w-=18;
    } else if (br == 'Firefox') {
        w-=16;
    }
    
    var offset = (h/2) - 140;
    //var offset = 82;
    //alert(all_width);
    //window.document.all.rightIcon.style.top = window.document.body.scrollTop +0 ;
    rightIcon.style.top = window.document.body.scrollTop + offset ;
    if(all_width>w) {
        rightIcon.style.left= all_width;
    } else {
        rightIcon.style.left= all_width+((w-all_width)/2);
    }
    return ;
}
*/
function rightIconView(all_width, br) {
    try {
    //var w = document.getElementById('topMenuTable').offsetLeft+document.getElementById('topMenuTable').offsetWidth;
        /*
        if (br == 'IE') {
            if (document.documentElement.clientHeight) {
                var h = document.getElementById('topMenuTable').offsetTop+document.documentElement.clientHeight;
            } else {
                var h = document.getElementById('topMenuTable').offsetTop+document.getElementById('mainBody').clientHeight;
            }
        } else {
            var h = document.getElementById('topMenuTable').offsetTop+document.getElementById('mainBody').clientHeight;
        }
        */
        var h = getClientHeight();
        var offset = (h+30)/2;
        //alert(document.documentElement.clientHeight);

        //document.getElementById('rightIcon').style.left= w + 'px';
        document.getElementById('rightIcon').style.top = getScrollTop() + offset + 'px';
    } catch(e) {}
}

function getClientHeight() {
      if ( window.innerHeight )
         return window.innerHeight;
      else if ( document.documentElement && document.documentElement.clientHeight )
         return document.documentElement.clientHeight;
      else if ( document.body )
         return document.body.clientHeight;
      else
         return 0;
}

function getClientWidth() {
      if ( window.innerWidth )
         return window.innerWidth;
      else if ( document.documentElement && document.documentElement.clientWidth )
         return document.documentElement.clientWidth;
      else if ( document.body )
         return document.body.clientWidth;
      else
         return 0;
}

function getScrollTop() {
      if ( window.pageYOffset )
         return window.pageYOffset;
      else if ( document.documentElement && document.documentElement.scrollTop )
         return document.documentElement.scrollTop;
      else if ( document.body )
         return document.body.scrollTop;
      else
         return 0;
}

function getScrollLeft() {
      if ( window.pageXOffset )
         return window.pageXOffset;
      else if ( document.documentElement && document.documentElement.scrollLeft )
         return document.documentElement.scrollLeft;
      else if ( document.body )
         return document.body.scrollLeft;
      else
         return 0;
}

function ghostS(path,w,h) {
    //var e = e?e:event;
    
    //alert('x');
    //alert(e.screenY+'x');
    //return true;

    return overlib("<div><img src='"+path+"' border='0'></div>",FOLLOWMOUSE,WIDTH,w,HEIGHT,h,HAUTO,ABOVE,OFFSETX,30,OFFSETY,40,FGCLASS,'overDivFGCLASS',BGCLASS,'overDivBGCLASS',DELAY,200);
    //alert(xL); return;
/*
    if(over.style.left<(w+30)) {
        overlib("<div><img src='"+path+"' border='0'></div>",FOLLOWMOUSE,WIDTH,w,HEIGHT,h,RIGHT,FGCLASS,'overDivFGCLASS',BGCLASS,'overDivBGCLASS');
    }
*/

}

function ghostL(all_width,br) {
    var s_x=document.getElementById('topMenuTable').offsetLeft+document.getElementById('topMenuTable').offsetWidth-400;

    return overlib("<iframe src='/search/change_layout.php' style='float:none;margin:0px;padding:0px;width:350px;height:500px;border:0px;'></iframe>",FOLLOWMOUSE,STICKY,CLOSECLICK,FIXX,s_x,FIXY,82,FGCLASS,'overDivFGCLASS');
    //overDiv.innerHtml='fjdkslafjdkslafjklhi';
    //return ture;
}
/*
function ghostL(all_width,br) {
    var w=window.innerWidth;
    if (w == undefined) { 
        var w=window.document.body.clientWidth; 
    }
    if (br == 'IE') {
        w=w;
    } else if (br == 'Safari') {
        w-=18;
    } else if (br == 'Firefox') {
        w-=16;
    }

    if(all_width>w) {
       var s_x=all_width;
    } else {
       var s_x=(all_width+((w-all_width)/2)) -370;
    }

    return overlib("<iframe src='/search/change_layout.php' style='float:none;margin:0px;padding:0px;width:350px;height:500px;border:0px;'></iframe>",FOLLOWMOUSE,STICKY,CLOSECLICK,FIXX,s_x,FIXY,82,FGCLASS,'overDivFGCLASS');
    //overDiv.innerHtml='fjdkslafjdkslafjklhi';
    //return ture;
}
*/

function winReload() {
    self.location.reload();
}

function CAP_showCDImage_tit(tit) {
    window.location.href = "/search/photoList.php?keywordStr="+tit+"&cdt="+tit;
} 

function CAP_showCDAllImage_tit(tit) {
    var url = "/search/title_show.php?ctg="+tit+"&url=/search/title_show_close.php";

    var photoWin_pop = window.open(url,'photoWin_pop', 'menubar=no,resizable=yes,scrollbars=yes,width=860,height=655,top=0,left=0');
    photoWin_pop.focus();
}

function go_search(kwd) {
    window.location.href = "/search/photoList.php?keywordStr="+kwd;
} 

function followmouse(e) {
    if (!e) { e = event; }
    var scrollH = window.document.body.scrollTop;
    var top = e.clientY;
    try {
        var barTop = document.getElementById('g-bar').offsetTop;
        var arrowTop = (top + scrollH - 67);
        if (arrowTop < barTop) {
            arrowTop = barTop;
        }
            document.getElementById('show_arrow').style.top = arrowTop + "px";
            document.getElementById('hide_arrow').style.top = arrowTop + "px";
            /*
        if (document.getElementById('g-bar1')) {
            document.getElementById('show_arrow').style.top = arrowTop + "px";
        } else {
            document.getElementById('hide_arrow').style.top = arrowTop + "px";
        }
        */
    } catch(e) {}
}

//var layoutTimer = '';

function arrowdiv1_over(e,obj) {
    var top = e.clientY;
    /*
    if (layoutTimer) { clearTimeout(layoutTimer); }
    var request = 'changeLayout_1('+top+')';
    layoutTimer = setTimeout(request,500);
}

function changeLayout_1(top) {
*/
    document.getElementById('g-bar1').className = 'div1';
    var scrollH = window.document.body.scrollTop;
    var left = document.getElementById('g-bar').offsetLeft;
    var barTop = document.getElementById('g-bar').offsetTop;
    var arrow = document.getElementById('show_arrow');

    var clientInfo = new getClientInfo();
    var browser_type = clientInfo.getBrowserType();
    var os_type = clientInfo.getOSType();
    if (browser_type == 'EXPLORER' && os_type == 'MAC') {
        arrow.style.left = (left + 6) + "px";
    } else {
        arrow.style.left = (left + 6) + "px";
    }
    var arrowTop = (top + scrollH - 67);
    if (arrowTop < barTop) {
        arrowTop = barTop;
    }
    arrow.style.top = arrowTop + "px";
    if (browser_type == 'EXPLORER' && os_type == 'MAC') {
    } else {
        arrow.style.display = "";
    }
    document.getElementById('g-bar').onmousemove = followmouse;
}

function arrowdiv2_over(e,obj) {
    var top = e.clientY;
    /*
    if (layoutTimer) { clearTimeout(layoutTimer); }
    var request = 'changeLayout_2('+top+')';
    layoutTimer = setTimeout(request,500);
}

function changeLayout_2(top) {
*/
    document.getElementById('g-bar2').className = 'div2';
    var scrollH = window.document.body.scrollTop;
    var left = document.getElementById('g-bar').offsetLeft;
    var barTop = document.getElementById('g-bar').offsetTop;
    var arrow = document.getElementById('hide_arrow');

    var clientInfo = new getClientInfo();
    var browser_type = clientInfo.getBrowserType();
    var os_type = clientInfo.getOSType();
    if (browser_type == 'EXPLORER' && os_type == 'MAC') {
        arrow.style.left = (left - 18) + "px";
    } else {
        arrow.style.left = (left - 18) + "px";
    }
    var arrowTop = (top + scrollH - 67);
    if (arrowTop < barTop) {
        arrowTop = barTop;
    }
    arrow.style.top = arrowTop + "px";
    if (browser_type == 'EXPLORER' && os_type == 'MAC') {
    } else {
        arrow.style.display = "";
    }
    document.getElementById('g-bar').onmousemove = followmouse;
}

function arrowdiv_out() {
    try {
        //if (layoutTimer) { clearTimeout(layoutTimer); }
        if (document.getElementById('g-bar1')) {
            document.getElementById('g-bar1').className = '';
        }
        if (document.getElementById('g-bar2')) {
            document.getElementById('g-bar2').className = '';
        }
        document.getElementById('hide_arrow').style.display = "none";
        document.getElementById('show_arrow').style.display = "none";
    } catch(e) {}
}

function viewPhoto_global(newurl)
{
    var photoWin_globalpop = window.open(newurl,'photoWin_globalpop', 'menubar=no,resizable=yes,scrollbars=yes,width=860,height=655,top=0,left=0');
    photoWin_globalpop.focus();
}

function setKeywordStr(val) {
    document.getElementById('keywordStr').value = val;
}
