function getRefToDiv(divID,oDoc) {
    if( !oDoc ) { oDoc = document; }
    if( document.layers ) {
        if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
            //repeatedly run through all child layers
            for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
                //on success, return that layer, else return nothing
                y = getRefToDiv(divID,oDoc.layers[x].document); }
            return y; } }
    if( document.getElementById ) {
        return document.getElementById(divID); }
    if( document.all ) {
        return document.all[divID]; }
    return false;
}

function showDiv(divID_as_a_string) {
    //get a reference as above ...
    myReference = getRefToDiv(divID_as_a_string);
    if( !myReference ) {
        return false; //don't go any further
        //return anything would work,
        //but I am using false to show failure
    }
    //now we have a reference to it
    if( myReference.style ) { //DOM & proprietary DOM
        myReference.style.visibility = 'visible';
    } else {
        if( myReference.visibility ) { //Netscape
            myReference.visibility = 'show';
        } else {
            return false; //don't go any further
        }
    }
    return true;
}

function hideDiv(divID_as_a_string) {
	var myReference = getRefToDiv(divID_as_a_string);
	if( !myReference ) { 
	    return false;
	}
	if( myReference.style ) { 
	    myReference.style.visibility = 'hidden'; 
	} else {
	    if( myReference.visibility ) { 
	        myReference.visibility = 'hide'; 
	    } else {
		return; 
	    }
	}
}

// ***********************************************************
// COOKIES
// ***********************************************************
function getCookie(NameOfCookie)
{
        if (document.cookie.length > 0)
        {
                begin = document.cookie.indexOf(NameOfCookie+"=");
                if (begin != -1) // Note: != means "is not equal to"
                {
                        begin += NameOfCookie.length+1;
                        end = document.cookie.indexOf(";", begin);
                        if (end == -1) end = document.cookie.length;
                        return unescape(document.cookie.substring(begin, end));
                }
        }
        return null;
}

function setCookie(NameOfCookie, value, expiredays)
{
        var ExpireDate = new Date ();
        ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
        document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) + "; path=/segfault/blog/";
}


function delCookie (NameOfCookie) {
        if (getCookie(NameOfCookie)) {
                document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
        }
}


// De mas alto nivel

function showLinks() {
	showDiv('EnlacesOn');
	hideDiv('EnlacesOff');
}

function hideLinks() {
	showDiv('EnlacesOff');
	hideDiv('EnlacesOn');
}

function rememberMe(doit) {
	if(doit==true) {
		setCookie('name', document.post.name.value, 7);
		setCookie('email', document.post.email.value,7);
		setCookie('website', document.post.website.value,7);
	} else {
		delCookie('name');
		delCookie('email');
		delCookie('website');
	}
}
	
var timerLinks=0;
