/* Printing features */
function PrintContents() {
    PrintHtml('<div id="divPageContents">' + document.getElementById('divPageContents').innerHTML + '</div>', ['/x/css/Reset.css', '/x/css/PageContents.css']);
}

function PrintHtml(html, stylesheetArray) {
    if (html != '') {
        var printWindow = window.open('', 'Printvindue', '', '');
        var printDocument = '<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>';

        for (var i = 0; i < stylesheetArray.length; i++) {
            printDocument += '<link href="' + stylesheetArray[i] + '" type="text/css" rel="stylesheet" />';
        }

        printDocument += '</head><body>';
        printDocument += html;
        printDocument += '<script type="text/javascript">setTimeout("this.print(); this.close();",500);</' + 'script></body></html>';

        printWindow.document.write(printDocument);
        printWindow.document.close();
        printWindow.focus();
    }
}
/****/

/* Popup features */
var newwindow = null;

function OpenPopup(sUrl, sName, iWidth, iHeight, iTop, iLeft, iScrollbars, iStatus) {
    if ((newwindow != null) && (!newwindow.closed)) {
        newwindow.close();
    }
    newwindow = window.open(sUrl, sName, "width=" + iWidth + ", height=" + iHeight + ", top=" + iTop + ", left=" + iLeft + ", screenY=" + iTop + ", screenX=" + iLeft + ", scrollbars=" + iScrollbars + ", status=" + iStatus);
    newwindow.focus();
}

function OpenPopupInCenterScreen(sUrl, sName, iWidth, iHeight) {
    var iTop = (jQuery(window).height() - iHeight) / 2;
    var iLeft = (jQuery(window).width() - iWidth) / 2;
    OpenPopup(sUrl, sName, iWidth, iHeight, iTop, iLeft, 0, 0);
}

function OpenImagePopup(sURL, iWidth, iHeight) {
    OpenPopup("/x/function/ImageViewer.aspx?iU=" + sURL, "Billedviser", iWidth, iHeight, 100, 100, 0, 0);
}

function OpenSendLinkToFriendWindow(sUrl, sName, iWidth, iHeight, iLeft, iTop) {
    OpenPopup(sUrl, sName, iWidth, iHeight, iLeft, iTop, 0, 0);
}

function OpenCreateUserPopup(loginId) {
    OpenPopupInCenterScreen("/Popup/Login/CreateUser.aspx?loginid=" + loginId, "CreateUser", 940, 640);
}
/****/

/* Bookmark feature */
function Bookmark() {
	var title = document.title;
	var url = location.href;

	if (window.sidebar)
		window.sidebar.addPanel(title, url,"");
	else if (window.opera && window.print)
	{
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
	}
	else if (document.all)
		window.external.AddFavorite( url, title);
}
/****/

/* Utility funtions */
function SetFocus(ControlID) {
    document.getElementById(ControlID).focus();
    document.getElementById(ControlID).value = document.getElementById(ControlID).value;
}
/****/