//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

//------------------------------------------------Saját függvények

function jumpto()
{
	val = document.jumpform.tip_id.value;
	document.location.href = "termek_list.php?tip_ref=" + val;
}

function testkiszer(tt_id)
{
	pathh = document.getElementById('tocart'+tt_id);
	if (pathh.kisz_id.value == 0) alert("Előbb válasszon egy raktáron lévő kiszerelést!");
	else pathh.submit();
}

function incr(tt_id)
{
	obj = document.getElementById('menny'+tt_id);
	val = parseInt( obj.value );
	if (val < 99) obj.value = val+1;
}

function decr(tt_id)
{
	obj = document.getElementById('menny'+tt_id);
	val = parseInt( obj.value );
	if (val > 1) obj.value = val-1;
}

function toggleSearch(isFocus) {
				var mySearch = document.getElementById('search');
				if (mySearch) {
					if (isFocus == true) {
						mySearch.style.backgroundColor = '#fff';
					} else {
						mySearch.style.backgroundColor = '#808B60';
					}
				}
			}


function getElementsByClassName( strClassName, obj ) {
    var ar = arguments[2] || new Array();
    var re = new RegExp("\\b" + strClassName + "\\b", "g");

    if ( re.test(obj.className) ) {
        ar.push( obj );
    }
    for ( var i = 0; i < obj.childNodes.length; i++ )
        getElementsByClassName( strClassName, obj.childNodes[i], ar );
    
    return ar;
}

function elso_doboz()
{
	var dobozok = new Array;
	dobozok = getElementsByClassName( 'fieldbox' , document.body);
	for(var i = 0; i < dobozok.length; i++)
	{
		//alert(dobozok[i]);
		if (dobozok[i].style.display != "none")
		{
			cimsorok = getElementsByClassName( 'cim' , dobozok[i]);
			if (navigator.appName == "Microsoft Internet Explorer")
			{
				cimsorok[0].style.marginTop = 90;
			}
			else cimsorok[0].style.marginTop = 90 + 'px';
			
			return;
		}
	}
}


function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    //myWidth = window.innerWidth;
	myWidth = document.documentElement.clientWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myWidth;
}

function alertSize2() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    //myWidth = window.innerWidth;
	myWidth = document.documentElement.clientWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myHeight;
}

/*function resize()
{
	var adiv = document.getElementById('maintable');
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		adiv.style.pixelHeight = alertSize();
	}
	else adiv.style.height = alertSize() + 'px';
	
}
*/	
function res()
{
	var adiv = document.getElementById('base');
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		adiv.style.pixelHeight = alertSize2();
	}
	else adiv.style.height = alertSize2() + 'px';
}

function place(name, offs)
{
	//alert(((alertSize()/2)-(950/2)));
	var adiv = document.getElementById(name);
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		adiv.style.left = Math.floor((alertSize()/2)-(950/2))+offs;
	}
	else adiv.style.left = (Math.floor((alertSize()/2)-(950/2))+offs) + 'px';
}
//alert(alertSize());