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) {  
    location.href="/cookie.php?n="+name+"&v="+escape(value)+"&p="+escape(location.href);
}

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 openPOP(url,WName) {
    var WinW = 250;
    var WinH = 120;
    var newWinW =  320;
    var newWinH =  200;

    var options = 'width='+ WinW +',height=' + WinH + ',left='+ newWinW +',top=' + newWinH + ', status=no,menubar=no,location=no,directiories=no,scrollbars=no,resizable=yes';
    window.open(url,WName,options);
}

function viewPhoto_global(newurl)
{
    var photoWin = window.open(newurl,'photoWin', 'menubar=no,resizable=yes,scrollbars=yes,width=860,height=640,top=0,left=0');
    photoWin.focus();
}

