﻿function RenderCorners(id, cssClass, top) {

    /*
        $(document).ready(function() {
            RenderCorners("#towrap", 'white', true);
            RenderCorners("#towrap", 'white', false);
        });
    */

    //TODO add more options for placement of corners
    // top, bottom, left right
    if (top) {
        CornersTop(id, cssClass);
    }

    if (!top) {
        CornersBottom(id, cssClass);
    }



    function CornersTop(id, cssClass) {
        jQuery(id).before(Get3(cssClass, 'left'))
            .before(Get3(cssClass, 'right'))
            .before(getClear())
            .before(Get2(cssClass, 'left'))
            .before(Get2(cssClass, 'right'))
            .before(getClear())
            .before(Get1(cssClass, 'left'))
            .before(Get1(cssClass, 'right'))
            .before(getClear());
    }

    function CornersBottom(id, cssClass) {
        jQuery(id).after(Get3(cssClass, 'left'))
            .after(Get3(cssClass, 'right'))
            .after(getClear())
            .after(Get2(cssClass, 'left'))
            .after(Get2(cssClass, 'right'))
            .after(getClear())
            .after(Get1(cssClass, 'left'))
            .after(Get1(cssClass, 'right'))
            .after(getClear());
    }


    function Get3(strclass, strside) {
        return '<b style="float: {1};" class="transparent100 {0}">&nbsp;<\/b><b style="float: {1};" class="transparent80 {0}">&nbsp;<\/b><b style="float: {1};" class="transparent40 {0}">&nbsp;<\/b>'.replace(new RegExp("\\{0\\}", "gi"), strclass).replace(new RegExp("\\{1\\}", "gi"), strside);
    }
    function Get2(strclass, strside) {
        return '<b style="float: {1};" class="transparent80 {0}">&nbsp;<\/b><b style="float: {1};" class="transparent20 {0}">&nbsp;<\/b>'.replace(new RegExp("\\{0\\}", "gi"), strclass).replace(new RegExp("\\{1\\}", "gi"), strside);
    }
    function Get1(strclass, strside) {
        return '<b style="float: {1};" class="transparent40 {0}">&nbsp;<\/b>'.replace(new RegExp("\\{0\\}", "gi"), strclass).replace(new RegExp("\\{1\\}", "gi"), strside);
    }
    function getClear() {
        return '<div style="height:0px;clear:both;"><\/div>';
    }
}


function MenuMouseEvents(id, path) {
    document.images['MainMenuImage' + id].src = path;
}


function MapObject(objMap, fLat, fLng, gPoint, gMap, infoHtml) {
    this.Map = objMap || null;
    this.Lat = fLat || 0;
    this.Lng = fLng || 0;
    this.GPoint = gPoint || null;
    this.GMap = gMap || null;
    this.InfoHtml = infoHtml || null;

}



function Hash() {
    this.length = 0;
    this.items = new Array();
    for (var i = 0; i < arguments.length; i += 2) {
        if (typeof (arguments[i + 1]) != 'undefined') {
            this.items[arguments[i]] = arguments[i + 1];
            this.length++;
        }
    }

    this.removeItem = function(in_key) {
        var tmp_value;
        if (typeof (this.items[in_key]) != 'undefined') {
            this.length--;
            var tmp_value = this.items[in_key];
            delete this.items[in_key];
        }

        return tmp_value;
    }

    this.getItem = function(in_key) {
        return this.items[in_key];
    }

    this.setItem = function(in_key, in_value) {
        if (typeof (in_value) != 'undefined') {
            if (typeof (this.items[in_key]) == 'undefined') {
                this.length++;
            }

            this.items[in_key] = in_value;
        }

        return in_value;
    }

    this.hasItem = function(in_key) {
        return typeof (this.items[in_key]) != 'undefined';
    }
}


function Querystring(qs) { // optionally pass a querystring to parse
    this.params = new Object()
    this.get = Querystring_get

    if (qs == null)
        qs = location.search.substring(1, location.search.length)

    if (qs.length == 0) return

    // Turn <plus> back to <space>
    // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
    qs = qs.replace(/\+/g, ' ')
    var args = qs.split('&') // parse out name/value pairs separated via &

    // split out each name=value pair
    for (var i = 0; i < args.length; i++) {
        var value;
        var pair = args[i].split('=')
        var name = unescape(pair[0])

        if (pair.length == 2)
            value = unescape(pair[1])
        else
            value = name

        this.params[name] = value
    }
}

function Querystring_get(key, default_) {
    // This silly looking line changes UNDEFINED to NULL
    if (default_ == null) default_ = null;

    var value = this.params[key]
    if (value == null) value = default_;

    return value
}


function OpenGrillMethodFlash(strPath) {
    window.open(strPath, "grillmethod", "height=415,width=415");
}