function cp(imgID){
	if (document.images["img" + imgID]){
		document.images["img" + imgID].src=eval("img" + imgID + "Over.src");
	}
}

function cp2(imgID){
	if (document.images["img" + imgID]){
		document.images["img" + imgID].src=eval("img" + imgID + ".src");
	}
}

function CP(imgID, Level){
	if (document.images["img" + imgID]){
		document.images["img" + imgID].src=eval("imgL" + Level + "Over.src");
	}
}

function CP2(imgID, Level){
	if (document.images["img" + imgID]){
		document.images["img" + imgID].src=eval("imgL" + Level + ".src");
	}
}

function SetContentHeight(){ //Enables
	DwTopGraphicHeight = 0;
	if(document.getElementById("DwTopGraphic")){
		if(document.getElementById("DwTopGraphic").length){
			for(var iDT = 0; iDT < document.getElementById("DwTopGraphic").length; iDT++){
				DwTopGraphicHeight += document.getElementById("DwTopGraphic")[iDT].offsetHeight;
			}
		}
		else{
			DwTopGraphicHeight += document.getElementById("DwTopGraphic").offsetHeight;
		}
	}
	
	DwFooterHeight = 0;
	if(document.all.DwFooter){
		if(document.getElementById("DwFooter").length){
			for(var iDT = 0; iDT < document.getElementById("DwFooter").length; iDT++){
				DwFooterHeight += document.getElementById("DwFooter")[iDT].offsetHeight;
			}
		}
		else{
			DwFooterHeight += document.getElementById("DwFooter").offsetHeight;
		}
	}
	//alert(height + ' ' + document.all.DwContentCell.style.height);
	
	if(document.getElementById("DwContentCell")){
		document.getElementById("DwContentCell").style.overflow = "auto";
		height = document.body.clientHeight - DwFooterHeight - DwTopGraphicHeight; //- 15
		//alert(height + ' : ' + document.all.DwContentCell.style.height);
		document.getElementById("DwContentCell").style.height = height;
	}
	//alert(document.body.clientHeight);
}

function isRadioButtonChecked(theOption, theForm){ 
	if (theForm.elements[theOption].checked){
		return true;
	}
	else{
		for (i=0;i < theForm.elements[theOption].length;i++) {
			if (theForm.elements[theOption][i].checked) {
				return true;
			}
		}
	}
	return false;
}

function validateEmail_OLD(strEmail){
	 var re = new RegExp(/^[\w-\.]{1,}\@([\w-]{1,}\.){1,}[\w]{2,4}$/);
	 var s = re.test(strEmail);
	 return(s);
}

function validateEmail( email ){
  var regExp = /^[\w\-_]+(\.[\w\-_]+)*@[\w\-_]+(\.[\w\-_]+)*\.[a-z]{2,4}$/i;
  return regExp.test( email );
}

function changeCardImage(dir){
	//document.EcardForm.ECardImage.src = dir + '/' + document.EcardForm.AttachImage.value;
	document.getElementsByName('ECardImage')[0].src = dir + '/' + document.getElementsByName('AttachImage')[0].value;
}

//Factbox script
fb = new Array();

FactboxSettingMovebox = true;
FactboxSettingDontKeepOnmouseover = false
FactboxSettingBordercolor = "#000000"
FactboxSettingWidth = 250
FactboxSettingHeight = 0
FactboxSettingShowheading = true
FactboxSettingDelay = 500
FactboxSettingImagePos = "right"

FactboxSettingHbgColor = "#CCCCCC"
FactboxSettingHFont = "Verdana, Helvetica, Arial"
FactboxSettingHColor = "#000000"
FactboxSettingHsize = "10px"
FactboxSettingTbgColor = "#E1E1E1"
FactboxSettingTFont = "Verdana, Helvetica, Arial"
FactboxSettingTColor = "#000000"
FactboxSettingTsize = "10px"

fbhideok = true
fbDivID = "Factbox"
function FB(WordID){
	WordID = parseInt(WordID);
	for(var i = 0;i < fb.length;i++){
		if(fb[i][0] == WordID){
			showbox(i)
		}
	}
}

function FBC(WordID){ //Click on word
	WordID = parseInt(WordID);
	for(var i = 0;i < fb.length;i++){
		if(fb[i][0] == WordID && fb[i][4] != ""){
			if(fb[i][5]){
				window.open(fb[i][4]);
			}
			else{
				location = fb[i][4];
			}
		}
	}
}

function mmfb(){ //Mousemove
	if(document.getElementById(fbDivID) && FactboxSettingMovebox){
		document.getElementById(fbDivID).style.top = event.clientY + document.body.scrollTop
		document.getElementById(fbDivID).style.left = event.clientX + 10
	}
}

function mofb(){ //Mouseout
	if(document.getElementById(fbDivID)){
		fbhideok = true
		if(FactboxSettingDontKeepOnmouseover){
			fbhide();
		}
		else{
			setTimeout('fbhide()', FactboxSettingDelay);
		}
	}
}

function fbhide(){ //Do the actual hide of the box
	if(fbhideok){
		document.getElementById(fbDivID).style.display = "none";
	}
}

function showbox(ArrayIndex){ //write the boks
	fbhideok = false
	tmp = ""
	tmp += "<table width=100% cellpadding=2 cellspacing=0 style=\"border:1px solid " + FactboxSettingBordercolor + "\">"
	if(FactboxSettingShowheading){
		tmp += "<tr bgColor=\"" + FactboxSettingHbgColor + "\"><td colspan=2><span style=\"color:" + FactboxSettingHColor + ";font-weight:bold;font-size:" + FactboxSettingHsize + ";font-family:" + FactboxSettingHFont + "\">" + fb[ArrayIndex][1] + "</td></tr>"
	}
	img = "";
	if(fb[ArrayIndex][3].length > 1){
		img = "<img src=\"" + fb[ArrayIndex][3] + "\">";
	}
	if(FactboxSettingImagePos == "left"){
		tmp += "<tr bgColor=\"" + FactboxSettingTbgColor + "\"><td valign=top>" + img + "</td><td valign=top><span style=\"color:" + FactboxSettingTColor + ";font-weight:norma;font-size:" + FactboxSettingTsize + ";font-family:" + FactboxSettingTFont + "\">" + fb[ArrayIndex][2] + "</td></tr>"
	}
	else if(FactboxSettingImagePos == "right"){
		tmp += "<tr bgColor=\"" + FactboxSettingTbgColor + "\"><td valign=top><span style=\"color:" + FactboxSettingTColor + ";font-weight:norma;font-size:" + FactboxSettingTsize + ";font-family:" + FactboxSettingTFont + "\">" + fb[ArrayIndex][2] + "</td><td valign=top>" + img + "</td></tr>"
	}
	else{
		tmp += "<tr bgColor=\"" + FactboxSettingTbgColor + "\"><td valign=top><span style=\"color:" + FactboxSettingTColor + ";font-weight:norma;font-size:" + FactboxSettingTsize + ";font-family:" + FactboxSettingTFont + "\">" + fb[ArrayIndex][2] + "</td></tr>"
	}
	tmp += "</table>"
	
//	alert(tmp)
	
	if(!document.getElementById(fbDivID)){
		document.body.insertAdjacentHTML("beforeEnd", "<DIV ID=\"" + fbDivID + "\" style=\"position:absolute;width:" + FactboxSettingWidth + ";height:" + FactboxSettingHeight + "px;left:" + event.clientX + "px;top:" + event.clientY + "px;background-color:#FFFFFF;\" onMouseover=\"fbhideok=" + FactboxSettingDontKeepOnmouseover + ";\" onMouseout=\"mofb();\"></DIV>");
	}

	document.getElementById(fbDivID).innerHTML = tmp
	document.getElementById(fbDivID).style.top = event.clientY + document.body.scrollTop
	document.getElementById(fbDivID).style.left = event.clientX + 10
	document.getElementById(fbDivID).style.display = "";
}
//
// Frontend editing
//
// News frontend edit
function FrontendNews_Mouseover(Hwnd) {
	var MouseoverStyle	= "cursor: hand";
	Hwnd.style.cssText	= MouseoverStyle;
	window.status		= "Rediger nyhed...";


	Hwnd.parentElement.style.position	= "relative";
	Hwnd.parentElement.appendChild(document.getElementById('FrontendNewsEditMenu'))
	objNewsEditMenu = document.getElementById('FrontendNewsEditMenu')
	objNewsEditMenu.style.position	= "absolute";
	objNewsEditMenu.style.top		= "8px";
	objNewsEditMenu.style.left		= "8px";
	objNewsEditMenu.style.display	= "";

	FrontendMenuActive = false;
	Frontend_Mouseout();
		
}
//function FrontendNews_Mouseout(Hwnd) {
function FrontendNews_Mouseout() {
	if (!FrontendNewsMenuActive) {
		var MouseoutStyle	= "cursor: default";
		//Hwnd.style.cssText	= MouseoutStyle;
		window.status		= "";

		document.getElementById('FrontendNewsEditMenu').style.display	= "none";
	}
}

function Frontend_NewNews(pageid) {
	window.open("admin/Module/News/News_Module_Edit.asp?CategoryID=" + FrontendNewsGroupIDs + "&source=frontend","_blank",Frontend_NewsWindowFeatures);
}

function Frontend_EditNews(CurrentID, GroupID) {
	window.open("admin/Module/News/News_Module_Edit.asp?CategoryID=" + FrontendNewsGroupID + "&NewsID=" + FrontendNewsCurrentID + "&source=frontend","_blank",Frontend_NewsWindowFeatures);
}

function Frontend_DelNews(paragraphid) {
	if (confirm("Vil du slette nyheden?") == true) {
		window.open("admin/Module/News/News_Module_Del.asp?CategoryID=" + FrontendNewsGroupID + "&NewsID=" + FrontendNewsCurrentID + "&source=frontend","_blank","location=no, menubar=no, status=yes, resizable=no, toolbar=no, width=10, height=10");
	}
}
// Default frontend edit
function Frontend_Mouseover(Hwnd) {
	var MouseoverStyle	= "cursor: hand";
	Hwnd.style.cssText	= MouseoverStyle;
	window.status		= "Rediger afsnit...";

	Hwnd.parentElement.style.position	= "relative";
	Hwnd.parentElement.appendChild(document.getElementById('FrontendEditMenu'))
	document.getElementById('FrontendEditMenu').style.position	= "absolute";
	document.getElementById('FrontendEditMenu').style.top		= "8px";
	document.getElementById('FrontendEditMenu').style.left		= "8px";
	document.getElementById('FrontendEditMenu').style.display	= "";
	
	FrontendNewsMenuActive = false;
	FrontendNews_Mouseout();
}

//function Frontend_Mouseout(Hwnd) {
function Frontend_Mouseout() {
	if (!FrontendMenuActive) {
		var MouseoutStyle	= "cursor: default";
		//Hwnd.style.cssText	= MouseoutStyle;
		window.status		= "";

		document.getElementById('FrontendEditMenu').style.display	= "none";
	}
}

function Frontend_NewParagraph(pageid) {
	window.open("admin/paragraph/paragraph_edit.asp?source=frontend&pageid=" + pageid,"_blank",Frontend_WindowFeatures);
}

function Frontend_EditParagraph(paragraphid, pageid) {
	window.open("admin/paragraph/paragraph_edit.asp?source=frontend&id=" + paragraphid + "&pageid=" + pageid,"_blank",Frontend_WindowFeatures);
}

function Frontend_DelParagraph(paragraphid) {
	if (confirm("Vil du slette afsnittet?") == true) {
		window.open("admin/paragraph/paragraph_delete.asp?source=frontend&id=" + paragraphid,"_blank","location=no, menubar=no, status=yes, resizable=no, toolbar=no, width=10, height=10");
	}
}

function Frontend_Help() {
	window.open('http://manual2002.dynamicweb.dk/Default.asp?ID=1&m=keywordfinder&keyword=frontendedit', '_blank', 'location=no,directories=no,menubar=no,toolbar=yes,width=950,height=700');
}

function UnHighlight(Hwnd) {
	Hwnd.style.cssText = "margin: 2px; padding: 2px; background-color: ; border: 1px solid white; cursor: ";
}

function Highlight(Hwnd) {
	Hwnd.style.cssText = "margin: 2px; padding: 2px; background-color:#C1D2EE; border: 1px solid #316AC5; cursor: hand";
}
var FrontendNewsCurrentID = 0;
var FrontendNewsGroupIDs = '';
var FrontendNewsGroupID = '';
var FrontendNewsMenuActive = false;
var FrontendMenuActive = false;
var FrontendMenuHwd, FrontendNewsMenuHwd
var Frontend_WindowFeatures = "location=no, menubar=no, status=yes, resizable=no, toolbar=no, width=630, height=560";
var Frontend_NewsWindowFeatures = "scrollbars=yes, location=no, menubar=no, status=yes, resizable=no, toolbar=no, width=630, height=560";
var CurrentParagraphID = 0;