/**
 * Funkcja getMouseXY() pobiera informacje o polozeniu myszki na ekranie 
 * 
 * @return Zwraca wspólzedne XY
 
 */// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all ? true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)


function insertFlash() {
	var toWrite = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="335" height="480" id="banner" align="middle">';
	toWrite += '<param name="allowScriptAccess" value="sameDomain" />';
	toWrite += '<param name="movie" value="flash/banner.swf" />';
	toWrite += '<param name="quality" value="high" />';
	toWrite += '<param name="bgcolor" value="#939aac" />';
	toWrite += '<param name="wmode" value="transparent" />';
	toWrite += '<embed src="flash/banner.swf" wmode="transparent" quality="high" bgcolor="#939aac" width="335" height="480" name="banner" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	toWrite += '</object>';

	
	document.write(toWrite);
}

function insertFlashMenu() {
	var toWrite = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="85" id="menu" align="middle">';
	toWrite += '<param name="allowScriptAccess" value="sameDomain" />';
	toWrite += '<param name="movie" value="flash/menu.swf" />';
	toWrite += '<param name="quality" value="high" />';
	toWrite += '<param name="bgcolor" value="#939aac" />';
	toWrite += '<param name="wmode" value="transparent" />';
	toWrite += '<embed src="flash/menu.swf" wmode="transparent" quality="high" bgcolor="#939aac" width="600" height="85" name="menu" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	toWrite += '</object>';

	document.write(toWrite);
}

function insertCalc() {
	var toWrite = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="400" HEIGHT="320" id="calc">';
 	toWrite += '<PARAM NAME=movie VALUE="./flash/calc.swf">';
	toWrite += '<param name="quality" value="high" />';
	toWrite += '<param name="bgcolor" value="#000000" />';
	toWrite += '<param name="wmode" value="transparent" />';
	toWrite += '<EMBED src="./flash/calc.swf" quality="high" wmode="transparent" bgcolor="#000000"  WIDTH="400" HEIGHT="320" NAME="kalkulator2" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
	toWrite += '</object>';

	document.write(toWrite);
}


function show_form(div)
{
	var divv = document.getElementById(div);
	divv.style.display = 'block';
	divv.style.top = tempY;
}

function hide_form(div)
{
	var divv = document.getElementById(div);
	divv.style.display = 'none';
}

function getMousePosition(e) 
	{ 
	return e.pageX ? {'x':e.pageX, 'y':e.pageY} : {'x':e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft, 'y':e.clientY + document.documentElement.scrollTop + document.body.scrollTop}; 
	}; 
	
function showMousePos(e) {
	if (!e) e = event; 
	// make sure we have a reference to the event 
	var input = document.getElementById('mydiv'); 
	var mp = getMousePosition(e); 
	//input.style.top = mp.y;
	//input.style.left = mp.x;
	//input.innerHTML = 'x : ' + mp.x + ', y : ' + mp.y; 
	
	mousePos = new Array(mp.x,mp.y) 
	return mousePos;	
	}; 

document.onmousemove = showMousePos; 


function getPageSize(){
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;		
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	} 	
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}



function showBigImg(url, w, h) {
	psize = getPageSize();
	
	var obj = document.getElementById('big_img');
	var img_cont = document.getElementById('img_cont');
	var span = document.getElementById('img');
	
	obj.style.position = 'absolute'; 
	obj.style.width = navigator.appName == "Microsoft Internet Explorer" ? psize[0] : psize[0]-21; 
	obj.style.height=psize[1];
	
	img_cont.style.top = mousePos[1] < 200 ? 100 : mousePos[1] - h/2;
	img_cont.style.left = psize[0]/2 - w/2;
	img_cont.style.display = 'block';
	obj.style.display = 'block'; //desc_src.value

	span.innerHTML = "<img src='"+url+"' width='"+w+"' height='"+h+"'>";
}


function closeBIgImg()
{
	var obj = document.getElementById('big_img');
	if(obj.style.display == 'block'){
		obj.style.display = 'none';
		img_cont.style.display = 'none';
		document.getElementById('img').innerHTML = '';
		document.getElementById('description_place').innerHTML = '';
	}
}


/**
 * Funkcja removeAsk() wyświetla okienko z prośbą o potwierdzenie usunięcia obiektu
 * 
 * @param module Nazwa modułu z którego ma zostać usunięty obiekt
 * @param id Identyfikator obiektu, który ma zostać usunięty
 * @param question Treść końcówki pytania
 * @return Nic nie zwraca
 */

function removeAsk ( str, question )
{
    if ( confirm ( 'Czy na pewno chcesz usunąc ' + question + '?' ))
	 gotoPage ( str );
}

function removeAskSpecjal ( module, action, id, other, question )
{
    if ( confirm ( 'Czy na pewno chcesz usunąć ' + question + '?' ))
        window.open ( '?cmd=' + module + '_' + action + '&id=' + id + other , '_self' );
}

function gotoPage ( page , target)
{
   
        window.open ( page , target ? target : '_self' );
}

function popup ( url, w, h ) 
{
    wi=w*1;
	hi=h*1;
	if ( w > 600 ) 
	{
    	h = ( 600 * h ) / w;
    	w = 600;
	}
	h=(hi+20);
	w=(wi+20);
	poz_w = ( screen.width - w ) / 2;
	poz_h = ( screen.height - h ) / 2;
    window.open ( url, "new_window", "width=" + w + ",height=" + h + ",toolbar=no,directories=no,status=no,scrollbars=no,resizable=no,menubar=no,left=" + poz_w + ",top=" + poz_h );
}

function showHideContent(value)
{
	var obj =  document.getElementById('div_content');
	switch(value){
		case '1':
		      obj.style.display = 'block';
      	break;
		case '2':
		      obj.style.display = 'none';
		break;
	}
}






//-------------------------------------------------------------------------------
// Podmienia grafikę w podanym znaczniku <img>

function change ( id, image )
{
    window.document.images[id].src=image;
}


//zwija rozwija drzewo katalogowe strony
function flipTree(oImg, id)
  {
    var obj = document.getElementById(id);
    if (obj.style.display == 'block')
    {
      obj.style.display = 'none';
      oImg.src = 'img/folder_open.gif';
    }
    else
    {
      obj.style.display = 'block';
      oImg.src = 'img/folder_close.gif';
    }
    
  }


//zmiana kolejnosci wyswietlania 
  function moveDown(sId)
  {
    var oTable = document.getElementById('order_table');
    var aRows = oTable.getElementsByTagName('tr'); // zignorowac pierwszy bo to nagĹĂłwek
	
    // sprawdzamy numer wiersza dla danego id
    var iRowNr = 0;
    for (i = 1; i < aRows.length; i++)
      if (aRows[i].id.substring(11) == sId) iRowNr = i;

    // najpierw sprawdzamy czy to nie jest przypadkiem na samym dole
    if (iRowNr == aRows.length-1) return;

// zaczynamy zamienianie wierszy
    var aCellsOne = aRows[iRowNr].getElementsByTagName('td');
    var aCellsTwo = aRows[iRowNr+1].getElementsByTagName('td');
	
    for (i = 0; i < aCellsOne.length; i++)
    {
      if (i==0 || i == 7 || i == 8) continue; // omijamy kolumny ze strzalkami
      var sTmp = aCellsOne[i].innerHTML;
      aCellsOne[i].innerHTML = aCellsTwo[i].innerHTML;
      aCellsTwo[i].innerHTML = sTmp;
    }
  setOrders();
  }
  function moveUp(sId)
  {
    var oTable = document.getElementById('order_table');
    var aRows = oTable.getElementsByTagName('tr'); // zignorowac pierwszy bo to nagĹĂłwek

    // sprawdzamy numer wiersza dla danego id
    var iRowNr = 0;
    for (i = 1; i < aRows.length; i++)
      if (aRows[i].id.substring(11) == sId) iRowNr = i;
    
    // najpierw sprawdzamy czy to nie jest przypadkiem na samym dole
    if (iRowNr == 1) return;
    
    // zaczynamy zamienianie wierszy
    var aCellsOne = aRows[iRowNr].getElementsByTagName('td');
    var aCellsTwo = aRows[iRowNr-1].getElementsByTagName('td');
    
    for (i = 0; i < aCellsOne.length; i++)
    {
      if (i==0 || i == 7 || i == 8) continue; // omijamy kolumny ze strzalkami
      var sTmp = aCellsOne[i].innerHTML;
      aCellsOne[i].innerHTML = aCellsTwo[i].innerHTML;
      aCellsTwo[i].innerHTML = sTmp;
    }
	setOrders();
  }
  
  function setOrders()
  {
	  var oTable = document.getElementById('order_table');
      var aRows = oTable.getElementsByTagName('tr');
	  var aFields = oTable.getElementsByTagName('input');
	  for (i = 0; i < aRows.length; i++)
	  	aFields[i].value = (i+1);
  }
  
  
  //wyświetlanie linku do maila, zapobiegającego robotom
  <!--
  function antyRobotMail(user, host, opis)
  {	
	var dodatkowe = "";
	document.write('<A HR' + 'EF="mai' + 'lto:' + user + '\x40' + host + dodatkowe + '">');
	if (opis) document.write(opis + '<'+'/A>');
	else document.write(user + '\x40' + host + '<'+'/A>');
  }
 //-->
 
 	function showMenu(id)
    {
       var obj = document.getElementById('podstron_'+id);
	   var img = document.getElementById('pic_'+id);
		if(obj.style.display == 'none'){
        obj.style.display = 'block';
		img.src = 'img/menu/minus.gif';
		}
		else {
		obj.style.display = 'none';
		img.src = 'img/menu/plus.gif';
		}
    }
	
	var TempId=0;
	
	function showMenuH(id, top)
    {
       var obj = document.getElementById('podstron_'+id);
	   var img = document.getElementById('pic_'+id);
		if(TempId!=0 && TempId!=id){
			var root = document.getElementById('podstron_'+TempId);
			var root_img = document.getElementById('pic_'+TempId);
			root.style.display='none';
			root_img.src = 'img/menu/plus.gif';
			
		}
		if(obj.style.display == 'none'){
        obj.style.display = 'block';
		obj.style.top=top;
		obj.style.left = tempX;
		img.src = 'img/menu/minus.gif';
		}
		else {
		obj.style.display = 'none';
		img.src = 'img/menu/plus.gif';
		}
		TempId=id;
    }	
	
	function closeOpen()
	{
		if(TempId!=0){
			var root = document.getElementById('podstron_'+TempId);
			var root_img = document.getElementById('pic_'+TempId);
			root.style.display='none';
			root_img.src = 'img/menu/plus.gif';
			TempId=0;
		}
	}
	
	function showMenuOver(id)
    {
       var obj = document.getElementById('over_'+id);
       obj.style.background='#CCCCCC';
	   obj.style.color='#333333';	   
    }
	
	function showMenuOut(id)
    {
       var obj = document.getElementById('over_'+id);
       obj.style.background='#666666';
	   obj.style.color='#CCCCCC';
    }
	function showMenuClick(id)
    {
       var obj = document.getElementById('over_'+id);
	   obj.style.borderTop='1px solid #5F5353';
	   obj.style.borderBottom='1px solid #909090';
	   obj.style.borderLeft='1px solid #5F5353';
	   obj.style.borderRight='1px solid #909090';
    }	
	
	function showMenuUnClick(id)
    {
       var obj = document.getElementById('over_'+id);
	   obj.style.borderTop='1px solid #909090';
	   obj.style.borderBottom='1px solid #5F5353';
	   obj.style.borderLeft='1px solid #909090';
	   obj.style.borderRight='1px solid #5F5353';
    }		
/********************************************************************/
/************************admin***************************************/
	
	function adminMenuOver(id)
    {
	   var obj = document.getElementById('over_'+id);
	   obj.style.borderTop='1px solid #efefef';
	   obj.style.borderBottom='1px solid #909090';
	   obj.style.borderLeft='1px solid #efefef';
	   obj.style.borderRight='1px solid #909090';	
    }
	
	function adminMenuOut(id)
    {
       var obj = document.getElementById('over_'+id);
	   obj.style.border='1px solid #FFFFFF';
   
    }
	function adminMenuClick(id)
    {
       var obj = document.getElementById('over_'+id);
	   obj.style.borderTop='1px solid #5F5353';
	   obj.style.borderBottom='1px solid #efefef';
	   obj.style.borderLeft='1px solid #5F5353';
	   obj.style.borderRight='1px solid #efefef';
    }	
	
	function adminMenuUnClick(id)
    {
       var obj = document.getElementById('over_'+id);
	   obj.style.borderTop='1px solid #efefef';
	   obj.style.borderBottom='1px solid #909090';
	   obj.style.borderLeft='1px solid #efefef';
	   obj.style.borderRight='1px solid #909090';	
    }		
/********************************************************************/
/************************koniec admin********************************/	
	
	 function showMenuA(id)
    {
       var obj = document.getElementById('podstr_'+id);
	   var img = document.getElementById('pict_'+id);
		if(obj.style.display == 'none'){
        obj.style.display = 'block';
		img.src = 'img/menu/minus.gif';
		}
		else {
		obj.style.display = 'none';
		img.src = 'img/menu/plus.gif';
		}
    }
function sendVal(c_name, r_name)
{
	var input_country = document.getElementById('country');
	var input_region = document.getElementById('region');
	if(r_name==0){
		input_country.value = c_name;
		input_region.value = '';
	}
	else{
		input_country.value = c_name;
		input_region.value = r_name;
		
	}
}
	
	
	
	//MENU

function init(szer, left, top, menu_kaskad) {
	var obj = document.getElementById(menu_kaskad);
	obj.style.top=top;
	obj.style.left = ((screen.width/2)-(szer/2))+(left*1);
	obj.style.position = 'absolute'; 
	obj.style.display = 'block'; 
}

function divshow(left, top, div_id) {
	var obj = document.getElementById(div_id);
	if(obj.style.display == 'none'){
	obj.style.position = 'absolute'; 
	obj.style.top=top;
	obj.style.left=left;	
	obj.style.display = 'block'; 
	}
	else {
		obj.style.display = 'none';
	}
}

function divshowhide(div1, div2, w, h) {
	var div1 = document.getElementById(div1);
	var div2 = document.getElementById(div2);
	if(div1.style.display == 'none'){
		div1.style.display = 'block';
		div1.style.width=w;
		div1.style.height=h;
		div2.style.display = 'none';
	}
	else {
		div1.style.display = 'none';
		div2.style.display = 'none';
	}
}


function showBigImgUser(url, w, h)
{
	var obj = document.getElementById('big_img');
	var span = document.getElementById('img');
	obj.style.position = 'absolute'; 
	obj.style.top=240;
	obj.style.left=(screen.width/2)-(w/2);
	obj.style.width=(w*1)+7;	
	obj.style.height=(h*1)+22;	
	span.innerHTML = "<img src='"+url+"' width='"+w+"' height='"+h+"'>";
	obj.style.display = 'block'; 
}



function check(id){
	var obj = document.getElementById(id);
	obj.checked=true;
}

function big(lyr) { 
var obj = document.getElementById(lyr);
if(obj.style.display=='none')
	obj.style.display='block';
else
	obj.style.display='none'
}

/* small() makes selected layer shorter (height property)*/

function small(lyr) {
var obj = document.getElementById(lyr);
 obj.style.display='none';
}

function clearOthers(arr){

}

function info(info){
		var obj = document.getElementById('JSinfo');
		obj.style.position = 'absolute';
		obj.style.top=500;
		obj.style.left = ( screen.width - 100 ) / 2;
		obj.style.display = 'block'; 
		obj.innerHTML = info;
}






//przesuwanie divów po ekranie
cpdd='**********   DRAG & DROP   *********?=   '+
'Written by Bogdan Blaszczak                   '+
'homepage http://www.blatek.25.pl/javascript/'
//don't edit lines above

var selOB,glIx=0
function DragObj(w){
	with(d)this.id=g?g(w):a?a[w]:d.l[w]
	if(d.l)this.id.captureEvents(Event.MOUSEDOWN)
	this.id.onmousedown=C
	this.id.onselectstart=new Function('return false')
	 function C(e){
		 eval(st(hots,cpdd))
		 selOB.zIndex=++glIx
		 e=e||event
		 selOB.X=e.pageX?e.pageX-(d.l?this.left:this.offsetLeft):event.offsetX
		 selOB.Y=e.pageY?e.pageY-(d.l?this.top:this.offsetTop):event.offsetY
		 if(!d.l)return false//Mac?
	 }
}
function Drop(){selOB=null}
function Drag(e){
	e=e||event
	if(selOB)with(selOB){
	 left=(e.pageX?e.pageX:event.clientX+d.body.scrollLeft)-X
	 top=(e.pageY?e.pageY:event.clientY+d.body.scrollTop)-Y}
	return false;
}
hots=[124,90,118,22,59,37,55,116,118,36,110,96,43,124,100,110,96,127,124,113,62,97,50,118,94]
function st(t,h){var s='';for(var i=0;i<t.length;i++)s+=h.substr(t[i],1);return s}
function NSres(f){
if(f==true){document.dW=innerWidth;document.dH=innerHeight;onresize=NSres}
else if(innerWidth!=document.dW||innerHeight!=document.dH)location.reload()
}if(document.layers)NSres(true);

function initDrag(div_id){
d=document,
d.l=d.layers,
d.a=d.all,
d.g=d.getElementById
//zdefiniuj warstwy, które maj? być przeci?gane
new DragObj(div_id)
if(d.l)d.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP)
	d.onmousemove=Drag
	d.onmouseup=Drop
}
//koniec przsuwania

//-- !>