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;
}

/**
 * filters out bad chars
 */
function safeName(name)
{
   name = name.replace(/ /g , '_');

   noalpha = 'ÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÀÈÌÒÙàèìòùÄËÏÖÜäëïöüÿÃãÕõÅåÑñÇç@°ºª';
   alpha   = 'AEIOUYaeiouyAEIOUaeiouAEIOUaeiouAEIOUaeiouyAaOoAaNnCcaooa';

   for(i=0; i<alpha.length; i++)
   {
   	name = name.replace(noalpha[i], alpha[i]);
   }

   return name;
}

/**
 * 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();
}

/**
 * select award and close popup
 */
function selectaward(date)
{
	var txtarea = window.opener.document.forms[0]["award_date"];

	txtarea.value = date;

	txtarea.focus();

	self.close();
}

/**
 * adds a contribution to favorites
 */
function addContributionToFavorites(objectId)
{
   if(confirm(lang.addContributionToFavorites))
   {
      alert('nog te doen');
   }
}

/**
 * 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;
      }
   }
}
function delete_input_value($id)
{
	$($id).value = '';
}

function edit_row($id)
{
	$("row_" + $id).style.display = 'none';
	$("edit_row_" + $id).style.display = '';
	
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function bindup()
{			
	$display_stetting = $('action_block_down').style.display;		
	if($display_stetting == '' || $display_stetting == 'block')
	{
		s('action_block', 'BlindDown'); 			
		s('action_block_up' , 'Appear');
		h('action_block_down'); 			
		$display_stetting = 'visible';		
	}
	else
	{
		h('action_block','BlindUp');			
		s('action_block_down' , 'Appear');
		h('action_block_up');		
		$display_stetting = 'none';	
	}		
		
	$coockie_value = $display_stetting;	
	createCookie('yp_actions',$coockie_value,20);
}
function get_cookie_info()
{	
	var $cookie_value = readCookie('yp_actions');
	
	if ($cookie_value != null)
	{
		
		if($cookie_value != 'visible')
		{			
			h('action_block');			
			s('action_block_down');
			h('action_block_up');
		}
		else
		{
			s('action_block'); 			
			s('action_block_up' );
			h('action_block_down'); 
		}	
	}
	
}
