﻿// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") +
        (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    if (f.author != undefined)
       setCookie('mtcmtauth', f.author.value, now, '/', '', '');
    if (f.email != undefined)
       setCookie('mtcmtmail', f.email.value, now, '/', '', '');
    if (f.url != undefined)
       setCookie('mtcmthome', f.url.value, now, '/', '', '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '/', '');
    deleteCookie('mtcmthome', '/', '');
    deleteCookie('mtcmtauth', '/', '');
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}

function hideDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'none';
}

function showDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'block';
}

var commenter_name;

function individualArchivesOnLoad(commenter_name) {

    hideDocumentElement('trackbacks-info');



    if (document.comments_form) {
        if (!commenter_name && (document.comments_form.email != undefined) &&
            (mtcmtmail = getCookie("mtcmtmail")))
            document.comments_form.email.value = mtcmtmail;
        if (!commenter_name && (document.comments_form.author != undefined) &&
            (mtcmtauth = getCookie("mtcmtauth")))
            document.comments_form.author.value = mtcmtauth;
        if (document.comments_form.url != undefined && 
            (mtcmthome = getCookie("mtcmthome")))
            document.comments_form.url.value = mtcmthome;
        if (document.comments_form["bakecookie"]) {
            if (mtcmtauth || mtcmthome) {
                document.comments_form.bakecookie.checked = true;
            } else {
                document.comments_form.bakecookie.checked = false;
            }
        }
    }
}

function writeTypeKeyGreeting(commenter_name, entry_id) {

}



function writeMenubar()
{
   document.write('<ul id="nav">');
   document.write('  <li><a href="http://www.dbanotes.net">DBA notes</a></li>');
   document.write('  <li><a href="http://www.cnoug.net/index.html">Home</a></li>');
   document.write('  <li><a href="http://www.anysql.net/aul.html">AUL</a></li>');
   document.write('  <li><a href="http://www.freelists.org/archives/oracle-l/">Oracle-L</a></li>');
   document.write('  <li><a href="http://search.dbanotes.net">Search</a></li>');   
   document.write('  <li><a href="http://www.anysql.net/otop.html">Tools</a></li>');
   document.write('  <li><a href="http://www.dbanotes.net/archives.html">Archive</a></li>');
   document.write('  <li><a href="http://www.cnoug.net/rss.php">RSS</a></li>');
   document.write('  <li><a href="http://www.dbatools.net">DBAtools</a></li>');
   document.write('  <li><a href="http://www.dbanotes.net/database/cnoug_planet.html">About</a></li>');
   document.write('</ul>');
}

function writeCopyright()
{
   document.write('<div class="contact-method">Powered by <a href="http://www.cnoug.net/">CNOUG.net</a><br />')
   document.write('ORACLE DBA User Group Planet<br />');
   document.write('感谢 <a href="http://www.anysql.net/">AnySQL.net</a> 提供技术支持</div>');
}

function writeTopAdv()
{
  ran_number= Math.random()*40; 

  if (ran_number < 10)
  {
   document.write('  <div align="center" style="margin-bottom: 0px;"><div style="font-size: 18px; color:#0082FF; margin-bottom: 0px;"><a href="http://www.dbanotes.net/">DBA notes -- 关注 Web 2.0 架构与优化</a></div></div>');  
   }
  else if (ran_number < 20)
  {
   document.write('  <div align="center" style="margin-bottom: 0px;"><div style="font-size: 18px; color:#0082FF; margin-bottom: 0px;"><a href="http://www.dbanotes.net/">DBA notes -- 关注 Web 2.0 架构与优化</a></div></div>');    
   }
  else if (ran_number < 30)
  {
   document.write('  <div align="center" style="margin-bottom: 0px;"><div style="font-size: 18px; color:#0082FF; margin-bottom: 0px;"><a style="font-size: 18px; color:#0082FF;" href="http://www.anysql.net/news.html">AUL/MyDUL, 与 Oracle DUL 同等功能</a></div></div>');
  }
  else if (ran_number < 40)
  {
   document.write('  <div align="center" style="margin-bottom: 0px;"><div style="font-size: 18px; color:#0082FF; margin-bottom: 0px;"><a href="http://www.dbanotes.net/">Personal Tech Portal of Fenng</a></div></div>');
  }
  else 
  {
   document.write('  <div align="right"></div>');
  }
}
