﻿function setOnloadEvent(func) {
    if (document.all) {
        window.attachEvent('onload', func);
    }
    else {
        window.addEventListener('load', func, false);
    }
}
function onLoadEvent() {
    $(document).ready(function() {
        // remove the first node of bread crumb if the cuttent site is english or arabic
        if ($(".English").html() != null || $(".Arabic").html() != null) {
            $(".breadCrumbContent span span a").first().remove();
            $(".breadCrumbContent span span").first().next().remove();
        }

        $(".sendMailMainTable tbody tr  td table tr").each(function(i) {

            if (i == 4) {
                $(this, "td").remove();
            }

        });
        setGlobalNav();

        adjustSiteMapPage();

        SetNvcArticle();

        quickNavigation();

        setNvcLobby();

        SetTextAreaCounter();

        SetEilatImageGallery();

        setAddGallery();

        setBreadcrumbLink();

        $(".UrlToAlbum").css("visibility", "hidden");

        //setPublicationsSearch();
        //setNewsLetterPopup();


        /// remove empty p tags 
        if ($("div[id*=_RichHtmlField] p img").length >= 1) {
            $("div[id*=_RichHtmlField] p").each(function(p) {
                if ($(this).html() == "&nbsp;") {
                    $(this).remove();
                }
            });
        }

        $("#RollerTitle").text($(".boxInnerContent .LeftNewsBar").text());
        //        $("a").each(function(i) {
        //            if ($(this).attr('alt') == null) {


        //                $(this).attr("alt", $(this).text())
        //                $(this).attr("title", $(this).text())
        //            }
        //        });

    });
}


////////////////////////////////////////////////////////
//     Eilat Image Gallery WP Edit mode functions     // 
////////////////////////////////////////////////////////
function SetNewSort() {
    $(".panelSortSmall1").show();
    $(".panelSortAddClear").show();
    $(".SetDefaultSort").hide();
    $(".EIGeditModeSortText").hide();
    $(".EIGeditModeSetNewSort").hide();
}

function ShowNextFieldPanel(i) {

    //if not selected - return
    if (i > 1)
        if ($(".ddlSort" + (i - 1) + " option:selected").attr("value") == -1)
        return;

    for (j = 1; j < i; j = j + 1) {

        var val = $(".ddlSort" + j + " option:selected").attr("value");

        $(".ddlSort" + i + " option[value='" + val + "']").remove();

    }

    $(".panelSortSmall" + i).show();

}
function DeleteFieldPanel(i) {


    var val = $(".ddlSort" + (i - 1) + " option:selected").attr("value");
    var text = $(".ddlSort" + (i - 1) + " option:selected").html();


    $(".ddlSort" + i).append("<option value='" + val + "'>" + text + "</option>");
    $(".panelSortSmall" + i).hide();
}

function DeleteAllFieldPanels() {

    for (i = 9; i > 1; i = i - 1) {

        if ($(".panelSortSmall" + i).css("display") == "none")
            continue;

        DeleteFieldPanel(i);

    }
}

////////////////////////////////////////

function setAddGallery() {


    $(document).ready(function() {
        if ($('.ad-gallery').html() != null) {

            if ($(".English").html() != null) {
                $('.ad-gallery').adGallery({
                    start_at_index: 0,
                    Url: $(".UrlToAlbum").text()

                });
            }
            else {
                $('.ad-gallery').adGallery({
                    start_at_index: $(".ad-thumb-list li").length - 1,
                    Url: $(".UrlToAlbum").text()
                });
            }

            setTimeout("setAddGalleryWidth()", 100);

            $(".eventsAndGalleryDiv").show();
        }
    });
}

function setAddGalleryWidth() {
    var totalLength = 2;
    $('.ad-thumb-list li').each(function() {
        totalLength = totalLength + $(this).width() + 20;
    });

    $('.ad-thumb-list').width(totalLength);

    while ($('.ad-thumb-list').height() > 50) {
        totalLength = 20 + totalLength;
        $('.ad-thumb-list').width(totalLength);        
    }
}

function CheckAddGalleryWidth() {

    if ($('.ad-thumb-list').height() < 50)
        return;
        
    var totalLength = 2;
    $('.ad-thumb-list li').each(function() {
        totalLength = totalLength + $(this).width() + 20;
    });

    $('.ad-thumb-list').width(totalLength);

    while ($('.ad-thumb-list').height() > 50) {
        totalLength = 2 + totalLength;
        $('.ad-thumb-list').width(totalLength);
    }
}

function aaaa() {
    $('.ad-thumb-list').width(20 + $('.ad-thumb-list').width());

}
function SetTextAreaCounter() {
    $(document).ready(function() {

        $("textarea").each(function(i) {
            $(this).attr("maxlength", "255");
        });

        $("textarea[id*=_TextField]").addClass("TextareaCounter");
        $(".TextareaCounter").before("<div id='Counter' style='color:red'></div>")

        $('textarea[maxlength]').keyup(function() {
            //get the limit from maxlength attribute
            var limit = parseInt($(this).attr('maxlength'));
            //get the current text inside the textarea
            var text = $(this).val();
            //count the number of characters in the text
            var chars = text.length;
            $("#Counter").text("נשארו עוד " + (255 - $(".TextareaCounter").val().length) + " תווים ")
            //$(".TextareaCounter").val().length
            //check if there are more characters then allowed
            if (chars > limit) {
                //and if there are use substr to get the text before the limit
                var new_text = text.substr(0, limit);

                //and change the current text with the new text
                $(this).val(new_text);
            }
        });

    });
}

function ShowCurrentEvents(eventlink) {
    window.open(eventlink, "_self");
}

function SetEilatImageGallery() {

    if ($(".EilatImageGallery").html() == null) {
        return;
    }

    $(window).resize(function(event) {
        event.preventDefault();
    });

    setInitialEffects();

    if (navigator.appName != "Microsoft Internet Explorer")
        setTimeout("setSmallPicsHeight()", 444);
    else
        setSmallPicsHeight();

}
function setBreadcrumbLink() {

    var LinkToGallery = document.location.href;
    var ImageGalleryName = $(".breadCrumbCurrent:last").text();

    if ($(".EilatConferenceWP img").attr("src") != undefined) {
        $(".EilatConferenceWP").css("display", "block");
        $(".EilatConferenceWP").css("padding-bottom", "10px");
    }
    if ($(".EilatImageGallery").html() != null) {

        $(".breadCrumbCurrent:last").html("<a class='breadCrumbCurrent' alt=" + LinkToGallery + " title=" + LinkToGallery + " href=" + LinkToGallery + ">" + ImageGalleryName + "</a>")
    }

    if ($(".EventsSearchTable").html() != null) {

        $(".breadCrumbCurrent:last").html("<a class='breadCrumbCurrent' alt=" + LinkToGallery + " title=" + LinkToGallery + " href=" + LinkToGallery + ">" + ImageGalleryName + "</a>")
    }

}
function setSmallPicsHeight() {

    var i = 0;

    var panel;
    var panelBaseStr;
    var panelMaxHeight;

    var img;
    var imgBaseStr = ".imgGallerySmallImg";
    var imgMaxHeight;

    var imgDivWrap;
    var imgDivWrapBaseStr = ".secondPicDiv";
    var imgDivWrapMaxHeight;

    if ($(".smallAlbumsPanel").html() != null) {
        panelBaseStr = ".smallImagePanel";
    }
    else {
        panelBaseStr = ".smallPicPanel";
    }

    panel = panelBaseStr + "0";
    imgDivWrap = imgDivWrapBaseStr + "0";

    while ($(panel).html() != null) {

        //get image max height
        imgMaxHeight = 0;
        var j;
        for (j = i; j < i + 4; j = j + 1) {

            img = imgBaseStr + j;

            if ($(img).height() > imgMaxHeight) {
                imgMaxHeight = $(img).height();
            }
        }

        //set image padding-top 
        for (j = i; j < i + 4; j = j + 1) {

            img = imgBaseStr + j;

            if ($(img).height() < imgMaxHeight) {

                imgDivWrap = imgDivWrapBaseStr + j;
                var hefresh = Math.floor((imgMaxHeight - $(img).height() - 1));
                $(imgDivWrap).css("padding-top", hefresh + "px");
            }
        }

        panelMaxHeight = 0;

        //get panel max height
        for (j = i; j < i + 4; j = j + 1) {

            panel = panelBaseStr + j;
            img = imgBaseStr + j;

            if ($(panel).height() > panelMaxHeight) {
                panelMaxHeight = $(panel).height();
            }
            if ($(img).height() > imgMaxHeight) {
                imgMaxHeight = $(img).height();
            }
        }
        //set panel height
        for (j = i; j < i + 4; j = j + 1) {

            panel = panelBaseStr + j;
            //imgDivWrap = imgDivWrapBaseStr + j;

            if ($(panel).html() == null) {
                break;
            }

            $(panel).height(panelMaxHeight);
            //$(imgDivWrap).height(imgMaxHeight);
        }
        i = i + 4;
        //alert(j + ":" + panelMaxHeight);

    }
}
function setInitialEffects() {

    if ($(".bigImgAndAnchorsDiv").html() != null) {
        var effectType = $(".EffectTypeDiv").html();
        var effectTime = $(".InitialEffectTimeDiv").html();

        if (effectType == "resize") {
            $(".AllPicsDiv").css("display", "block");
            $(".smallImagePanel").css("display", "block");
            $(".smallPicPanel").css("display", "block");
        }
    }

    $(document).ready(function() {

        if ($(".bigImgAndAnchorsDiv").html() != null) {

            SetMainImage(effectType, effectTime, 0, "false");
        }

        $(".bigImgAndAnchorsDiv").css("display", "block");
        $(".ajaxLoaderDiv").css("display", "none");

        if (effectType != "resize") {

            $(".bigImgAndAnchorsDivInner").fadeIn(effectTime);
            $(".EilatMainImageDivWithBorder").fadeIn(effectTime);
            //            $(".bigImgAndAnchorsDivInner").fadeIn(effectTime, function() { $(".EilatMainImageDivWithBorder").fadeIn(effectTime); });
            $(".AllPicsDiv").fadeIn(effectTime);
            $(".smallImagePanel").fadeIn(effectTime);
            $(".smallPicPanel").fadeIn(effectTime);

        }

    });
}
//function OLD_SetNvcArticle() {
//    $(".sendMailMainTable td table").each(function(i) {
//        if (i == 4) {
//            $(this).css("margin-top", "-3px");
//            $(this).css("margin-right", "18px");
//        }
//    });
//}

//function setNewsLetterPopup() {

//    $("input.sendBtnImg").click(function() {
//        $("#newsLetterInnerTitle").html("");
//    });
//    $("input.clearBtnImg").click(function() {
//        $("#newsLetterInnerTitle").html("לקבלת עדכונים במייל הרשמו לרשימת התפוצה שלנו");
//    });

//    $("#newsletterInnerDiv").before("<div id='newsLetterInnerTitle' style='margin:0px 2px 15px 0px;height:16px;'>לקבלת עדכונים במייל הרשמו לרשימת התפוצה שלנו</div>");

//    $("#newsLetterPopupDiv td").attr("vAlign", "center");
//    $("#newsLetterPopupDiv input.clearBtnImg").attr("title", "נקה");
//    $("#newsLetterPopupDiv input.clearBtnImg").attr("alt", "נקה");

//    if (navigator.appName != "Microsoft Internet Explorer") {
//        $("#newsLetterPopupDiv input.clearBtnImg").css("padding-top", "1px");
//        $("#newsLetterPopupDiv input.sendBtnImg").css("padding-top", "1px");
//        $("#newsLetterPopupDiv div.boxContent").css("padding-bottom", "0px");
//    }
//}

//function closeNewsLetterPopup() {

//    if ($("#newsLetterPopupDiv input.backBtnImg").html() != null) {
//        document.location = document.location.href;
//    }
//    document.getElementById('newsLetterPopupDiv').style.display = 'none';
//    document.getElementById('newsLetterOpacity').style.display = 'none';
//    $("#newsLetterPopupDiv input[type='text']").val("");

//}

//function showNewsLetterPopup() {
//    $("#newsLetterPopupDiv span").each(function(i) {
//        if ($(this).css("color") == "red") {
//            $(this).css("display", "none");
//        }
//    });
//    var popup = document.getElementById('newsLetterPopupDiv');
//    var opacityDiv = document.getElementById('newsLetterOpacity');
//    opacityDiv.style.width = document.body.scrollWidth + "px";
//    opacityDiv.style.height = document.body.scrollHeight + "px";
//    opacityDiv.style.opacity = '0.4';
//    opacityDiv.style.filter = 'alpha(opacity=40)';
//    opacityDiv.style.display = "block";
//    popup.style.display = "block";

//    $("#newsLetterInnerTitle").html("לקבלת עדכונים במייל הרשמו לרשימת התפוצה שלנו");
//}
//function showRedirectPopup() {

//    var popup = document.getElementById('RedirectDiv');
//    var opacityDiv = document.getElementById('RedirectOpacity');
//    opacityDiv.style.width = document.body.scrollWidth + "px";
//    opacityDiv.style.height = document.body.scrollHeight + "px";
//    opacityDiv.style.opacity = '0.4';
//    opacityDiv.style.filter = 'alpha(opacity=40)';
//    opacityDiv.style.display = "block";
//    popup.style.display = "block";
//    setTimeout("window.location='http://www.mops.gov.il/BPEng/CWV+Program/'", 4000)

//}


function setNvcLobby() {

    if ($(".nvcLobby").html() == null) { return; }

    if ($("#centerTextDiv").height() < 60) {

        $("#centerTextDiv").css("display", "block");
    }

    AddPublicationsCopyRights();

    setPagerNextPrevDisabled();

    setDatePicker();
}

function AddPublicationsCopyRights() {

    if ($(".XslPublicationsCopyRights").html() != null) {

        $("#centerTextDiv div").first().css("padding-bottom", "0px");

        if ($(".resultsPaging").html() != null) {
            $(".resultsPaging").after("<div class='PublicationsCopyRights'>" + $(".XslPublicationsCopyRights").html() + "</div>");
        }
        else {
            $(".XslPublicationsCopyRights").show();

        }
    }
}
function setPagerNextPrevDisabled() {

    if ($(".EilatImageGallery").html() != null) {
        return;
    }

    if ($(".English").html() != null) {

        //change arrow direction for english

        $(".resultsPagingArrowPrevious").attr("src", "/SiteCollectionImages/Pagination/arrow_next.gif");
        $(".resultsPagingDoubleArrowPrevious").attr("src", "/SiteCollectionImages/Pagination/two_arrows_next.gif");

        $(".resultsPagingArrowNext").attr("src", "/SiteCollectionImages/Pagination/arrow_previous.gif");
        $(".resultsPagingDoubleArrowNext").attr("src", "/SiteCollectionImages/Pagination/two_arrows_previous.gif");
    }

    if ($(".aPreviousLabelStyle span").html() != null) {

        if ($(".English").html() != null) {
            $(".resultsPagingArrowPrevious").attr("src", "/SiteCollectionImages/Pagination/find_to_left_off.gif");
            $(".resultsPagingDoubleArrowPrevious").attr("src", "/SiteCollectionImages/Pagination/two_arrows_next_off.gif");
        }
        else {
            $(".resultsPagingArrowPrevious").attr("src", "/SiteCollectionImages/Pagination/find_to_right_off.gif");
            $(".resultsPagingDoubleArrowPrevious").attr("src", "/SiteCollectionImages/Pagination/two_arrows_previous_off.gif");
        }

        $(".aPreviousLabelStyle span").css("color", "#999999");
        $(".resultsPagingArrowPrevious").attr("alt", "");
        $(".resultsPagingDoubleArrowPrevious").attr("alt", "");
        $(".resultsPagingArrowPrevious").attr("title", "");
        $(".resultsPagingDoubleArrowPrevious").attr("title", "");
        $(".resultsPagingLabel").attr("alt", "");
        $(".resultsPagingLabel").attr("title", "");

    }

    if ($(".aNextLabelStyle span").html() != null) {

        if ($(".English").html() != null) {
            $(".resultsPagingArrowNext").attr("src", "/SiteCollectionImages/Pagination/find_to_right_off.gif");
            $(".resultsPagingDoubleArrowNext").attr("src", "/SiteCollectionImages/Pagination/two_arrows_previous_off.gif");
        }
        else {
            $(".resultsPagingArrowNext").attr("src", "/SiteCollectionImages/Pagination/find_to_left_off.gif");
            $(".resultsPagingDoubleArrowNext").attr("src", "/SiteCollectionImages/Pagination/two_arrows_next_off.gif");
        }

        $(".aNextLabelStyle span").css("color", "#999999");

        $(".resultsPagingArrowNext").attr("alt", "");
        $(".resultsPagingDoubleArrowNext").attr("alt", "");
        $(".resultsPagingArrowNext").attr("title", "");
        $(".resultsPagingDoubleArrowNext").attr("title", "");
        $(".resultsPagingLabel").attr("alt", "");
        $(".resultsPagingLabel").attr("title", "");

    }

    $(".resultsPaging div").show();

    var W;
    //case double arrows exist
    if ($(".resultsPaging .aRightArrows").html() != null) {

        W = getPagerWidth();
        $(".resultsPaging > div").width(W);
    }
    else {

        $(".resultsPaging").css("margin", "auto");

        if ($(".English").html() != null) {
            $(".resultsPaging div").css("float", "left");
        }
        else {
            $(".resultsPaging div").css("float", "right");
        }

        $(".resultsPaging div").first().css("margin-top", "4px");

        W = getPagerWidth();
        $(".resultsPaging").width(W);
    }
}

function getPagerWidth() {
    var W1;
    if ($(".resultsPaging .aRightArrows").html() != null) {
        W1 = $(".resultsPaging .aRightArrows").width();
    }
    else {
        W1 = $(".resultsPaging div").first().width();
    }

    var W2 = $(".resultsPaging .aPreviousLabelStyle").width();
    var W3 = $(".resultsPaging .mumbers").width();
    var W4 = $(".resultsPaging .aNextLabelStyle").width();
    var W5 = $(".resultsPaging .aLeftArrows").width();

    var W = W1 + W2 + W3 + W4 + W5;

    if (navigator.appName == "Microsoft Internet Explorer") {
        return (W);
    }
    else {
        return (31 + W);
    }
}
function setDatePicker() {

    //check Language
    var strAltText = "בחרו תאריך מתוך לוח השנה";

    if ($(".English").html() != null) {
        strAltText = "Choose a date from the Calender";
    }
    if ($(".Arabic").html() != null) {
        strAltText = "حدد تاريخ";
    }

    var index = 1;
    if (navigator.appName == "Microsoft Internet Explorer")
        $(".ms-dtinput:has(img)").remove();

    if ($(".ms-dtinput").length > 0) {
        $(".ms-dtinput").each(function(i) {

            var DatePicker = "DatePicker" + i;
            var DatePickerContainer = "DatePickerContainer" + i
            if (i > 0)
                index = i - 1;

            $(this).after("<td id='" + DatePickerContainer + "' class='ms-dtinput'  style='padding-left:74px;cursor:pointer'><A  onclick=ShowDatePicker('" + DatePicker + "','DatePicker" + index + "') ><IMG id=FromCalculatedPublishDate src='/_layouts/images/calendar.gif' border='0' alt='" + strAltText + "' title='" + strAltText + "'style='margin-left:0px; '></IMG></A><div id='" + DatePicker + "'  style='position:absolute;display:none;' class='datepicker' type='text'></div></td>");
        });
        $(".datepicker").datepicker({
            onSelect: function(dateText, inst) {
                var PickerID = $(this).attr("id");
                PickerID = PickerID.substring(10);
                var NewID = "DatePickerContainer" + PickerID;
                $("td[id='" + NewID + "']").prev().find("input").val(dateText);
                $(this).css("display", "none");
            }
        });
    }
    if (navigator.appName != "Microsoft Internet Explorer") {
        $("input$[id$=dtcFromUpdatedDate]").css("margin", "-10px 39px 0px 0px");
        $("td.dtcFromCalculatedPublishDate input").css("margin-right", "33px");
    }
    $("#ui-datepicker-div").remove();
}


function ShowDatePicker(id, idToHide) {
    if ($("div [id='" + id + "']").css("display") == "none") {
        $("div [id='" + id + "']").css("display", "block");

        if ($("div [id='" + id + "']").css("display") == "block") {
            $("div [id='" + idToHide + "']").css("display", "none")
        }
    }
    else {
        $("div [id='" + id + "']").css("display", "none");

    }
}

function setPublicationsSearch() {
    var strTitle = document.location.href;
    for (var i = 0; i < 3; i = i + 1) {
        strTitle = strTitle.substring(document.location.href.indexOf('/'));
    }
    strTitle = strTitle.substring(1);
    strTitle = strTitle.substring(0, strTitle.indexOf('/'));
    if (strTitle == "NewsAndUpdates") {
        $("input$[id$=dtcFromCalculatedPublishDate").css("margin-right", "40px");
    }
}

//function quickNavigation() {
//    $(document).ready(function() {

//   // debugger
//        //for right nav site links
//        $("table.zz1_GlobalNav_7 td").append("<br/><div class=\"blueLine\" style=\"font-size:18px !important;\">&nbsp</div>");

//        //remove last blue line
//        $("table.zz1_GlobalNav_7 td:last div").removeClass("blueLine");

//        var strTitle = document.location.href;
//        var strLink;
//        var readWrithSite = location.host.substring(0, 2)
////        if (readWrithSite == "e.") {
////            strLink = "https://"
////        }
////        else {
////            strLink = "http://"
////        }
//        //check if in site default or other page
//        var found = "false";
//        var pageLinks = false;
//        $("table.zz1_GlobalNav_7 a").each(function(i) {
//            pageLinks = "true"
//            strLink += location.host + $(this).attr("href");
//            if (strLink == strTitle) {
//                found = "true";
//               $(this).css("text-decoration", "underline");
//            }
//        });

//        if (found == "false") {

//           $("div.darkTitleText").append($("span.breadCrumbCurrent").html());
//        }
//        else {

//            $("div.darkTitleText").append($("span a.breadCrumbCurrent:last").html());
//        }

//        //Show only if not in root site
//        if (strTitle.substring(1, 6) != "Pages" && pageLinks == "true") {
//            $("#ctl00_PageLinksDiv").css("display", "block");
//        }
//    });
//}
function quickNavigation() {
    $(document).ready(function() {
        //for right nav site links
        $("table.zz1_GlobalNav_7 td").append("<br/><div class=\"blueLine\" style=\"font-size:18px !important;\">&nbsp</div>");

        //remove last blue line
        $("table.zz1_GlobalNav_7 td:last div").removeClass("blueLine");

        var strTitle = document.location.href;
        var readWrithSite = location.host.substring(0, 2)
        if (readWrithSite == "e.") {
            strLink = "https://"
        }
        else {
            strLink = "http://"
        }

        //check if in site default or other page
        var found = "false";
        var pageLinks = false;
        $("table.zz1_GlobalNav_7 a").each(function(i) {
            pageLinks = "true"
            var strLink = "http://" + location.host + $(this).attr("href");
            if (strLink == strTitle) {
                found = "true";
                $(this).css("text-decoration", "underline");
            }
        });

        if (found == "false") {
            $("div.darkTitleText").append($("span.breadCrumbCurrent").html());
        }
        else {
            $("div.darkTitleText").append($("span a.breadCrumbCurrent:last").html());
        }

        //Show only if not in root site
        if (strTitle.substring(1, 6) != "Pages" && pageLinks == "true") {
            $("#ctl00_PageLinksDiv").css("display", "block");
        }
    });
}
function FPBtn_onclick() {

    try {


        var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
        disp_setting += "scrollbars=yes,width=850, height=600, left=100, top=25";
        var PHMC = document.getElementById("ContentToPrint");
        var pagetitle = $("h1").text();
        if (PHMC != null) {

            var ClassName = "Hebrew";
            var strPrintText = "גרסת הדפסה";
            var LogoToPrint = "/SiteCollectionImages/banner-top-CITY_HEB.jpg";
            //check Language

            if ($(".English").html() != null) {
                strPrintText = "Print Version";
                ClassName = "English";
                LogoToPrint = "/SiteCollectionImages/banner-top-CITY_ENG.jpg";
            }
            if ($(".Arabic").html() != null) {
                strPrintText = "صيغة للطباعة";
                ClassName = "arabic";
                LogoToPrint = "/SiteCollectionImages/banner-top-CITY_ARA.jpg";
            }


            var content_vlue = PHMC.innerHTML;
            var docprint = window.open("", "", disp_setting);
            docprint.document.open();
            docprint.document.write('<html ><head><title>' + strPrintText + '-' + pagetitle + '</title>');
            docprint.document.write('<link type="text/css" rel="stylesheet" href="/Style Library/CustomCSS/PrintVersion.css"/>');
            docprint.document.write('<link type="text/css" rel="stylesheet" href="/Style Library/Universal.css"/>');
            docprint.document.write('<link rel="stylesheet" type="text/css" href="/Style Library/Custom.css"/>');
            docprint.document.write('</head><body onLoad="self.print()">');

            docprint.document.write('<div class=' + ClassName + '>')
            docprint.document.write('<img border="0" align="top"  style="border: 0px solid;width:580px;" src=' + LogoToPrint + ' />')
            docprint.document.write(content_vlue);
            docprint.document.write('</div>')
            docprint.document.write('</body></html>');
            docprint.document.close();
            docprint.focus();
        }
        else {
            window.print();
        }
    }
    catch (err) {
        txt = "There was an error on this page.\n\n";
        txt += "Error description: " + err.description + "\n\n";
        txt += "Click OK to continue.\n\n";
        alert(txt);
    }
}

function setGlobalNav() {
    $("div.GlobalNav div:first").removeClass("btn");
    $("div.breadCrumbContent span:first").css("display", "block");
    $("div.breadCrumbContent span:first").css("padding-right", "10px");
    $("div.breadCrumbContent span:first").css("padding-left", "10px");
}

function adjustSiteMapPage() {
    $("td.siteMapTdLink > a").append("<br/><div class=\"blueLine4SiteMap\">&nbsp</div>");

    if ($("div .EmptyDiv").height() > 0) {
        $("div .EmptyDiv").addClass("wideZoomBox");
    }
}

// for nvcArticle page
function SetNvcArticle() {
    $(".sendMailMainTable td table").each(function(i) {
        if (i == 4) {

            if ($(".English").html() == null) {

                $(".addthis_button div img").css(".margin-top", "0px");
                $(".addthis_button div img").css("margin-top", "2px");
                //$(this).css(".margin-top", "0px");
                // $(this).css("margin-top", "4px");

                //$(this).css("margin-right", "-18px");
            }
            else {
                //$(this).css("margin-left", "-18px"); 
            }
        }
    });

    buildMoreInfoAndFileDownloadDivs();
    SetNvcArticleWidth();
}

function SetNvcArticleWidth() {
    if ($("#articalLeftImges").height() < 20) {
        $("#articalLeftImges").css("display", "none");
        $("#centerArticleTextDiv").addClass("centerArticleTextDiv");
    }
    else {
        $("#centerArticleTextDiv").addClass("centerArticleTextDivWithImage");
        if ($(".English").html() == null) {
            $("#centerArticleTextDiv").css("margin-left", "10px");
        }
    }
}

function buildMoreInfoAndFileDownloadDivs() {

    //check Language
    var strMoreInfo = "מידע נוסף";
    var strFiles4Download = "קבצים להורדה";
    var strGetAdobe = "להורדת גרסה מעודכנת של";

    if ($(".English").html() != null) {
        strMoreInfo = "More Information";
        strFiles4Download = "Files for Download";
        strGetAdobe = "To Download an updated version of";
    }
    if ($(".Arabic").html() != null) {
        strMoreInfo = "مزيد من التفاصيل";
        strFiles4Download = "ملفات للتنزيل ";
        strGetAdobe = "لتحميل نسخة محدثة من";
    }

    $("div .DLFMain").before("<div style='float:right;padding-left:10px;padding-bottom:10px;'><img style='margin-top:2px;' src='/WebResources/Images/HE/Symbols/download.png'/></div><div style='font-weight:bold;float:right;color:#3067a0' class='smallFont'>" + strFiles4Download + "</div><div style=\"clear:both;font-size:1px;\"></div>");

    if ($("div .moreInfoDiv").height() > 0) {
        $("div .moreInfoDiv").before("<div class='moreInfoDivTitleImg'><img style='margin-top:2px;' src='/WebResources/Images/HE/Symbols/info.png'/></div><div class='moreInfoDivTitleText smallFont' class=''>" + strMoreInfo + "</div><div style=\"clear:both;font-size:1px;margin-bottom:10px;\">&nbsp</div>");
    }

    $("table .FileToDownLoad  img").each(function(i) {

        var str1 = $(this).attr("src");
        var str2 = str1.substring(str1.length - 7);
        var strLang = $(this).attr("src");
        if (str2 == "pdf.png") {
            $("div.DLFMain").after("<div class=\"xsmallFont getAdobeDiv\"><span class=\"xsmallFont getAdobeText\">" + strGetAdobe + "</span><a href=\"http://get.adobe.com/reader/\" class=\"xsmallFont getAdobeLink\" style='color:#3067a0;text-decoration:underline' target='_blank'>Adobe Reader</a></div>");
            return;
        }
    });
}

function currentSelectionEN(btnId) {

    $(document).ready(function() {

        $("div.GlobalNav div[id*=" + btnId + "]").removeClass("btn-offEN");
        $("div.GlobalNav div[id*=" + btnId + "]").addClass("btn-onEN");
    });
}

function currentSelection(btnId) {

    $(document).ready(function() {
        $("div.GlobalNav div[id*=" + btnId + "]").removeClass("btn-off");
        $("div.GlobalNav div[id*=" + btnId + "]").addClass("btn-on");
    });
}
function onRadDropDownOpen(s, e) {

    var curLeft = $(s.get_dropDownElement()).parent().offset().left;


    var buttonWidth = $(s.get_imageDomElement()).width();
    var buttonLeft = $(s.get_imageDomElement()).offset().left;
    $(s.get_dropDownElement()).parent().css("left", buttonLeft - 2 * $(window).scrollLeft() + "px");
};

function ShowPopupImage(show, srcUrl, desc, isWide) {


    var popup = document.getElementById('popupDiv');
    var opacityDiv = document.getElementById('opacityMask');
    var PopUpImage = document.getElementById('PopUpImage');

    if (show == "false") {
        opacityDiv.style.display = "none";
        popup.style.display = "none";
        return;
    }

    while (desc.indexOf('@@@') >= 0)
        desc = desc.replace("@@@", "'");

    //set image bottom text



    document.getElementById('popImgDescDiv').innerHTML = desc;



    opacityDiv.style.opacity = '0.4';
    opacityDiv.style.filter = 'alpha(opacity=40)';

    opacityDiv.style.width = document.body.scrollWidth + "px";
    opacityDiv.style.height = document.body.scrollHeight + "px";
    opacityDiv.style.display = "block";
    popup.style.display = "block";

    PopUpImage.src = srcUrl;

    PopUpImage.setAttribute("title", desc);
    PopUpImage.setAttribute("alt", desc);

    var iWidth = $(".ZoomBoxImg[src*=" + srcUrl + "]").width();
    var iHeight = $(".ZoomBoxImg[src*=" + srcUrl + "]").height();

    if (iWidth > iHeight) {
        PopUpImage.style.width = "450px";
        popup.style.width = "459px";
        popup.style.left = 27 + "%";
        popup.style.top = 20 + "%";
    }
    else {
        PopUpImage.style.width = "315px";
        popup.style.width = "324px";
        popup.style.left = 36 + "%";
        popup.style.top = 20 + "%";
    }
}

function DisplayMessageToUser(ContactUsSentOk1, ContactUsSentOk2, ContactUsSentOk3) {

    $(document).ready(function() {

        if ($("#SentOK").html() != null) {
            $("#EmptyLayoutDiv").html("<table style='margin:auto'><tr><td><DIV class='MessageSentOKMain'><DIV class='dirRTL'><IMG class='MessageSentOKIMG' alt='" + ContactUsSentOk1 + "' src='/WebResources/Images/HE/Symbols/send.png'/></div><table><tr><td class='royalBlue mediumFont MessageSentOKInner1'>" + ContactUsSentOk1 + "</td></tr><tr><td class='royalBlue mediumFont MessageSentOKInner2'>" + ContactUsSentOk2 + "</td></tr><tr><td class='MessageSentOKFinal'>" + ContactUsSentOk3 + "</td></tr></table></td></tr></table>");
        }
    });
}

function SendMail(title, strtdate, enddate) {

    alert(title)
    alert(strtdate)
    alert(enddate)
}


var AjaxSucceeded = "true";
var AjaxFailed = "false";

// AjaxSucceeded(result);
function PageMethod(fn, paramArray, successFn, errorFn) {



    var pagePath = window.location.pathname;
    var paramList = '';
    if (paramArray.length > 0) {
        for (var i = 0; i < paramArray.length; i += 2) {
            if (paramList.length > 0) paramList += ',';
            paramList += '"' + paramArray[i] + '":"' + paramArray[i + 1] + '"';
        }
    }
    paramList = '{' + paramList + '}';

    //Call the page method
    $.ajax({
        type: "GET",
        url: pagePath + "/" + fn,
        contentType: "application/json; charset=utf-8",
        data: paramList,
        dataType: "json"
        // error: errorFn
    });
}






