function pic(path) {


	var ov = $('overlay');
	var ablak_pic = $('ablak_pic');

	var lb = $('lightbox_pic');
	
	if(ov == null){
	
	var arrayPageSize = getPageSize();
		

				    bod = document.getElementsByTagName('body')[0];
					overlay	= document.createElement('div');
					overlay.id = 'overlay';
					overlay.style.display = 'none';
					
					bod.appendChild(overlay);
					$('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });
				   }
				   
				   	if(lb == null){
					bod 				= document.getElementsByTagName('body')[0];
					overlay 			= document.createElement('div');
					overlay.id			= 'lightbox_pic';
					overlay.style.display = 'none';
					bod.appendChild(overlay);
				   }
				   
	if(ablak_pic == null){
					bod = document.getElementsByTagName('body')[0];
					ablak_pic = document.createElement('div');
					ablak_pic.id = 'ablak_pic';
					ablak_pic.style.display = 'none';
					$('lightbox_pic').appendChild(ablak_pic);
					kep = document.createElement('IMG');
					
				
					//ov.appendChild(kep);

					
				   }


	
					kep.setAttribute('src' , path);
					ablak_pic.appendChild(kep);

				   
	 var arrayPageScroll = document.viewport.getScrollOffsets();
	 var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); 
	ablak_pic.style.top = ''+eval(lightboxTop+200)+'px';
				   
				  
	Effect.Appear('overlay', { duration: 0.4, to: 0.8  });

	Effect.Appear('lightbox_pic', { duration: 0.4});
	Effect.Appear('ablak_pic', { duration: 1.0});










	Event.observe('overlay', 'click', function(){ 
											Effect.Fade('overlay', { duration: 0.4 });
										
											Effect.Fade('ablak_pic', { duration: 0.4 });
											Effect.Fade('lightbox_pic', { duration: 0.4 });
										
												}
										 , false);

}



function cart(id) {

var aa = 'item_'+id;

var name = "";
var price = "";
var id = document.forms[aa].id.value;
var db = document.forms[aa].db.value;


if (db != 0 && isNaN(db) == false){

var box = $("cart");
box.update("Töltök...");

ajaxRequest = new Ajax.Request(
				'index.php',
				{
					method: 'get',
					parameters: 'a=add_cart&id=' + id + '&db=' + db,
					onComplete: function(request){cart_refresh();light_box('1');}, 
					onFailure: function(){
					alert('Valami hiba csuszott be...');
							}	
				}
			);
		}

 
}







function cart_refresh() {

ajaxRequest = new Ajax.Request(
				'index.php',
				{
					method: 'get',
					parameters: 'a=cart_refresh',
					onComplete:  function(request){cart_refresh_done(request);

								     }, 
					onFailure: function(){
					alert('Valami hiba csuszott be...');
							}	
				}
			);

}






function cart_refresh_done(request) {

var xml = request.responseXML;
var root = xml.documentElement;

var total = '';
var tetel = 0;

var box = $("cart");
var box2 = $("innertxt");
var output = '';
var inthecart = '';

var item_mess = root.childNodes[0];
var mess = getChildNodeText(item_mess, 'mess');

if (mess){
		
		box2.innerHTML = mess;
}else{

for (var i = 0; i < root.childNodes.length; i++)
				{
					var item = root.childNodes[i];
					var id = getChildNodeText(item, 'id');
					var cikkszam = getChildNodeText(item, 'cikkszam');
					var name = getChildNodeText(item, 'name');
					var price = getChildNodeText(item, 'price');
					var db = getChildNodeText(item, 'db');
					var sub_total = (price*db);
					db = eval(db);
					total = eval(total+sub_total);
					tetel = eval(tetel+db);
                    			
					
				if (name){
				
			inthecart =	"<span class=\"item_price\">"+tetel+" db</span> t&eacute;tel van a kos&aacute;rban, <span class=\"item_price\">"+total+" Ft</span> &eacute;rt&eacute;kben"; 
			 	
		 output+="<div id=\"item\"><span class=\"item_det\">"+name+"</span><label> <input name=\"textfield\" type=\"text\" class=\"item_det\" value=\""+db+"\"  id=\"db_form_" + id + "\" size=\"4\" maxlength=\"7\" /></label><span class=\"item_det\"> db <strong class=\"item_price\">"+price+" Ft/db</strong></span>		  </div>";
				
				
					
					}
				}


//output+="<br/>";
//output+="Végösszeg:" + total + " -Ft <br><br>";
//output+="<a href=\"index.php?a=static&w=cart\">Tovább a megrendeléshez</a>";
box.innerHTML = output;
box2.innerHTML = inthecart;
}

}







function cart_refresh2() {

ajaxRequest = new Ajax.Request(
				'index.php',
				{
					method: 'get',
					parameters: 'a=cart_refresh',
					onComplete:  function(request){cart_refresh_done2(request);

								     }, 
					onFailure: function(){
					alert('Valami hiba csuszott be...');
							}	
				}
			);

}






function cart_refresh_done2(request) {

var xml = request.responseXML;
var root = xml.documentElement;

var total = '';

var box = $("cart");
var output = '';

var item_mess = root.childNodes[0];
var mess = getChildNodeText(item_mess, 'mess');

if (mess){
		box.innerHTML = mess;
		
}

for (var i = 0; i < root.childNodes.length; i++)
				{
					var item = root.childNodes[i];
					var id = getChildNodeText(item, 'id');
					var cikkszam = getChildNodeText(item, 'cikkszam');
					var name = getChildNodeText(item, 'name');
					var price = getChildNodeText(item, 'price');
					var db = getChildNodeText(item, 'db');
					var sub_total = (price*db);
					total = eval(total+sub_total);
                    			
					
				if (name){
			 	
				output+=name + "<span class=\"style1\"> Ára:" + price + " Ft/db</span>   <input type=\"text\" id=\"db_form_" + id + "\" value=\"" + db + "\" class=\"item_det\" size=\"4\"> db";
				
				
				
					output+="<br/>";
					}
				}


output+="<br/>";
output+="Végösszeg:<span class=\"item_price\">" + total + " -Ft </span<br><br>";
box.innerHTML = output;

}





function cart_update() {

var db = '';
var hiba = 0;

var form_hossz = document.forms["cart_form"].length;

for(i=0; i<form_hossz; i++){
var aaa = document.forms["cart_form"].elements[i].value;
if (isNaN(aaa) == true){hiba = 1; break;}
db+=aaa+"-";
}

if (hiba != 1){

ajaxRequest = new Ajax.Request(
				'index.php',
				{
					method: 'get',
					parameters: 'a=cart_update&db=' + db,
					onComplete:  function(request){cart_refresh();}, 
					onFailure: function(){
					alert('Valami hiba csuszott be...');
							}	
				}
			);

		}

}



function cart_update2() {

var db = '';
var hiba = 0;

var form_hossz = document.forms["cart_form"].length;

for(i=0; i<form_hossz; i++){
var aaa = document.forms["cart_form"].elements[i].value;
if (isNaN(aaa) == true){hiba = 1; break;}
db+=aaa+"-";
}

if (hiba != 1){

ajaxRequest = new Ajax.Request(
				'index.php',
				{
					method: 'get',
					parameters: 'a=cart_update&db=' + db,
					onComplete:  function(request){cart_refresh2();}, 
					onFailure: function(){
					alert('Valami hiba csuszott be...');
							}	
				}
			);

		}

}















function empty_cart() {

ajaxRequest = new Ajax.Request(
				'index.php',
				{
					method: 'get',
					parameters: 'a=empty_cart',
					onComplete:  function(request){cart_refresh();

								     }, 
					onFailure: function(){
					alert('Valami hiba csuszott be...');
							}	
				}
			);

}










function loading(what,button){
		  	var button = $(button);
	                var loading = $(what);
	       		loading.update("Töltök...");
			button.disabled = true;
			var img = document.createElement("img");
			img.id = "loading";
			img.src = "images/ajaxupdating.gif";
			loading.appendChild(img);

	                
}














function getChildNodeText(element, childTagName) {
		var elements = element.getElementsByTagName(childTagName);
			if (elements.length == 0) {
				return '';
			}			
			else if (elements.item(0).textContent) {
				return elements.item(0).textContent;
			}
			else {	
			      return elements.item(0).text;
			}
} 














function getPageSize() {
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			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
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				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 = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	}














function light_box(event,path) {
 
    
	var ov = $('overlay');
	var ablak = $('ablak');
	var lb = $('lightbox');
	
	if(ov == null){
	
	var arrayPageSize = getPageSize();
		

				    bod = document.getElementsByTagName('body')[0];
					overlay	= document.createElement('div');
					overlay.id = 'overlay';
					overlay.style.display = 'none';
					
					bod.appendChild(overlay);
					$('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });
				   }
				   
				   	if(lb == null){
					bod 				= document.getElementsByTagName('body')[0];
					overlay 			= document.createElement('div');
					overlay.id			= 'lightbox';
					overlay.style.display = 'none';
					bod.appendChild(overlay);
				   }
				   
	if(ablak == null){
					bod = document.getElementsByTagName('body')[0];
					ablak = document.createElement('div');
					ablak.id = 'ablak';
					ablak.style.display = 'none';

 var arrayPageScroll = document.viewport.getScrollOffsets();
 var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); 



					ablak.style.top = ''+eval(lightboxTop+200)+'px';
					$('lightbox').appendChild(ablak);
					
					h1 = document.createElement('h1');
					ablak.appendChild(h1);
					h1.innerHTML = "A termék a kosárba került!";
					
				   }
				   
				   
				  
	Effect.Appear('overlay', { duration: 0.4, to: 0.8  });
	if (event == 0){
												var c = $('cart_a');
												c.style.zIndex = '101';
										
											}
	
	
	if (event == 1){

	 var arrayPageScroll = document.viewport.getScrollOffsets();
	 var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); 
	ablak.style.top = ''+eval(lightboxTop+200)+'px';

	Effect.Appear('lightbox', { duration: 0.4});
	Effect.Appear('ablak', { duration: 1.0});

	var n=setTimeout("out()",2000);





	}


	Event.observe('overlay', 'click', function(){ 
											Effect.Fade('overlay', { duration: 0.4 });
											if (event == 0){
												var dropdown = $('dropdown');
												dropdown.style.display = 'none';
												
													var c = $('cart_a');
												c.style.zIndex = '1';
										
											}
											
											if (event == 1){
											Effect.Fade('ablak', { duration: 0.4 });
											Effect.Fade('lightbox', { duration: 0.4 });
											}
												}
										 , false);

}


function out(){

Effect.Fade('ablak', { duration: 0.4 });
Effect.Fade('lightbox', { duration: 0.4 });
Effect.Fade('overlay', { duration: 0.4 });

}














function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}




function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}



