function submitWebForm (formName){
	var formular = document.forms[formName];
	
	var ok = _ValidateForm(formular);
	
	if (ok) {
		formular.submit();	
	}
	return (ok);
}

function WriteRandomTopBg(tableWidth,tableClass,heading,height) {
	var max=4;
	var topBgId = Math.floor(Math.random()*max+1);
	var tableHeight='';
	if (height>0) {
		tableHeight = 'style="height:'+height+'px"';	
	}
	
	var out ='<table width="'+tableWidth+'" border="0" cellpadding="0" cellspacing="0" class="boks infoboks boks_top'+topBgId+'" '+tableHeight+'>';
	document.write(out);
};


function ShowSearchWindow (){
	var pop_width = 300;
	var pop_height = 20;
	
	var leftVal = (screen.width-pop_width) / 2;
	var topVal = (screen.height-pop_height) / 2;
	
	var win = window.open('search.html','SEARCH','width='+pop_width+', height='+pop_height+', resizable=0, scrollbars=0, left='+leftVal+', top='+topVal);
}

function answerItem( item_id ) {
	var headline = get_layer("debate-form-name");	
	var myForm = document.forms['debatereplyform'];
	
	if ( item_id ) {
		headline.innerHTML = 'Besvar indl&aelig;g';		
		myForm.elements['item_id'].value = item_id;
	} else {
		headline.innerHTML = 'Opret nyt indl&aelig;g';
		myForm.elements['item_id'].value = 0;
	}
}

function SubmitDebateForm(frm) {
	var headline = frm.elements['name'].value;	
	var txt = frm.elements['text'].value;
	var author = frm.elements['author'].value;
	var	email = frm.elements['email'].value;
	
	var err = false;
	
	var fieldsNotOk = ((headline == '') || ( txt == '' ) || (author == '') || ( email ==''));
	
	if (fieldsNotOk) {
		alert('Alle felter skal udfyldes!');
		return false;
	}	
	
	email = email.replace(/^\s+/, '');
	email = email.replace(/\s+$/, '');
	
	
	email = _ValidateEmailStrip(email);
	if (!(email.match(_ValidateEmailStringRegExp))) {
		alert("Feltet 'Din email-adresse' er udfyldt med en ugyldig e-mailadresse'");
		return false;	
	} 
	
	frm.submit();
}