
function activateAdminButton(name, type, form, index)
{
	
	if (type == 'submit')
	{

		$("a#button" + index).click(function() {
	     $("form#" + form).submit();
	     return false;
	   });
   
	} 
	else if(type == 'cancel')
	{
	
		$("a#button" + index).click(function() {
		    var answer = confirm("Are you sure you want to cancel? Your changes will not be saved!");
		    if (answer)
		    {
				history.go(-1); // this should be changed to the last visited page
			}
			
			return false;
	
	   });
	   
	} else if(type == 'hook') {
		$("a#button" + index).click(function() {
			setTimeout(form+'()',1);
			return false;
		});
	} else if(type == 'url') {
		$("a#button" + index).click(function() {
			window.location=form;
			return false;
		});
	}

	$("a#button" + index).hover(function() {
	    $(this).addClass("buttonHover");
	  },function(){
	    $(this).removeClass("buttonHover");
	  });

}

/**
*
* str_replace
*
* This function returns a string or an array with all occurrences of 
* [search] in [subject] replaced with the given [replace] value.
* If you don't need fancy replacing rules (like regular expressions), you should always use this function. 
*
* last modified: 04-04-2007
* 
* @param	string	search
* @param	string	replace
* @param	string	string
*/
function str_replace (search, replace, subject)
{
  var result = "";
  var  oldi = 0;
  for (i = subject.indexOf (search)
     ; i > -1
     ; i = subject.indexOf (search, i))
  {
    result += subject.substring (oldi, i);
    result += replace;
    i += search.length;
    oldi = i;
  }
  return result + subject.substring (oldi, subject.length);
}

$(document).ready(function() {
	$('.defaultvalue').click(function() {
		
		if($(this).hasClass('defaultvalue')) {
			$(this).attr('value','');
			$(this).removeClass('defaultvalue');
		}
		
	});
});