isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;
var path = "http://"+document.domain+"/";

function name_hover(e,v)
{
	if(v)
		//e.setAttribute("class", "name nameHA");
		e.className = "name nameHA";
	else
		//e.setAttribute("class", "name nameHN");
		e.className = "name nameHN";
}

function on_off(ob)
{
	if (document.getElementById)
	{
		if (document.getElementById(ob).style.display=='none')
		{
		document.getElementById(ob).style.display='';
		// document.location=lx;
		}
		else
		{
		document.getElementById(ob).style.display='none';
		}
	}
	if(document.layers)
	{
		if (document.layers[ob].style.display=='none')
		{
		document.layers[ob].style.display='';
		//document.location=lx;
		}
		else
		{
		document.layers[ob].style.display='none';
		}
	}
}


function SAddEvent(obj,event_t,event_f)
{
	if(typeof window.addEventListener != "undefined")
	{
		if(obj)
			obj.addEventListener(event_t, event_f, false );
		else
			window.addEventListener(event_t, event_f, false );
		return 1;
	}

	if(typeof window.attachEvent != "undefined" )
	{
		if(obj)
			obj.attachEvent("on"+event_t, event_f);
		else
			if(document.attachEvent("on"+event_t, event_f))
				window.attachEvent("on"+event_t, event_f)
		return 1;
	}
	return 0;
}

function load_jscript(plik) {
    var newscript = document.createElement("script");
    newscript.setAttribute("type", "text/javascript");
    newscript.setAttribute("src", plik); // + ".js"
    document.getElementsByTagName("head")[0].appendChild(newscript);
}

function getelement(id)
{
if (isNS4)
	{
		elm = document.layers[id];
	    //elm.document.open();
        //elm.document.write(totalprice);
        //elm.document.close();
        if (!elm)
			elm = false;
	}
	else 
		if (isIE4) 
		{
			elm = document.all[id];
			//elm.innerText = totalprice;
			if (!elm)
		        elm = false;
		}
		else 
			if (isIE5)
			{
				elm = document.getElementById(id);
				if (!elm)
		       		elm = false;
			}
			else 
				if (isNS6)
				{
					elm = document.getElementById(id);
					if (!elm)
		        		elm = false;
					
				}

	return elm;
}


	SAddEvent(null,"click",myclick);

	var old_radio;
	function myclick(event)
	{
		/*type - this property indicates the type of event.
		target - this property indicates the object to which the event was originally sent.
		srcElement - this property indicates the object to which the event was originally sent.
		*layerX - the cursor location when the click event occurs.
		*layerY - the cursor location when the click event occurs.
		*pageX - the cursor location when the click event occurs.
		*pageY - the cursor location when the click event occurs.
		*screenX - the cursor location when the click event occurs.
		*screenY - the cursor location when the click event occurs.
		which - 1 represents a left mouse click and 3 a right click.
		modifiers - lists the modifier keys (shift, alt, ctrl, etc.) held down when the click event occurs.*/
		var el;
		el = event.target ? el = event.target : event.srcElement;
		if(el.tagName == "INPUT" && el.type == "radio")
		{
			switch(el.name)
			{
				case "show_text":
				{
					var radio = getelement(el.id.replace("show_",""));
					radio.style.display = "";
					if(!old_radio)
						old_radio = getelement("0");
					if(old_radio)
						old_radio.style.display = "none";
		
					old_radio = radio;
				}
					break;
				case "":
					break;
			}
			
		}
	}
	
function moveXbySlicePos2 (x, img) {
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) { x += img.x; alert(x);}
	return x;
}

function moveYbySlicePos2 (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.y >= 0) y += img.y;
	return y;
}


	SAddEvent(null,"load",myinit);	

	function myinit()
	{
		var x1 = document.getElementById("c_center");
		var x2 = document.getElementById("article");
		if(x2)
		{
			//var x3 = moveYbySlicePos2(0,x1)+x1.clientHeight;
			//alert((x1.clientHeight-(x2.clientHeight+5))+" "+x1.clientHeight+"-"+(x2.clientHeight+5));
			x2.style.marginTop = (x1.clientHeight-(x2.clientHeight+139))+"px";
			x2.style.width = x1.clientWidth+"px";
			//x2.style.marginLeft = moveXbySlicePos2(0,x1)+"px";
			//x1.style.paddingBottom = x2.clientHeight+"px";
		}
		
		
		/*if(getelement("lastbuy"))
		{
			
		}*/
	}

	

SAddEvent(null,"mouseover",slidemouseover);
SAddEvent(null,"mouseout",slidemouseoutr);

var image_slide_panelL;
var image_slide_panelR;
var image_slide_panelC;
var old_imgX=0,old_imgY=0;
var over_img;
var img_reload = false;
function slidemouseover(event)
{
	var el;
	el = event.target ? el = event.target : event.srcElement;
	if(el.tagName == "IMG" && !img_reload)
	{
		/*var sparent = el.parentNode;
		while(sparent.tagName != "DIV")
		{
			sparent = sparent.parentNode;
		}
		alert(sparent);*/
		var img_parent = el.parentNode;
		var img = el;
		if(img.title == "tbm")
		{
			if(!image_slide_panelL)
			{
				var newdiv_c=document.createElement("div");
				var newdiv_l=document.createElement("div");
				var newdiv_r=document.createElement("div");
				var newtext=document.createTextNode("Loading...");
				
				newdiv_c.className = "image_isp";
				newdiv_l.className = "image_isp_left";
				newdiv_r.className = "image_isp_right";

				var pm = document.body;
				pm.insertBefore(newdiv_l,pm.firstChild); 
				pm.insertBefore(newdiv_r,pm.firstChild); 
				pm.insertBefore(newdiv_c,pm.firstChild); 
				newdiv_c.appendChild(newtext) //append new div to another div
				
				image_slide_panelL = newdiv_l;
				image_slide_panelR = newdiv_r;
				image_slide_panelC = newdiv_c;
				image_slide_panelC.style.width = img.clientWidth+"px";
				
				SAddEvent(image_slide_panelL,"click",image_slide_clickL);
				SAddEvent(image_slide_panelR,"click",image_slide_clickR);
			}
			else
			{
				image_slide_panelL.style.display = "";
				image_slide_panelR.style.display = "";
			}
			
			//moveXbySlicePos2(0,img);
			//moveYbySlicePos2(0,img);
			//clientWidth;
			//c = (clientHeight/2)-(newdiv_c.clientHeight/2);
			if(old_imgX != img.clientWidth && old_imgY != img.clientHeight)
			{
				over_img = img;
				image_slide_panelL.style.left = 1+moveXbySlicePos2(0,img)+"px";
				image_slide_panelL.style.top = (moveYbySlicePos2(0,img)+(img.clientHeight/2)-(image_slide_panelL.clientHeight/2))+"px"; //
				image_slide_panelR.style.left = 1+moveXbySlicePos2(0,img)+"px";
				image_slide_panelR.style.top = (moveYbySlicePos2(0,img)+(img.clientHeight/2)-(image_slide_panelR.clientHeight/2))+"px"; //
				image_slide_panelR.style.marginLeft = (img.clientWidth-image_slide_panelR.clientWidth)+"px"; //
				image_slide_panelC.style.left = image_slide_panelL.style.left;
				image_slide_panelC.style.top = image_slide_panelL.style.top;
				image_slide_panelC.style.width = img.clientWidth+"px";
				image_slide_panelC.style.display = "none";
			}
		}
	}
	
	if(el.tagName == "DIV")
	{
		if(el.className == "image_isp_left" || el.className == "image_isp_right")
		{
			image_slide_panelL.style.display = "";
			image_slide_panelR.style.display = "";
		}
	}
}

function slidemouseoutr(event)
{
	var el;
	el = event.target ? el = event.target : event.srcElement;
	if(el.tagName == "IMG")
	{
		var img_parent = el.parentNode;
		var img = el;
		if(img.title == "tbm")
		{
			if(image_slide_panelL)
			{
				image_slide_panelL.style.display = "none";
				image_slide_panelR.style.display = "none";
			}
		}
	}
	if(el.tagName == "DIV")
	{
		if(el.className == "image_isp_left" || el.className == "image_isp_right")
		{
			image_slide_panelL.style.display = "none";
			image_slide_panelR.style.display = "none";
		}
	}
}

function image_slide_clickL()
{
	img_reload = true;
	image_slide_panelC.style.display = "";
	system_i.push_last(new Array(path+"slide/index.php","img="+over_img.src+"&slaid=next",reload_img));
}

function image_slide_clickR()
{
	img_reload = true;
	image_slide_panelC.style.display = "";
	system_i.push_last(new Array(path+"slide/index.php","img="+over_img.src+"&slaid=prev",reload_img));
}

function reload_img(xml_val)
{
	image_slide_panelC.style.display = "none";
	var tree = xml2json.parser(xml_val,"",false);
	over_img.src = tree.imagelist.img.src;
	img_reload = false;
}



function TSystem()
{
	var process_list;
	var process_exec_status;
	var interval;
	
	this.process_list = new Array();
	this.exec_status = true;
}

TSystem.prototype.push_last = function() {
    var n = this.process_list.length >>> 0;
    for(var i = n; i > 0; i--)
    {
    	//alert(n+" do "+(n+1)+" "+this.process_list[n]+" << "+this.process_list[n-1])
    	this.process_list[i] = this.process_list[i-1];
    }
    this.process_list[0] = arguments[0];
    this.process_list.length = n+1;
    //return n;
    this.proces_top();
};

TSystem.prototype.pop_first = function() {
    var n = this.process_list.length >>> 0, value;
    //alert(n+" x"+this.process_list)
    if (n) {
	value = this.process_list[--n];
	delete this.process_list[n];
    }
    this.process_list.length = n;
    return value;
};

TSystem.prototype.process_timer = function() {
	if(this.process_list.length > 0 && this.exec_status)
		this.proces_exec();
	else
		return 0;
}

TSystem.prototype.proces_exec = function() {
	
	this.exec_status = false;
	var tablica = this.pop_first();
	//this.makeRequest_post("http://new.e-niespodzianka.pl/index.php", null, null, "");
	this.makeRequest_post(tablica[0], null, null, tablica[1], tablica[2]);
	var self = this;
	this.exec_status = true;
	//setTimeout(function(){self.process_timer();},1550);
}

TSystem.prototype.proces_top = function()
{
	var self = this;
	if(self.interval)
	{
		clearInterval(self.interval);
	}
	self.interval = setInterval(function(){self.process_timer();},100);
}

TSystem.prototype.makeRequest_post = function(url,load_handle_m,load_handle_info_m,params, return_data)
{
	var self = this;
	load_handle = load_handle_m;
    load_handle_info = load_handle_info_m;
    	
    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                //http_request.overrideMimeType('text/html, text/xml');
                http_request.overrideMimeType('text/html');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Poddaje się :( Nie mogę stworzyć instancji obiektu XMLHTTP');
            return false;
        }
        //document.getElementById(load_handle_info).innerHTML = "Load";
        if(load_handle != null)
        	getelement(load_handle_info).innerHTML = "Load";
        /*http_request.onreadystatechange = alertContents;*/
        http_request.onreadystatechange = function() { self.alertContents(return_data); };
        http_request.open('POST', url, true);
        http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        http_request.send(params);

}

var partId = 1;
TSystem.prototype.alertContents = function(contener)
{
//5.01 wywala tu blad
//var regexp1 = /<script(.|\n)*?>(.|\n|\r\n)*?<\/script>/ig;
//var regexp2 = /<script(.|\n)*?>((.|\n|\r\n)*)?<\/script>/im;
        			
	if (http_request.readyState == 4) {
    	if (http_request.status == 200) {
                
               contener(http_request.responseText);
            } else {
                alert('Wystąpił problem z zapytaniem.');
            }
        }
        else
        {
        	/*switch(http_request.readyState)
        	{
        		case 0: wartosc = "niezainicjowane";
        			break;
        		case 1: wartosc = "w trakcie pobierania";
        			break;
        		case 2: wartosc = "pobrano";
        			break;
        		case 3: wartosc = "interaktywne";
        			break;
        	}*/
        }
}

function gotolink(url)
{
	window.location.href = url;
}

var system_i = new TSystem();

/*TSugs*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('4 H=5(){4 8=5(){4 3=6;4 r,y,s,7,f,B,h=u;3.r=J 12();3.h=S;Y(u,"10",5(e){3.a(e)})};8.k.a=5(e){4 3=6;4 9;g(!3.7){3.7=18("7");3.7.F=5(){3.h=z;3.B=E.1f(5(){3.d()},1l,z)}}9=e.M?9=e.M:e.1d;g(9.1c=="1a"&&9.1b=="D"&&9.n.w>0){g(3.r[9.n]){3.c(3.r[9.n]);1g}g(3.f==u)3.f=v.K("1k")[\'1i\'];g(3.s==u){3.s=v.K("19")[0]}g(3.y!=u){3.s.L(3.y)}4 p=v.N("Z");p.A("W","X/11");p.A("17","16-15-2");p.A("13",14+"1j/1r.1m?q="+9.n);3.s.G(p);3.y=p}};8.k.b=5(l){4 3=6;3.r[l[0]]=l[1];3.c(3.r[l[0]])};8.k.c=5(l){4 3=6;4 c=3.7.1p;4 i=c.w;3.7.m.C="";O(4 x=0;x<i;x++){3.7.L(c[0])}g(l.w>0){O(4 x=0;x<l.w;x++){4 j=v.N("1s");j.V=l[x][0];j.m.1n="1o%";j.1u=5(e){3.Q(e,6)};j.1v=5(e){3.P(e,6)};j.F=5(e){3.T(e,6)};j.m.1A="1y";3.7.G(j)}}1w{3.7.m.C="U"}};8.k.d=5(){4 3=6;g(3.h)3.7.m.C="U"};8.k.Q=5(e,o){4 t=6;t.f.1t.n=t.f.D.n;t.f.D.n=o.V;t.f.1q()};8.k.P=5(e,o){4 t=6;t.h=S;t.I();o.m.R="#1z"};8.k.T=5(e,o){4 t=6;t.h=z;o.m.R="#1h"};8.k.I=5(){4 t=6;E.1e(t.B)};E.1x=J 8()};H();',62,99,'|||_this|var|function|this|s3|Ts|el|||||||if|||ds|prototype|xv|style|value||jc||oq|he||null|document|length||sc|true|setAttribute|to|visibility|search|window|onmouseout|appendChild|tsug|si|new|getElementsByTagName|removeChild|target|createElement|for|mcb|mca|backgroundColor|false|mcc|hidden|innerHTML|type|text|SAddEvent|SCRIPT|keyup|javascript|Array|src|path|8859|ISO|charset|getelement|HEAD|INPUT|name|tagName|srcElement|clearTimeout|setTimeout|return|fff|searchForm|sugestion|FORM|1000|php|width|100|childNodes|submit|index|div|osearch|onclick|onmouseover|else|sugs|pointer|eee|cursor'.split('|'),0,{}))

/*shObj*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('K 3=L.3=6(){8 M 3.w.m()};3.5=3.w={m:6(){2.p()},J:6(l){2.b=0;7(2.4){7(2.4==v("t"+l))8 n;x 2.i(2.4)}2.4=v("t"+l);2.E(2.4);7(2.4){2.m();2.g(2.4,"I",2.r);2.g(2.4,"H",2.q);2.c=0;2.j()}},k:6(u){2.b=u},N:6(){8 2.4;Q(2.b+"--")},g:6(o,z,f){7(o.s){o.s(z,f,n)}x{o.T("U"+z,f)}},q:6(e){3.5.k(0);R(3.5.C)},r:6(e){3.5.k(1)},j:6(S){7(!3.5.4)8 n;3.5.4.a.d=3.5.c/y;3.5.4.a.B=\'F(d=\'+3.5.c*y+\')\';7(3.5.c++<9){h(3.5.j,D)}},E:6(4){7(!4)8 0;4.a.d=0;4.a.B=\'F(d=\'+0+\')\';4.a.G=""},i:6(4){7(!4)8 0;4.a.G="P";2.b=0},p:6(){7(3.5.b==1){3.5.C=h(3.5.A,D)}h(3.5.p,O)},A:6(){3.5.i(3.5.4);3.5.4=V}}',58,58,'||this|shObj|obj|fn|function|if|return||style|off|value_0|opacity|||AddEvent_m|setTimeout|setToStop|StartShow_a|SetInfoMouse|id|init|false||idle|sh_mouseover|sh_mouseout|addEventListener|sd_|nr|getelement|prototype|else|10||HideDesc|filter|stop_i|50|setToStart|alpha|display|mouseover|mouseout|ShowDesc|var|window|new|Spr|1000|none|alert|clearTimeout|val|attachEvent|on|null'.split('|'),0,{}));
