﻿function jsMNSearch_KeyDown(e) {
    if (!e) e = window.event;
    var key = e.charCode ? e.charCode : e.keyCode;
    if (key != 13) return true;

    var f = document.forms[0];
    var q = document.forms[0].q.value;
    if (q.length > 0) {
        document.location = "/Search.aspx?Q=" + encodeURIComponent(q);
    }

    return false;
}

function OpenWindow(url) {
    window.open(url, "_blank", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=700,height=600');
    return false;
}

function Messages(msg, url) {
    alert(msg);
    document.location.href = url;
}
function showImageDetail(DivPicture, BigPicture) {
    var divObj = document.getElementById(DivPicture);
    var PWidth = document[BigPicture].width + 3;
    var PHeight = document[BigPicture].height + 3;
    divObj.style.width = PWidth + 'px';
    divObj.style.height = PHeight + 'px';
    divObj.style.visibility = 'visible';
    divObj.focus();
    return false;
}
function hideImageDetail(DivPicture) {
    DivPicture.style.visibility = 'hidden';
    return false;
}
function Printer(url) {
    window.open(url, "_blank", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=650,height=600,left=60, top=60,screenX=60px,screenY=60px");
    return false;
}
function SendMail(url) {
    window.open(url, "_blank", "toolbar=no,location=no,directories=no,addressbar=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=530,height=220,left=230, top=120,screenX=230px,screenY=120px");
    return false;
}
function ActivePrinter(idTopHidden, idBottomHidden) {
    document.getElementById(idTopHidden).style.visibility = 'hidden';
    document.getElementById(idBottomHidden).style.visibility = 'hidden';
    window.print();
    window.close();
    return false;
}
function OnClickInObject(obj) {
    if (obj) {
        if (obj.dispatchEvent) {
            var e = document.createEvent("MouseEvents");
            e.initEvent("click", true, true);
            obj.dispatchEvent(e);
        }
        else {
            obj.click();
        }
    }
}
function DisableControls() {
    for (var i = 0; i < document.forms[0].elements.length; i++) {
        var obj = document.forms[0].elements[i];
        obj.disabled = true;
    }
}
function EnableControls() {
    for (var i = 0; i < document.forms[0].elements.length; i++) {
        var obj = document.forms[0].elements[i];
        obj.disabled = false;
    }
}

function findPos(obj) {

    var curleft = curtop = 0;

    if (obj.offsetParent) {
        curleft = obj.offsetLeft

        curtop = obj.offsetTop

        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft

            curtop += obj.offsetTop

        }

    }
    return [curleft, curtop];
}


function dumpProps(obj, parent) {
    // Go through all the properties of the passed-in object
    for (var i in obj) {
        // if a parent (2nd parameter) was passed in, then use that to
        // build the message. Message includes i (the object's property name)
        // then the object's property value on a new line
        if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
        // Display the message. If the user clicks "OK", then continue. If they
        // click "CANCEL" then quit this level of recursion
        if (!confirm(msg)) { return; }
        // If this property (i) is an object, then recursively process the object
        if (typeof obj[i] == "object") {
            if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
        }
    }
}

function getScrollXY() {
    var scrOfX = 0, scrOfY = 0;
    if (typeof (window.pageYOffset) == 'number') {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    return [scrOfX, scrOfY];
}

function getInnerSize() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return [myWidth, myHeight];
}


function ScrollToElement(theElement) {

    var selectedPosX = 0;
    var selectedPosY = 0;

    while (theElement != null) {
        selectedPosX += theElement.offsetLeft;
        selectedPosY += theElement.offsetTop;
        theElement = theElement.offsetParent;
    }

    window.setTimeout("window.scrollTo(" + selectedPosX + "," + selectedPosY + ")", 100);

}

function GetCenteredXY(w, h) {
    var ps = getScrollXY();
    var sz = getInnerSize();
    var Left = (sz[0] - w) / 2 + ps[0];
    var Top = (sz[1] - h) / 2 + ps[1];
    return [Math.ceil(Left), Math.ceil(Top)];
}

function dateToString(d) {
    return d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
}
function setLighbox(idcontent, classLighbox) {
    $(document).ready(function() {
        $(idcontent + ' a.' + classLighbox).lightBox({
            fixedNavigation: true,
            imageBtnClose: '/App_Themes/ANTJEWELLS/JS/jquery/LightBox/Images/lightbox-btn-close.gif',
            imageLoading: '/App_Themes/ANTJEWELLS/JS/jquery/LightBox/Images/lightbox-ico-loading.gif',
            imageBtnNext: '/App_Themes/ANTJEWELLS/JS/jquery/LightBox/Images/lightbox-btn-next.gif',
            imageBtnPrev: '/App_Themes/ANTJEWELLS/JS/jquery/LightBox/Images/lightbox-btn-prev.gif'
        });
    });

}
function LoadFlash_Rotator(sWidth, sHeight, sBgColor, sXMLPath, sSWFPreview, sSWFExpressInstall) {
    var cacheBuster = "?t=" + Date.parse(new Date());
    var stageW = sWidth; //"100%";
    var stageH = sHeight; //"100%";
    var attributes = {};
    attributes.id = 'FlabellComponent';
    attributes.name = 'FlabellComponent';
    var params = {};
    params.bgcolor = sBgColor;
    params.menu = "false";
    params.scale = 'noScale';
    params.wmode = "transparent";
    params.allowfullscreen = "false";
    params.allowScriptAccess = "always";
    var flashvars = {};
    flashvars.componentWidth = stageW;
    flashvars.componentHeight = stageH;
    flashvars.pathToFiles = "";
    flashvars.xmlPath = sXMLPath;
    swfobject.embedSWF(sSWFPreview + cacheBuster, attributes.id, stageW, stageH, "9.0.124", sSWFExpressInstall, flashvars, params, attributes);
}
//Open popup window
function Show_Popup(url, title, width, height) {

    var objpopup_window = $('#popup_window'); //Get object popup window
    var document_popup_window = document.getElementById('popup_window'); //Get object document poup window
    var objiframe = document.getElementById("popup_iframe"); //Get object iframe
    var objpopup_title = $('#popup_title'); //Get object popup title

    objpopup_window.width(width); //set popup width
    objpopup_window.height(height); //set popup height
    objpopup_title.text(title); //set popup title

    var ps = getScrollXY(); //Get Scroll X,y
    var sz = getInnerSize(); //Get Innnder Size
    //Set popup top
    document_popup_window.style.top = (ps[1] + (sz[1] / 2) - (height / 2)) + "px";
    //Set popup left
    document_popup_window.style.left = (ps[0] + (sz[0] / 2) - (width / 2)) + "px";

    //Set iframe width
    objiframe.width = (width - 8) + "px";
    //Set iframe height
    objiframe.height = (height - 32) + "px";
    //Clear cache browser
    url = (url.toString().indexOf("?") != -1) == true ? url + "&rnd=" + Math.random() : url + "?rnd=" + Math.random();
    //Set iframe URL
    objiframe.src = url;
    //Move popup window
    objpopup_window.draggable();
    //Resize popup window
    objpopup_window.resizable(
            {
                animate: false,
                resize: function(event, ui) { objiframe.width = (objpopup_window.width() - 8) + "px"; objiframe.height = (objpopup_window.height() - 32) + "px"; }
            });
    objpopup_window.fadeIn('fast'); //fade in popup
}

//Close popup window
function Close_Popup() {
    $('#popup_window').fadeOut('fast');
}
$(document).ready(function() {
    //    $("div.outline").FontEffect({
    //        outline: true,
    //        outlineColor1: "#ffffff",
    //        outlineColor1: "#000000",
    //        outlineWeight: 1,
    //        shadow: false,
    //        shadowColor: "#ffffff",
    //        shadowOffsetTop: 0,
    //        shadowOffsetLeft: 0,
    //        shadowOpacity: 1
    //    })
})
