function popup($url)
{
	var $day	= new Date();
	var $id	= $day.getTime();

	eval("page" + $id + " = window.open('" + $url + "' , '" + $id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=600,height=400,left = 400,top = 325');");
}

/**
* get HTML element by ID
*/
function g(id)
{
	if(document.getElementById(id))
	{
	   return document.getElementById(id);
	}
	else
	{
	   return false;
	}
}


function h($id , $effect)
{
	try
	{
		switch ($effect)
		{
			case 'BlindUp':

				new Effect.BlindUp($id);

				break;

			case 'Fade':

				new Effect.Fade($id);

				break;

			default:

				$($id).style.display = 'none';
		}
	}
	catch($e)
	{
		$($id).style.display = 'none';
	}
}


function s($id , $effect)
{
	try
	{
		switch ($effect)
		{
			case 'Appear':

				new Effect.Appear($id);

				break;

			case 'BlindDown':

				new Effect.BlindDown($id);

				break;

			default:

				$($id).style.display = 'block';
		}
	}
	catch($e)
	{
		try
		{
			$($id).style.display = 'block';
		}
		catch(e){};
	}
}


function tog($id , $hide_effect , $show_effect)
{
	var $element = $($id);

	if (!$hide_effect)
	{
		var $hide_effect = '';
	}

	if (!$show_effect)
	{
		var $show_effect = '';
	}

	if ($element.style.display == 'none')
	{
		s($id , $show_effect);
	}
	else
	{
		h($id , $hide_effect);
	}
}


/**
 * @desc: Checks if javascript is enabled
 */
function check_js(element)
{
	if ($(element))
	{
		h(element + '_nojs');
		s(element);
	}
}


/**
 * goes to page
 */
function goTo(page)
{
	location.href=page;
}

/**
 * trims a string
 *
 * @author Kevin Van Den Haute
 */
String.prototype.trim = function()
{
	return(this.replace(/^\s+/,'').replace(/\s+$/,''));
}

/**
 * checks if value is in array
 */
function in_array(needle, haystack)
{
	for(var i=0;i<haystack.length;i++)
	{
	   if(haystack[i] == needle)
	   {
	      return true;
	   }
	}

	return false;
}

/**
 * validates URL
 */
function isUrl(s)
{
	var v = new RegExp();

   v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=~]+$");

   if (!v.test(s))
   {
      return false;
   }
   else
   {
   	return true;
   }

	return true;
}

/**
 * creates popup page
 */
function popup(page, width, height)
{
	popupframe=window.open(page, 'popupframe', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height + ',left=100,top=60');
	popupframe.focus();
}

/**
 * change height of HTML element
 */
function changeSize(id, offset, minSize)
{
   // get element
   el = id;

   // if element is an id and not a reference: get reference
   if ($(id))
   {
      el = $(id);
   }

   // set minimum size
   if (minSize == undefined)
   {
      minSize = 77;
   }

   // get height
   height = parseInt(el.style.height);

   if(!height && el.offsetHeight)
	{
		height = el.offsetHeight;
	}

	// calculate new height
	height += offset;

	if(height <= minSize)
	{
	   height = minSize;
	}

	// set new height
   el.style.height = height+"px";
}

/**
 * change TinyMCE textarea
 */
function changeTinyMCESize(textareaId, offset)
{
   var el = $(textareaId);
   var parent = el.parentNode;
   var set = false;
   var nEditor = 0;

   // expand table
   for(var i in parent.childNodes)
   {
      // if this is first element of tiny_mce
      if (set)
      {
         // table from tiny_mce
         table = parent.childNodes[i].firstChild;

         // get id for iframe
         nEditor = parent.childNodes[i].id;
         nEditor = nEditor.substr(11, 1);
         nEditor = 'mce_editor_' + nEditor

         // set sizes
         changeSize(table, offset);
         changeSize(nEditor, offset);

         // sizes are set
         set = false;
      }
      // this is the textarea we made in a .tpl
      if (parent.childNodes[i].id == el.id)
      {
         // set = true (so next item is a span of tiny_mce)
         set = true;
      }
   }
}