<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 at = '@';
		var dot = '.';
		
        var fname = jQuery('#name');
		var femail = jQuery('#email');
		var tel = jQuery('#tel');
		var fmessage = jQuery('#message');
		
		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(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': '#ddd' });
			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;
			}
		}
		
		
		
		if(nameok==true && emailok==true && telok==true )
		{
			jQuery('#urlap').submit();
		}
		else
		{
			//message.html('<?=$this->lang->line('downloads_error_div')?>');
		}
    }
    
    
    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>
	input, textarea, select{
		background: #ddd;
		width: 350px;
		border: 1px solid #ccc;
	}
</style>

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

<form action="/palyazat/submit" method="post" name="urlap" id="urlap">
<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>
	<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 name="url" id="url" type="text"></td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><input type="button" class="send" value="<?=lang('send')?>" style="width: 80px;" onclick="checkForm()" /></td>
</tr>
</table>
</form>

<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?>