function zapamietaj(numer,idk){	
new Ajax.Updater('mem_' + numer, 'ajax.php?mod=porownywarka&action=zapamietaj&produkt=' + numer +'&idk='+ idk , {asynchronous:true, evalScripts:true});	
}

function zapomnij(numer,idk){	
new Ajax.Updater('mem_' + numer, 'ajax.php?mod=porownywarka&action=zapomnij&produkt=' + numer +'&idk='+ idk , {asynchronous:true, evalScripts:true});	
}

function chiphome(numer,idk){	
$("chip_home").innerHTML = '<div class="dvchip"><img src="ajax/img/loadb.gif" width="220" height="60" border="0"></div>';
new Ajax.Updater('chip_home', 'ajax.php?mod=adopcja&action=chips&produkt=' + numer +'&idk='+ idk , {asynchronous:true, evalScripts:true});	
}



function nchip(numer,idk){	
$("chip_home").innerHTML = "<div class='dvchip' align='center'><img src='system/ajax/img/loadc.gif' width='100' height='9' border='0' style='padding-top:50px;'></div>";
new Ajax.Updater('chip_home', 'ajax.php?mod=home2&action=nchip&produkt=' + numer +'&idk='+ idk , {asynchronous:true, evalScripts:true});	
}



// do usuniecia
popup="";
function oknop(arg,x,y)
{
if (popup.closed == false) {popup.close()} else {}
popup=window.open(arg,'szczegoly','toolbar=0,location=0,direction=0,status=0,resize=0,menubar=0,scrollbars=1,width='+x+',height='+y);
}


function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}


function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); 
  if (skew > 0) 
    date.setTime (date.getTime() - skew);
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}


function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}




/*
function showHide(inID) {
     if (document.getElementById(inID).style.display == 'none') {
          document.getElementById(inID).style.display = 'block';
     } else {
          document.getElementById(inID).style.display = 'none';
     }
}
*/

  



function showHide(inID) {
     if (document.getElementById(inID).style.display == 'none') {
          //Effect.Appear(inID);
          Effect.BlindDown(inID);
     } else {
     //Effect.Fade(inID);
       Effect.BlindUp(inID);
     }
}



function cookieSet(ID,wartosc)
{
           var ID;
           var wartosc;
           var s;
           var tt;
           var tx;
         for (s=1; s<9; s++) {
         tt="a" + s;
		document.getElementById(tt).className = 'mlevel';	
		}
	
	   document.getElementById("wojewod").className = 'podswietl';
	
	tx="a" + wartosc;
	
        document.getElementById(tx).className = 'xlevel';
        
        document.cookie="cook"+ID+"="+wartosc;
            

}




function taaber() {

	this.defaults = {
		
		id: null,
		active: 1,
		interval: null,
		wait: null,
		persist: null,
		tabclass: 'tab',
		activeclass: 'active',
		callback: null,
		leavecallback: null
	
	};
	
	this.activebackup = null;
	
	for (var n in arguments[0]) { this.defaults[n]=arguments[0][n]; };	
	
	this.getTabs = function() {
        	
        var retnode = [];
        var elem = document.getElementById(this.defaults.id).getElementsByTagName('*');
		
		var regexp = new RegExp("(^|\\s)" + this.defaults.tabclass.replace(/\-/g, "\\-") + "(\\s|$)");
	
        for (var i = 0; i < elem.length; i++) {
			if (regexp.test(elem[i].className)) retnode.push(elem[i]);
        }
    
        return retnode;
    
    };
	
	this.links = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('a');
	this.listitems = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('li');
	
	this.show = function(number) {
        
        for (var i = 0; i < this.tabs.length; i++) {
			
			this.tabs[i].style.display = ((i+1)==number) ? 'block' : 'none';
				
			if ((i+1)==number) {
				this.addClass(this.links[i], this.defaults.activeclass);
				this.addClass(this.listitems[i], this.defaults.activeclass);
			} else {
				this.removeClass(this.links[i], this.defaults.activeclass);
				this.removeClass(this.listitems[i], this.defaults.activeclass);
			}
		
		}
		
		
		if (this.defaults.leavecallback && (number != this.activebackup)) this.defaults.leavecallback(this.defaults.active);
		
		this.activebackup = number;
		
		
		this.defaults.active = number;
		
		if (this.defaults.callback) this.defaults.callback(number);
		
    
    };
	
	this.rotate = function(interval) {
    
        this.show(this.defaults.active);
        this.defaults.active++;
    
        if (this.defaults.active > this.tabs.length) this.defaults.active = 1;
    
	
        var self = this;
		
		if (this.defaults.wait) clearTimeout(this.timer2);
		 
        this.timer1 = setTimeout(function(){self.rotate(interval);}, interval*1000);
    
    };
	
	this.next = function() {
		
		this.defaults.active++;
    	if(this.defaults.active > this.tabs.length) this.defaults.active = 1;
		this.show(this.defaults.active);
	
	};
	
	this.previous = function() {
		
		this.defaults.active--;
    	if(!this.defaults.active) this.defaults.active = this.tabs.length;
		this.show(this.defaults.active);
	
	};
	
	this.gup = function(name) {
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp( regexS );
		var results = regex.exec( window.location.href );
		if (results == null) return null;
		else return results[1];
	};
	
	this.parseurl = function(tabinterfaceid) {
		
		var result = this.gup(tabinterfaceid);
		
		if (result==null) return null;
		if (parseInt(result)) return parseInt(result); 
		if (document.getElementById(result)) {	
			for (var i=0;i<this.tabs.length;i++) {
				if (this.tabs[i].id == result) return (i+1);
			}
		}
		
		return null;
		
	};

	this.createCookie = function(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	};
	
	this.readCookie = function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	};
	
	this.contains = function(el, item, from) {
		return el.indexOf(item, from) != -1;
	};
	
	this.hasClass = function(el, className){
		return this.contains(el.className, className, ' ');
	};
	
	this.addClass = function(el, className){
		if (!this.hasClass(el, className)) el.className = (el.className + ' ' + className).replace(/\s{2,}/g, ' ').replace(/^\s+|\s+$/g, '');
	};
	
	this.removeClass = function(el, className){
		el.className = el.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
		el.className.replace(/\s{2,}/g, ' ').replace(/^\s+|\s+$/g, '');
	};


	this.tabs = this.getTabs();
	this.defaults.active = (this.parseurl(this.defaults.id)) ? this.parseurl(this.defaults.id) : this.defaults.active;
	if (this.defaults.persist && this.readCookie(this.defaults.id)) this.defaults.active = this.readCookie(this.defaults.id);  
	this.activebackup = this.defaults.active;
	this.show(this.defaults.active);
	
	var self = this;
	for (var i = 0; i < this.links.length; i++) {
	this.links[i].customindex = i+1;
	this.links[i].onclick = function(){ 
		
		if (self.timer1) clearTimeout(self.timer1);
		if (self.timer2) clearTimeout(self.timer2); 
		
		self.show(this.customindex);
		if (self.defaults.persist) self.createCookie(self.defaults.id, this.customindex, 0);
		
		if (self.defaults.wait) self.timer2 = setTimeout(function(){self.rotate(self.defaults.interval);}, self.defaults.wait*1000);
		
		return false;
	};
    }
	
	if (this.defaults.interval) this.rotate(this.defaults.interval);
	
};







function sack(file) {
	this.xmlhttp = null;

	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createAJAX();
}



var ajax = new sack();

function getCityList(sel)
{
 
 
	var countryCode = sel.options[sel.selectedIndex].value;

	document.getElementById('ad_rasa').options.length = 0;	
	if(countryCode.length>0){
		ajax.requestFile = 'getCities.php?countryCode='+countryCode;	
		ajax.onCompletion = createCities;
		ajax.runAJAX();	
	}
}

function getCityListEdit(sel,wel)
{
 
 
	var countryCode = sel;
	var rasaw = wel;
	
	document.getElementById('ad_rasa').options.length = 0;	

  
	    ajax.requestFile = 'getCities.php?rasab=' + rasaw +'&countryCode='+countryCode;
		ajax.onCompletion = createCities;	
		ajax.runAJAX();		
	
}


function getMiastoListEdit(asel,awel)
{
 
 
	var acountryCode = asel;
	var arasaw = awel;
	
	document.getElementById('ad_city').options.length = 0;	

   
	    ajax.requestFile = 'getMiasta.php?rasab=' + arasaw +'&countryCode='+acountryCode;
		ajax.onCompletion = createCitiesM;	
		ajax.runAJAX();		
	
}




function getMiastoList(sel)
{
 
 
	var countryCode = sel.options[sel.selectedIndex].value;

	document.getElementById('ad_city').options.length = 0;
	if(countryCode.length>0){
		ajax.requestFile = 'getMiasta.php?countryCode='+countryCode;	
		ajax.onCompletion = createCitiesM;	
		ajax.runAJAX();	
	}
}






function createCitiesM()
{
	var obj = document.getElementById('ad_city');
	eval(ajax.response);
}







function createCities()
{
	var obj = document.getElementById('ad_rasa');
	eval(ajax.response);
}

		
