﻿// JScript File
function clickButton(e, buttonid) {
    var evt = e ? e : window.event;
    var bt = document.getElementById(buttonid);
    if (bt) {
        if (evt.keyCode == 13) {
            bt.click();
            return false;
        }
    }
}
// JScript File
function show(cid) {
    var obj = window.document.getElementById(cid);
    obj.style.display = '';
}
function hide(cid) {
    var obj = window.document.getElementById(cid);
    obj.style.display = 'none';
}


// Reviews & Other common methods
// Attach character counter and restrict it to a number
function BindMaximumChacterLimit(txtBoxID, maxCharacterSize) {
    // text area counter
    var options2 = {
        'maxCharacterSize': maxCharacterSize,
        'originalStyle': 'originalDisplayInfo',
        'warningStyle': 'warningDisplayInfo',
        'warningNumber': 40,
        'displayFormat': '#input Characters | #left Characters Left | #words Words'
    };
    var fieldname = '#' + txtBoxID;

    $(fieldname).textareaCount(options2);
}

// this methiid will open a centered window in the screen
function OpenLoginPopUp(url) {
    var winH = $(window).height();
    var winW = $(window).width();

    var yPos = $(document).scrollTop();
    var xPos = 100;

    window.open(url, 'LoginMenu', "width=688,height=400,left=" + xPos + ",top=" + yPos + ",location=0,scrollbars=0,titlebar=0,toolbar0,resizable=0,menubar=0,status=0", true);
}


// This method is to resolve the query string and find the appropriate values

// Getting & setting  the right ShoppingTool Value for MiniPDPOmnitureJson and Cookie

function QueryString(querystringparameter) {
    var qsParm = new Array();
    try {
        var query = window.location.search.substring(1);
        var parms = query.split('&');
        for (var i = 0; i < parms.length; i++) {
            var pos = parms[i].indexOf('=');
            if (pos > 0) {
                var key = parms[i].substring(0, pos);
                var val = parms[i].substring(pos + 1);
                qsParm[key] = val;
            }
        }
    } catch (e) {
        return null;
    }
    return qsParm[querystringparameter];
}


