function checkSize() {
    return;
}

var recordcounter = 0;

var wflag = 0;
var w='';

function checkSize() {
    if (navigator.appName=="Netscape") {
	winW = window.innerWidth;
	winH = window.innerHeight;
    }
    if (navigator.appName.indexOf("Microsoft")!=-1) {
	winW = document.body.offsetWidth;
	winH = document.body.offsetHeight;
    }
    if (winW < 632) {
	window.resizeTo(640,480);
    }
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		orszag_01_komarom_esztergom_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-komarom-esztergom.gif");
		orszag_01_veszprem_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-veszprem_over.gif");
		orszag_01_gyor_moson_sopron_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-gyor-moson-sopron.gif");
		orszag_01_vas_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-vas_over.gif");
		orszag_01_zala_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-zala_over.gif");
		orszag_01_nograd_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-nograd_over.gif");
		orszag_01_heves_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-heves_over.gif");
		orszag_01_jasz_nagykun_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-jasz-nagykun_over.gif");
		orszag_01_baranya_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-baranya_over.gif");
		orszag_01_baz_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-baz_over.gif");
		orszag_01_szabolcs_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-szabolcs_over.gif");
		orszag_01_hajdu_bihar_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-hajdu-bihar_over.gif");
		orszag_01_bekes_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-bekes_over.gif");
		orszag_01_csongrad_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-csongrad_over.gif");
		orszag_01_tolna_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-tolna_over.gif");
		orszag_01_fejer_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-fejer_over.gif");
		orszag_01_bacs_kiskun_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-bacs-kiskun_over.gif");
		orszag_01_somogy_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-somogy_over.gif");
		orszag_01_pest_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-pest_over.gif");
		orszag_01_budapest_over = newImage("http://www.obliga.hu/e-x/images/map/orszag_01-budapest_over.gif");
		preloadFlag = true;
	}
}

function isEmpty (inputField)
{
	if (!inputField.value) return true;
	else return false;
}

function CharCounter(textarea, charcount, max) {
   if (textarea.value.length > max) {
      textarea.value = textarea.value.substring(0, max);
   } else {
      charcount.value = max - textarea.value.length;
   }
}

function buildSelect2(selectedItem, list, listvalues, childid)
{
	if(selectedItem.value=="0")
	{
		document.getElementById(childid).length = (1);
        document.getElementById(childid).options[0].text = 'Nincs kiválasztva';
        document.getElementById(childid).options[0].value = '0'; 
        document.getElementById(childid).options[0].id = childid + '0';
	}
	else
	{			
			theMakeIndex = selectedItem.selectedIndex+1;	
			strModelList = list[theMakeIndex];
		    strModelList = strModelList.replace(/&#337;/g,"ő");
		    strModelList = strModelList.replace(/&#369;/g,"ű");
		    strModelValues = listvalues[theMakeIndex]
            document.getElementById(childid).length = 1          
            
            arrModel = new Array();
            arrModelValues = new Array();
            tstModel = new Array();
            arrModel = strModelList.split("|");
            arrModelValues = strModelValues.split("|");


		   if(strModelList != ""){
				document.getElementById(childid).length = (1);
	            document.getElementById(childid).options[0].text = 'Nincs kiválasztva';
	            document.getElementById(childid).options[0].value = '0'; 
	            document.getElementById(childid).options[0].id = childid + '0';
	        }  
			
			for (i=0; i<arrModel.length; i++) { 
				if(arrModel[i].value==0 || arrModelValues[i].value==0) {return}                
                document.getElementById(childid).length = (i+1)    //start at 1 to leave 'no preference' option untouched
                if(arrModel[i] != "") { //test for blank model name 
                    document.getElementById(childid).options[(i)].text = arrModel[i];
                    document.getElementById(childid).options[(i)].value = arrModelValues[i]; 
                    document.getElementById(childid).options[(i)].id = childid + arrModelValues[i]; 
                }
             }     
					
	}
}

function popup(mylink, windowname, width, height)
{
	if (!window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
   		href=mylink;
	else
   		href=mylink.href;

	leftPos = 0;
	topPos = 0;

	if (screen) {
   		x = ((screen.width / 2) - (width / 2));
   		y = ((screen.height / 2) - (height / 2));
   		if (x>0) {
      		leftPos = x;
   		}
   		if (y>0) {
      		topPos = y;
   		}
	}

	w = window.open(href, windowname, 'width=' + width +',height='+ height + ',scrollbars=no, resizable=yes, left=' + leftPos + ',top=' + topPos);
	w.focus();
	return false;
}

function scrollpopup(mylink, windowname, width, height)
{
	if (!window.focus)return true;
		var href;
	if (typeof(mylink) == 'string')
   		href=mylink;
	else
   		href=mylink.href;

	leftPos = 0;
	topPos = 0;

	if (screen) {
   		x = ((screen.width / 2) - (width / 2));
   		y = ((screen.height / 2) - (height / 2));
   		if (x>0) {
      		leftPos = x;
   		}
   		if (y>0) {
      		topPos = y;
   		}
	}

	w = window.open(href, windowname, 'width=' + width +',height='+ height + ',scrollbars=yes, resizable=yes, left=' + leftPos + ',top=' + topPos);
	w.focus();
	return false;
}


function createpopup(mylink, windowname, width, height)
{
	var href;
	if (typeof(mylink) == 'string')
   		href=mylink;
	else
   		href=mylink.href;

	leftPos = 0;
	topPos = 0;

	if (screen) {
   		x = ((screen.width / 2) - (width / 2));
   		y = ((screen.height / 2) - (height / 2));
   		if (x>0) {
      		leftPos = x;
   		}
   		if (y>0) {
      		topPos = y;
   		}
	}

	w = window.open(href, windowname, 'width=' + width +',height='+ height + ',scrollbars=no, resizable=yes, left=' + leftPos + ',top=' + topPos);
	w.focus();
	return w;

}

function closepopup(flag, popupwindow) {
	if (flag == 1) {
		if (popupwindow.closed == false) {
	    	popupwindow.close();
		}
	}
}

function CharCounter(textarea, charcount, max) {
   if (textarea.value.length > max) {
      textarea.value = textarea.value.substring(0, max);
   } else {
      charcount.value = max - textarea.value.length;
   }
}
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_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_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 MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function categoryCheck(input)
{
	if ( input.value != '0')
	{
		document.searchForm.submit();
	
	}
	else
	{
		alert ("Kérem válasszon kategóriát!");
	}
}

// Rámuatásnál autómatikusan betöltődik a nagyított kép

function showProductImage(imageName, object) {
	var image_top = findPosY(object);
	var image_left = findPosX(object);
	
    document.getElementById('productImageLayer').style.top = (image_top-330)+'px';
    document.getElementById('productImageLayer').style.left = (image_left+0)+'px';
    document.getElementById('productImageLayer').style.display = 'block';
    document.getElementById('productImage').height = 320;
    document.getElementById('productImage').src = imageName;
    }

function showProductImage_2(imageName, object) {
	var image_top = findPosY(object);
	var image_left = findPosX(object);
	
    document.getElementById('productImageLayer').style.top = (image_top+130)+'px';
    document.getElementById('productImageLayer').style.left = (image_left+0)+'px';
    document.getElementById('productImageLayer').style.display = 'block';
    document.getElementById('productImage').height = 320;
    document.getElementById('productImage').src = imageName;
    }

function hideProductImage() {
    document.getElementById('productImage').src = 'images/spacer.gif';
    document.getElementById('productImageLayer').style.display = 'none';
    }
    
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function makeDate() {
	var d, da, day, mon, dofm, the_time;

	a_months = new Array("Januás","Február","Március","Április","Május","Június","Július","Augusztus","Szeptember","Október","November","December");
	a_days = new Array("Vasárnap","Hétfő","Kedd","Szerda","Csütörtök","Péntek","Szombat");

	d=document;
	da = new Date();
	day = da.getDay();		
	day = a_days[day];
	dofm = da.getDate();
	mon = da.getMonth();
	mon = a_months[mon];

	the_time = mon + " " + dofm  + ", " + day;

	d.getElementById("dateBox").innerHTML = the_time;
}