﻿function signSending(name, id) {
    var link = "/News/news.aspx/" + id;
   /// $.post(link, {}kt )
    var link = "/News/news.aspx";
    var sendingform = document.createElement("form");
    sendingform.action = link + "/" + id;
    sendingform.method = "post";
    sendingform.id = "sendingform";
    sendingform.name = "sendingform";
    var hidden = document.createElement("input");
    hidden.type = "hidden";
    hidden.name = "catName";
    hidden.value = name;
    sendingform.appendChild(hidden);
    _("formid").appendChild(sendingform);
    document.sendingform.submit();
}
function PageDirective(juList,mainList) 
{
    this.ju = juList; this.main = mainList;
    this.injJU = function(juarr) {
        var inj = ""

        for (var i = 0; i < this.ju.length ; i++) {
            imgid = parseInt(this.ju[i][5]);
            inj += " <div class='features' onClick='window.open( \" http://" + this.ju[i][6] + " \");target =\"_blank\";' > " +
            "<p style='float:left;'><img src='/static/pictures/resized/120-93/" + Math.floor(imgid / 1000) + "/" + imgid + ".jpg' alt='israel national news' class='shadow' rel='black' style='border:1px solid #abaabb' /></p>" +
            "<div style='float:right;width:180px;'>" +
                "<p class='feat_head'>" + this.ju[i][1] + "</p>" +
                "<p class='feat_cont'>" + this.ju[i][2] + "</p>" +
            "</div></div><div class='clear'></div>";
        }
        $("#julinks").html(inj);
        
        
    };
    this.injMain = function(isFirst) {
        if (isFirst) {
            this.firstStory(this.main[0]);
            var i = 1;
        } else { var i = 0; }
        var injStories = "<ul class='ls_headlines'>";
        for (i; i < this.main.length ; i++) {
            injStories += "<li>&#9658;<a href='/News/news.aspx/ " + this.main[i][0] + "'> " + this.main[i][3] + "</a></li>";
        }
        injStories += "</ul>";
        $("#stories").html(injStories);
    };
    this.firstStory = function(firstarr) {
        var imgid = parseInt(firstarr[3])
        var id = parseInt(firstarr[0])
        var injFirst = "<a href='/News/news.aspx/" + id + "'><img height='183' width='286' src='/static/pictures/resized/244-153/" + Math.floor(imgid / 1000) + "/" + imgid + ".jpg' style='width:286;height:183' alt=' " + firstarr[7] + "'/></a>" +
            "<a  href='/News/news.aspx/" + id + "'><p class='sec_header'>" + firstarr[2] + "</p></a>" +
            "<a  href='/News/news.aspx/" + id + "'><p class='sec_cont'>" + firstarr[1] + "</p></a>";
            $("#mainstory").html(injFirst);
    };
    this.setBA = function(strBA) {

    $("#ba").html(strBA.replace(/<li>/g,"<li>&#9658;&nbsp;"));

};
this.topStories = function(stories) {
    write("stories", stories.replace(/<li>/g, "<li>&#9658;&nbsp;"));
};
this.fillHeader = function(list) {
    $("#sSnippet").html(list[2]); $("#sTitle").html(list[1]); $("#sBackground").css('background-color', list[3]); $("#sImage").attr('src', "/images/news/" + list[5] + ".gif");
    $("#sGardiant").css("background", "url('/images/news/" + list[4] + ".gif') repeat-x");
    $("#sTitle").css("color", list[6]); $("#featured_sites").css("color", list[6]); $("#headlines").css('background-color', list[6]);
    $(".section_header li a").hover(function() { $(this).css("color", list[6]) }, function() { $(this).css("color", "#3B3A3A") });
    this.activate(list[1], list[6]);
    $("#nl_title").html(list[0] != 19 ? list[1] : list[1].replace(/ /g, "-"));
    $("#advInSection").attr("src", "/images/news/" + list[7]);
    $("#featured_sites").html("Featured " + list[1] + " Sites");
    $("#headlines").html("More " + list[1] + " Headlines");
  };
this.activate = function(name, color) {
    var activ = $("#mainNav li a:contains(" + name + ")");
    activ.addClass('activated');
    activ.hover(function() { }, function() { activ.css("color", color) });
    activ.css("color", color);
    $("#mainNav li a:contains(" + name + ")");
};
}

function write(id, str) {
    $("#" + id).html(str);
}   


var gradientshadow = {}
gradientshadow.depth = 5 //Depth of shadow in pixels
gradientshadow.containers = []

gradientshadow.create = function() {
    var a = document.all ? document.all : document.getElementsByTagName('*')
    for (var i = 0; i < a.length; i++) {
        if (a[i].className == "shadow") {
            for (var x = 0; x < gradientshadow.depth; x++) {
                var newSd = document.createElement("DIV")
                newSd.className = "shadow_inner"
                newSd.id = "shadow" + gradientshadow.containers.length + "_" + x //Each shadow DIV has an id of "shadowL_X" (L=index of target element, X=index of shadow (depth) 
                if (a[i].getAttribute("rel"))
                    newSd.style.background = a[i].getAttribute("rel")
                else
                    newSd.style.background = "black" //default shadow color if none specified
                document.body.appendChild(newSd)
            }
            gradientshadow.containers[gradientshadow.containers.length] = a[i]
        }
    }
    gradientshadow.position()
    window.onresize = function() {
        gradientshadow.position()
    }
}

gradientshadow.position = function() {
    if (gradientshadow.containers.length > 0) {
        for (var i = 0; i < gradientshadow.containers.length; i++) {
            for (var x = 0; x < gradientshadow.depth; x++) {
                var shadowdiv = document.getElementById("shadow" + i + "_" + x)
                shadowdiv.style.width = "122px";//gradientshadow.containers[i].offsetWidth + "px"
                shadowdiv.style.height = "95px"; //gradientshadow.containers[i].offsetHeight + "px"
                shadowdiv.style.left = gradientshadow.containers[i].offsetLeft + x + "px"
                shadowdiv.style.top = gradientshadow.containers[i].offsetTop + x + "px"
            }
        }
    }
}

if (window.addEventListener)
    window.addEventListener("load", gradientshadow.create, false)
else if (window.attachEvent)
    window.attachEvent("onload", gradientshadow.create)
else if (document.getElementById)
    window.onload = gradientshadow.create