var sorsz = 0;		
var lasthotel = "";
			
function openpicwin(poz,hid)
{window.open('/showpic.aspx?lg=hu&poz='+poz+'&hid='+hid,'Picture','width=590;height=427;location=0;menubar=0;status=0;titlebar=0,toolbar=0');}

			
function winpopup(wurl)
{window.open(wurl,'csehszlo','scrollbars=yes,status=yes,menubar=yes,titlebar=yes,location=yes,toolbar=yes,width=800,height=427');}


function offer(wurl)
{a=window.open(wurl,'csehszlo','scrollbars=no,status=no,menubar=no,titlebar=no,location=no,toolbar=no,width=500,height=280');
 a.location=wurl;
}

function deluser(b,s)
{
	b.removeChild(document.getElementById("row"+s.name.substring(3)));
	document.utform.usz.value = document.getElementById("utazok").getElementsByTagName("tr").length-1;
}
function chguser(s)
{
	var b = document.getElementById("dat3_ubirth"+s.name.substring(12));
	if (s.selectedIndex==1)
		b.style.display="";
	else
		b.style.display="none";
}

function showhotel(name)
{
    if (lasthotel!="")
    {
        hotel = document.getElementById('h'+lasthotel);
        hotel.style.display = "none";    
        hotel = document.getElementById('b'+lasthotel);
        hotel.style.display = "block";    
	hotel = document.getElementById('l'+lasthotel);
        hotel.className="divclose";  
        
    }    
    hotel = document.getElementById('h'+name);
    hotel.style.display = "block";
    hotel = document.getElementById('b'+name);
    hotel.style.display = "none";
    hotel = document.getElementById('l'+name);
    hotel.className="divopen";  
    lasthotel = name;
}	
function adduser()
{
		mytable = document.getElementById("utazok");
		if (sorsz==0) sorsz = mytable.getElementsByTagName("tr").length+1;
		else sorsz = sorsz +1 ;				
        mytablebody = mytable.getElementsByTagName("tbody").item(0);
        mycurrent_row=document.createElement("TR");mycurrent_row.setAttribute("id","row"+sorsz);

		mycurrent_cell=document.createElement("TD");				
		input = document.createElement("INPUT");input.setAttribute("type","button");input.name="del"+sorsz;input.value="Torles";
		input.onclick = function(){deluser(mytablebody,this);};
		mycurrent_cell.appendChild(input);				
		mycurrent_row.appendChild(mycurrent_cell);


		mycurrent_cell=document.createElement("TD");
		input = document.createElement("INPUT");input.setAttribute("type","text");input.setAttribute("name","dat2_uname"+sorsz);				
		mycurrent_cell.appendChild(input);	
		mycurrent_row.appendChild(mycurrent_cell);			
		
		mycurrent_cell=document.createElement("TD");
		input = document.createElement("INPUT");input.setAttribute("type","text");input.setAttribute("name","dat3_unat"+sorsz);				
		mycurrent_cell.appendChild(input);	
		mycurrent_row.appendChild(mycurrent_cell);			
		
		mycurrent_cell=document.createElement("TD");			
		input = document.createElement("SELECT");
		elem = new Option("nem","0");	input[0]=elem;
		elem2 = new Option("igen","1");	input[1]=elem2;
		input.name = "dat3_ugyerek"+sorsz;
		input.onclick = function(){chguser(this);};
		mycurrent_cell.appendChild(input);	
		mycurrent_row.appendChild(mycurrent_cell);			

		mycurrent_cell=document.createElement("TD");
		input = document.createElement("INPUT");input.setAttribute("type","text");input.setAttribute("name","dat3_ubirth"+sorsz);				
		input.setAttribute("id","dat3_ubirth"+sorsz);		
		input.style.display="none";
		mycurrent_cell.appendChild(input);	
		mycurrent_row.appendChild(mycurrent_cell);			
		
		mytablebody.appendChild(mycurrent_row);
		mytable.appendChild(mytablebody);
		document.utform.usz.value = document.getElementById("utazok").getElementsByTagName("tr").length-1;
}

function trim(e) {return e.replace(/(^\s*)|(\s*$)/g, "");}

function isemptystr(e)
{
  if (trim(e)=='') return true; else return false;
}

function ncheckEmail(a) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(a)){
		return (true)
	}		
	return (false)
}

function chkRadio(f){
	var sel = false; 
	var a = eval("document."+f);
	for (var i=0;i<a.length;i++)
	{
		var e = a[i];if (e.checked) 
		sel = true;
	} 
	return sel;
}

function submitkapcs()
{
	theform  = eval('document.kapcs');
	if (isemptystr(theform.name.value)) {alert(err_empty);theform.name.focus();return;}
	if (isemptystr(theform.phone.value)) {alert(err_empty);theform.phone.focus();return;}
	if (!ncheckEmail(theform.email.value)) {alert(err_email);theform.email.focus();return;}
	if (isemptystr(theform.targy.value)) {alert(err_empty);theform.targy.focus();return;}	
	if (isemptystr(theform.message.value)) {alert(err_empty);theform.message.focus();return;}
				
	theform.submit();
}

function szavaz()
{
	theform  = eval('document.szavazas');
	if (!chkRadio("szavazas.vote")) {alert(err_empty);return;}	
	theform.submit();	
}

function showoffer()
{
	window.document.offer.url.value=unescape(window.opener.document.location);
	window.document.offer.content.value=window.opener.document.body.innerHTML;
}
