	// common js functions
	
	var isIE = navigator.userAgent.indexOf('Internet Explorer') >= 0;

	function showElement(elmnt, display){show(elmnt, (!display ? "inline" : display));}
	function hideElement(elmnt){hide(elmnt);}
	
	function hide()
	{
		if(hide.arguments.length > 0)
		{
			var el = hide.arguments[0];
			el = (typeof(el) == "string") ? document.getElementById(el) : el;
			if(el && typeof(el) == "object") el.style.display = "none";
		}
		return false;
	}//hide
	
	function show()
	{
		if(show.arguments.length > 0)
		{
			var display = show.arguments.length > 1? show.arguments[1] : "block";
			var el = show.arguments[0];
			el = (typeof(el) == "string") ? document.getElementById(el) : el;
			if(el && typeof(el) == "object") el.style.display = display;
		}
		return false;
	}//show

	function openPopup(url,winName,winWidth,winHeight,showScrollbars)
	{
		if(winName == null) winName = '';
		if(!(winWidth > 0)) winWidth = 700;
		if(!(winHeight > 0)) winHeight = 550;

		showScrolls = showScrollbars == true ? "1" : "0";

		if(url != null)
			window.open(url,winName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + showScrolls + ',resizable=1,width=' + winWidth + ',height=' + winHeight);
	}//openPopup



	function deleteRecord(recordID, recordName)
	{
		if(recordID > 0 && (frm = document.getElementById('form_records')))
		{
			if(!recordName) recordName = "record";
			if(confirm("Are you sure you want to delete this " + recordName + "?"))
			{
				frm.elements.id_to_delete.value = recordID;
				frm.submit();
			}
		}
		return false;
	} // /deleteRecord()
	
	function publishRecord(recordID)
	{
		if(recordID > 0 && (frm = document.getElementById('form_records')))
		{
			frm.elements.id_to_publish.value = recordID;
			frm.submit();
		}
		return false;
	} // /publishRecord()
	
	function moveRecord(position, move_to)
	{
		if(position > 0 && (frm = document.getElementById('form_records')))
		{
			frm.elements.id_to_move.value = position;
			frm.elements.move_to.value = move_to;
			frm.submit();
		}
		return false;
	} // /moveRecord()
	
	function doAction(action, id)
	{
		if(id > 0 && (frm = document.getElementById('form_records')))
		{
			eval("frm.elements.id_to_"+action+".value = id");
			frm.submit();
		}
		return false;
	}//doAction



	////
	// moves up/down a record (changing position)
	//
	function changePosition(id, direction)
	{
		if (id > 0 && (direction == "move_up" || direction == "move_down") && (frm = document.getElementById('form_position')))
		{
			frm.elements.mode.value = direction;
			frm.elements.id_to_move.value = id;
			frm.submit();
		}

		return false;
	} // /changePosition()
	
	function submitForm(id, rf)
	{
		var frm = document.getElementById(id);
		if(!rf || validateFields(frm, rf)) frm.submit();
		return false;
	}//submitForm
	
	function include(filename)
	{
		var scripts = document.getElementsByTagName("script");
		for(var i in scripts) if(scripts[i].src == filename) return false;
		
    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', filename);
    html_doc.appendChild(js);
    return false;
	}//include
	
	
	function printPage()
	{
    if(typeof(window.print) != 'undefined') window.print();
	}//printPage
	
	document.createElementCopy = document.createElement;
	document.createElement = function(tagName, name)
	{
		var obj;
		if(!name)
		{
			obj = document.createElementCopy(tagName);
		}
		else if(isIE)
		{
			obj = document.createElementCopy('<'+tagName+' name="'+name+'"/>');
		}
		else
		{
			obj = document.createElementCopy(tagName);
			obj.name = name;
		}
		return obj;
	}//createElement
	
	function remove(el)
	{
		el = (typeof(el) == "string") ? document.getElementById(el) : el;
		el.parentNode.removeChild(el);
		return false;
	}
	
	function setElementOpacity(elem, opacity)
	{
	  var opacityProperty = getOpacityProperty();	
	  if (!elem || !opacityProperty) return;
	  if (opacityProperty == "filter")
	  {
	    elem.style.filter = "alpha(opacity=" + (opacity * 100) + ")";
	  }
	  else
	  {
	    elem.style[opacityProperty] = opacity;
	  }
	}

	function getOpacityProperty()
	{
	  if (typeof document.body.style.opacity == 'string') return 'opacity'; // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
	  else if (typeof document.body.style.MozOpacity == 'string') return 'MozOpacity'; // Mozilla 1.6-, Firefox 0.8 
	  else if (typeof document.body.style.KhtmlOpacity == 'string') return 'KhtmlOpacity'; // Konqueror 3.1, Safari 1.1
	  else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) return 'filter'; // Internet Exploder 5.5+
	  return false;
	}
