﻿if (typeof (console) == 'undefined') var console = { log: function () { } }

/*
* jQuery UI Position @VERSION
* http://docs.jquery.com/UI/Position
*/
//    (function ($, undefined) { $.ui = $.ui || {}; var horizontalPositions = /left|center|right/, verticalPositions = /top|center|bottom/, center = "center", _position = $.fn.position, _offset = $.fn.offset; $.fn.position = function (options) { if (!options || !options.of) { return _position.apply(this, arguments); } options = $.extend({}, options); var target = $(options.of), targetElem = target[0], collision = (options.collision || "flip").split(" "), offset = options.offset ? options.offset.split(" ") : [0, 0], targetWidth, targetHeight, basePosition; if (targetElem.nodeType === 9) { targetWidth = target.width(); targetHeight = target.height(); basePosition = { top: 0, left: 0 }; } else if (targetElem.setTimeout) { targetWidth = target.width(); targetHeight = target.height(); basePosition = { top: target.scrollTop(), left: target.scrollLeft() }; } else if (targetElem.preventDefault) { options.at = "left top"; targetWidth = targetHeight = 0; basePosition = { top: options.of.pageY, left: options.of.pageX }; } else { targetWidth = target.outerWidth(); targetHeight = target.outerHeight(); basePosition = target.offset(); } $.each(["my", "at"], function () { var pos = (options[this] || "").split(" "); if (pos.length === 1) { pos = horizontalPositions.test(pos[0]) ? pos.concat([center]) : verticalPositions.test(pos[0]) ? [center].concat(pos) : [center, center]; } pos[0] = horizontalPositions.test(pos[0]) ? pos[0] : center; pos[1] = verticalPositions.test(pos[1]) ? pos[1] : center; options[this] = pos; }); if (collision.length === 1) { collision[1] = collision[0]; } offset[0] = parseInt(offset[0], 10) || 0; if (offset.length === 1) { offset[1] = offset[0]; } offset[1] = parseInt(offset[1], 10) || 0; if (options.at[0] === "right") { basePosition.left += targetWidth; } else if (options.at[0] === center) { basePosition.left += targetWidth / 2; } if (options.at[1] === "bottom") { basePosition.top += targetHeight; } else if (options.at[1] === center) { basePosition.top += targetHeight / 2; } basePosition.left += offset[0]; basePosition.top += offset[1]; return this.each(function () { var elem = $(this), elemWidth = elem.outerWidth(), elemHeight = elem.outerHeight(), marginLeft = parseInt($.curCSS(this, "marginLeft", true)) || 0, marginTop = parseInt($.curCSS(this, "marginTop", true)) || 0, collisionWidth = elemWidth + marginLeft + parseInt($.curCSS(this, "marginRight", true)) || 0, collisionHeight = elemHeight + marginTop + parseInt($.curCSS(this, "marginBottom", true)) || 0, position = $.extend({}, basePosition), collisionPosition; if (options.my[0] === "right") { position.left -= elemWidth; } else if (options.my[0] === center) { position.left -= elemWidth / 2; } if (options.my[1] === "bottom") { position.top -= elemHeight; } else if (options.my[1] === center) { position.top -= elemHeight / 2; } position.left = parseInt(position.left); position.top = parseInt(position.top); collisionPosition = { left: position.left - marginLeft, top: position.top - marginTop }; $.each(["left", "top"], function (i, dir) { if ($.ui.position[collision[i]]) { $.ui.position[collision[i]][dir](position, { targetWidth: targetWidth, targetHeight: targetHeight, elemWidth: elemWidth, elemHeight: elemHeight, collisionPosition: collisionPosition, collisionWidth: collisionWidth, collisionHeight: collisionHeight, offset: offset, my: options.my, at: options.at }); } }); if ($.fn.bgiframe) { elem.bgiframe(); } elem.offset($.extend(position, { using: options.using })); }); }; $.ui.position = { fit: { left: function (position, data) { var win = $(window), over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(); position.left = over > 0 ? position.left - over : Math.max(position.left - data.collisionPosition.left, position.left); }, top: function (position, data) { var win = $(window), over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(); position.top = over > 0 ? position.top - over : Math.max(position.top - data.collisionPosition.top, position.top); } }, flip: { left: function (position, data) { if (data.at[0] === center) { return; } var win = $(window), over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(), myOffset = data.my[0] === "left" ? -data.elemWidth : data.my[0] === "right" ? data.elemWidth : 0, atOffset = data.at[0] === "left" ? data.targetWidth : -data.targetWidth, offset = -2 * data.offset[0]; position.left += data.collisionPosition.left < 0 ? myOffset + atOffset + offset : over > 0 ? myOffset + atOffset + offset : 0; }, top: function (position, data) { if (data.at[1] === center) { return; } var win = $(window), over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(), myOffset = data.my[1] === "top" ? -data.elemHeight : data.my[1] === "bottom" ? data.elemHeight : 0, atOffset = data.at[1] === "top" ? data.targetHeight : -data.targetHeight, offset = -2 * data.offset[1]; position.top += data.collisionPosition.top < 0 ? myOffset + atOffset + offset : over > 0 ? myOffset + atOffset + offset : 0; } } }; if (!$.offset.setOffset) { $.offset.setOffset = function (elem, options) { if (/static/.test($.curCSS(elem, "position"))) { elem.style.position = "relative"; } var curElem = $(elem), curOffset = curElem.offset(), curTop = parseInt($.curCSS(elem, "top", true), 10) || 0, curLeft = parseInt($.curCSS(elem, "left", true), 10) || 0, props = { top: (options.top - curOffset.top) + curTop, left: (options.left - curOffset.left) + curLeft }; if ('using' in options) { options.using.call(elem, props); } else { curElem.css(props); } }; $.fn.offset = function (options) { var elem = this[0]; if (!elem || !elem.ownerDocument) { return null; } if (options) { return this.each(function () { $.offset.setOffset(this, options); }); } return _offset.call(this); }; } } (jQuery));


//        $.fn.center = function() {
//        this.css("position", "absolute");
//        this.css("top", ($(window).height() - this.outerHeight()) / 2 + $(window).scrollTop() + "px");
//        this.css("left", ($(window).width() - this.outerWidth()) / 2 + $(window).scrollLeft() + "px");
//        return this;
//    }



    /* *************************************************************************************** */
    /* ******                              IFRame Opener                                   *** */
    /* *************************************************************************************** */


        function OpenIFrame(eUrl, eWidth, eHeight, eProductID) {
        var xPageSizes = GetPageSize();var xPageScroll = GetPageScroll();var xDivContainerWidth;var xDivContainerHeight;

        if (eWidth == 0) {
            xDivContainerWidth = xPageSizes[2] - (xPageSizes[2] / 10) - (xPageSizes[2] / 10);
        }
        else {
            xDivContainerWidth = eWidth;
        }

        if (eHeight == 0) {
            xDivContainerHeight = xPageSizes[3] - (xPageSizes[3] / 10) - (xPageSizes[3] / 10);
        }
        else {
            xDivContainerHeight = eHeight;
        }

        $('embed, object, select').css({ 'visibility': 'hidden' });
        $('body').append('<div id="divIFrameOverlay" style="background: #000000; position: absolute; top: 0; left: 0; z-index: 1109999999999; width: 100%; height: 500px;"></div>');
        $('body').append('<div id="divIFrameContainer01" style="background: #F9F9F9; border: solid 1px #000000; position: absolute; top: 0; left: 0; width: ' + xDivContainerWidth + 'px; height: ' + xDivContainerHeight + 'px; z-index: 11099999999991; text-align: center;"></div>');
        $('#divIFrameContainer01').append('<div id="divIFrameContainer02" style="border: solid 1px #FFFFFF; position: relative;  width:' + (xDivContainerWidth - 2) + 'px; height: ' + (xDivContainerHeight - 2) + 'px;"><div>');
        $('#divIFrameContainer02').append('<img onmouseover="style.cursor=\'pointer\';" id="imgCloseIFrame" src="/Images/CloseIFrame.png" style="position: absolute; top: 6px; right: 5px; border: solid 0px #FFFFFF; z-index: 11099999999992;" />');
        $('#divIFrameContainer02').append('<div id="divIFrameContainer03" style="background: #FFFFFF; position: absolute; top: 50px; width:' + (xDivContainerWidth - 2) + 'px; height: ' + (xDivContainerHeight - 52) + 'px;"><div>')
        $('#divIFrameContainer03').append('<iframe src="' + eUrl + '" name="iFrame" id="iFrame" scrolling="auto" frameborder="0" width="' + (xDivContainerWidth - 2) + 'px" height="' + (xDivContainerHeight - 52) + 'px"></iframe>')
        $('#imgCloseIFrame').click(function() { CloseIFrame(eProductID); });
        $('#divIFrameOverlay').css("opacity", "0.6");
        $('#divIFrameOverlay').css("height", xPageSizes[1]);
        $('#divIFrameOverlay').css("width", xPageSizes[0]);
        $('#divIFrameOverlay').fadeIn();
        $('#divIFrameContainer01').css("top", xPageScroll[1] + (xPageSizes[3] / 10));
        $('#divIFrameContainer01').css("left", (xPageSizes[0] / 2) - (xDivContainerWidth / 2));
        $(window).resize(function() {

            var yPageSizes = GetPageSize();
            var yPageScroll = GetPageScroll();
            var yDivContainerWidth = xYoureDreamsPopUpDivContainerWidth;
            var yDivContainerHeight = xPageSizes[3] - (xPageSizes[3] / 10) - (xPageSizes[3] / 10);

            $('#divIFrameOverlay').css("height", yPageSizes[1]);
            $('#divIFrameOverlay').css("width", yPageSizes[0]);

            $('#divIFrameContainer01').css("top", yPageScroll[1] + (yPageSizes[3] / 10));
            $('#divIFrameContainer01').css("left", (yPageSizes[0] / 2) - (yDivContainerWidth / 2));

        });

        $(window).scroll(function() {

            var zPageSizes = GetPageSize();
            var zPageScroll = GetPageScroll();

            $('#divIFrameContainer01').css("top", zPageScroll[1] + (zPageSizes[3] / 10));

        });
    }

    function CloseIFrame(eProductID) {
        $('#divIFrameContainer01').remove();
        $('#divIFrameOverlay').fadeOut(function() { $('#divIFrameOverlay').remove(); });
        $('embed, object, select').css({ 'visibility': 'visible' });
    }

    function GetPageSize() {
        var xScroll, yScroll, windowWidth, windowHeight;

        if (window.innerHeight && window.scrollMaxY) {
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY;
        }
        else if (document.body.scrollHeight > document.body.offsetHeight) {
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        }
        else {
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }

        if (self.innerHeight) {
            if (document.documentElement.clientWidth) {
                windowWidth = document.documentElement.clientWidth;
            }
            else {
                windowWidth = self.innerWidth;
            }

            windowHeight = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight) {
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        }
        else if (document.body) {
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }

        if (yScroll < windowHeight) {
            pageHeight = windowHeight;
        }
        else {
            pageHeight = yScroll;
        }

        if (xScroll < windowWidth) {
            pageWidth = xScroll;
        }
        else {
            pageWidth = windowWidth;
        }

        arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);

        return arrayPageSize;
    }
    function GetPageScroll() {
        var xScroll, yScroll;

        if (self.pageYOffset) {
            yScroll = self.pageYOffset;
            xScroll = self.pageXOffset;
        }
        else if (document.documentElement && document.documentElement.scrollTop) {
            yScroll = document.documentElement.scrollTop;
            xScroll = document.documentElement.scrollLeft;
        }
        else if (document.body) {
            yScroll = document.body.scrollTop;
            xScroll = document.body.scrollLeft;
        }

        arrayPageScroll = new Array(xScroll, yScroll);

        return arrayPageScroll;
    }
