function MM_findObj(n, d) { 
	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 && document.getElementById)x=document.getElementById(n); 
	return x;
}

function turnDiv(d){
	tmpObject=MM_findObj(d);
	if(tmpObject.style.display=='none'){
		tmpObject.style.display='';
	} else {
		tmpObject.style.display='none';
	}
}

function turnDivOn(d){
	tmpObject=MM_findObj(d);
	tmpObject.style.display='block';
}

function turnDivOff(d){
	tmpObject=MM_findObj(d);
	tmpObject.style.display='none';
}

function bigpicview(piclink, width, height){
	x=(screen.width-width)/2;
	y=(screen.height-height)/2;
	window.open('/picview.php?pic='+piclink, 'bpv', 'width='+width+', height='+height+', left='+x+', top='+y+', resizeable=0, scrollbars=0');
}

function changeClass(ele,cls){
	row.className=cls;
}

function changeRowClass(ele,cls){
	row=document.getElementById(ele);
	row.className=cls;
}

function js_in_array(a,v){
	for(js_in_i=0;js_in_i<a.length;js_in_i++){
		if(a[js_in_i]==v)return true;
	}
	return false;
}


//cross frame spoofing
//if(parent!=self)top.location.href=location.href;

//fotoalbum
var albumpopUp='/photoalbum_popup.php';
var albumpopW=600;
var albumpopH=565;
//var albumpopUp='<? echo $cfg['site']['fotoalbum_popup']; ?>';
//var albumpopW=<? echo $cfg['site']['fotoalbum_popup_width']; ?>;
//var albumpopH=<? echo $cfg['site']['fotoalbum_popup_height']; ?>;

function fotoAlbum(albumid){
	winleft=(screen.width-albumpopW)/2;
	winUp=(screen.height-albumpopH)/2;
	winProp='width='+albumpopW+',height='+albumpopH+',left='+winleft+',top='+winUp+',scrollbars=0,resizable';
	Win=window.open(albumpopUp+'?id='+albumid, 'fotoAlbum', winProp);
}

/*/
function formatPenz(field){
	field.value=number_format(field.value.replace(/[^0-9]/ig,""),0,'.',' ');
}
/*/

function number_format(a, b, c, d) {
	// number_format(number, decimals, comma, formatSeparator)
	a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
	e = a + '';
	f = e.split('.');
	if(!f[0]) f[0] = '0';
	if(!f[1]) f[1] = '';
	if(f[1].length < b){
		g = f[1];
		for(i = f[1].length + 1; i <= b; i++) {
			g += '0';
		}
		f[1] = g;
	}
	if(d != '' && f[0].length > 3) {
		h = f[0];
		f[0] = '';
		for(j = 3; j < h.length; j += 3) {
			i = h.slice(h.length - j, h.length - j + 3);
			f[0] = d + i +  f[0] + '';
		}
		j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
		f[0] = j + f[0];
	}
	c = (b <= 0) ? '': c;
	return f[0] + c + f[1];
}

function is_email(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    return false
	 }

	 return true					
}

var tab_active='';

function tab_on(a,b,c){
    //elozo kikapcsolasa
    if(tab_active!='')tab_off(a,b,tab_active);
    //uj bekapcsolasa
    changeRowClass(a+c,'tabon');     
    changeRowClass(b+c,'contenton');
    //ez az aktiv most     
    tab_active=c;
}

function tab_off(a,b,c){
    changeRowClass(a+c,'taboff');     
    changeRowClass(b+c,'contentoff');     
}
