//function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } }
function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') { 
		window.onload = func; 
		} 
		else 
		{ 
		window.onload = function() { 
			if (oldonload) { 
				oldonload(); 
				} 
			func(); 
		} 
	} 
}
function isDefined(variable) { return (typeof(window[variable]) == "undefined") ? false : true; }
function isEnter(e) { 	var keycode = (window.event) ? window.event.keyCode : e.which; 	return (keycode == 13) ? true : false; }
function onEnterSubmitForm(thisFormItem, e) { if (isEnter(e)) { thisFormItem.form.submit(); return true; } else { return true; }; }
function onEnterPreventSubmitForm() { return false; }
function upload(field, location) { imageWin = window.open('/uploader/uu_file_upload.php?field=' + field + '&location=' + location + '', 'win1', 'scrollbars, resizable,width=520,height=420'); if (imageWin.opener == null) { imageWin.opener = self; }; };
function guestUpload() { upload('uploadphoto', 'guestbook') };
function $(v) { return(document.getElementById(v)); }
function $T(v,i) { return((i?$(i):document).getElementsByTagName(v)); }
function ckLan() { return 0; }
function mkLan(a,b,c) { return(c?'babelfish.altavista.com/babelfish/trurl_pagecontent?lp=en_'+a+'&url='+b:'translate.google.com/translate?u='+b+'&langpair=en%7C'+a+'&hl=en&ie=UTF-8&oe=UTF-8'); }
function mkURL(v,b) { var e=v.split('/'); return(e.slice(0,3).join('/')+'/'+(b!='en'?langMK[b]+':':'')+(e[3])); }
function mkBabel() {
	function commit(v) { v=v.replace('http://','').replace(/\/[a-z]{3}\:/,'/'); return(Array(v,escape(v))); }
	var R=commit(!ckLan()?document.location.href:$T('base')[0].href),D,Tm={'el':1,'nl':1,'ru':1,'zh':1,'ar':2,'zh-CN':2,'ko':2,'ja':2},z=''; R[1]=R[1].replace(/\+/g,'%2B').replace(/:/,'%3A').replace(/\//g,'%2F');
	var langV={'fr':'French','pt':'Portugese','ru':'Russian','it':'Italian','el':'Greek'};
	for(var i in langV) z+='<a href="http://'+($('trans-'+i)?mkURL(R[0],i):mkLan(i,R[1],Tm[i]==2?0:1))+'" target="_top"'+(!$('trans-'+i)?' class="transLight"':'')+'><span>'+langV[i]+"<\/span><\/a><br>";
	return(z);
}
function bookmark(url,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");
  }
}

function getElementsById(/* $el */){

	var i=0,j=0,k=0,items=[],nodes=[];
	var d=document,a=arguments,l=a.length;

	if(typeof a[0]=='object'){
		d=a[0];
	}else if(typeof a[l-1]=='object'){
		d=a[l-1];
	}

	for(;l>i;i++){
		if(typeof a[i]=='string'){
			items=ElementsById(a[i]);
			for(;items.length>j;j++){
				nodes[k++]=items[j];
			}
		}
	}

	return (nodes.length==1)?nodes[0]:nodes;
}

function ElementsById($id){
	var startDate=new Date();

	var c=0,i=0,j=0,k=0;
	var nodes=[],storage=arguments.callee.storage;
	var elements=document.getElementsByTagName('*'),length=elements.length;

	if(storage&&storage.nodes&&
		storage.length==length&&
		storage.first==elements[0]&&
		storage.last==elements[length-1]){
		k=$id;
		while(storage.nodes[k]){
			nodes[nodes.length]=storage.nodes[k];
			k=$id+'*'+(++i);
		}
	}else{
		storage={};
		storage.length=0;
		storage.nodes={};
		storage.first=elements[0];
		storage.last=elements[length-1];
		while(length>i){
			c=elements[i];
			if((k=c.id)==$id){
				nodes[nodes.length]=c;
				if(storage.nodes[k]){
					k=c.id+'*'+(++j);
				}
			}
			i++;
			storage.nodes[k]=c;
			storage.length++;
		}
		arguments.callee.storage=storage;
	}

	var endDate=new Date();
	alert('It took '+(endDate-startDate)+' ms');
	alert('Total # of nodes returned: '+nodes.length);

	return nodes;
}
// ---
/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];		
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}	
	}
	return (arrReturnElements)
}
// ---
// Revised version May 11th 2007
function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}	
	}
	return returnElements;
}
// ---
/*
	Revised to support looking for multiple class names,
	no matter in which order they're applied to the element
*/
function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}
// ---
// Array support for the push method in IE 5
if(typeof Array.prototype.push != "function"){
	Array.prototype.push = ArrayPush;
	function ArrayPush(value){
		this[this.length] = value;
	}
}
// ---
/*
	Examples of how to call the function:
	
	To get all a elements in the document with a "info-links" class:
    getElementsByClassName(document, "a", "info-links");
    
	To get all div elements within the element named "container", with a "col" and a "left" class:
    getElementsByClassName(document.getElementById("container"), "div", ["col", "left"]);
*/
// ---
function launchwin(winurl,winname,winfeatures,parentname)
{
//This launches a new window if one isn't already launched. If one is launched, it focuses it.
//It works in Nav3+ and MSIE4+, and does not cause errors in IE3. This function requires that the following
//code be called by the ONUNLOAD handler in all pages that reside in the new window:
//	if(!document.images){opener.newwin = null}

// Use this when not specifying params from the event handler:
// var parentname = "mainwindow";
// var winurl = "content.html"
// var winname = "newwindow"
// var winfeatures = "height=150,"
//			+ "width=300,"
//			+ "channelmode=0,"
//			+ "dependent=1,"
//			+ "directories=0,"
//			+ "fullscreen=0,"
//			+ "location=0,"
//			+ "menubar=0,"	
//			+ "resizable=0,"
//			+ "scrollbars=0,"
//			+ "status=0,"
//			+ "toolbar=0,"
//			+ "screenX=0,"
//			+ "screeny=0,"
//			+ "left=0,"
//			+ "top=0";
			//Only use the following attributes with a signed script:
			//-------------------------------
			//			+ "hotkeys=1, "
			//			+ "alwaysLowered=0, "
			//			+ "alwaysRaised=0, "
			//			+ "titlebar=0, "
			//			+ "z-lock=0, "
			//-------------------------------




if (!document.images) 	//Quick sniff for IE3. If the browser is IE3, don't check to see if the
						//window is already open. Just pretend it's always closed.
	{
		newwin = null;
	}


	if (newwin == null || newwin.closed)
		//-check for the existence of the window.
		//-we check in two ways: 1) is the newwin object null? It should be if we've closed the window
		// because we set newwin to null in a function called by the onunload handler.
		// And 2) is the newwin.closed property true? We check this second state because Netscape 4.5
		// doesn't call the onunload handler when you use the exit button on the window itself. So we
		// check the closed property for the benefit of Nav 4.5. Why not just check that? Because IE4
		// chokes on it if you do.  It's probably a good idea to check both anyway because "closed"
		// wouldn't be set before the first time the user launches the window. IE4 doesn't choke if we
		// check the status of newwin first.
						
		{
			//we've determined that no window is open, so launch one now
	
			newwin = window.open(winurl,winname,winfeatures);

			if (newwin.opener == null) // set the opener property manually for Nav 2.0.
			{
				newwin.opener = window;
			}
			newwin.opener.name = parentname; // give our parent window a name so we can target it from newwin

		}

	else


		{
			//if a window already exists, bring it to the front using windowname.focus()
			//(for Nav3+ and IE4+). IE3 will never get here because we force it to think the
			//window is always closed. IE3 always launches a new window when launchwin() is called.
			//Interestingly, IE3 will focus the newwin the first time we try to recreate it, but not
			//any subsequent times.

				alert("This link is already open in another window. Click OK to continue.");
				newwin.focus(); 

		}

}