
function stdclass(formname,fieldname){

	this.getData = function(formname,fieldname){return document.forms[formname].elements[fieldname].value;};
	this.setData = function(formname,fieldname,ertek){document.forms[formname].elements[fieldname].value=ertek;}
	this.submit = function(formname){document.forms[formname].submit();};

}
window.commi = new stdclass();

function check(urlap){
   


	fcount = window.commi.getData(urlap,"icount")
	
	hibavan = 0
	for(fe=0;fe<fcount;fe++){
	   darab =  Math.abs(window.commi.getData(urlap,"TDB"+ fe))
	   egyseg = Math.abs(window.commi.getData(urlap,"MINDB"+ fe))
	   
	   if(!checkn(darab,egyseg) && darab>0){
		hibavan=1
	   }
	}
	
	
	
	if(hibavan){
	
		alert("A megrendelt mennyiségnek a minimális rendelési mennyiségnek ("+egyseg+"), vagy annak többszörösének kell lennie!");
		return false;
	
	}else{
		
		window.commi.submit(urlap);
		// if we doing it with ajax, complete other handling required
		return true;
	
	}

}

function okp(e){

	e = e||event;
	k = e.keyCode||e.which;
	if(k==13){
	
		if(window.event){e.returnValue=false;}else{e.preventDefault();}
	
	}

}

function termektalloz(tf){

	window.commi.setData("dataform","targetfield",tf);
	window.open('adm_dolista.php',"selecttermek","height=500,width=800,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");

}

function checkform(){

	fcount = window.commi.getData("smform","ciom");
	canpost = true;
	for(fe=1;fe<fcount;fe++){
	
		fmindb = window.commi.getData("smform","mindb"+fe);
		fmenny = window.commi.getData("smform","mennyiseg"+fe);
		if(fmenny<1||Math.ceil(fmenny/fmindb)!=(fmenny/fmindb)){
		
			canpost = false;
			break;
		
		}
	
	}
	fcszam = window.commi.getData("smform","cikkszam0");
	fmindb = window.commi.getData("smform","mindb0");
	fmenny = window.commi.getData("smform","mennyiseg0");
	if((fcszam!=""&&(fmenny<1||Math.ceil(fmenny/fmindb)!=(fmenny/fmindb)))){
		canpost = false;
	
	}
	if(canpost){
		window.commi.setData("smform","submit_send","1");
		window.commi.submit("smform");
	
	}else{
	
		alert("A megrendelést nem lehet elküldeni, mivel valamelyik termék darabszáma nem megengedett értéket tartalmaz.");
	
	}

}

function checkformadd(){

	canpost = true;
	fmindb = window.commi.getData("smform","mindb0");
	fmenny = window.commi.getData("smform","mennyiseg0");
	if(fmenny<1||(Math.ceil(fmenny/fmindb)!=(fmenny/fmindb))){
	
		canpost = false;
	}
	if(canpost){
	
		window.commi.setData("smform","submit_add","1");
		window.commi.submit("smform");
	
	}else{
	
		alert("A terméket nem lehet hozzáadni, mivel a termék darabszáma nem megengedett értéket tartalmaz.");
	
	}

}

function kivalaszt(){

	tf = window.opener.commi.getData("dataform","targetfield");
	window.opener.commi.setData("smform","cikkszam0",window.comm.getData("selectform","termekkod"));
	window.opener.commi.setData("smform","mindb0",window.comm.getData("selectform","mindb"));
	window.close();

}

function cserel(obj){

	document.all["cikkszam"+aktsor].value=obj.value;

}

function valasztott(tk,mindb){

	document.getElementById('gomb1').disabled=false;
	document.getElementById('gomb2').disabled=false;
	window.commi.setData("selectform","termekkod",tk);
	window.commi.setData("selectform","mindb",mindb);
	

}

function checkn(darab,egyseg){

	return !(darab<egyseg||darab*0!=0||darab/egyseg!=Math.ceil(darab/egyseg));

}
	
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";
function JSFX_FloatDiv(id, sx, sy)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
	el.flt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.flt()", 40);
	}
	return el;
}
// Show Advanced Search:
function setStyleById(i, p, v) {
	var n = document.getElementById(i);
	n.style[p] = v;
}

function showadvsearch() {
	var as = document.getElementById("advsearch");
	setStyleById('advsearch', 'display', 'block');
	setStyleById('advsearch', 'visibility', 'visible');
}

// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function OpenMenu(MenuGroupNum)
{
	var m = 0;
	
	for (m=0; m<menuarray.length; m++)
	{ 
		if (document.getElementById('SideSub' + menuarray[m])) {
			document.getElementById('SideSub' + menuarray[m]).style.display = 'none';
			document.getElementById('SideSub' + menuarray[m]).style.visibility = 'hidden';
		}
	}
	if (document.getElementById('SideSub' + MenuGroupNum)) {	
		document.getElementById('SideSub' + MenuGroupNum).style.display = 'block';
		document.getElementById('SideSub' + MenuGroupNum).style.visibility = 'visible';
	}
	return false;
}
var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();
   /************************************************************************************************************
   (C) www.dhtmlgoodies.com, October 2005

   This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.

   Terms of use:
   You are free to use this script as long as the copyright message is kept intact. However, you may not
   redistribute, sell or repost it without our permission.

   Thank you!

   www.dhtmlgoodies.com
   Alf Magne Kalleland

   ************************************************************************************************************/

   var dhtmlgoodies_menuObj;   // Reference to the menu div
   var currentZIndex = 1000;
   var liIndex = 0;
   var visibleMenus = new Array();
   var activeMenuItem = false;
   var timeBeforeAutoHide = 1200; // Microseconds from mouse leaves menu to auto hide.
   var dhtmlgoodies_menu_arrow = 'http://www.dhtmlgoodies.com/scripts/dhtmlgoodies-menu2/images/arrow.gif';

   var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
   var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox')>=0?true:false;
   var navigatorVersion = navigator.appVersion.replace(/.*?MSIE ([0-9]\.[0-9]).*/g,'$1')/1;
   var menuBlockArray = new Array();
   var menuParentOffsetLeft = false;


    // {{{ getStyle()
   /**
   * Return specific style attribute for an element
   *
   * @param Object el = Reference to HTML element
   * @param String property = Css property
   * @private
   */
   function getStyle(el,property)
   {

      if (document.defaultView && document.defaultView.getComputedStyle) {

         var retVal = null;
         var comp = document.defaultView.getComputedStyle(el, '');
         if (comp){
            retVal = comp[property];

            if(!retVal){
               var comp = document.defaultView.getComputedStyle(el, null);
               retVal = comp.getPropertyCSSValue(property);
            }
         }

         if(retVal==null)retVal='';

         return el.style[property] || retVal;
      }
      if (document.documentElement.currentStyle && MSIE){
         var value = el.currentStyle ? el.currentStyle[property] : null;
         return ( el.style[property] || value );

      }
      return el.style[property];
   }

   function getTopPos(inputObj)
   {
   	var origInputObj = inputObj;

     var returnValue = inputObj.offsetTop;
     if(inputObj.tagName=='LI' && inputObj.parentNode.className=='menuBlock1'){
        var aTag = inputObj.getElementsByTagName('A')[0];
        if(aTag)returnValue += aTag.parentNode.offsetHeight;
     }
     var topOfMenuReached = false;
     while((inputObj = inputObj.offsetParent) != null){
        if(inputObj.parentNode.id=='dhtmlgoodies_menu')topOfMenuReached=true;
        if(topOfMenuReached && !inputObj.className.match(/menuBlock/gi) || (!MSIE && origInputObj.parentNode.className=='menuBlock1')){
           var style = getStyle(inputObj,'position');
           if(style=='absolute' || style=='relative'){
              return returnValue;
           }
        }

        returnValue += inputObj.offsetTop;
     }

     return returnValue;
   }

   function getLeftPos(inputObj)
   {
     var returnValue = inputObj.offsetLeft;

     var topOfMenuReached = false;
     while((inputObj = inputObj.offsetParent) != null){
       if(inputObj.parentNode.id=='dhtmlgoodies_menu')topOfMenuReached=true;
        if(topOfMenuReached && !inputObj.className.match(/menuBlock/gi)){
           var style = getStyle(inputObj,'position');
           if(style=='absolute' || style=='relative')return returnValue;
        }

        returnValue += inputObj.offsetLeft;
     }
     return returnValue;
   }



   function showHideSub()
   {

      var attr = this.parentNode.getAttribute('currentDepth');
      if(navigator.userAgent.indexOf('Opera')>=0){
         attr = this.parentNode.currentDepth;
      }

      this.className = 'currentDepth' + attr + 'over';

      if(activeMenuItem && activeMenuItem!=this){
         activeMenuItem.className=activeMenuItem.className.replace(/over/,'');
      }
      activeMenuItem = this;

      var numericIdThis = this.id.replace(/[^0-9]/g,'');
      var exceptionArray = new Array();
      // Showing sub item of this LI
      var sub = document.getElementById('subOf' + numericIdThis);
      if(sub){
         visibleMenus.push(sub);
         sub.style.display='';
         sub.parentNode.className = sub.parentNode.className + 'over';
         exceptionArray[sub.id] = true;
      }

      // Showing parent items of this one

      var parent = this.parentNode;
      while(parent && parent.id && parent.tagName=='UL'){
         visibleMenus.push(parent);
         exceptionArray[parent.id] = true;
         parent.style.display='';

         var li = document.getElementById('dhtmlgoodies_listItem' + parent.id.replace(/[^0-9]/g,''));
         if(li.className.indexOf('over')<0)li.className = li.className + 'over';
         parent = li.parentNode;

      }


      hideMenuItems(exceptionArray);



   }

   function hideMenuItems(exceptionArray)
   {
      /*
      Hiding visible menu items
      */
      var newVisibleMenuArray = new Array();
      for(var no=0;no<visibleMenus.length;no++){
         if(visibleMenus[no].className!='menuBlock1' && visibleMenus[no].id){
            if(!exceptionArray[visibleMenus[no].id]){
               var el = visibleMenus[no].getElementsByTagName('A')[0];
               visibleMenus[no].style.display = 'none';
               var li = document.getElementById('dhtmlgoodies_listItem' + visibleMenus[no].id.replace(/[^0-9]/g,''));
               if(li.className.indexOf('over')>0)li.className = li.className.replace(/over/,'');
            }else{
               newVisibleMenuArray.push(visibleMenus[no]);
            }
         }
      }
      visibleMenus = newVisibleMenuArray;
   }



   var menuActive = true;
   var hideTimer = 0;
   function mouseOverMenu()
   {
      menuActive = true;
   }

   function mouseOutMenu()
   {
      menuActive = false;
      timerAutoHide();
   }

   function timerAutoHide()
   {
      if(menuActive){
         hideTimer = 0;
         return;
      }

      if(hideTimer<timeBeforeAutoHide){
         hideTimer+=100;
         setTimeout('timerAutoHide()',99);
      }else{
         hideTimer = 0;
         autohideMenuItems();
      }
   }

   function autohideMenuItems()
   {
      if(!menuActive){
         hideMenuItems(new Array());
         if(activeMenuItem)activeMenuItem.className=activeMenuItem.className.replace(/over/,'');
      }
   }


   function initSubMenus(inputObj,initOffsetLeft,currentDepth)
   {
      var subUl = inputObj.getElementsByTagName('UL');
      if(subUl.length>0){
         var ul = subUl[0];

         ul.id = 'subOf' + inputObj.id.replace(/[^0-9]/g,'');
         ul.setAttribute('currentDepth' ,currentDepth);
         ul.currentDepth = currentDepth;
         ul.className='menuBlock' + currentDepth;
         ul.onmouseover = mouseOverMenu;
         ul.onmouseout = mouseOutMenu;
         currentZIndex+=1;
         ul.style.zIndex = currentZIndex;
         menuBlockArray.push(ul);
         ul = dhtmlgoodies_menuObj.appendChild(ul);
         var topPos = getTopPos(inputObj);
         var leftPos = getLeftPos(inputObj)/1 + initOffsetLeft/1;

         ul.style.position = 'absolute';
         ul.style.left = leftPos + 'px';
         ul.style.top = topPos + 'px';
         var li = ul.getElementsByTagName('LI')[0];
         while(li){
            if(li.tagName=='LI'){
               li.className='currentDepth' + currentDepth;
               li.id = 'dhtmlgoodies_listItem' + liIndex;
               liIndex++;
               var uls = li.getElementsByTagName('UL');
               li.onmouseover = showHideSub;

               if(uls.length>0){
                  var offsetToFunction = li.getElementsByTagName('A')[0].offsetWidth+2;
                  if(navigatorVersion<6 && MSIE)offsetToFunction+=15;   // MSIE 5.x fix
                  initSubMenus(li,offsetToFunction,(currentDepth+1));
               }
               if(MSIE){
                  var a = li.getElementsByTagName('A')[0];
                  a.style.width=li.offsetWidth+'px';
                  a.style.display='block';
               }
            }
            li = li.nextSibling;
         }
         ul.style.display = 'none';
         if(!document.all){
            //dhtmlgoodies_menuObj.appendChild(ul);
         }
      }
   }


   function resizeMenu()
   {
      var offsetParent = getLeftPos(dhtmlgoodies_menuObj);

      for(var no=0;no<menuBlockArray.length;no++){
         var leftPos = menuBlockArray[no].style.left.replace('px','')/1;
         menuBlockArray[no].style.left = leftPos + offsetParent - menuParentOffsetLeft + 'px';
      }
      menuParentOffsetLeft = offsetParent;
   }

   /*
   Initializing menu
   */
   function initDhtmlGoodiesMenu()
   {
      dhtmlgoodies_menuObj = document.getElementById('dhtmlgoodies_menu');


      var aTags = dhtmlgoodies_menuObj.getElementsByTagName('A');
      for(var no=0;no<aTags.length;no++){

         var subUl = aTags[no].parentNode.getElementsByTagName('UL');
         if(subUl.length>0 && aTags[no].parentNode.parentNode.parentNode.id != 'dhtmlgoodies_menu'){
            var img = document.createElement('IMG');
            img.src = dhtmlgoodies_menu_arrow;
            aTags[no].appendChild(img);

         }

      }

      var mainMenu = dhtmlgoodies_menuObj.getElementsByTagName('UL')[0];
      mainMenu.className='menuBlock1';
      mainMenu.style.zIndex = currentZIndex;
      mainMenu.setAttribute('currentDepth' ,1);
      mainMenu.currentDepth = '1';
      mainMenu.onmouseover = mouseOverMenu;
      mainMenu.onmouseout = mouseOutMenu;

      var mainMenuItemsArray = new Array();
      var mainMenuItem = mainMenu.getElementsByTagName('LI')[0];
      mainMenu.style.height = mainMenuItem.offsetHeight + 2 + 'px';
      while(mainMenuItem){

         mainMenuItem.className='currentDepth1';
         mainMenuItem.id = 'dhtmlgoodies_listItem' + liIndex;
         mainMenuItem.onmouseover = showHideSub;
         liIndex++;
         if(mainMenuItem.tagName=='LI'){
            mainMenuItem.style.cssText = 'float:left;';
            mainMenuItem.style.styleFloat = 'left';
            mainMenuItemsArray[mainMenuItemsArray.length] = mainMenuItem;
            initSubMenus(mainMenuItem,0,2);
         }

         mainMenuItem = mainMenuItem.nextSibling;

      }

      for(var no=0;no<mainMenuItemsArray.length;no++){
         initSubMenus(mainMenuItemsArray[no],0,2);
      }

      menuParentOffsetLeft = getLeftPos(dhtmlgoodies_menuObj);
      window.onresize = resizeMenu;
      dhtmlgoodies_menuObj.style.visibility = 'visible';
   }
	window.onload = initDhtmlGoodiesMenu;
