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;

if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
   // document.onmouseclick = captureMouseclick;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
    //document.onmouseclick = captureMouseclick;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
    //document.onmouseclick = captureMouseclick;
}


function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
        silnik = "NC";
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position
        // reflects the position from the top/left of the screen the
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no
        // matter if the user has scrolled or not.
        //xMousePos = window.event.x;//+document.body.scrollLeft;
        //yMousePos = window.event.y+document.body.scrollTop;
        
        
        if (document.documentElement && document.documentElement.scrollTop)
        {
        	xMousePos=window.event.x+document.documentElement.scrollLeft;
        	yMousePos=window.event.y+document.documentElement.scrollTop;
        	xMousePosMax = document.body.clientWidth+document.documentElement.scrollLeft;
        	yMousePosMax = document.documentElement.clientHeight+document.documentElement.scrollTop;;
        	silnik = "IE";
        	
        }
        else
        {
        	xMousePos=window.event.x+document.body.scrollLeft;
        	yMousePos=window.event.y+document.body.scrollTop;
        	xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
       		yMousePosMax = document.documentElement.clientHeight;
       		silnik = "IE"; //napewno 6
        }
            
     //   xMousePos = window.event.x+document.body.scrollLeft;
     //   yMousePos = window.event.y+document.body.scrollTop;
        
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
        silnik = "FF";
    }
    
    if (document.layers)
			{
			}
			else
			if (document.all)
			{
				if (document.documentElement && document.documentElement.scrollTop)
			 	{
			 		events_my = window.event;
			 	}
			 	else
			 	{
			 		events_my = window.event;
				 }
			}
			else
			if (document.getElementById)
			{
			// Netscape 6 behaves the same as Netscape 4 in this regard
			// FF
				events_my = e;
			}
			
		if(silnik == "FF")
 		{
		 	obj_click = events_my.originalTarget;
		}
		if(silnik == "IE")
		{
			obj_click = events_my.srcElement;
		}
		
		/*if(obj_click)
			alert(obj_click);*/
}

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;
}

/*-----------------------------------------------------
var ar1 = new Array();//("11", "12", "13", "14", 15)
			ar1.push_last("16");
			ar1.push_last("17");
            document.write(ar1.pop_first())
            document.write(ar1.pop_first())
-----------------------------------------------------*/

Array.prototype.push_last = function() {
    var n = this.length >>> 0;
    for(var i = n; i > 0; i--)
    {
    	this[n] = this[n-1];
    }
    this[0] = arguments[0];
    this.length = n+1;
    return n;
    /*for (var i = 0; i < arguments.length; i++) {
	this[n] = arguments[i];
	n = n + 1 >>> 0;
    }
    this.length = n;
    return n;*/
};

Array.prototype.pop_first = function() {
    var n = this.length >>> 0, value;
    if (n) {
	value = this[--n];
	delete this[n];
    }
    this.length = n;
    return value;
};

/*window.google=
{
	kEI:"Y2Q3R_eKKoykwgGlwpiZCw",kEXPI:"17259,17735",kHL:"pl"
};*/

//window.clk=function(b,c,d,e,f,g)
function clk(b,c,d,e,f,g)
{
	if(document.images)
	{
		var a=encodeURIComponent||escape;
		(new Image).src="/url.php?sa=T"+(c?"&oi="+a(c):"")+(d?"&cad="+a(d):"")+"&ct="+a(e)+"&cd="+a(f)+(b?"&url="+a(b.replace(/#.*/,"")).replace(/\+/g,"%2B"):"")+"&ei=Y2Q3R_eKKoykwgGlwpiZCw"+g
//		alert("/url.php?sa=T"+(c?"&oi="+a(c):"")+(d?"&cad="+a(d):"")+"&ct="+a(e)+"&cd="+a(f)+(b?"&url="+a(b.replace(/#.*/,"")).replace(/\+/g,"%2B"):"")+"&ei=Y2Q3R_eKKoykwgGlwpiZCw"+g);
//		document.innerHTML = "/url.php?sa=T"+(c?"&oi="+a(c):"")+(d?"&cad="+a(d):"")+"&ct="+a(e)+"&cd="+a(f)+(b?"&url="+a(b.replace(/#.*/,"")).replace(/\+/g,"%2B"):"")+"&ei=Y2Q3R_eKKoykwgGlwpiZCw"+g
	}
	return true; 
};

function on_off(ob)
{
	var obj = getelement(ob);
	if(obj)
	{
		if(obj.style.display == "none")
			obj.style.display = "";
		else
			obj.style.display = "none";
	}
}

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

	return elm;
}

	function findPos(obj)
	{
		var curleft = curtop = 0;
		var curw = curh = 0;
		if (obj.offsetParent)
		{
			curleft = obj.offsetWidth;
			curtop = obj.offsetTop;
			curw = obj.offsetWidth;
			curh = obj.offsetHeight;
			while (obj = obj.offsetParent)
			{
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			}
		}
		else
		{
			curleft = obj.offsetWidth;
			curtop = obj.offsetTop;
			curw = obj.offsetWidth;
			curh = obj.offsetHeight;
			
		}
	return [curleft,curtop,curw,curh];
	}
	
	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;
	}

	
	//var preImages = new Image();
	function show_img(obj,nr)
	{
		/*var tabelkaX = moveXbySlicePos2(0,obj);
		var tabelkaY = moveYbySlicePos2(0,obj);
		if(nr == 1)
		{
			var divek = getelement("show_img");
			var preImages = getelement("show_img2");
			
			preImages.src = obj.firstChild.src.replace("min-","");
			preImages.style.width = "250px";
			//preImages.style.height = "200px";
			divek.style.left = tabelkaX+"px";
			divek.style.top = tabelkaY+"px";
			divek.style.display = "";
		}
		else
		{
			
		}
		//alert(obj.firstChild.src);*/
	}
