// 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) {




    if (document.comments_form) {
        if (document.comments_form.email != undefined &&
            (mtcmtmail = getCookie("mtcmtmail")))
            document.comments_form.email.value = mtcmtmail;
        if (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 (mtcmtauth || mtcmthome) {
            document.comments_form.bakecookie.checked = true;
        } else {
            document.comments_form.bakecookie.checked = false;
        }
    }
}

function writeTypeKeyGreeting(commenter_name, entry_id) {

}





//===================================================================================================
// o y a t s u
//===================================================================================================

function restoreCookie()
{
	document.comments_form.email.value  = getCookie("mtcmtmail");
	document.comments_form.author.value = getCookie("mtcmtauth");
	document.comments_form.url.value    = getCookie("mtcmthome");
	if( getCookie("mtcmtauth") ){
	    document.comments_form.bakecookie[0].checked = true;
	}else{
	    document.comments_form.bakecookie[1].checked = true;
	}
}


function OpenVote (c) {
    window.open(c,
                    'vote',
                    'width=480,height=110,scrollbars=no,status=yes');
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function acc( pg ){
	var a = "&&";
	var pf = navigator.platform + a;
	var lng = navigator.language + a;
	var swh = screen.width + "x" + screen.height + a;
	var cd = screen.colorDepth + a;
	var pd = screen.pixelDepth + a;
	var rf = document.referrer;

	pg = "1_" + pg;
	document.write("<img src='http://www.polygonoid.com/mcy/ds/dsw.cgi?");
	document.write("pg="+pg+a+"pf="+pf+"lng="+lng+"swh="+swh+"cd="+cd+"pd="+pd+"rf="+rf);
	document.write("' width=1 height=1 border='0' alt='.'>");
}



function cmnt()
{
	if( document.getElementById("cmnt-box").style.display != "block" ){
		document.getElementById("cmnt-box").style.display  = "block";
		document.getElementById("trbk-box").style.display  = "none";
		document.getElementById("container").style.display = "none";
		location.href = "#title";
	}else{
		document.getElementById("cmnt-box").style.display  = "none";
		document.getElementById("trbk-box").style.display  = "none";
		document.getElementById("container").style.display = "block";
	}
}

function trbk()
{
	if( document.getElementById("trbk-box").style.display != "block" ){
		document.getElementById("trbk-box").style.display  = "block";
		document.getElementById("cmnt-box").style.display  = "none";
		document.getElementById("container").style.display = "none";
		location.href = "#title";
	}else{
		document.getElementById("trbk-box").style.display  = "none";
		document.getElementById("cmnt-box").style.display  = "none";
		document.getElementById("container").style.display = "block";
	}
}


function scrt()
{
	if( document.getElementById("normal").style.display != "none" ){
		document.getElementById("normal").style.display  = "none";
		document.getElementById("secret").style.display  = "block";
	}else{
		document.getElementById("normal").style.display  = "block";
		document.getElementById("secret").style.display  = "none";
	}
}




var imgNew;
var imgPath;
function changeImg( path ){
	imgNew = new Image();
	imgNew.src = path;
	imgPath = path;
	checkLoadImg();
}

function checkLoadImg(){
	var loadFlag = imgNew.complete;
	if( !loadFlag ){
		setTimeout('checkLoadImg()',20);
	}else{
		changeImgExe();
	}
}

function changeImgExe()
{
	var w = imgNew.width;
	var h = imgNew.height;

	var imgCur = document.getElementById("IMG");

	imgCur.src = imgPath;
	imgCur.width  = w;
	imgCur.height = h;
}
