﻿
$(function () {

    $('.button').button();

    $('#searchbox').focus(
        function () {
            if ($('#searchbox').val() == 'Search our site') { $('#searchbox').val(''); }
            $('#searchbox').css('color', 'black');
            $('#searchbox').css('font-style', 'normal');
        }
    )
    $('#searchbox').blur(
        function () {
            $('#searchbox').val(jQuery.trim($('#searchbox').val()));
            if ($('#searchbox').val() == 'Search our site' || $('#searchbox').val() == '') {
                $('#searchbox').val('Search our site');
                $('#searchbox').css('color', '#777777');
                $('#searchbox').css('font-style', 'italic');
            }
        }
    )

    $('#searchbox').bind('keypress', function (e) {
        if (e.keyCode == 13) {
            doSearch();
            return false;
        }
    });




    $('.paracontent a').filter(function () {
         return this.hostname && this.hostname !== location.hostname;
    }).after('<img src="/images/external.png" alt="" title="External Link" />');
    

});

function doSearch() {
    $('#searchbox').val(jQuery.trim($('#searchbox').val()));
   
    var criteria = $('#searchbox').val();
    if (criteria.length > 0) {
        document.location.href = '/Search.aspx?q=' + encodeURIComponent(criteria);
     }
}


function ShowApplication() {

        if (document.getElementById('divApplicationForm')) {
            $('#divApplicationForm').show();
            $(divTag).load('../_Application-Intro.aspx');
        } else {
            var divTag = document.createElement("div");
            divTag.id = 'divApplicationForm';
            divTag.style.backgroundColor = 'White';
            divTag.style.position = 'fixed';
            divTag.style.width = '450px';
            divTag.style.height = '200px';
            divTag.style.top = '150px';
            divTag.style.left = '100px';
            divTag.style.border = 'solid 3px Silver';
            divTag.style.left = '50%';
            divTag.style.marginLeft = '-225px';
            divTag.style.overflow = 'hidden';
            $(divTag).load('../_Application-Intro.aspx');
            document.body.appendChild(divTag);
        }

}

function HideApplication() {
    try {
        $('#divApplicationForm').hide();
    } catch (err) { }
}


function loadJS(file) {
    var jsElm = document.createElement("script");
    jsElm.type = "application/javascript";
    jsElm.src = file;
    document.body.appendChild(jsElm);
}


function openWin(url, n, w, h, s, r, t) {
    var attribs = '';
    if (s == true) { attribs += ',scrollbars=1'; }
    if (r == true) { attribs += ',resizable=1'; }
    if (t == true) { attribs += ',toolbar=1'; }

    var NewWin = null;

    var sW = screen.width; if (sW < w || sW < 1024) { sW = 1024; }; if (sW < w) { sW = w };
    var sH = screen.height; if (sH < h || sH < 768) { sH = 768; }; if (sH < h) { sH = h };

    var LeftPosition = (sW - w) / 2;
    var TopPosition = (sH - h) / 2;

    try {
        NewWin = window.open(url, n, 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + attribs);
        NewWin.focus()
    } catch (er) { alert('Popup window blocked. Disable popup window blockers and try again.'); }

}
