try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {
}

/* utvider med standard trim-funkson */
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

/* utvider med standard left-trim-funkson */
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}

/* utvider med standard right-trim-funkson */
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

/**
 * Sjekker om en streng er en gyldig epost via ett regulært uttrykk
 *
 * @access public
 * @param string	strEmail	Strengen som skal sjekkes
 * @return boolean	True om strengen er en epostadresse
 */
String.prototype.isValidEmail = function() {
	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,4}$/;
	if(((this.search(exclude) != -1)||(this.search(check)) == -1)||(this.search(checkend) == -1)){
		return true;
	} else {
		return false;
	}
}

/**
 * Returns the value of the selected radio button in the radio group
 * 
 * @param {radio Object} or {radio id} el
 * OR
 * @param {form Object} or {form id} el
 * @param {radio group name} radioGroup
 */
function $RF(el, radioGroup) {
	if($(el).type == 'radio') {
		var el = $(el).form;
		var radioGroup = $(el).name;
	} else if ($(el).tagName.toLowerCase() != 'form') {
		return false;
	}
	return $F($(el).getInputs('radio', radioGroup).find(
		function(re) {return re.checked;}
	));
}


//A function that returns unique IDs
//(it's like a class with a class attribute)
getId = function() {
 if (!this.id)
   this.id = 0;
 this.id++;
 return this.id;
}
//A function that acts like a stack (registers objects by unique IDs)
registerObject = function(objType, id, o) {
 if (!this.objById)
   this.objById = new Array();
 if (!this.objById[objType])
   this.objById[objType] = new Array();
 if (this.objById[objType][id])
   alert('Object already registered with this ID!!');
 else
   this.objById[objType][id] = o;
}
//A function that unstacks the registered object with a given ID
getObjectById = function(objType, id) {
 return this.objById[objType][id];
}
//We use objType for our stack to be reusable
//in other parts of our program
//This way, the stack can hold several object in different use contexts
//A test class to be instantiate
testClass = function() {
 //Attribute
 this.phrase = 'Cool! The context is saved!';
 //Method with reference to the class object
 this.doSomething = function() {
   alert(this.phrase);
 }
}
//The function that delay code execution
delay = function(code, contexte, time) {
 //We provide a unique ID for our context object to be memorized
 var id = getId();
 //We register our context object in the stack
 registerObject('delay', id, contexte);
 //When time is out, the code will be evaluated within the stacked context
 setTimeout('eval('+code+'.call(getObjectById(\'delay\','+id+')));', time);
}

function initiateFuncions(){
	if(input.activate){
		input.activate();
	}
}

Event.observe(window, 'load', function(event){
	$$('table[cellspacing!=0]','table[cellpadding!=0]').each(
		function(table){
			table.cellSpacing = '0';
			table.cellPadding = '0';
		}
	);
});