﻿document.write("<div class='w150'>");
document.write("<style type='text/css'>");

if (ffMode == "bred")
{
    document.write(".w150 { width: 280px; padding: 10px; border: 1px solid #cfcfcf; font-family: arial, sans-serif; }");
    document.write(".w150 .ipM { width: 274px; border: 1px solid #cfcfcf; padding: 2px; margin-top: 5px; }");
    document.write(".w150 .ipbM { width: 63px; height: 20px; border: none; color: #fff; background: url(http://www.folkogfag.dk/css/images/soeg.gif) 0 0 no-repeat; cursor: pointer; margin: 10px 0 0 0; font-size: 13px; font-weight: bold; position: relative; left: 217px; }");
} else if (ffMode == "smal")
{
    document.write(".w150 { width: 128px; padding: 10px; border: 1px solid #cfcfcf; font-family: arial, sans-serif; }");
    document.write(".w150 .ipM { width: 122px; border: 1px solid #cfcfcf; padding: 2px; margin-top: 5px; }");
    document.write(".w150 .ipbM { width: 63px; height: 20px; border: none; color: #fff; background: url(http://www.folkogfag.dk/css/images/soeg.gif) 0 0 no-repeat; cursor: pointer; margin: 10px 0 0 0; font-size: 13px; font-weight: bold; position: relative; left: 65px; }");
} else if (ffMode == "aalborg.dk")
{
    document.write(".w150 { width: 172px; padding: 10px; border: 1px solid #cfcfcf; font-family: arial, sans-serif; }");
    document.write(".w150 .ipM { width: 148px; border: 1px solid #cfcfcf; padding: 2px; margin-top: 5px; }");
    document.write(".w150 .ipbM { width: 63px; height: 20px; border: none; color: #fff; background: url(http://www.folkogfag.dk/css/images/soeg.gif) 0 0 no-repeat; cursor: pointer; margin: 10px 0 0 0; font-size: 13px; font-weight: bold; position: relative; left: 90px; }");
} else if (ffMode == "nordjyske.dk")
{
    document.write(".w150 { width: 300px; height: 94px; border: 1px solid #cfcfcf; font-family: arial, sans-serif; background-image: url('http://www.nordjyske.dk/App_Ressources/AMProduction.Web500.Ressource.getImage.aspx?id=452'); background-repeat: no-repeat; }");
    document.write(".w150 .ipM { width: 200px; border: 1px solid #cfcfcf; padding: 2px; margin-top: 5px; }");
    document.write(".w150 .ipbM { width: 63px; height: 20px; border: none; color: #fff; background: url(http://www.folkogfag.dk/css/images/soeg.gif) 0 0 no-repeat; cursor: pointer; margin: 10px 0 0 0; font-size: 13px; font-weight: bold; position: relative; left: 10px; }");
    document.write(".w150 fieldset{ position: relative; top: 0px; left: 10px;}");
    document.write(".fofLogoLink{position: relative; top:0; left: 185px;}");
} else if (ffMode == "vejleAmtsblad")
{
    document.write(".w150 { width: 300px; height: 94px; border: 1px solid #cfcfcf; font-family: arial, sans-serif; background-image: url('http://www.nordjyske.dk/App_Ressources/AMProduction.Web500.Ressource.getImage.aspx?id=452'); background-repeat: no-repeat; }");
    document.write(".w150 .ipM { width: 200px; border: 1px solid #cfcfcf; padding: 2px; margin-top: 5px; }");
    document.write(".w150 .ipbM { width: 63px; height: 20px; border: none; color: #fff; background: url(http://www.folkogfag.dk/css/images/soeg.gif) 0 0 no-repeat; cursor: pointer; margin: 10px 0 0 0; font-size: 13px; font-weight: bold; position: relative; left: 10px; }");
    document.write(".w150 fieldset{ position: relative; top: 0px; left: 10px;}");
    document.write(".fofLogoLink{position: relative; top:0; left: 185px;}");
}

document.write(".w150 form, .w150 fieldset { margin: 0; padding: 0; }");
document.write(".w150 fieldset { border: none; }");
document.write(".w150 legend { display: none; }");
document.write(".w150 a { display: block; }");
document.write("</style>");
if(ffMode != "nordjyske.dk" && ffMode != "vejleAmtsblad"){
	document.write("<a href='http://www.folkogfag.dk/'><img src='http://www.folkogfag.dk/images/embed_logo.gif' width='79' height='24' alt='Folk&amp;Fag' border='0' /></a>");

} else if(ffMode == "nordjyske.dk") {
	document.write("<a href='http://www.folkogfag.dk/' class='fofLogoLink'><img src='http://www.folkogfag.dk/images/fofLogo.png'height='51' width='105' alt='Folk&amp;Fag' border='0' /></a>");
} else if(ffMode == "vejleAmtsblad"){
	document.write("<a href='http://www.folkogfag.dk/' class='fofLogoLink'><img src='http://www.folkogfag.dk/images/fofLogo.png'height='51' width='105' alt='Folk&amp;Fag' border='0' /></a>");
}
document.write("<fieldset>");
document.write("<input type='text' class='ipM' id=\"qqry\" name=\"qqry\" onKeyPress='return checkEnter(event);' onfocus='ffChange();' onblur='ffChange();' value='Hvem/Hvad/Hvor' />");
document.write("<input type='button' onclick='ffSubmit();' class='ipbM' value='Søg' />");
document.write("</fieldset>");
document.write("</div>");
document.write("<span id=\"msgmsg\"></span>");

function ffChange(){
    var ffObject = document.getElementById("qqry");
    
    if(ffObject !== null){
        if(ffObject.value == "Hvem/Hvad/Hvor"){
            ffObject.value = "";
        }else if(ffObject.value == ""){
            ffObject.value = "Hvem/Hvad/Hvor";
        }
    }
}

function URLEncode(str)
{
    // The Javascript escape and unescape functions do not correspond
    // with what browsers actually do...
    var SAFECHARS = "0123456789" + 				// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()"; 				// RFC2396 Mark characters
    var HEX = "0123456789ABCDEF";


    var encoded = "";
    for (var i = 0; i < str.length; i++)
    {
        var ch = str.charAt(i);
        if (ch == " ")
        {
            encoded += "+"; 			// x-www-urlencoded, rather than %20
        } else if (SAFECHARS.indexOf(ch) != -1)
        {
            encoded += ch;
        } else
        {
            var charCode = ch.charCodeAt(0);
            if (charCode > 255)
            {
                alert("Unicode Character '"
                        + ch
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted.");
                encoded += "+";
            } else
            {
                encoded += "%";
                encoded += HEX.charAt((charCode >> 4) & 0xF);
                encoded += HEX.charAt(charCode & 0xF);
            }
        }
    } // for

    return encoded;
};

function checkEnter(e)
{
    var characterCode;

    if (e && e.which)
    {
        e = e;
        characterCode = e.which;
    }
    else
    {
        e = event;
        characterCode = e.keyCode;
    }

    if (characterCode == 13)
    {
        ffSubmit();
        return false;
    }
    else
    {
        return true;
    }

}

function ffSubmit() {
    var ffObject = document.getElementById("qqry");
    var ffWindow = window.open('http://www.folkogfag.dk/qviksoeger/qvikresultat.aspx?qqry=' + URLEncode(ffObject.value), 'folkogfag');
    ffWindow.focus();
}