function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;}
 
function openIt(url,name,width,height,params) {
  width += 16; height += 16;
	var win=window.open(url,name,'width='+width+',height='+height+','+params);
	 winWidth=width;winHeight=height;
  	screenWidth=screen.width;screenHeight=screen.height;
	  var x=parseInt((screenWidth/2)-(winWidth/2));
	 var y=parseInt((screenHeight/2)-(winHeight/2));	
	win.moveTo(x,y);
 win.focus();} 
 
function checkLogin() {
  var loginForm = document.getElementById('belepes');
  if (loginForm.elements['usermail'].value == '' || loginForm.elements['password'].value == '') {
    alert('Kérjük, adja meg e-mail címét és jelszavát!');
    return false;}
  return true;}  
 
function checkShipping() {
  var ship = document.getElementById('shipping').checked;
  var fields = new Array('ship_postcode','ship_city','ship_street','ship_strno');
  var status = (ship) ? true : false;
    for (var x = 0; x < fields.length; x++)  
      document.getElementById(fields[x]).disabled = status;}
    
function toggle(id) {
  var div = document.getElementById('prod'+id);
  var btn = document.getElementById('btn'+id);
  if (div.style.display == 'block') {
    btn.src = 'images/misc/plusb.gif';
    div.style.display = 'none';}
  else {
    btn.src = 'images/misc/minusb.gif';  
    btn.width = 14;btn.height = 14;
    div.style.display = 'block';}}

function swapImg(name,img,width,height,fullWidth,fullHeight) {
alert(img);
  var image = document.getElementById('img');
    image.src = img;image.width = width;image.height = height;
    var link = document.getElementById('link');  
  link.onclick = function() {openIt(img,'img',fullWidth,fullHeight,'');};}
  
valid = false; 

function checkQuantity(field,max) {
  if (field.value > max) {
    if (max < 1) {
      field.value = '';
      alert('Az Ön által kiválasztott termékből jelenleg nincs raktáron!');}    
    else {
      field.value = max;
      alert('Az Ön által kiválasztott termékből jelenleg csak '+ max +' db van raktáron!');}}
  else if (field.value <= max) {
    valid = true;}   
    }

function cart(field,value) {
 /*if (!valid && field == 'add') return false;*/
  document.getElementById(field).value = value;}

function checkall() {
  var items = document.getElementsByName('delete[]');
  var check = document.getElementById('check');
  var status = (check.checked == true) ? true : false;
  for (var x = 0; x < items.length; x++) {
    items[x].checked = status;
    }
  }

function showFlash(path,width,height,id,background) {
	if ( document.all ) {
		document.write('<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="' + width + '" height="' + height + '" id="' + id + '">');
		document.write('        <param name="movie" value="' + path + '" />');} 
  else {
		document.write('<object data="' + path + '" width="' + width + '" height="' + height + '" id="' + id + '" type="application/x-shockwave-flash">');}
		
  document.write('        <param name="quality" value="high" />');
  document.write('        <param name="scale" value="noscale" />');
  document.write('        <param name="menu" value="false" />');
  document.write('        <param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />');
  document.write('        <param name="bgcolor" value="' + background + '" />');
  document.write('</object>');}

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_swapImage2(img) { //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 MM_swapImage(img,link,width,height) { //v3.0
  var image = document.getElementById(img);
    image.src = link;
image.width = width;
image.height = height;


}

