function getTopUrl()
{
  var top_url = top.location.href;
  var idx = top_url.indexOf(";internal");
  if (idx != -1)
    top_url = top_url.substr(0,idx);
  idx = top_url.indexOf("?");
  if (idx != -1)
    top_url = top_url.substr(0,idx);
  return top_url;
}


function identify(e) 
{
  if (e && e.shiftKey) 
  {
    e.cancelBubble=true;
  }
  var href = getTopUrl() + ";internal&action=dialog.login.action&Request=" + getTopUrl();
  opDlg(href,'identify',{height: 300, width: 600});
}

function logout (e) 
{
  if (e && e.shiftKey) 
  {
    e.cancelBubble=true;
    identify();
    return false;
  }

  setCookie("sk","",null);
  setCookie("HW_POOL_SELECTOR","",null);
  
  var href = getTopUrl() + ";internal&action=logout.action";
  location.replace(href);
  return false;
}

function opDlg(url,target,winstylep){
  if (target=="_top") {
    top.location.href = url;
    return false;
  }
  if(target=="HW_Mainwindow") {
  if ((top.frames.length) && (top.frames.HW_Mainframe)) {
    top.frames.HW_Mainframe.location.href = url;
    return false;  }
  else {
    if ((opener.top.frames.length) && (opener.top.frames.HW_Mainframe)) {
      opener.top.frames.HW_Mainframe.location.href = url;
      return false;    }    else      return window.open(url,target+"811b996c80");
    }
  }
  var winstyle=winstylep||{};
  if (!winstyle.minHeight)winstyle.minHeight=100;
  if (!winstyle.maxHeight)winstyle.maxHeight=window.screen.height;
  if (!winstyle.minWidth)winstyle.minWidth=100;
  if (!winstyle.maxWidth)winstyle.maxWidth=window.screen.width;
  var h=""+((typeof winstyle!="undefined" && winstyle.height) ? winstyle.height : window.screen.height*0.75);
  if (h.indexOf("%")>=0)
    h = parseInt(h.substring(0,h.indexOf("%")))/100*window.screen.height;h=Math.min(h,winstyle.maxHeight);
  h=Math.max(h,winstyle.minHeight);
  
  var w=""+((typeof winstyle!="undefined" && winstyle.width) ? winstyle.width : 640);
  if (w.indexOf("%")>=0)
    w = parseInt(w.substring(0,w.indexOf("%")))/100*window.screen.width;w=Math.min(w,winstyle.maxWidth);
  w=Math.max(w,winstyle.minWidth);
  
  var win=window;
  if ((self.name==target || target=="")) {
    self.location.href=url;
  }
  else
  if (typeof winstyle=="undefined")
    win=window.open(url,target+"811b996c80","status=yes,toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
  else
    win=window.open(url,target+"811b996c80","status="+((winstyle.status) ? winstyle.status : "yes")+",toolbar="+((winstyle.toolbar) ? winstyle.toolbar : "no")+",scrollbars="+((winstyle.scrollbars) ? winstyle.scrollbars : "yes")+",resizable="+((winstyle.resizable) ? winstyle.resizable : "yes")+",width="+w+",height="+h);
  return win;
}

function doLogout() 
{
  var doc = top.document;
  doc.open();
  doc.writeln(" ");
  doc.close();
  doc.open();
  doc.writeln("<HTML>\n<BODY>\n<FORM METHOD=\"POST\" NAME=\"identify\" ACTION=\"/jucs_journal;internal&amp;action=login.action\">\n<INPUT TYPE=\"HIDDEN\" NAME=\"username\" VALUE=\"logout\">\n<INPUT TYPE=\"HIDDEN\" NAME=\"password\" VALUE=\" \">");
  doc.writeln("\n<INPUT TYPE=\"HIDDEN\" NAME=\"NOATTR_SAVEPASSWORD\" VALUE=\"false\">\n");
  doc.writeln("\n</FORM>\n</BODY>\n</HTML>");
  doc.close();
  doc.forms.identify.submit();
  return false;
}
