function openEditor(url)
{
	var win
	
	win = window.open(url, "editWin", "height=360,width=465,scrollbars");
//	win.moveTo((screen.width - 570) / 2, (screen.height - 230) / 2)
	win.focus()
}

function openBrowser(url)
{
	var win
	
	win = window.open(url, "browsewin");
	win.focus()
}

function openBigEditor(url)
{
	var win
	
	win = window.open(url, "editWin", "height=560,width=675,scrollbars");
//	win.moveTo((screen.width - 570) / 2, (screen.height - 230) / 2)
	win.focus()
}

function openColorDialog(Id)
{
	return(window.showModalDialog("pickColor.aspx?ID=" + Id, "", "dialogHeight:180px;dialogWidth:465px;"));
}

function openPictureDialog(txtID,idID)
{
	var strRetur;
	strRetur =  window.showModalDialog("pickPicture.aspx?txtID=" + txtID + "&idID=" + idID, "", "dialogHeight:480px;dialogWidth:465px;");
	var strArray = strRetur.split(",");
	if (idID == null)
	{
		return strRetur;
	}
	else
	{
		document.getElementById(idID).value = strArray[0];
		document.getElementById(txtID).value = strArray[1];
		return strRetur;
	}
}

function openStyleDialog(txtID,idID)
{
	var strRetur;
	strRetur =  window.showModalDialog("pickStyle.aspx??txtID=" + txtID + "&idID=" + idID, "", "dialogHeight:480px;dialogWidth:465px;");
	var strArray = strRetur.split(",");
	if (idID == null)
	{
		return strRetur;
	}
	else
	{
		document.getElementById(idID).value = strArray[0];
		document.getElementById(txtID).value = strArray[1];
	}
}

function openLinkDialog(txtID, idID)
{
	var strRetur;
	strRetur =  window.showModalDialog("pickLink.aspx?link=" + idID, "", "dialogHeight:480px;dialogWidth:465px;");
	if (strRetur == "Opret")
	{
		strRetur = window.showModalDialog("editLink.aspx?ID=0", "", "dialogHeight:480px;dialogWidth:465px;");
	}
	if (strRetur != null)
	{
		var strArray = strRetur.split(",");
		if (idID == null)
		{
			return strRetur;
		}
		else
		{
			document.getElementById(idID).value = strArray[0];
			document.getElementById(txtID).value = strArray[1];
			return strRetur;
		}
	}
	else
		return "";
}

function openNewLink()
{
	var strRetur;
	strRetur = window.showModalDialog("editLink.aspx?ID=0", "", "dialogHeight:480px;dialogWidth:465px;");
	setReturnValue(strRetur);
}

function setParentElement(Id, str)
{
	if (opener != null) {
		opener.document.getElementById(Id).value = str;
	}
	//window.returnValue = str;
	window.close();
}

function setReturnValue(str)
{
	window.returnValue = str;
	window.close();
}

function closerefresh()
{
	if (opener != null) {
		opener.document.execCommand("Refresh")
	}
	window.close()
}

function hideshowrow(id)
{
	if (document.getElementsByName(id).length != 0)
	{
		if (document.getElementById(id).style.display == "none")
		{
			document.getElementById(id).style.display = "";
			document.getElementById("img" + id).src = "images/trm.gif";
			setCookie(id, "open");
		}
		else
		{
			document.getElementById(id).style.display = "none";
			document.getElementById("img" + id).src = "images/trp.gif";
			setCookie(id, "closed");
		}
	}
}

function hideshowcalendar(id)
{
	if (document.getElementsByName(id).length != 0)
	{
		if (document.getElementById(id).style.display == "none")
		{
			document.getElementById(id).style.display = "";
			setCookie(id, "openCalendar");
		}
		else
		{
			document.getElementById(id).style.display = "none";
			setCookie(id, "closedCalendar");
		}
	}
}

function hideshowToggleHeader(id)
{
	if (document.getElementsByName(id).length != 0)
	{
		if (document.getElementById(id).style.display == "none")
		{
			document.getElementById(id).style.display = "";
			document.getElementById("img" + id).src = "images/kryds.jpg";
			setCookie(id, "openHeader");
		}
		else
		{
			document.getElementById(id).style.display = "none";
			document.getElementById("img" + id).src = "images/maksm.jpg";
			setCookie(id, "closedHeader");
		}
	}
}

function offsetX (p_obj)
{
	var x = 0;
	
	obj = p_obj;

	while (obj.tagName.toUpperCase() != "BODY") {
		x += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return x;
}


function offsetY (obj)
{
	var y = 0

	while (obj.tagName.toUpperCase() != "BODY") {
		y += obj.offsetTop
		obj = obj.offsetParent
	}
	return y;
}

function showmenu(parentid, id)
{
	document.getElementById(id).style.pixelLeft = offsetX(document.getElementById(parentid)) + 20;
	document.getElementById(id).style.pixelTop = offsetY(document.getElementById(parentid)) + document.getElementById(parentid).offsetHeight;
	document.getElementById(id).style.display = '';
}

function showsubmenu(parentid, id)
{
	document.getElementById(id).style.pixelLeft = document.getElementById(parentid).clientWidth;
	//document.getElementById(id).style.pixelTop = document.getElementById(parentid).style.pixelTop;
	document.getElementById(id).style.display = '';
}

function showsubmenuwidth(parentid, id)
{
	document.getElementById(id).style.pixelLeft = offsetX(document.getElementById(parentid)) + document.getElementById(parentid).clientWidth;
	//document.getElementById(id).style.pixelTop = document.getElementById(parentid).style.pixelTop;
	document.getElementById(id).style.display = '';
}

function askDeleteCustomer()
{
    if (confirm("Skal profilen slettes?"))
    {
        document.URL = "deletecustomer.aspx";
    }
}

function switchprofile(profileid)
{
    window.location = "switchprofile.aspx?ID=" + profileid;
}

function swapImage(imageID, fileID)
{
	document.getElementById("image" + imageID).src = "showpicture.aspx?ID=" + fileID;
}

function preload(fileID)
{
    var d = document;
    if(d.images)
    {
        if(!d.bitpreload)
            d.bitpreload = new Array();

        var i = d.bitpreload.length;
        
        d.bitpreload[i] = new Image;
        d.bitpreload[i].src = "showpicture.aspx?ID=" + fileID;
    }
}
