
var gAutoPrint = true; // Flag for whether or not to automatically call the print function 

function getURL() {
    var curURL = String(window.location);
    var arrLoc = curURL.split("?");
    return arrLoc[0];
}

function printFriendly(printFriendlyName) 
{ 
if (document.getElementById!= null) 
{ 
var html = '<HTML>\n<HEAD>\n'; 

if (document.getElementsByTagName!= null) 
{ 
var headTags = document.getElementsByTagName("head"); 
if (headTags.length > 0) 
html += headTags[0].innerHTML; 
html +=     '<style type=\"text/css\">';
html +=     '   #tools,.tools{';
html +=                 'display:none;';
html +=             '}';
html +=     '</style>';
}
html += '\n</HEAD>';
html += '\n<BODY style="background:#FFFFFF;padding:10px;">';

var printPageElem = document.getElementById(printFriendlyName);
if (printPageElem!= null) 
{
html += '<center>';
html += '	<div id=\"container\" align=\"left\">';
html += '							<div id=\"header\">';
html += '								<a href=\"/web/guest\">';
html += '				<img  src=\"/Vestfor-theme/images/Vestfor/logo.png\" alt=\"\">';
html += '								</a>';
html += '							</div>';
html += '				<div id=\"coreContent\">';
html += '							<div id=\"layout-content-container\">';
html += '		<table class=\"dropTable\" border=\"0\" cellpadding=\"4\" cellspacing=\"4\" width=\"100%\">';
html += '									<tbody> <tr>';
html += '		<td height=\"55\" align=\"left\" style=\"padding-top:30px;padding-bottom:30px;\">';
html += '			<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" summary=\"\">';
html += '										 <tr>';
html += '<td id=\"printCell\">';
html += printPageElem.innerHTML;
html += '</td></tr> </table></td></tr></tbody> </table>';
html += '							</div>';
html += '				</div>';
html += '<br />';
html += '<span style="color:#999999;">URL: <a style="color:#bbbbbb" href="';
html += getURL();
html += '">';
html += getURL();
html += '</a></span>';
html += '			</div>';
html += '</center>';
} 
else 
{ 
alert("Could not find the printReady section in the HTML"); 
return; 
}
html += '\n</BODY>\n</HTML>'; 

var printWin = window.open('','printFriendly','status=no,toolbar=no,location=no,menubar=yes,directories=no,resizable=yes,scrollbars=yes,height=640,width=600');
printWin.document.open(); 
printWin.document.write(html); 
printWin.document.close(); 
if (gAutoPrint)
{
printWin.print(); 
} 
else 
{ 
alert("Sorry, the printer friendly feature works\nonly in javascript enabled browsers."); 
}
}
}

function emailContent(contentName)
{
if (document.getElementById!= null)
{
var html = '<HTML>\n<HEAD>\n';

if (document.getElementsByTagName!= null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;
html +=     '<style type=\"text/css\">';
html +=     '   #tools,.tools{';
html +=                 'display:none;';
html +=             '}';
html +=     '</style>';
}
html += '\n</HEAD>';
html += '\n<BODY>';

    var oldJQuery = jQuery;

    function validateEmail() {
        if (jQuery('#yourName').val() == "" ||
                jQuery('#recipientName').val() == "" ||
                jQuery('#yourEmail').val() == "" ||
                jQuery('#recipientEmail').val() == "" ||
                jQuery('#yourName').val() == "" ||
                jQuery('#recipientName').val() == "") {
            alert('Husk at udfylde alle felter (pånær kommentar)');
            return false;
        }
    }

var pageElem = document.getElementById(contentName);
if (pageElem!= null)
{
html += '<center>';
html += '<div id=\"container\" align=\"left\">';
html += '<div class=\"formArticle\">' +
        '    <div class=\"testView\"> ' +
        '        <form onsubmit=\"return validateEmail()\" accept-charset=\"UTF-8\" method=\"POST\" action=\"/ssm/servlet/JFormMail\"> ' +
        '            <div class=\"contactFormContent\"> ' +
        '                <div id=\"frmMail\"> ' +
        '                    <input type=\"hidden\" name=\"title\" value=\"Thank you, your form has been submitted\"> ' +
        '                    <input type=\"hidden\" name=\"subject\" value=\"Mail From Friend\"> ' +
        '                    <input type=\"hidden\" name=\"redirect\" value=\"/Vestfor-theme/templates/success.html"> ' +
        '                        <table width="100%" cellspacing=\"0\" cellpadding=\"0\" class=\"mail\"> ' +
        '                            <tbody>' +
        '                                <tr style="border: medium none;"> ' +
        '                                    <td valign="center" class="listTitle">' +
        '                                        <label>E-mail denne side</label> ' +
        '                                        <hr> ' +
        '                                    </td> ' +
        '                                </tr> ' +
        '                                <tr> ' +
        '                                    <td height="24" class="labelName">' +
        '                                        <label>Navn: </label> ' +
        '                                        <input type="text" name="recipientName" value="" id="recipientName" class="textBox required-field">' +
        '                                    </td> ' +
        '                                </tr> ' +
        '                                <tr> ' +
        '                                    <td height="24" class="labelName">' +
        '                                        <label>Modtager email:</label>' +
        '                                        <input type="text" name="recipient" value="" id="recipientEmail" class="textBox required-field valid-email"> ' +
        '                                    </td> ' +
        '                                </tr> ' +
        '                                <tr> ' +
        '                                    <td height="24" class="labelName">' +
        '                                        <label>Dit navn: </label> ' +
        '                                        <input type="text" name="realname" value="" id="yourName" class="textBox required-field">' +
        '                                    </td> ' +
        '                                </tr> ' +
        '                                <tr> ' +
        '                                    <td height="24" class="labelName">' +
        '                                        <label>Din email:</label>                                     ' +
        '                                        <input type="text" name="email" value="" id="yourEmail" class="textBox required-field valid-email"> ' +
        '                                    </td> ' +
        '                                </tr> ' +
        '                                <tr> ' +
        '                                    <td height="24" class="labelName">' +
        '                                        <div id="addComment"> ' +
        '                                            <label>Her er der plads til at skrive din tekst...</label> ' +
        '                                            <textarea name="comment" cols="30" rows="10"></textarea> ' +
        '                                        </div> ' +
        '                                    </td> ' +
        '                                </tr> ' +
        '                            </tbody> ' +
        '                        </table> ' +
        '                        <textarea name="urlHidden" cols="30" rows="10" style="display:none;">'+getURL()+'</textarea> ' +
        '                    </div> ' +
        '                    <div class="sendButton">' +
        '                        <input type="submit" value="Send">' +
        '                    </div> ' +
        '                </div> ' +
        '            </form> ' +
        '        </div> ' +
        '    </div>' +
        '</div>';
html += '			</div>';
html += '</center>';
}
else
{
alert("Could not find the printReady section in the HTML");
return;
}
html += '\n</BODY>\n</HTML>';

var left = (screen.width/2)-(280/2);
var top = (screen.height/2)-(480/2);
var formWin = window.open('','printFriendly','directories=no,height=480,location=no,menubar=yes,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=280,left='+left+',top='+top);
formWin.document.open();
formWin.document.write(html);
formWin.document.close();

}
}


