// JavaScript Document

//bookmrk this page
function bookmark() 
{ 
	var url = document.location.href;
	var title = document.title;
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
		window.external.AddFavorite(url,title);
	} else if (navigator.appName == "Netscape") {
		window.sidebar.addPanel(title,url,"");
	} else {
		alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
	}

} 

//used to trim strings
function trim_string(str) 
{
    return str.replace(/^\s*/, "").replace(/\s*$/, "");
}


//image popup
function view_image_popup(theURL,winName,features) 
{ //v2.0
  window.open(theURL,winName,features);
}


//get all elements with the same class (NOT USED ANYMORE)
function countElementsByClass(classname)
{
	var count = 0;
	var elements = document.getElementsByTagName('*');
	for(i=0;i<elements.length;i++)
	{
		var clase = elements[i].className;
		if(clase.search(classname) >= 0)
			count++;
	}
	return count;
}


//helper function source: http://www.dustindiaz.com/getelementsbyclass/
function getElementsByClass(searchClas,node,tag) 
{
	var clasElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClas+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			clasElements[j] = els[i];
			j++;
		}
	}
	return clasElements;
}


//Deletion prompt
function confirmDelete(message) 
{
	//replace [l] with \n so we can have page breaks without the browser rendering them 
	while(message.indexOf("[l]")>0)
		message = message.replace("[l]", "\n");

	if (confirm(message))
		return true;
	else
		return false;
} 

function slideBox(Box) /*doesnt work right now, will be for scrolling*/
{
	Box.style.height = (Box.style.height + 1) + "px";	
	window.document.write(Box.style.height + " - ");
}


function forward_url($url)
{
	window.location = $url;	
}


