function pic_replace(data,data2)
{
    document.getElementById('fenykep').src = "images/galeria/big/" + data;
    document.getElementById('text').innerHTML = data2;    
}
function insertsmiley(smiley) {
	var text = document.newpost.message.value;
	text = text+' '+smiley+' ';
	document.newpost.message.value = text;
	document.newpost.message.focus();
}
function toggle(id) {
  var e = document.getElementById(id)
/*	for (var x = 1; x <= osszes; x++)
	{
  		var f = document.getElementById(x);
  		f.style.display="none";
	}*/
	e.style.display = (e.style.display != 'none' ? 'none' : '' );
}
function toggle_left(id1) {
  var e = document.getElementById(id1);
	e.style.display = (e.style.display != 'none' ? 'none' : '' );
}
function pic_open(data,data1,data2)
{
    window.open ('pic_big.php?id=' + data + '', 'newwin', 'width='+data1+', height='+data2+', top=0, left=0');
}
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 change_prod_pic(adat)
{
    document.getElementById('prodpic').src="images/termekek/big/" + adat;
}
var aktualis=0
function prev()
{
    aktualis--;
    if( aktualis<0 )
    {
    	aktualis=masodik.length-1;
    }
    document.getElementById('fenykep').src="images/galeria/big/" + masodik[aktualis];
    document.getElementById('text').innerHTML=masodik_text[aktualis];    
}
function next() {
    aktualis++;
    if( aktualis>=masodik.length )
    {
    	aktualis=0;
    }
    document.getElementById('fenykep').src="images/galeria/big/" + masodik[aktualis];
    document.getElementById('text').innerHTML=masodik_text[aktualis];    
}
function prev2()
{
    aktualis--;
    if( aktualis<0 )
    {
    	aktualis=masodik.length-1;
    }
    document.getElementById('prodpic').src="images/termekek/big/" + masodik[aktualis];
    document.getElementById('text').innerHTML=szamlalo[aktualis];    
}
function next2() {
    aktualis++;
    if( aktualis>=masodik.length )
    {
    	aktualis=0;
    }
    document.getElementById('prodpic').src="images/termekek/big/" + masodik[aktualis];
    document.getElementById('text').innerHTML=szamlalo[aktualis];    
}
function replace(name)
{
    document.getElementById('map').src="images/" + name;
}
function swapPicture()
{
  if (document.images)
  {
    var nextImage=curImage+1;
    if (nextImage>=numImages)
      nextImage=0;
    if (dimages[nextImage] && dimages[nextImage].complete)
    {
      var target=0;
      if (document.images.rendbox)
        target=document.images.rendbox;
      if (document.all && document.getElementById("rendbox"))
        target=document.getElementById("rendbox");
  
      // make sure target is valid.  It might not be valid
      //   if the page has not finished loading
      if (target)
      {
        target.src=dimages[nextImage].src;
        curImage=nextImage;
      }

      setTimeout("swapPicture()", 4000);

    }
    else
    {
      setTimeout("swapPicture()", 500);
    }
  }
}
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
function video_open(data,data1)
{
window.open ('main/video.php?id=' + data + '', 'newwin', 'status=no, toolbar=0, width=384, height=314, top=0, left=0');
}
function confirmation(URL)
{
if (confirm("Biztos benne, hogy üríteni szeretné a kosarát?\n"))
{location = String(URL);}
}
function playconfirmation()
{
    if(confirm("Biztos benne, hogy részt vesz a játékban?\n")){
        return true;
    }
    else return false;
}
function playconfirmation_de()
{
    if(confirm("Sind Sie sicher, dass Sie zur Teilnahme an dem Spiel?\n")){
        return true;
    }
    else return false;
}
function playconfirmation_en()
{
    if(confirm("Are you sure you want to play?\n")){
        return true;
    }
    else return false;
}
function playconfirmation_ru()
{
    if(confirm("Вы уверены, что хотите принять участие в игре?\n")){
        return true;
    }
    else return false;
}
function Confirmation(delUrl) {
  if (confirm("Biztos benne, hogy törölni szeretné?\nA galéria törlésével törlődik az össze benne lévő kép is!")) {
    document.location = delUrl;
  }
}
var xmlhttp_obj = false;
//create the XMLHttpRequest
function puskas_xmlhttp(){  
 if (window.XMLHttpRequest){ // if Mozilla, Safari etc  
  xmlhttp_obj = new XMLHttpRequest();  
 }else if (window.ActiveXObject){ // if IE  
  try{  
   xmlhttp_obj = new ActiveXObject("Msxml2.XMLHTTP");  
  }catch (e){  
   try{  
    xmlhttp_obj = new ActiveXObject("Microsoft.XMLHTTP");  
   }catch (e){  
   }  
  }  
 }else{  
  xmlhttp_obj = false;  
 }  
 return xmlhttp_obj;  
}   //get content via GET  

function showUserPics(uid){  
    var xmlhttp_obj = puskas_xmlhttp();  
    var e = document.getElementById('picrow')
    e.innerHTML = '<p width="100%" style="float:left;padding:10px 0 10px 0;"><center><img src="images/loader.gif"></center></p>';
    xmlhttp_obj.onreadystatechange=function(){  
        loadpage(xmlhttp_obj);  
    }  
    xmlhttp_obj.open('GET', 'showUserPic.php?uid='+uid, true);  
    xmlhttp_obj.send(null);  
}
function loadpage(xmlhttp_obj){  
    if ( xmlhttp_obj.readyState == 4 && xmlhttp_obj.status == 200 ){  
        document.getElementById('picrow').innerHTML = xmlhttp_obj.responseText;
    }  
}
function checkall(formname,checkname)
{
var el_collection=eval("document.forms."+formname)
for (i=0;i<el_collection.length;i++)
    if (el_collection.elements[i].name.indexOf(checkname)==0){
        el_collection.elements[i].checked=true;
  }
}
function uncheckall(formname,checkname)
{
var el_collection=eval("document.forms."+formname)
for (i=0;i<el_collection.length;i++)
    if (el_collection.elements[i].name.indexOf(checkname)==0){
        el_collection.elements[i].checked=false;
  }
}
function applyToAllPic(){
    source_inputs = document.getElementById('basemeret').getElementsByTagName('input');
    dest_inputs = document.getElementById('meretek').getElementsByTagName('input');
    source_select = document.getElementById('basemeret').getElementsByTagName('select');
    dest_select = document.getElementById('meretek').getElementsByTagName('select');

    sumprice=0;                            
    for (i = 0;i<source_inputs.length;i++)
    {
        if (source_inputs[i].type == "text") {
            for (j = 0;j<dest_inputs.length;j++)
            {
                var namearr=dest_inputs[j].id.split("_");
                if (document.getElementById(source_inputs[i].id) == document.getElementById(namearr[1]+"_"+namearr[2])) {
                    if(!isNaN(document.getElementById(source_inputs[i].id).value)){
                        dest_inputs[j].value = document.getElementById(source_inputs[i].id).value;
                    }
                    else{
                        dest_inputs[j].value="0";
                    }
                }
            }
        }
    }
    for (i = 0;i<source_select.length;i++)
    {    
        opts = document.getElementById(source_select[i].id).options;
        for (j = 0;j<dest_select.length;j++)
        {    
            if (document.getElementById(source_select[i].id) == document.getElementById(dest_select[j].id)) {
                for (b = 0;b<opts.length;b++)
                {
                    dest_select[j].options[b].selected = opts[b].selected;    
                }
            }
        }
    }
    setTimeout("summarize();", 1);
}
function changePicPcs(id,val){
    if(isNaN(val))document.getElementById(id).value="0";
    else {
        document.getElementById(id).value=val;
        setTimeout("summarize();", 1);        
    }
}
function summarize(){
    dest_inputs = document.getElementById('meretek').getElementsByTagName('input');
    sumprice=0;
    //if(document.getElementById("hidden_"+dest_inputs[j].id).value!="0") alert("hidden_"+dest_inputs[j].id);
    x=1;
    for (j = 0;j<dest_inputs.length;j++)
    {
        if(dest_inputs[j].type=="text" && dest_inputs[j].value!="0"){    
            var pricearr=dest_inputs[j].name.split("_")
            sumprice=sumprice+(parseInt(pricearr[1])*parseInt(document.getElementById(dest_inputs[j].id).value));
        } 
    }
    document.getElementById('allPrice').value=sumprice;    
}
