﻿///<reference path="~/static/scripts/Jquery.IntelliSense.js" />
/// <reference path="~/static/scripts/Dates.js" />
var sStaticURL = "/static/";O = {}; sLinkData=""
function DoNothing() { }
function GetImage(id, w, h) { if (!id) id = 0; if (w) return sStaticURL + "Resizer.ashx?source=news&image=" + id + "&a=" + w + "&b=" + h; return sStaticURL + "pictures/" + Math.floor(id / 1000) + "/" + id + ".jpg" }

Array.prototype.write = function () { document.write(this.join("")) }
Array.prototype.string = function () { return this.join("") }
Array.prototype.remove = function (from, to) {
    var rest = this.slice((to || from) + 1 || this.length);
    this.length = from < 0 ? this.length + from : from;
    return this.push.apply(this, rest);
};

String.prototype.write = function () { document.write(this) }
String.prototype.toNick = function () { return this.replaceStr("&", "&amp;").replaceStr("<", "&lt;").replaceStr(">", "&gt;"); }
String.prototype.toHTML = function (str) { var str = this; if (!str) return ""; str += ""; return this.toNick().replaceStr('"', "&quot;").replaceStr("'", "&#39;") }
String.prototype.toJS = function (str) { var str = this; if (!str) return ""; str += ""; return str.replaceStr('"', '\\"').replaceStr("'", '\\\'').replaceStr("\n", "\\n"); }
String.prototype.replaceStr = function (oldValue, newValue) { return this.split(oldValue).join(newValue); }
String.prototype.removeStr = function (oldValue) { return this.replaceStr(oldValue, "") }
String.prototype.Short = function (num) { var str = this; if (!str) return ""; return str.replace(new RegExp("(.{" + num + "}\S{0,})(?:.*)", "gi"), "$1"); }
String.prototype.toHTMLS = function () {
    sString = this; if (!sString) return "";

    function rxescape(str) { return str.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, "\\$&"); }
    sString = sString.replace(/target=_top/g, "").replace(/(<A |<a)/g, "<A target=_blank ").replace(/<\/?\w+:[^>]*>/gi, "");

    var a = [[":-)", "smile"], [":-D", "vhappy"], [";-(", "boche"], [":-(", "sad"], [":-P", "tongue"], [";-)", "wink"], ["(ישן)", "k"], ["(מחשב)", "computer"], ["(כוכב)", "star"], ["(בלון)", "balon"], ["(דוס)", "dos"]];

    for (var i = 0; i < a.length; i++) {
        var sSmile = rxescape(a[i][0]); sString = sString.replace(new RegExp("(" + sSmile + (sSmile.indexOf(";") == -1 ? "|" + sSmile.replace("\\-", "") : "") + ")", "gi"), "<img src=\"" + sStaticURL + "images/forum/smilies/" + a[i][1] + ".gif\">")
    }

    sString = sString.replace(/<IMG src=\"http:\/\/forumpics.a7.org\/\?file=(.*?)\"[^>]*>/g, "<a href=http://forumpics.a7.org/?file=$1 target=_blank><IMG  src=\"" + sStaticURL + "Resizer.ashx?image=$1&a=760&save=1\"$2></a>")
    return sString;
}

function LogIt(act, value)
{ }

var Info = { aIDs: [], aZones: [], View: { aIDs: [], aZones: [], aClients: [] }, Add: function (zone, id) { Info.aIDs.push(id); Info.aZones.push(zone); return Info }, Remove: function (id) { for (var i = 0; i < Info.aIDs.length; i++) if (Info.aIDs[i] == id) { Info.aIDs.remove(i); Info.aZones.remove(i) } },
    HTML: function (i, bid, cid, zone, type, url, file, ver, height, width, append) {
        var fileurl = 'http://info.a7.org/info_he/' + encodeURIComponent(file);
        var clickurl = "http://info.a7.org/php/c.php?b=" + bid + "&z=" + zone;
        var code = "";
        switch (type) {
            case "jpeg": case "png": case "gif":
                code = "<a rel=nofollow href=" + clickurl + " target=_blank><img width=" + width + " height=" + height + " src=" + fileurl + ">" + append + "</a>";
                break;
            case "swf":
                var v = "";
                fileurl += "?alink1=" + escape(clickurl) + "&atar1=_blank"; if (zone % 100 == 80 || window.mit) v = "<PARAM NAME=WMode VALUE=Transparent>";
                code = "<OBJECT codeBase=http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0 height=" + height + " width=" + width + " classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>" + v + "<param name=\"flashvars\" value=\"alink=" + fileurl + "\" /><PARAM NAME=Movie VALUE='" + fileurl + "'><PARAM NAME=Src VALUE='" + fileurl + "'><PARAM NAME=Menu VALUE=-1><PARAM NAME=AllowScriptAccess VALUE=never><PARAM NAME=AllowFullScreen VALUE=false><embed src='" + fileurl + "' quality=high wmode='opaque' width='" + width + "' height='" + height + "' type='application/x-shockwave-flash' pluginspace='http://www.adobe.com/go/getflashplayer' allowScriptAccess='never' FlashVars=\"alink=" + escape(fileurl) + "\"></embed></OBJECT>"; break;
            case "html":
                code = file.replaceStr("{target}", "_blank").replaceStr("{source}", "").replaceStr("{zoneid}", zone).replaceStr("{ban" + "nerid}", bid).replaceStr("{url_prefix}", clickurl.split("/c.php")[0]);
        }
        return code;
    },
    Insert: function (i, bid, cid, zone, type, url, file, ver, height, width, append) {
        var code = Info.HTML(i, bid, cid, zone, type, url, file, ver, height, width, append)
        var v = Info.View
        v.aIDs.push(bid); v.aClients.push(cid); v.aZones.push(zone);
        $((Info.aIDs[i].indexOf(".") > -1 || Info.aIDs[i].indexOf('#') > -1 ? "" : "#") + Info.aIDs[i]).append(code);
    },
    Reload: function () {
        for (var i = 0; i < Info.aIDs.length; i++) _(Info.aIDs[i]).innerHTML = "";
        Info.Final(true);
    },
    Log: function () { ExecuteUrl("http://info.a7.org/infol.php?clients=" + Info.View.aClients.join(",") + "&zones=" + Info.View.aZones.join(",") + "&b=" + Info.View.aIDs.join(",")); },
    LoadOne: function (zone, id, text) { ExecuteJS("http://click.inn.co.il/infoonenew.php?" + (text ? "text=1" : "") + "&zones=" + zone + "&ids=" + id) },
    ReloadTO: function (timeout) { window.setTimeout(this.Reload, timeout) },
    Final: function (nottrim) {
        ExecuteJS("http://info.a7.org/infonew.php?zones_list=" + Info.aZones.join(",") + "&" + new Date().getTime());
        if (!nottrim && window.aAdSource && location.pathname != "/") if (aAdSource[2]) document.write("<sc" + "ript src=http://ww.inn.co.il/pop.asp?" + new Date() + "></scr" + "ipt>")
    },
    LogC: function (type, cat, item, place) { ExecuteUrl("/Controls/HPJS.ashx?act=log&type=" + type + "&cat=" + cat + "&place=" + place + "&item=" + item + "&_" + new Date().getTime()); }
}

getE = function (name) { return document.getElementById(name) }
_ = getE;
if (!window.jQuery) jQuery = {};
jQuery.findPos = function (obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft;
        curtop = obj.offsetTop;
        while (obj = obj.offsetParent) {
            var origcurleft = curleft;
            curleft += obj.offsetLeft;
            if (curleft < 0) {
                curleft = origcurleft;
            }
            curtop += obj.offsetTop;
        }
    }
    return { x: curleft, y: curtop };
}
jQuery.getMouseCoordsWithinEvent = function (event) {
    var coords = { x: 0, y: 0 };
    if (!event) {
        event = window.event;
        coords.x = event.offsetX;
        coords.y = event.offsetY;
    }
    else {
        var e = jQuery.findPos(event.target)
        coords.x = event.pageX - e.x;
        coords.y = event.pageY - e.y;
    }
    return coords;
}

function ExecuteJS(url, func) {
    var scriptElem = document.createElement('script'); scriptElem.setAttribute('src', url + (func ? "&func=" + func : "")); window.document.getElementsByTagName('head')[0].appendChild(scriptElem);
}
function ExecuteUrl(url) { var i = document.createElement("img"); i.src = url + "&_" + new Date().getTime(); i.style.display = "none"; _("divMain").appendChild(i); }
window.ExecuteJS = ExecuteJS; window.ExectueUrl = ExecuteUrl;

INNData = { UDObject: null, UseUD: $.browser.msie && $.browser.version < 8,
    Save: function (name, data) {
        if (this.UseUD) { this.UDObject.setAttribute(name, data); this.UDObject.save("IData"); }
        else if (window.localStorage) window.localStorage["IData-" + name] = data;
    },
    Load: function (name) {
        var s; try {
            if (this.UseUD == 1) { this.UDObject.load("IData"); s = this.UDObject.getAttribute(name); }
            else if (window.localStorage) s = window.localStorage["IData-" + name];
        } catch (e) { } if (s) return s; else return "";
    }
}

Windows = {
    CenterGen: function (title, content, width, closef) {
        var pos = { x: $(window).width() / 2 - width / 2, y: $(window).scrollTop() + 200 }
        return this.Generic(title, content, pos, width, closef);
    },
    Generic: function (title, content, pos, width, closefunc) {
        var d = document.createElement("div"); d.className = "GenericWindow";
        d.innerHTML = "<span class=X onclick=\"" + closefunc + ";$(this.parentNode).remove();\"></span><div class=Ttl>" + title + "</div>";
        $(d).append(content);
        $(d).css("width", width).css("top", pos.y).css("left", pos.x); $(document.body).append(d);
        return d;
    }
};
var iAutoNum = 0;
if ($.browser.mozilla) $(document).ready(function () { $(document.body).addClass("Firefox") })
if ($.browser.version == 6) $(document).ready(function () { $(document.body).addClass("IE6") })

View = { AddZero: function (time) { if (time * 1 > 9) return "" + time; else return "0" + time },
    PaseTime: function (time) { return Math.floor(View.AddZero(time / 60)) + ":" + View.AddZero(Math.floor(time - (Math.floor(time / 60)) * 60)) },
    EmailName: function (from) { if (from.indexOf("<") > -1 && from.split("<")[0].replace(/ /g, "") != "") return from.split("<")[0]; else return from.replace("<", "").replace(">", ""); },
    SelectFromArr: function (arr, selected) { var s = ""; for (var i = 0; i < arr.length; i++) s += "<option value=" + i + (i == selected ? ' selected' : '') + ">" + arr[i] + "</option>"; return s; }
}
