//*******************************************
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"], ["(חופר)", "digg"], ["(נשיקה)", "remybussi"], ["(נפנוף)", "nifnuf"], ["(מרחף)", "h"], ["(טלפון)", "telphone"]];

    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.{0,50}src=\"http:\/\/forumpics\.a7\.org\/\?file=([0-9.jpg]*)\"[^>]*>/gi, " <a href=http://a7.org/?file=$1 target=_blank><IMG src=\"http://n2.a7.org/Resizer.ashx?image=$1&forum=1&a=500&save=1\"></a> ")

    return sString;

}



//*******************************************



function DoNothing() { }
var sOXURL = "http://info2.a7.org/info/";

var Info = { aIDs: [], aNoAds: [], aOne: [], Vars: {}, View: { a: [] }, BeforeLog: DoNothing,
 Add: function (zone, id, opts) { 
 /*if (Info.aIDs.length==0){
   Info.aIDs.push({ id: 'ad1', zone: 76, opts: opts ? opts : [] }); 
   }*/
 
 Info.aIDs.push({ id: id, zone: zone, opts: opts ? opts : [] });
 return Info ;
 
 }
 , Remove: function (id) { for (var i = 0; i < Info.aIDs.length; i++) if (Info.aIDs[i].id == id) { Info.aIDs.remove(i); } },
    HTML: function (b, opts) {
        if (!opts) opts = {};
        var fileurl = sOXURL + "images/" + encodeURIComponent(b.file);
        var clickurl = sOXURL + "delivery/ck.php?oaparams=2__b=" + b.b + "__z=" + b.z;
        var code = "";
        switch (b.type) {
            case "jpeg": case "png": case "gif":
                code = "<a rel=nofollow href=" + clickurl + " target=_blank>" + (b.width > 1 && !opts.text ? "<img width=" + b.width + " height=" + b.height + " src=" + fileurl + ">" : "") + (opts.text ? b.append + b.alt : "") + "</a>";
                break;
            case "swf":
                var v = "";
                var escu = escape(clickurl) + "&atar1=_blank"; //.replaceStr("{zoneid}",b.zone).replaceStr("{ban"+"nerid}",b.bid)
                if (b.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=" + b.height + " width=" + b.width + " classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>" + v + "<param name=\"flashvars\" value=\"alink1=" + escu + "\" /><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='" + b.width + "' height='" + b.height + "' type='application/x-shockwave-flash' pluginspace='http://www.adobe.com/go/getflashplayer' allowScriptAccess='never' FlashVars=\"alink1=" + escape(clickurl) + "\"></embed></OBJECT>"; break;
            case "html":
                code = b.file.replaceStr("{target}", "_blank").replaceStr("{source}", "").replaceStr("{zoneid}", b.zone).replaceStr("{ban" + "nerid}", b.bid).replaceStr("{url_prefix}", clickurl.split("/c.php")[0]);
        }
        return code;
    },
    Object: function (bid, cid, zone, type, url, file, ver, height, width, append, alt, block_ad, cap_ad, session_cap_ad, block_campaign, cap_campaign, session_cap_campaign, block_zone, cap_zone, session_cap_zone, last_view, last_click) { return { b: bid, c: cid, z: zone, type: type, url: url, file: file, width: width, height: height, append: append, alt: alt }; },
    Insert: function (i, b) {
	var rows = document.getElementById(Info.aIDs[i].id).children;
	    if (rows.length>0)  return;
        Info.View.a.push({ b: b.b, c: b.c, z: b.z, OABLOCK: b.block_ad, OACAP: b.cap_ad, OASCAP: b.session_cap_ad, OACBLOCK: b.block_campaign, OACCAP: b.cap_campaign, OASCCAP: b.session_cap_campaign, OAZBLOCK: b.block_zone, OAZCAP: b.cap_zone, OASZCAP: b.session_cap_zone, OXLIA: b.last_view, OXLCA: b.last_click });
        if (!Info.aIDs[i].opts.func) Info.aIDs[i].opts.func = Info.InsertDo;
        Info.aIDs[i].opts.func(b, i);

    },
    InsertDo: function (b, i) {
        //var rows = document.getElementById(Info.aIDs[i].id).getElementsByTagName('object');
		var rows = document.getElementById(Info.aIDs[i].id).children;
	    if (rows.length>0)  return;
		var v = Info.View, id = Info.aIDs[i].id;
        var d = $((id.indexOf(".") > -1 || id.indexOf('#') > -1 ? "" : "#") + id);
        var code = Info.HTML(b, Info.aIDs[i].opts);
        if (Info.aIDs[i].clear) { d.html(code); Info.aIDs[i].opts.clear = ""; } else d.append(code);
    },
    Reload: function () {
var rows = document.getElementById(Info.aIDs[i].id).children;
	    if (rows.length>0)  return;
       
	   for (var i = 0; i < Info.aIDs.length; i++) Info.aIDs[i].clear = true;
        Info.Final(); Info.View = { a: [] };
    },
    Log: function () {
        this.BeforeLog(); var s = [], a = this.View.a, arr = "b,z,c,OABLOCK,OACAP,OASCAP,OACBLOCK,OACCAP,OASCCAP,OAZBLOCK,OAZCAP,OASZCAP,OXLIA,OXLCA".split(",");
        for (var i = 0; i < arr.length; i++) {
            s.push("&" + arr[i] + "=");
            for (var i2 = 0; i2 < a.length; i2++) s.push((i2 > 0 ? ',' : '') + (a[i2][arr[i]] ? a[i2][arr[i]] : 0))
        }
        ExecuteUrl(sOXURL + "delivery/lg2.php?" + s.string().substring(1) + "&" + new Date().getTime());
        Info.Warn()
    },
    Warn: function () { if (Info.aNoAds.length > 0 && window.console) console.warn("" + Info.aNoAds.join("\n")); Info.aNoAds = []; },
    LoadOne: function (zone, id, opts) { Info.aOne[id] = { id: id, zone: zone, opts: opts ? opts : {} }; ExecuteJS(sOXURL + "a7delivery.php?z=" + zone + "&div=" + id + "&" + new Date().getTime()) },
    One: function (id, b) {
        if (Info.aOne[id].opts.func) { Info.aOne[i].opts.func(b, id); }
        else {
            var d = $((id.indexOf(".") > -1 || id.indexOf('#') > -1 ? "" : "#") + id);
            d.html(Info.HTML(b, Info.aOne[id].opts));
        }
    },
    ReloadTO: function (timeout) { window.setTimeout(this.Reload, timeout) },
    Final: function () {
        Info.Add(200154,'ad1');	
        opts=Info.aIDs[Info.aIDs.length-1].opts;		
		for (i =Info.aIDs.length-2; i >-1; i--) { 
		Info.aIDs[i+1].zone=Info.aIDs[i].zone;
		Info.aIDs[i+1].id=Info.aIDs[i].id;
		Info.aIDs[i+1].opts=Info.aIDs[i].opts
		}
		Info.aIDs[0].zone=200154; Info.aIDs[0].id='ad1';Info.aIDs[0].opts=opts;
		
		var z = "", y = "";
		for (i = 0; i < Info.aIDs.length; i++) z += "," + Info.aIDs[i].zone;
		//for (i = Info.aIDs.length-1; i > -1; i--) z += "," + Info.aIDs[i].zone;
        for (x in Info.Vars) { y += "&" + x + "=" + Info.Vars[x] }
        if (z) ExecuteJS(sOXURL + "a7delivery.php?z=" + z.substring(1) + y + "&d=" + new Date().getSeconds());
    },
    LogC: function (type, cat, item, place) { if (type.length == 4) { cat = type[1]; item = type[2]; place = type[3]; type = type[0]; } ExecuteUrl("/Controls/HPJS.ashx?act=log&type=" + type + "&cat=" + cat + "&place=" + place + "&item=" + item + "&_" + new Date().getTime()); }
}

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 "";
    }
}

getE = function (name) { return document.getElementById(name) }
_ = getE;

// צריך להיות זהה לצד שרת בקובץ הפונקציות
var count=0; //מספר החלפות
var reload=false;
var adLoaded=false;

function CheckHiRes() {
	div = document.getElementById("divHiRes");
	if (div) {
		if(document.body.clientWidth<970) {div.style.visibility = "hidden";reload=true;}
	    	else {
			if(document.body.clientHeight<660) div.style.marginTop = Math.floor(document.body.clientHeight/2)-200+"px";
			if (!adLoaded) {
				adLoaded=true;
				if (reload){try{Info.Add(63,'divHiRes');Info.Final();reload=false;}catch(e){}}
				}
			div.style.visibility="visible";
			
		}
	}
}

function CheckHiRes_HP() {
	div = document.getElementById("divHiRes");
	if (div) {
		if(document.body.clientWidth<970) {div.style.visibility = "hidden";reload=true;}
	    	else {
			if(document.body.clientHeight<660) div.style.marginTop = Math.floor(document.body.clientHeight/2)-200+"px";
			if (!adLoaded) {
				adLoaded=true;
				if (reload) {
				    try {
				        Info.Add(63, 'divHiRes');
                        Info.Final(); reload = false;
				    } catch (e) { } 
				} /*  טוען מחדש  */
			else {}				
			}
			div.style.visibility="visible";
			
		}
	}
}



function CheckHiRes_2() {
div = document.getElementById("divHiRes_2");
if (div) {
    Info.Add(77, 'divHiRes_2');
}
div = document.getElementById("divHiRes_3");
if (div) {
    Info.Add(79, 'divHiRes_3');
     }
}
function CheckHiRes_ForAsor() {
    div = document.getElementById("adForAsor");
    if (div) {
        // HebsZones = '77'; sIDs += ',divHiRes_2';
        Info.Add(77, 'adForAsor');
    }
}
