	var ns4 = document.layers;
	var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1);
	var op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) ||(navigator.userAgent.indexOf("Opera/6")!=-1);
	var agt = navigator.userAgent.toLowerCase();
	var mac = (agt.indexOf("mac")!=-1);
	var ie = (agt.indexOf("msie") != -1);
	var mac_ie = mac && ie;

    function displayNodeItems(itemName) {
        var nodeItems = "";
        var counter = 1;
        for(var node in itemName) {
            nodeItems += node + ", ";
            if(counter == 5) {
            nodeItems += "\n";
            counter = 0;
            }
            counter++
        }
    }


    function OverOutClass(item_name, bg_color, font_color) {
        var row = item_name.parentNode;
        var node = item_name.lastChild;
        node.nextSibling;

        row.style.backgroundColor = bg_color;
        node.style.color = font_color;
    }

    function OverOutImg(img_name, img_src) {
        document[img_name].src = img_src;
    }




    function view_img(img, title, width, height) {
        var page_to_open = "/directory/viewimg_old.php?img=" + img + "&title=" + title + "";
        window.open(page_to_open, "resource_pic_open", "toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no, width=" + width + ", height=" + height + "");
    }

    function view_img_new(image_id, title) {
        var page_to_open = "/directory/viewimg.php?image_id=" + image_id + "&title=" + title + "";
        window.open(page_to_open, "resource_pic_open", "toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no, width=1, height=1");
    }

    function openRankWindow(id) {
        window.open("rank_popup.php?id=" + id, "ranking_window", "toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no, width=470, height=255");
    }

    function openEmailWindow(id) {
        window.open("email_popup.php?id=" + id, "email_window", "toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no, width=470, height=400");
    }

	function getWindowWidth() {
		return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
	}

	function quick_link_mouse_over() {
	    document.getElementById("scroll_menu_inner").style.visibility = "visible";
	}

    function quick_link_mouse_out() {
        document.getElementById("scroll_menu_inner").style.visibility = "hidden";
    }



function view_img(img, title, width, height) {
    var page_to_open = "/directory/viewimg.php?img=" + URLencode(img) + "&title=" + title + "";
    window.open(page_to_open, "resource_pic_open", "toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no, width=" + width + ", height=" + height + "");
}

function URLencode(sStr) {
    return escape(sStr).replace(/\+/g, '%2C').replace(/\"/g,'%22').replace(/\'/g, '%27')
}



function copy_clip(maintext) {
    if (window.clipboardData) {
        window.clipboardData.setData("Text", maintext);
    } else if (window.netscape) {
       netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
       var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
       if (!clip) return;

       var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
       if (!trans) return;

       trans.addDataFlavor('text/unicode');
       var str = new Object();
       var len = new Object();
       var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
       var copytext=maintext;
       str.data=copytext;
       trans.setTransferData("text/unicode",str,copytext.length*2);
       var clipid=Components.interfaces.nsIClipboard;
       if (!clip) return false;
       clip.setData(trans,null,clipid.kGlobalClipboard);
   }
   alert(maintext + "\nhas been copied to your clipboard.");
}

function Next(size) {
    var curr_img = document.getElementById("curr_image").value;
    var show_img = document.getElementById("show_img");

    curr_img++;
    if(curr_img > size) { curr_img = 0; }

    show_img.src = image_array[curr_img];
    document.getElementById("curr_image").value = curr_img;

}

function Previous(size) {
    var curr_img = document.getElementById("curr_image").value;
    var show_img = document.getElementById("show_img");

    curr_img--;
    if(curr_img < 0) { curr_img = size; }

    show_img.src = image_array[curr_img];
    document.getElementById("curr_image").value = curr_img;
}


function addBookmark(page_type, bm_url) {
    //var alias = prompt("Enter bookmark name (max 20 characters)");
    //document.location.href = "/users/userBookmarks.php?bm_action=add_bookmark&bm_url=" + URLencode(bm_url) + "&bm_alias=" + URLencode(alias) + "&bm_page_type=" + page_type;
    document.location.href = "/users/userBookmarks.php?bm_action=add_bookmark&bm_url=" + URLencode(bm_url) + "&bm_page_type=" + page_type;
}

function editBookmark(page_type, bm_id, bm_url) {
    var alias = prompt("Enter bookmark name (max 20 characters)");
    document.location.href = "/users/userBookmarks.php?bm_action=edit_bookmark&bm_id=" + bm_id + "&bm_url=" + URLencode(bm_url) + "&bm_alias=" + URLencode(alias) + "&bm_page_type=" + page_type;
}

function showBookmark(bm_url) {
    document.location.href = "/users/userBookmarks.php?bm_action=show_bookmark&bm_url=" + URLencode(bm_url);
}

function hideBookmark(bm_url) {
    document.location.href = "/users/userBookmarks.php?bm_action=hide_bookmark&bm_url=" + URLencode(bm_url);
}


function getPageCenter() {
	return (screen.width / 2);
}

function getPageTop() {
    if(document.layers) {
        y = eval("window.pageYOffset");
    } else if(document.all) {
        y = eval("document.body.scrollTop");
    } else if(document.getElementById){
        y = eval("window.pageYOffset");
    }
    return y;
}

function getElementLeft(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.pageX;
	} else {
		var elem;
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		xPos = elem.offsetLeft;
		tempEl = elem.offsetParent;
  		while (tempEl != null) {
  			xPos += tempEl.offsetLeft;
	  		tempEl = tempEl.offsetParent;
  		}
		return xPos;
	}
}

function getElementTop(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.pageY;
	} else {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all) {
			var elem = document.all[Elem];
		}
		yPos = elem.offsetTop;
		tempEl = elem.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		}
		return yPos;
	}
}
