function ClientValidateEmail(source, clientside_arguments)
{         
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(clientside_arguments.Value)) 
        clientside_arguments.IsValid=true;   
    else {clientside_arguments.IsValid=false};
}

function calcHeight(the_iframe)
{
    if (document.getElementById(the_iframe).style.display != 'none')
    {
        try
        {
            var the_height=document.getElementById(the_iframe).contentWindow.document.body.scrollHeight;
            document.getElementById(the_iframe).style.height=the_height+20;
        } catch(err) {}
    }
} 

function submit_application()
{
	theform  = eval('window.document.application');

	if (isemptystr(theform.data_appname.value)) {alert(err_empty);theform.data_appname.focus();return;}
	if (!chktel(theform.data_appphone.value)) {alert(err_phone);theform.data_appphone.focus();return;}	
	if (!ncheckEmail(theform.data_appmail.value)) {alert(err_email);theform.data_appmail.focus();return;}	
	if (isemptystr(theform.data_apptext.value)) {alert(err_empty);theform.data_apptext.focus();return;}	
				
    theform.submit();
}

function submit_order()
{
	theform  = eval('window.document.order');

	if (isemptystr(theform.data_ordername.value)) {alert(err_empty);theform.data_ordername.focus();return;}
	if (!ncheckEmail(theform.data_ordermail.value)) {alert(err_email);theform.data_ordermail.focus();return;}		
	if (isemptystr(theform.data_orderaddress.value)) {alert(err_empty);theform.data_orderaddress.focus();return;}	
	if (!chktel(theform.data_orderphone.value)) {alert(err_phone);theform.data_orderphone.focus();return;}	
	if (!isnumeric(theform.data_orderticketnum.value)) {alert(err_number);theform.data_orderticketnum.focus();return;}	
				
    theform.submit();
}

function submit_search()
{
	theform  = eval('window.document.search');
	var s = trim(window.document.search.searchtext.value);
	if(s.length<=3) {alert(err_toosort); return; }
	window.document.search.searchtext.value = s.replace(/[<>]/g,"");	
    theform.submit();
}

function openpicwin(poz,kat)
{window.open('/sec/showpic.aspx?lg='+lg+'&poz='+poz+'&kategoriaid='+kat,'Picture','width=590;height=427;location=0;menubar=0;status=0;titlebar=0,toolbar=0');}

function openmap(map)
{window.open('/sec/showmap.aspx?pic='+map,'Map','width=800;height=800;location=0;menubar=0;status=0;titlebar=0,toolbar=0');}


function chktel(buf)
{
  	var re = new RegExp('^[0-9 ()-\\/]+$');
  	if ((buf.match(re)) && (buf.length>=7)) return true; else return false;
}

function trim(e) {return e.replace(/(^\s*)|(\s*$)/g, "");}

function isemptystr(e)
{
  if (trim(e)=='') return true; else return false;
}

function minmaxstr(e,smin,smax)
{
  var l = trim(e);
  if ((l.length<smin) || (l.length>smax)) return false; else return true;
}

function isnumeric(e)
{
  if ((trim(e)!='') && (isNaN(trim(e))==false)) return true; else return false;
}

function isnumbers(buf)
{
	buf = trim(buf);
	if (buf=='') return false;
  	var re = new RegExp('^[0-9]+$');
  	if (buf.match(re)) return true; else return false;
}

function isdate(buf)
{
	buf = trim(buf);
	if (buf=='') return true;
  	var re = new RegExp('^[1-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]$');
  	if (!buf.match(re)) return false;
	var ayear  = buf.substr(0,4);
	var amonth = buf.substr(5,2)-1;
	var aday   = buf.substr(8,2);
	var d = new Date(ayear,amonth,aday);
	if ( d.getYear()!=ayear) return false;
	if ( d.getMonth()!=amonth) return false;
	if ( d.getDate()!=aday) return false;
	return true;
}

function ncheckEmail(a) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(a)){
		return (true)
	}		
	return (false)
}


function setmenu(mid)
{
     var mmm = document.getElementsByTagName("div");
     for(var i = 0; i<mmm.length; i++)
     {
        var mmid = mmm[i].id;
        if (mmid.substr(0,2) == "mm")
        {
            if (mmid==('mm' + mid))
            {
                mmm[i].style.display = "block";                
            }
            else
            {
                mmm[i].style.display = "none";
            }
        }
        if (mmid.substr(0,2) == "nn")
        {
            if (mmid==('nn' + mid))
            {
                mmm[i].className = "menufix";                
            }
            else
            {
                 mmm[i].className = "menu";
            }
        }      
     }
 }

 function chk_vote() {

     var darab = 0;

     var s = document.getElementsByTagName("input");
     for (var k = 0; k < s.length; k++) {
         if (s[k].name.substring(0, 2) == "v_") {
             if (s[k].checked == true) darab = darab + 1
         }
     }

     if (darab > 5) {
         alert("Maximum 5 szavazatot lehet leadni!");
         return;
     }

     if (darab == 0) {
         alert("Nem szavazott senkire!");
         return;
     }
     theform = eval('window.document.vote');
     theform.submit();
 }
