// ÁLTALÁNOS FÜGGVÉNYEK

function showhidepanel(object,action) {
	var selectedaction=(document.getElementById(object).style.display == action) ? "block" : "none";
	document.getElementById(object).style.display = selectedaction;
}

function showhideobject(object,loop,action) {
	var position=loop.split("-");
	for(i=1;i<=position[1];i++){
		document.getElementById(object+i).style.display = action;
	}
}

function setaudit(){
	document.page.sa.value="";
	for(i=0;document.forms["page"].elements[i];i++){
		if(document.forms["page"].elements[i].value == "hour" || document.forms["page"].elements[i].value == "day" || document.forms["page"].elements[i].value == "week"  || document.forms["page"].elements[i].value == "month" || document.forms["page"].elements[i].value == "year"){
			if(document.forms["page"].elements[i].checked){
				document.page.sa.value+=document.forms["page"].elements[i].name.substr(2)+","+document.forms["page"].elements[i].value+";";
			}
		}
	}
}

function refresh(){
	document.listing.submit();
}

function search(){
	if (document.search.keyword.value.length < 3) { alert("A kulcsszó legalább 3 karakter legyen!"); }
	else if (!keresesCheck(document.search.keyword)) { alert("Tiltott karakter a kulcsszóban!"); }
	else { document.search.submit(); }
}

function auth(action){
	if (action=="exit") { document.auth.submit(); }
	else if (!emailCheck(document.auth.email)) { alert("Helytelen e-mail cím!"); }
	else if (document.auth.passw.value.length < 3) { alert("A jelszó legalább 3 betűs!"); }
	else if (!szovegesCheck(document.auth.passw)) { alert("Ékezetes vagy tiltott karakter a jelszóban!"); }
	else { document.auth.submit(); }
}

function wPopup(tURL,wNAME,wOPTIONS){
	window.open(tURL,wNAME,wOPTIONS);
}


// ELLENŐRZŐ FÜGGVÉNYEK

function teszt(adat,minta){
    if (!adat.length)
      return false;
  for (var i=0; i<adat.length; i++)
    if (minta.indexOf(adat.charAt(i)) == -1)
      return false;

  return true;
}

function linkCheck(ertek){
  if (!teszt(ertek.value.toLowerCase(),"abcdefghijklmnoprsqtuxyvwz0123456789/?=#@&~-_.:")){
    return false;
  }else{ return true; }
}

function numerikusCheck(ertek){
  if (!teszt(ertek.value,"1234567890")){
    return false;
  }else{ return true; }
}

function szovegesCheck(ertek){
  if (!teszt(ertek.value.toLowerCase(),"abcdefghijklmnoprsqtuxyvwz0123456789-_.")){
    return false;
  }else{ return true; }
}

function keresesCheck(ertek){
  if (!teszt(ertek.value.toLowerCase(),"abcdefghijklmnoprsqtuxyvwz0123456789íöüóőúéáűÍÖÜÓŐÚÉÁŰ@&'?!:.-_ ")){
    return false;
  }else{ return true; }
}

function emailCheck(ertek){
  szoveg = ertek.value;
  if (!(szoveg.indexOf('@')>1 && szoveg.indexOf('@')<szoveg.length-4 && szoveg.indexOf('.')>0 && szoveg.lastIndexOf('.')<szoveg.length-2)){
    return false;
  }else{ return true; }
}

function radiobuttonCheck(ertek){
	for(var i=0;i<ertek.length;i++){
	    if(ertek[i].checked){
      		return ertek[i].value;
		}
	}
	return false;
}

function checkboxCheck(ertek){
	for(var i=0;i<ertek.length;i++){
	    if(ertek[i].checked){
      		return true;
		}
	}
	return false;
}


// TOPLISTA FÜGGVÉNYEK

function from(from){
	document.listing.from.value=from;
	document.listing.submit();
}
function period(period){
	document.listing.period.value=period;
	document.listing.submit();
}
function group(group){
	document.listing.from.value=0;
	document.listing.cat.value=group;
	document.listing.submit();
}


// STATISZTIKA FÜGGVÉNYEK

	// GLOBAL VARIABLES
	var TimerID;

function setstat(p1){
	waitstat();
	document.stat.sid.value=p1;
	document.stat.spo.value=0;
	document.stat.sup.value=1;
	document.stat.shp.value=1;
	document.stat.sfw.value="";
	document.stat.sfc.value="";
	document.stat.sft.value="";
	stat();
}
function setperiod(p1){
	waitstat();
	document.stat.spe.value=p1;
	document.stat.spo.value=0;
	stat();
}
function setformat(p1){
	waitstat();
	document.stat.sfo.value=p1;
	stat();
}
function seturlparse(p1){
	waitstat();
	document.stat.spo.value=0;
	document.stat.sup.value=p1;
	stat();
}
function sethostparse(p1){
	waitstat();
	document.stat.spo.value=0;
	document.stat.shp.value=p1;
	stat();
}
function setfilter(){
	waitstat();
	document.stat.sfw.value=document.filter.sfw.value;
	document.stat.sfc.value=document.filter.sfc.value;
	document.stat.sft.value=document.filter.sft.value;
	stat();
}
function sethost(p1){
	waitstat();
	document.stat.sho.value=p1;
	stat();
}
function setorder(p1){
	waitstat();
	document.stat.sor.value=p1;
	document.stat.spo.value=0;
	stat();
}
function setposition(p1){
	waitstat();
	document.stat.spo.value=p1;
	stat();
}
function hour(p1){
	waitstat();
	if(p1<10){p1="0"+p1;}
	document.stat.hour.value=p1;
	document.stat.spo.value=0;
	stat();
}
function day(p1){
	waitstat();
	if(p1<10){p1="0"+p1;}
	document.stat.day.value=p1;
	document.stat.spo.value=0;
	stat();
}
function week(p1){
	waitstat();
	if(p1<10){p1="0"+p1;}
	document.stat.week.value=p1;
	document.stat.spo.value=0;
	stat();
}
function month(p1){
	waitstat();
	if(p1<10){p1="0"+p1;}
	document.stat.month.value=p1;
	document.stat.spo.value=0;
	stat();
}
function year(p1){
	waitstat();
	document.stat.year.value=p1;
	document.stat.spo.value=0;
	stat();
}
function show() {
	if(dayCheck()){
	document.stat.submit();
	}
	clearInterval(TimerID);
}
function dayCheck() {
	month["01"]=31;month["02"]=28;month["03"]=31;month["04"]=30;month["05"]=31;month["06"]=30;month["07"]=31;month["08"]=31;month["09"]=30;month[10]=31;month[11]=30;month[12]=31;
	if(month[document.stat.month.value] < document.stat.day.value){document.stat.day.value=month[document.stat.month.value];return true;}
	else { return true; }
}
function waitstat() {
	if(TimerID){
	clearInterval(TimerID);
	}
}
function stat() {
	var Wait=3000;
	var NextInt=false;
	if(! NextInt){
		NextInt=true;
		TimerID=setInterval("show()",Wait);
	}
}
function printstat(){
	alert("Hamarosan...");
}
function sendstat(){
	alert("Hamarosan...");
}
function savestat(){
	alert("Hamarosan...");
}

// LINKTÁR FÜGGVÉNYEK

function abc(abc){
	document.listing.abc.value=abc;
	document.listing.submit();
}
