function popup(href,name,width,height,r)
{
        popupWindow=window.open(href, name, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+width+',height='+height);
        popupWindow.opener=window;
		
		if( r!=null )
			return popupWindow;
}

function popupSizeable(href,name,width,height,r)
{
        popupWindow=window.open(href, name, 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width='+width+',height='+height);
        popupWindow.opener=window;
		
		if( r!=null )
			return popupWindow;
}

function popupImg(file,r)
{
        popupWindow=window.open('img.php?f='+file, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=10,height=10');
        popupWindow.opener=window;

		if( r!=null )
	        return popupWindow;
}


function popupFileUpload(f,dir)
{
	popup('file-upload.php?f='+f+'&dir='+dir,'',300,200);
}

function popupScroll(href,name,width,height,r)
{
        popupWindow=window.open(href, name, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height);
        popupWindow.opener=window;
		
		if( r!=null )
	        return popupWindow;
}

function trimString(s)
{
	return s.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function splitMax(str,by,max)
{
	var ar, r, i;
	ar=str.split(by);
	
	r=new Array();
	for(i=0;i<ar.length;i++)
	{
		if( i<(max-1) )
			r[i]=ar[i];
		else
		{
			if( r[max-1] )
				r[max-1]=r[max-1]+by+ar[i];
			else
				r[max-1]=ar[i];
		}
	}
	return r;	
}

function switchImg(id,path,desc)
{
	document.getElementById('img_'+id).src=path;
	document.getElementById('desc_'+id).innerHTML=desc;

}


function getKeyFromEvent(e) {
	var keynum
	var keychar
	var numcheck

	if(window.event) // IE
	{
	keynum = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
	keynum = e.which
	}
	return keynum;

}

