function loginVerify() {
	if (Login.Username.value == '') {
		document.getElementById('Error').innerHTML = '<b>Der er fejl i det indtastede:</b><br><br>Du skal indtaste et brugernavn.<br><br>Hvis du ikke har et, klik venligst på knappen Opret.';
		document.getElementById('Error').style.display = 'block';
		return false;
	}
	else if (Login.Password.value == '') {
		document.getElementById('Error').innerHTML = '<b>Der er fejl i det indtastede:</b><br><br>Du skal indtaste et kodeord.';
		document.getElementById('Error').style.display = 'block';
		return false;
	}
}

function registerVerify() {
	if (Register.Username.value == '') {
		document.getElementById('Reg_Error').innerHTML = '<b>Der er sket en fejl i det indtastede:</b><br><br>Du skal indtaste dit ønskede brugernavn.';
		doucment.getElementById('Reg_Error').style.display = 'block';
		return false;
	}
	else if (Register.Password.value == '') {
		document.getElementById('Reg_Error').innerHTML = '<b>Der er sket en fejl i det indtastede:</b><br><br>Du skal indtaste dit ønskede kodeord.';
		doucment.getElementById('Reg_Error').style.display = 'block';
		return false;
	}
	else if (Register.Password.value != Register.PasswordVerify.value) {
		document.getElementById('Reg_Error').innerHTML = '<b>Der er sket en fejl i det indtastede:</b><br><br>Kodeordene stemte ikke overens, prøv igen.';
		doucment.getElementById('Reg_Error').style.display = 'block';
		return false;
	}
}

function showBox(id) {
	document.getElementById(id).style.display = (document.getElementById(id).style.display == 'none') ? 'block' : 'none';
}

function showCalendar(id,note) {
	document.getElementById(id).style.display = (document.getElementById(id).style.display == 'none') ? 'block' : 'none';
	document.getElementById(id).innerHTML = (document.getElementById(id).innerHTML == '') ? '<b>Note</b>:<br>'+note : '';
	return false;
}

/*	DESIGN MODE	*/

function initForm() {
	Content.document.designMode = 'On';
}

function copyContent() {
	if (showStatus == "Design") {
		Form.dbContent.value = Content.document.body.innerHTML;
	}
	else if (showStatus == "Code") {
		Content.document.body.innerHTML = Form.dbContent.value;
	}
}

function makeBold() {
	Content.focus();
	Content.document.execCommand('bold', false, null);
}
function makeItalic() {
	Content.focus();
	Content.document.execCommand('italic', false, null);
}
function makeUnderline() {
	Content.focus();
	Content.document.execCommand('underline', false, null);
}


function makeAlignLeft() {
	Content.focus();
	Content.document.execCommand('justifyleft', false, null);
}
function makeAlignCenter() {
	Content.focus();
	Content.document.execCommand('justifycenter', false, null);
}
function makeAlignRight() {
	Content.focus();
	Content.document.execCommand('justifyright', false, null);
}


function makeNumbering() {
	Content.focus();
	Content.document.execCommand('insertorderedlist', false, null);
}
function makeBullets() {
	Content.focus();
	Content.document.execCommand('insertunorderedlist', false, null);
}


function makeCut() {
	Content.focus();
	Content.document.execCommand('cut', false, null);
}
function makeCopy() {
	Content.focus();
	Content.document.execCommand('copy', false, null);
}
function makePaste() {
	Content.focus();
	Content.document.execCommand('paste', false, null);
}


function makeUndo() {
	Content.focus();
	Content.document.execCommand('undo', false, null);
}
function makeRedo() {
	Content.focus();
	Content.document.execCommand('redo', false, null);
}

showStatus = "Design";
function showDesign() {
	if (showStatus == "Code") {
        iHTML = Form.dbContent.value;
        Content.document.body.innerHTML = iHTML;
		document.getElementById('dbContent').style.display = 'none';
		document.getElementById('htmlContent').style.display = 'block';
        showStatus = "Design";
        Content.focus();
    }
}
function showCode() {
	if (showStatus == "Design") {
        iHTML = Content.document.body.innerHTML;
		Form.dbContent.value = iHTML;
		document.getElementById('htmlContent').style.display = 'none';
		document.getElementById('dbContent').style.display = 'block';
        showStatus = "Code"
        Content.focus();
    }
}

/* Menu edit */

function linkstyleGo(id) {
	box = document.addmenu.LinkType;
	destination = box.options[box.selectedIndex].value;
	if (destination == "absolute") {
		location.href = "./?page=admin_menu&mode=add&linktype=absolute";
	}
	if (destination == "internal") {
		location.href = "./?page=admin_menu&mode=add&linktype=internal";
	}
}

function Go(id) {
	box = document.getElementById('SectionBox');
	if (box.options[box.selectedIndex].value != -1) {
		destination = box.options[box.selectedIndex].value;
		location.href = "./?page=section&id=" + destination;
	}
}

/*
_______________________________________________________________________________
			Extra Functions on the edit page
_______________________________________________________________________________
*/

function makeSave(Filename) {
	Content.focus();
	Content.document.execCommand('saveas', true, "C:\\" + Filename + ".html");
}


function makePrint() {
	Content.focus();
	Content.document.execCommand('print', true, null);
}


function makeIndent() {
	Content.focus();
	Content.document.execCommand('indent', false, null);
}


function makeOutdent() {
	Content.focus();
	Content.document.execCommand('outdent', false, null);
}

function makeAbsolute() {
	Content.focus();
	Content.document.execCommand('absoluteposition', false, true);
	Content.document.execCommand('2d-position', false, true);
}

function makeField() {
	Content.focus();
	Content.document.execCommand('insertFieldset')
}

function makeLink() {
	Content.focus();
	Content.document.execCommand('createlink');
}

function makeStaticLink(Link) {
	Content.focus();
	if (Link != "")
		Content.document.execCommand('createlink', false, Link);
	else
		Content.document.execCommand('unlink');
}


function makeImage() {
	Content.focus();
	Content.document.execCommand('insertimage', true, null);
}


function makeStaticimage(Dir) {
	Content.focus();
	Content.document.execCommand('insertimage', false, Dir);
}

function makeFont(newfont) {
	Content.focus();
	Content.document.execCommand('fontname', false, newfont);
}


function makeFontsize(newsize) {
	Content.focus();
	Content.document.execCommand('fontsize', false, newsize);
}


function makeBackColor(Color) {
	Content.focus();
	Content.document.execCommand('backcolor', false, Color);
}


function makeFontColor(Color) {
	Content.focus();
	Content.document.execCommand('forecolor', false, Color);
}

/*
_______________________________________________________________________________
			Startup, save, windows functions
_______________________________________________________________________________
*/

function makeShowimage() {
	if (showStatus == 1) {
		document.getElementById('Show').src = "img/show_html.gif";
	}
	else {
		document.getElementById('Show').src = "img/show_normal.gif";
	}
}

function makeHelp(Faq) {
	document.getElementById('Help').innerHTML = "<b>Hjælp</b>: " + Faq;
}

function clearHelp() {
	document.getElementById('Help').innerHTML = "";
}

function newWindow(file,pageWidth,pageHeight) {
	window.open(file,"CMS","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=" + pageWidth + ", height=" + pageHeight + "")
}

/*
_______________________________________________________________________________
			Announcement functions
_______________________________________________________________________________
*/

function ClearOthers(name) {
	if (name != 'Documents') { document.getElementById('Documents').selectedIndex = 0; }
	if (name != 'Generic') { document.getElementById('Generic').selectedIndex = 0; }
	if (name != 'News') { document.getElementById('News').selectedIndex = 0; }
	if (name != 'Pages') { document.getElementById('Pages').selectedIndex = 0; }
	if (name != 'Calendar') { document.getElementById('Calendar').selectedIndex = 0; }
}
