// 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.

// combination of old mt-site.js and popup.js

function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	} else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	} else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();
addEvent(window,'unload',EventCache.flush);

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');



    var mtcmtauth;
    var mtcmthome;
    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 tzone() {window.open('http://www.tzonefoundation.org', 'tzone', 'height=650,width=580,resizable=yes,status=yes,scrollbars=yes,location=yes,menubar=yes,toolbar=yes,left=30,top=30');}

function vidopen(url) {window.open(url, 'video', 'width=600,height=400,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function photopen(url) {window.open(url, 'photo', 'width=340,height=675,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function video_gallery(url) {window.open(url, 'video', 'width=760,height=542,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function video_tyraintwo(url) {window.open(url, 'video', 'width=760,height=542,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function picture_gallery(url) {window.open(url, 'photo', 'width=760,height=530,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function celebrity(url) {window.open(url, 'photo', 'width=760,height=530,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function pollopen(url) {window.open(url, 'poll', 'width=360,height=680,resizable=no,status=no,scrollbars=yes,location=no,menubar=no,toolbar=no,left=30,top=30');}

function cupidopen(url) {window.open(url, 'cupid', 'width=520,height=420,resizable=no,status=no,scrollbars=yes,location=no,menubar=no,toolbar=no,left=30,top=30');}

function daycare(url) {window.open(url, 'photo', 'width=760,height=510,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function blogphoto_player(url) {window.open(url, 'photo', 'width=500,height=390,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function quiz0919(url) {window.open(url, 'photo', 'width=660,height=480,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function slideshow(url) {window.open(url, 'photo', 'width=520,height=700,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}

function Infoopen(url) {window.open(url,'info', 'height=500,width=550,resizable=yes,status=no,scrollbars=yes,location=no,menubar=no,toolbar=no');}

function contestopen(url) {window.open(url,'contest', 'height=630,width=710,resizable=yes,status=no,scrollbars=yes,location=no,menubar=no,toolbar=no,left=50,top=10');}

function Advopen(url) {window.open(url,'adv', 'height=240,width=320,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=100,top=60');}

function replaceContent() {
     document.getElementById("wbad").innerHTML = "<iframe src='/includes/adref.html' name='adright' width='180' height='640' scrolling='no' frameborder='0'></iframe>"
}

function surfto(form) {
	var myindex=form.select1.selectedIndex
	if (form.select1.options[myindex].value != "0") {
	location=form.select1.options[myindex].value;}
}

// this is for the drop down menu

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
		
		
		navRootb = document.getElementById("bottom-nav");
		for (i=0; i<navRootb.childNodes.length; i++) {
			node = navRootb.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
		
		
		
		
	}
}
