﻿function Popup(strURL, strName, intWidth, intHeight, strStatus, strScroll, strResize, strToolbar, strMenu, intTop, intLeft) {
    if (!strURL) {
        alert('A link must be specified when using the Popup function.');
    } else {

    //strURL = "http://203.16.60.212/$sitepreview/scanbusiness.com.au" + strURL;
        strURL = "http://localhost:1952"
        if (!strName) strName = 'popup';
        if (!intWidth) intWidth = 600;
        if (intWidth > (window.screen.width - 25)) intWidth = (window.screen.width - 25);
        if (!intHeight) intHeight = 400;
        if (intHeight > (window.screen.height - 125)) intHeight = (window.screen.height - 125);
        if (!strStatus) strStatus = 'yes';
        if (!strScroll) strScroll = 'yes';
        if (!strResize) strResize = 'yes';
        if (!strToolbar) strToolbar = 'no';
        if (!strMenu) strMenu = 'no';

        var strTop, strLeft;
        if (intTop && !isNaN(intTop)) strTop = ',top=' + intTop;
        if (intLeft && !isNaN(intLeft)) strLeft = ',left=' + intLeft;
        var objWindow = window.open(strURL, strName, 'width=' + intWidth + ',height=' + intHeight + ',status=' + strStatus + ',scrollbars=' + strScroll + ',resizable=' + strResize + ',toolbar=' + strToolbar + ',menubar=' + strMenu + strTop + strLeft);
        //objWindow.moveTo(0, 0);
        objWindow.focus();
    }
}

function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g, '');
    if (isNaN(num))
        num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num * 100 + 0.50000000001);
    cents = num % 100;
    num = Math.floor(num / 100).toString();
    if (cents < 10)
        cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
        num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
    //return (((sign) ? '' : '-') + '$' + num + '.' + cents);
    return (((sign) ? '' : '-') + '$' + num);
}

function ClearList(name) {
    var list = document.getElementById(name);
    for (var i = 0; i < list.length; ++i)
        list[i].selected = false
    //alert('All Industries are selected.\n\nTo select multiple Industries hold the ctrl key down while selecting.');
}

function ClearIndustry(name) {
    var list = document.getElementById(name);
    for (var i = 0; i < list.length; ++i)
        list[i].selected = false
    //alert('All Industries are selected.\n\nTo select multiple Industries hold the ctrl key down while selecting.');
}

function ClearLocation(name) {
    var list = document.getElementById(name);
    for (var i = 0; i < list.length; ++i)
        list[i].selected = false
    //alert('All Locations are selected.\n\nTo select multiple Locations hold the ctrl key down while selecting.');
}

function ClearState(name) {
    var list = document.getElementById(name);
    for (var i = 0; i < list.length; ++i)
        list[i].selected = false
    //alert('All States are selected.\n\nTo select multiple States hold the ctrl key down while selecting.');
}

// Tip Box Display, version 1.0
// Bontrager Connection, LLC
// http://www.willmaster.com/
// -> Functions findPosX and findPosY by 
//    Peter-Paul Koch & Alex Tingle at 
//    http://www.quirksmode.org/js/findpos.html and 
//    http://blog.firetree.net/2005/07/04/javascript-find-position/
//
// One customization:
//
// Specify the ID of the DIV or other container that is the tip box.

var TipBoxID = "TipBox";

// No other customizations required
// // // // // // // // // // // //

var tip_box_id;

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent)
        while (1) {
        curtop += obj.offsetTop;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function DisplayTip(me, offX, offY, content) {
    var tipO = me;
    tip_box_id = document.getElementById(TipBoxID);
    var x = findPosX(me);
    var y = findPosY(me);
    tip_box_id.style.left = String(parseInt(x + offX) + 'px');
    tip_box_id.style.top = String(parseInt(y + offY) + 'px');
    tip_box_id.innerHTML = content;
    tip_box_id.style.display = "block";
    tipO.onmouseout = HideTip;
} // function DisplayTip()

function HideTip() { tip_box_id.style.display = "none"; }