<script type='text/javascript'>
	function checkError(inputID)
	{
		var value = jQuery('#' + inputID).val();
		
		if(value == '<?=$this->lang->line('downloads_error_empty_field')?>' || value == '<?=$this->lang->line('downloads_error_email_field')?>')
			jQuery('#' + inputID).val('');
	}
	
	function checkForm()
	{
		var nameok    = false;
		var emailok   = false;
		var telok     = false;
		var renderok  = false;
		var elfogadok = false;
		var at  = '@';
		var dot = '.';
        var fname  = jQuery('#name');	
		var femail = jQuery('#email');
		var tel    = jQuery('#tel');
		var felfogad = jQuery('#elfogad');
		var fmessage = jQuery('#message');
		var ffajl1   = jQuery("#kep1").val();
		var ffajl2   = jQuery("#kep2").val();
		var ffajl3   = jQuery("#kep3").val();
		var frendpr1 = true;
		var frendpr2 = true;
		var frendpr3 = true;

		if(fname.val() == '' || fname.val() == '<?=$this->lang->line('downloads_error_empty_field')?>')
		{
			fname.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			fname.css({ 'background-color': '#F9E3D3' });
		}
		else{
			fname.css({ 'background-color': '#ddd' });
			nameok = true;
		}
		
	//	if( document.forms[1]["elfogad"].checked != true ){
		if( felfogad.attr('checked') != true ){
			felfogad.css({ 'background-color': '#F9E3D3' });
			elfogadok = false;
			alert("<?=lang('kt_elfogadas')?>");
		}else{
			felfogad.css({ 'background-color': '#ddd' });
			elfogadok = true;
		}
		
		
		if(tel.val() == '' || tel.val() == '<?=$this->lang->line('downloads_error_empty_field')?>')
		{
			tel.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			tel.css({ 'background-color': '#F9E3D3' });
		}
		else if( !telefonCheck(tel.val()) ){
			tel.val('<?=$this->lang->line('downloads_error_tel_field')?>');
			tel.css({ 'background-color': '#F9E3D3' });
		}
		else{
			tel.css({ 'background-color': '#dddddd' });
			telok = true;
		}
		
		
		if(femail.val() == '' || femail.val() == '<?=$this->lang->line('downloads_error_empty_field')?>')
		{
			femail.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			femail.css({ 'background-color': '#F9E3D3' });
		}
		else
		{
			if(femail.val().indexOf(at)==-1 || femail.val().indexOf(at)==0 || femail.val().indexOf(at)==femail.val().length-1 || femail.val().indexOf(dot)==-1 || femail.val().indexOf(dot)==0 || femail.val().indexOf(dot)>=femail.val().length-2)
			{
				femail.val('<?=$this->lang->line('downloads_error_email_field')?>');
				femail.css({ 'background-color': '#F9E3D3' });
			}
			else
			{
				femail.css({ 'background-color': '#ddd' });
				emailok = true;
			}
		}
		
		<?for($i=1;$i<=3;$i++):?>
		var rendkiv<?=$i?> = false;
		if(ffajl<?=$i?> == "" || frendpr<?=$i?> != undefined){
			rendkiv<?=$i?> = true;
		}
		<?endfor;?>
		
		if(rendkiv1==true && rendkiv2==true && rendkiv3==true)
			renderok=true;
		
		if(nameok==true && emailok==true && telok==true && elfogadok==true && renderok==true)
		{
			jQuery('#urlap').submit();
		}
		else
		{
			//message.html('<?=$this->lang->line('downloads_error_div')?>');
			if(renderok==false){
				alert("Kérjük, adja meg, milyen renderelővel készültek a képek!");
			}
		}
    }
	
	
	function teszt(adat,minta){
		for (var i=0; i<adat.length; i++)
			if (minta.indexOf(adat.charAt(i)) == -1)
				return false;
		
		return true;
	}
	
	function tartalmaz(adat,minta){
		for (var i=0; i<adat.length; i++)
			if (minta.indexOf(adat.charAt(i)) != -1)
				return true;
		return false;
	}
	
	function telefonCheck(ertek){
		if (ertek == "") return false;
		if (ertek.length < 6 ) return false;
		if (!teszt(ertek,"1234567890()/- ") || !tartalmaz(ertek,"1234567890")){
			return false;
		}
		else{
			return true;
		}
	}
	
</script>

<style>
	#urlap input[type=text], textarea, select{
		background: #ddd;
		width: 320px;
		border: 1px solid #ccc;
	}
  
  .rejtettelem 
  {
    display: none;
  }
</style>

<h2><?=$page->page_title?></h2>

<?if(true):?>
<form action="/palyazat/designateraszonsubmit" method="post" name="urlap" id="urlap" enctype="multipart/form-data" >
<div style="width: 350px; float: left; margin-right: 30px;">
<input type="hidden" name="subject" id="subject" value="<?=$tema?>" />
<table>
<tr>
	<td><strong><?=lang('name')?>: </strong></td>
	<td><input type="text" name="name" id="name" /></td>
</tr>
<tr>
	<td><strong><?=lang('email')?>: </strong></td>
	<td><input type="text" name="email" id="email" /></td>
</tr>
<tr>
	<td><strong><?=lang('tel')?>: </strong></td>
	<td><input type="text" name="tel" id="tel" /></td>
</tr>
<tr>
	<td valign="top" style="padding-top: 20px;"><strong><?=lang('message')?>: </strong></td>
	<td>
	<p><textarea rows="10" cols="63" name="message" id="message"></textarea></p>
	</td>
</tr>
<tr class="rejtettelem">
	<td><strong>Link: </strong></td>
	<td><input type="text" name="url" id="url" /></td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><input type="button" class="send" value="<?=lang('send')?>" style="width: 80px;" onclick="checkForm()" /></td>
</tr>
</table>
</div>

<div style="width: 420px; margin-left: 390px;">
<table border="0">
<tr>
	<td valign="top"><strong>1. <?=lang("kt_kep")?>: </strong></td>
	<td>
		<input type="file" name="kep1" id="kep1" />
	</td>
</tr>
<tr>
	<td valign="top"><strong>2. <?=lang("kt_kep")?>: </strong></td>
	<td>
		<input type="file" name="kep2" id="kep2" />
	</td>
</tr>
<tr>
	<td valign="top"><strong>3. <?=lang("kt_kep")?>: </strong></td>
	<td>
		<input type="file" name="kep3" id="kep3" />
	</td>
</tr>
<tr>
	<td valign="top"><strong>4. <?=lang("kt_kep")?>: </strong></td>
	<td>
		<input type="file" name="kep4" id="kep4" />
	</td>
</tr>
</table>
<div style="border: 1px solid black; padding: 5px; margin-top: 10px;">
<?=lang('kt_szabalyzat')?><br />
<input type="checkbox" name="elfogad" id="elfogad" style="width: 12px;" /> <label for="elfogad"><?=lang("kt_elfogadom")?></label>
</div>
</div>
</form>
<?else:?>
<b>A beküldési határidő lejárt!</b>
<?endif;?>

<div class="clear"></div>



<script type="text/javascript" src="/public/editor/fckeditor.js"></script>
<script type="text/javascript">
/*window.onload = function()
{
	var oFCKeditor = new FCKeditor( 'message' ) ;
	oFCKeditor.BasePath = "/public/editor/";
	oFCKeditor.Width="350";
	oFCKeditor.Height="200";
	oFCKeditor.ToolbarSet="Basic";
	oFCKeditor.ReplaceTextarea() ;
}*/
</script>

<?=$page->page_body?>