window.addEvent('domready', function() {
	 addsok();
	 fjerninnhold($('form_brukernavn'), "");
	 fjerninnhold($('form_passord'), "");
});

function confirmbox(msg) {
	if(!confirm(msg)) {
		return false;
	}
	else {
		return true;	
	}
}

function addsok() {
	$('sok').onkeydown = function (e) {
		key = keydown(e);
		if(key == 13) { window.location = "/sok/alle/"+escape($('sokfelt').value); }
	}
}

function keydown(e) {
	var evt =(e)?e:(window.event)?window.event:null;
	var key = (evt.charCode)?evt.charCode: ((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
	return key;
}

function fjerninnhold(el, tekst) {
	if(el == null)
		return;
    el.value = tekst;
    
    el.addEvent('focus', function() {
    	if(this.value == tekst) {
    		this.value = "";
    	}
    });
    
    el.addEvent('blur', function() {
    	if(this.value == "") {
    		this.value = tekst;
    	}
    });
}

function getDisplayName(id,val){
	dispName= val.value
	if (dispName != '') {
        var m = dispName.match(/(.*)[\/\\]([^\/\\]+)\.\w+$/);
		document.getElementById(""+id+"").value = m[2];
    }
	
}

function submitFormSetIDBekreft(val, valName, formName, bekreftMelding) {
	if(confirm(bekreftMelding)){
		document.getElementById(""+valName+"").value = val;
		document.getElementById(""+formName+"").submit();
	}
	else {
		return false;
	}
}

function fb_open() {
	var filebrowser = window.open("/admin/lib/medialibrary/", "", "resizable,scrollbars=yes,status=0");
}

function fb_return(id,filnavn) {
	el = fb_getelement();
	children = el.parentNode.childNodes;
	
	
	children[1].value = id;
	children[0].innerHTML = filnavn;
	
}

function fb_setfiletypes(filetypes) {
	fb_filetypes = filetypes;
}

function fb_getfiletypes() {
	return fb_filetypes;
}

function fb_setelement(el) {
	fb_element = el;
}

function fb_getelement() {
	return fb_element;
}

function fb_setratio(r) {
	fb_ratio = r;
}

function fb_getratio() {
	return fb_ratio;
}

function fb_setothersizes(r) {
	fb_os = r;
}

function fb_getothersizes() {
	return fb_os;
}


