﻿/*
* LEVA - CHANGE MAIN CONTENT COLOR | REMOVE LAST SEPARATOR AND JUSTIFY MENU
**************************************************************************************************/

var levaMainNav = function() {
    var colors = [];
    colors.push(
                "leva_yellow",
                "leva_red",
                "leva_green",
                "leva_purple",
                "leva_orange",
                "leva_light_blue",
                "leva_pink",
                "leva_blue",
                "leva_maroon");

    $(colors).each(function(i, val) {
        if ($("div.container_submenu_left li a." + val).is('.active')) {
            $("body").addClass(val);
        };
    });

    $("div.container_menu .separator:last").hide();
    $("div.container_submenu_left li.separator:last").hide()

    // align menu
    var ul_width = $("div.container_menu ul").width();
    if (ul_width != 0 && ul_width < 950) {
        var result = 980 - ul_width;
        var sep_number = $("div.container_menu .separator").size();
        var plus_width = result / (sep_number - 1);
        $("div.container_menu .separator").css("width", plus_width)
    }
    // align submenu
    var ul_width2 = $("div.container_submenu_left ul").width();
    if (ul_width2 != 0 && ul_width2 < 930) {
        var result2 = 960 - ul_width2;
        var sep_number2 = $("div.container_submenu_left .separator").size();
        var plus_width2 = result2 / (sep_number2 - 1);
        $("div.container_submenu_left .separator").css("width", plus_width2);
    }

}
/*
* HALSA - CHANGE MAIN CONTENT COLOR | REMOVE LAST SEPARATOR AND JUSTIFY MENU
**************************************************************************************************/
var halsaMainNav = function() {
    if ($("div.container_submenu_left li a.halsa_yellow").is('.active')) {
        $("body").addClass("halsa_yellow");
    }
    if ($("div.container_submenu_left li a.halsa_red").is('.active')) {
        $("body").addClass("halsa_red");
    }
    if ($("div.container_submenu_left li a.halsa_green").is('.active')) {
        $("body").addClass("halsa_green");
    }
    if ($("div.container_submenu_left li a.halsa_purple").is('.active')) {
        $("body").addClass("halsa_purple");
    }
    if ($("div.container_submenu_left li a.halsa_orange").is('.active')) {
        $("body").addClass("halsa_orange");
    }
    if ($("div.container_submenu_left li a.halsa_light_blue").is('.active')) {
        $("body").addClass("halsa_light_blue")
    }
    if ($("div.container_submenu_left li a.halsa_pink").is('.active')) {
        $("body").addClass("halsa_pink");
    }
    if ($("div.container_submenu_left li a.halsa_blue").is('.active')) {
        $("body").addClass("halsa_blue");
    }
    if ($("div.container_submenu_left li a.halsa_maroon").is('.active')) {
        $("body").addClass("halsa_maroon");
    }
};


/* icakuriren - extended recipe search */
function headerSearch() {

    var advanceSearch = $("div.expandBox");
    if (!advanceSearch) return;
    //var exText = $("a.expand").text("Fler sökaltternativ");

    //When page loads...
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content
    var url = location.pathname;
    if (url.indexOf('/Sok/') > -1) {
        $("ul.tabs li:eq(0)").removeClass("active")
        $("ul.tabs li:eq(1)").addClass("active")
        $("#tab1").hide();
        $("#tab2").show();
    }

    //On Click Event
    $("ul.tabs li").click(function() {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).show(); //Fade in the active ID content
        var id = $(this).find("a").attr("href");
        if (id == "#tab1" && $(advanceSearch).is(":hidden")) {
            closeElement();
        }
        if (id == "#tab2" && $(advanceSearch).is(":visible")) {
            closeElement();
        }
        return false;
    });

    advanceSearch.mouseup(function() {
        return false;
    });
    $("div.expandBox a.close").click(function(e) {
        e.preventDefault();
        closeElement();
    });
    $("div.tab_content input.text, div.tab_content input.button, div.expandBox a").mouseup(function() {
        return false;
    });
    $("div.tab_content .recipe").mouseup(function() {
        openElement();
    });
    $("div.expandBox input").mouseup(function(event) {
        event.stopPropagation();
        return true;
    });

    $("body").mouseup(function() {
        if ($(advanceSearch).is(":visible")) {
            closeElement();
        }
    });

    // cloase advanced search
    function closeElement() {
        $(advanceSearch).hide();
    }
    // open advanced search
    function openElement() {
        $(advanceSearch).show();
    };

};

//icakuriren change recipe view
function recipeView() {

    var listButton = $("div.container_reciptlist div.view_buttons a:eq(0)");
    var gridButton = $("div.container_reciptlist div.view_buttons a:eq(1)");
    var recipeItem = $("div.container_reciptlist div.container_recipeitem");
    if (!listButton || !gridButton) return;

    if ($.cookie("recipe_view") == "grid" || $.cookie("recipe_view") == undefined) {
        setGridView();
    }
    else {
        setListView();
    }

    $(listButton).bind('click.list', function(event) {
        event.preventDefault();
        setCookie("list");
        if (recipeItem.hasClass('grid_view')) {
            setListView();
        }
    });

    $(gridButton).bind('click.grid', function(event) {
        event.preventDefault();
        setCookie("grid");
        if (recipeItem.hasClass('list_view')) {
            setGridView();
        }
    });

    // list view active
    function setListView() {
        var recipeItem = $("div.container_reciptlist div.container_recipeitem");

        recipeItem.removeClass("grid_view");
        recipeItem.addClass("list_view");
        $("div.list_view div.container_recipegrade span").show();

        if ($("div.container_recipeitem div:last").is("div.clearer")) {
            recipeItem.append('<div class="separator">&nbsp;</div>');
        };
        $(listButton).css({
            'opacity': 0.5
        });
        $(gridButton).css({
            'opacity': 1.0
        });
    }
    function setGridView() {
        var recipeItem = $("div.container_reciptlist div.container_recipeitem");

        recipeItem.removeClass("list_view");
        recipeItem.addClass("grid_view");
        $("div.container_recipegrade span").hide();
        $("div.container_recipeitem div.separator").remove();

        $(gridButton).css({
            'opacity': 0.5
        });
        $(listButton).css({
            'opacity': 1.0
        });
    }
    function setCookie(view) {

        if (view == "list") {
            $.cookie("recipe_view", view, {
                expires: 1
            });
        }
        else {
            $.cookie("recipe_view", view, {
                expires: 1
            });
        }
    }
};
/*
* ICAKURIREN & HOH - AUCTION TEXT EXPANDER
**************************************************************************************************/
var expandText = function() {
    $('div.auction p').expander({
        slicePoint: 200, // default is 100
        expandText: 'Visa hela beskrivningen', // default is 'read more...'
        collapseTimer: 0, // re-collapses after 5 seconds; default is 0, so no re-collapsing
        userCollapseText: 'Dölj fullständig beskrivning' // default is '[collapse expanded text]'
    });

    // On auction  -  right column
    $(".block").hide();

    //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
    $("div.box_column a.trigger").click(function(event) {
        event.preventDefault();
        $(this).toggleClass("tr_active").next().slideToggle("slow");
    });

};

/*
* ICAKURIREN - Full Screen Modal window
**************************************************************************************************/
var modalwindow = function() {
    $('a.fullscreenrecipe').click(function() {

        var popID = $(this).attr('rel'); //Get Popup Name
        var popURL = $(this).attr('href'); //Get Popup href to define size
        //Pull Query & Variables from href URL
        var query = popURL.split('^');
        var dim = query[1].split('&');
        var popWidth = dim[0].split('=')[1]; //Gets the first query string value
        //Fade in the Popup and add close button
        $('#' + popID).fadeIn().css({
            'width': Number(popWidth)
        }).prepend('<a href="#" class="close"><img src="/Images/Icakuriren/Buttons/button_close.png" class="btn_close" title="Close Window" alt="Close" /></a>');

        //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
        var popMargTop = ($('#' + popID).height() + 10) / 2;
        var popMargLeft = ($('#' + popID).width() + 80) / 2;

        //Apply Margin to Popup
        $('#' + popID).css({
            'margin-top': -popMargTop,
            'margin-left': -popMargLeft
        });

        //Fade in Background
        $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
        $('#fade').css({
            'filter': 'alpha(opacity=80)'
        }).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies
        // Clon content recipe and remove comments, link, share buttons
        if (($("#popup_recipe").find("div.container_recipelinks").size()) == 0) {
            $('.container_recipepresentation').clone().appendTo('#popup_recipe');
            $('#popup_recipe div.container_recipelinks, #popup_recipe div.container_comment_messagelist, #popup_recipe a.fullscreenrecipe').hide();
        };

        return false;
    });

    //Close Popups and Fade Layer
    $('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
        $('#fade , .popup_block').fadeOut(function() {
            $('#fade, a.close').remove(); //fade them both out
        });
        return false;
    });
}

/*
* Kotivinki H3 color change on Joulu page
**************************************************************************************************/
$(document).ready(function() {
    var url = location.pathname;
    if (url.indexOf('/Joulu/') > -1) {
        $("h3 a").css("color", "#a82e29").css("border-color", "#a82e29");
    }
});

$(document).ready(function() {
    var tab2 = $("#tab2 input.text");
    if (tab2 != null) {
        $("#tab2 input.text").keypress(function(e) {
            if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
                $('#tab2 input.button').click();
                return true;
            }
        });
    };
});

//hotspot
function hotSpot() {
    //image map hotspot plugin
    if (!$('img.map')) return;
    $('img.map').maphilight();


    var popup = $("#hotSpotPopup");
    var popupContent = $("#hotSpotPopup div.content");
    var loading = $("div.loading");

    $("div.media map area").click(function(e) {
        e.preventDefault();

        id = $(this).attr("href");
        var IdArray = id.split("/");

        popup.show().css("left", ($("div.media img.map").width() / 2 - popup.width() / 2));
        popup.show().css("top", ($("div.media img.map").height() / 2 - popup.height() / 2));


        loading.show().css("left", popup.width() / 2).css("top", popup.height() / 2);


        $.ajax({
            type: 'POST',
            url: '/Templates/Services/HotspotService.asmx/GetHotspotData',
            contentType: 'application/json',
            dataType: 'json',
            data: JSON.stringify({ "pageID": (IdArray[3]) }),
            success: function(data) {
                if (data.d != null) {
                    loading.hide();
                    hotspotTitle = data.d.Title;
                    hotspotImage = data.d.Image;
                    hotspotDescription = data.d.Description;
                    popupContent.append(
                        '<img src="' + hotspotImage + '" alt="' + hotspotTitle + '" />' +
                        '<h3>' + hotspotTitle + '</h3>' +
                        hotspotDescription
                    );

                }
            }
        });

    });
    $("a.close img").click(function(e) {
        e.preventDefault();
        popup.hide();
        popupContent.empty();
    });
}

//datePicker
function datePicker() {
    if ($('.TextBoxPublishDate'))
        $('.TextBoxPublishDate').datepicker({
            changeMonth: true,
            changeYear: true,
            minDate: "-5Y",
            maxDate: "+5Y",
            dateFormat: 'yy-mm-dd',
            firstDay: "1"
        });

    if ($('.blogCommentCheckLength'))
        $('.blogCommentCheckLength').jqEasyCounter({
            'maxChars': 1000,
            'maxCharsWarning': 1
        });
}

function homeCarouselHOH() {
    if ($("#hohCarousel") && $("#hohCarousel").is(":visible")) {
        jQuery('#hohCarousel').jcarousel({
        // Configuration
        //wrap: 'circular'
    });
    $("#CarouselAdImageContainer a").appendTo(".ScriptImage");
}
}

/* Custom SelectMenu*/
function customSelectMenu() {
    if ($('.customSelect1') && $('.customSelect2') && $('.customSelect1').is(':visible') && $('.customSelect2').is(':visible')) {
        $('.customSelect1, .customSelect2').selectmenu();
    }
}
function expander() {
    if ($("a.formExpand")) {
        $("a.formExpand").click(function(e) {
            e.preventDefault();
            $("div.createAlbum").toggleClass("hidden");
        });
    }
}

//Show and hide watermark on inputfields
function inputWatermark() {
    if ($('.watermark')) {
        var typeText = $('.watermark').find('input[type="text"]');
        var typeTextarea = $('.watermark').find('textarea');
        var typePassword = $('.watermark').find('input[type="password"]');

        var inputField = [];
        inputField.push(typeText, typeTextarea, typePassword);

        $.each(inputField, function() {
            var Self = $(this);

            if (Self.is(':visible')) {
                Self.each(function() {
                    if ($(this).val() != '') {
                        $(this).next().hide()
                    }
                });
                Self.focus(function() {
                    if (!$(this).val()) {
                        $(this).next().hide()
                    }
                });
                Self.focusout(function() {
                    if (!$(this).val()) {
                        $(this).next().show();
                    }
                });
            }
        });

        $('.watermarkInput').click(function() {
            $(this).hide();
            $(this).prev().focus();
        });
    }
}


/*
* All websites on common framework
**************************************************/
$(document).ready(function() {

    popUpRel = $("a[rel^='popupWindow']");

    if (popUpRel) {
        popUpRel.each(function() {
            href = $(this);
            hrefValue = $(this).attr('href');
            relValue = $(this).attr('rel');
            var newUrl = "";
            //create url for loading iframe
            if ((hrefValue.indexOf('streamio.com/api') != -1 || hrefValue.indexOf('www.streamio.se/Play') != -1) && hrefValue.indexOf('?iframe=true') == -1) {
                href.attr('href', function() {
                    newUrl = hrefValue + "?iframe=true";
                    return newUrl;

                });
            }
        });

        popUpRel.prettyPhoto({
            animation_speed: 'normal',
            theme: 'facebook',
            changepicturecallback:
            function() {
                if ($('.complexModal').is(':visible')) {
                    userTools();
                }
            }
        });
    }

    if ($("a[rel^='ajaxLogin']")) {
        $("a[rel^='ajaxLogin']").prettyPhoto({
            default_width: 260,
            callback: resetLoginBox,
            changepicturecallback: function() {
                $(".container_ajaxlogin input").keypress(function(e) {
                    if (e.which == 13) {
                        e.preventDefault();
                        doLogin();
                    }
                });
            }
        });
    }

    headerSearch();
    hotSpot();
    datePicker();
    recipeView();
    customSelectMenu();
    homeCarouselHOH();
    expander();
    setProtectedPopup();

    var queryStringVars = getUrlVars();
    var openDialog = queryStringVars["dialog"];
    if (openDialog == "true") {
        var urlForLightBox = queryStringVars["redir"];
        var width = queryStringVars["width"];
        var height = queryStringVars["height"];
        var colleague = queryStringVars["colleague"];
        $.prettyPhoto.open(urlForLightBox + "?colleague=" + colleague + '&iframe=true&width=' + width + '&height=' + height);
    }

});

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

/*********** Protected Pop-up********/

function setProtectedPopup() {
    popUpRel = $(".protected a");
    if (popUpRel) {
        popUpRel.each(function() {
            var href = protectedUrl;
            if (href.indexOf("?") >= 0) {
                href += "&";
            }
            else {
                href += "?";
            }
            href += "iframe=true&width=" + protectedWidth + "&height=" + protectedHeight;
            $(this).attr("href", href);
        });

        popUpRel.prettyPhoto({
            animation_speed: 'normal',
            theme: 'facebook'
        });
    }
}
/*********** Ajax Login ************/

function resetLoginBox() {
    $(".container_ajaxlogin .login_panel").show();
    $(".container_ajaxlogin .recovery_panel").hide();
    $(".container_ajaxlogin .error").hide();
    $(".container_ajaxlogin input[type=text]").val("");
    $('.AjaxLoginPersist:checked').attr('checked', false);
    $(".recovery_panel .user-error").hide();
    $(".recovery_panel .failed").hide();
    $(".recovery_panel .recovery_form").show();
    $(".recovery_panel .recovery_message").hide();
}
function doLogin() {
    var userName = $(".AjaxUsername").last().val();
    var passWord = $(".AjaxPassword").last().val();
    var persist = $(".AjaxLoginPersist:checked").length > 0;
    $.post("/Templates/Units/UserManagement/AjaxLogin.ashx", { userName: userName, passWord: passWord, persist: persist, url: document.URL }, function(data) {
        if (data == "Success") {
            window.location.href = window.location.href.substr(0, window.location.href.indexOf('#'));
        }
        else {
            $(".login_panel .error").show();
        }
    });
    return false;
}

function doPassswordRecovery() {
    var email = $(".AjaxPasswordRecovery").last().val();
    $.post("/Templates/Units/UserManagement/AjaxPasswordRecovery.ashx", { email: email }, function(data) {
        if (data == "Success") {
            $(".recovery_panel .recovery_form").hide();
            $(".recovery_panel .recovery_message").show();
        }
        else {
            $(".recovery_panel .error").show().text(data); ;
        }

    });
    return false;
}

function openPasswordRecovery() {
    $(".container_ajaxlogin .login_panel").hide();
    $(".container_ajaxlogin .recovery_panel").show();
    return false;
}

/*********** Complex Light Box ************/

//light box user tools
function userTools() {
    var ImageID = $('.lblImageID').text();
    //console.log(ImageID);
    var name = $('div.rightBody').find('input');
    var comment = $('div.rightBody').find('textarea');

    $('a.like').click(function(e) {
        e.preventDefault();
        var likeBtn = $('a.like');
        var likeNumber = $('.likeNumber');
        var numOfLikes = parseInt(likeNumber.text());

        updatePhotoDetails("IncreaseNumberOfLikes", ImageID, "like");
        $('img', likeBtn).attr('src', '/Images/HOH/icons/thumb-up-active.png');
        likeBtn.unbind('click');
        likeNumber.text(numOfLikes + 1);
    });
    $('a.unlike').click(function(e) {
        e.preventDefault();
        var unlikeBtn = $('a.unlike');
        var unlikeNumber = $('.dislikeNumber');
        var numOfUnlikes = parseInt(unlikeNumber.text());

        updatePhotoDetails("IncreaseNumberOfDislikes", ImageID, "unlike");
        $('img', unlikeBtn).attr('src', '/Images/HOH/icons/thumb-down-active.png');
        unlikeBtn.unbind('click');
        unlikeNumber.text(numOfUnlikes + 1);
    });
    $('a.favourite').click(function(e) {
        e.preventDefault();
        updatePhotoDetails("AddImageToFavourite", ImageID, "favourite");
        $('span', this).text('Tillagd som Favorit').end().unbind('click');
    });
    $('a.report').click(function(e) {
        e.preventDefault();
        updatePhotoDetails("ReportOffensiveImage", ImageID, "report");
        $('span', this).text('Rapporterad').end().unbind('click');
    });

    inputWatermark();
    handleComments(ImageID, name, comment);
};

// update photo details - like, dislike, favorite, share
function updatePhotoDetails(url, imageID, type) {
    $.ajax({
        type: "POST",
        url: '/Templates/Services/ImageGallery.asmx/' + url,
        data: "{'imageId':'" + imageID + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function() {
            /*console.log('success') */
        }
    });
};
//post comment
function addComment(imageID, authorName, body) {
    $.ajax({
        type: "POST",
        url: "/Templates/Services/ImageGallery.asmx/AddCommentToImage",
        data: "{'imageId':'" + imageID + "', 'authorName':'" + authorName + "', 'body':'" + body + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            /*console.log('success') */
        }
    });
};

//lightBox comment validation
function handleComments(ImageID, name, comment) {
    if ($('pp_content_container button.gray :visible')) {
        $('button.gray').click(function(e) {
            e.preventDefault();
            if (name.val() === '' || comment.val() === '') {
                alert('Var vänlig skriv ditt namn och din kommentar innan du postar!');
            }
            else {
                $('div.rightBody p').prepend('<b>' + name.val() + '</b><br />' + comment.val() + '<br/><br/>');
                addComment(ImageID, name.val(), comment.val());
            }
        });
    }
}


// on window load
$(window).load(function() {
    inputWatermark();
});



var blogList1, blogList2;
var randomNumber1, randomNumber2;

$(document).ready(function() {

    var pushData1 = [];
    var numberOfPush1;
    var fTime1 = true;

    if (blogList1 && blogList1 != "") {
        var obj1 = jQuery.parseJSON(blogList1);
        $.each(obj1, function() {
            pushData1.push({ "Title": this.Title, "Text": this.Text, "URL": this.URL, "ImageUrl": this.ImageUrl });
        });
        numberOfPush1 = pushData1.length - 1;
        function changePush1() {
            if (!fTime1) {
                if (numberOfPush1 > 0) {
                    var temprandomNumber1 = randomNumber1;
                    while (temprandomNumber1 == randomNumber1) {
                        temprandomNumber1 = Math.round(Math.random() * numberOfPush1);
                    }
                    randomNumber1 = temprandomNumber1;
                }
                else {
                    randomNumber1 = Math.round(Math.random() * numberOfPush1);
                }
            }
            else {
                fTime1 = false;
            }
            $('#headerPush1').find('.title').text(pushData1[randomNumber1].Title).end()
                             .find('.text').text(pushData1[randomNumber1].Text + (pushData1[randomNumber1].Text != "" ? "..." : ""))
                            .end().find('.over').attr('href', pushData1[randomNumber1].URL)
                            .end().find('img').attr('src', pushData1[randomNumber1].ImageUrl).attr('alt', pushData1[randomNumber1].Title);
        }
        if (numberOfPush1 > 0) {
            setInterval(changePush1, 5000);
        }
        if (numberOfPush1 > -1) {
            changePush1();
        }
    }

    var pushData2 = [];
    var numberOfPush2;
    var fTime2 = true;

    if (blogList2 && blogList2 != "") {
        var obj2 = jQuery.parseJSON(blogList2);
        $.each(obj2, function() {
            pushData2.push({ "Title": this.Title, "Text": this.Text, "URL": this.URL, "ImageUrl": this.ImageUrl });
        });
        numberOfPush2 = pushData2.length - 1;
        function changePush2() {
            if (!fTime2) {
                if (numberOfPush2 > 0) {
                    var temprandomNumber2 = randomNumber2;
                    while (temprandomNumber2 == randomNumber2) {
                        temprandomNumber2 = Math.round(Math.random() * numberOfPush2);
                    }
                    randomNumber2 = temprandomNumber2;
                }
                else {
                    randomNumber2 = Math.round(Math.random() * numberOfPush2);
                }
            }
            else {
                fTime2 = false;
            }
            $('#headerPush2').find('.title').text(pushData2[randomNumber2].Title).end()
                            .find('.text').text(pushData2[randomNumber2].Text + (pushData2[randomNumber2].Text != "" ? "..." : ""))
                            .end().find('.over').attr('href', pushData2[randomNumber2].URL)
                            .end().find('img').attr('src', pushData2[randomNumber2].ImageUrl).attr('alt', pushData2[randomNumber2].Title);
        }
        if (numberOfPush2 > 0) {
            setInterval(changePush2, 5000);
        }
        if (numberOfPush2 > -1) {
            changePush2();
        }
    }
});

//facebook share
function openFBShareWindow(urlie) {
    var A = 626, B = 436, C = screen.height, D = screen.width;
    var b = Math.round(D / 2 - A / 2), c = 0;
    C > B && (c = Math.round(C / 2 - B / 2));
    window.open(urlie, 'sharer', 'toolbar=0,status=0,width=626,height=436,left=' + b + ',top=' + c);
    return false;
}

function openTwitterShareWindow(urlie) {
    var z = "scrollbars=yes,resizable=yes,toolbar=no,location=yes", A = 550, B = 450, C = screen.height, D = screen.width;
    var b = Math.round(D / 2 - A / 2), c = 0;
    C > B && (c = Math.round(C / 2 - B / 2));
    window.open(urlie, "intent", z + ",width=" + A + ",height=" + B + ",left=" + b + ",top=" + c);
    return false;
}

