﻿function getGuid() {
    return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4()).toUpperCase()
}
function S4() { return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1) }

function Popup(id, data, width) {
    $("#" + id).html(data);
    $("#modalPopup").modal({
        opacity: 80,
        close: true,
        position: [(getScrollXY()[1] + 50), 0], //Changed, to open the popup as per the scroll position - Ankit 
        containerCss: ({
            //  background: "#fff",
            width: width + "px",
            height: "auto"
            // '-webkit-border-radius': '10px',
            // '-moz-border-radius': '10px'
        }),

        overlayCss: ({
            background: "#bebebe"
        })
    });
    // $("#simplemodal-container").resizable();
    /*
    Enabled the Draggble for modaltop bar, 
    Css need to be modified to show the dragable kind of cursor - Ankit
    */
    /*
    var title = $("#modalTop");
    $("#simplemodal-container").draggable({ handle: title });
    */
}

function getScrollXY() {
    var x = 0, y = 0;
    if (typeof (window.pageYOffset) == 'number') {
        // Netscape
        x = window.pageXOffset;
        y = window.pageYOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        // DOM
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        // IE6 standards compliant mode
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
    return [x, y];
}

function SetCalander(entity) {
    var dtFormat = 'mm/dd/yy';
    if (entity == "australia") 
        dtFormat = 'dd/mm/yy';

    try { $('Input[type=text].Calanlder').datepicker({ dateFormat: dtFormat }); } catch (ex) { }
    try { $('Input[type=text].calanlder').datepicker({ dateFormat: dtFormat }); } catch (ex) { }
    try { $('Input[type=text].calander').datepicker({ dateFormat: dtFormat }); } catch (ex) { }
    try { $('Input[type=text].propertycalander').datepicker({ dateFormat: dtFormat, yearRange: '-60:+1' }); } catch (ex) { }

}
function Popup2(data, width) {
    $.blockUI({ message: "<div><div style=\"float:right;\"><a href=\"javascript:void(0)\" OnClick=\"javascript:$.unblockUI();try{BlockUiClose();}catch(ex){}\" >Close</a></div><br/>" + data + "</div>",
        fadeIn: 300,
        fadeOut: 300,
        css: {
            background: "#fff",
            width: width + "px",
            padding: "10px",
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px',
            opacity: '0.9'
        }
        , overlayCSS: {
            backgroundColor: '#000',
            opacity: '0.4'
        }
    });

}