<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 cimok = false;
		var messageok = false;
		var at = '@';
		var dot = '.';
		
        var fname = jQuery('#name');
		var femail = jQuery('#email');
		var ftel = jQuery('#phone');
		var fmessage = jQuery('#message');
		var fcim = jQuery('#address');
		var tel = jQuery('#tel');
		
		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(ftel.val() == '' || ftel.val() == '<?=$this->lang->line('downloads_error_empty_field')?>')
		{
			ftel.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			ftel.css({ 'background-color': '#F9E3D3' });
		}
		else if( !telefonCheck(ftel.val()) ){
			ftel.val('<?=$this->lang->line('downloads_error_tel_field')?>');
			ftel.css({ 'background-color': '#F9E3D3' });
		}
		else{
			ftel.css({ 'background-color': '#ddd' });
			telok = true;
		}
		
		
		
		if(fcim.val() == '' || fcim.val() == '<?=$this->lang->line('downloads_error_empty_field')?>')
		{
			fcim.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			fcim.css({ 'background-color': '#F9E3D3' });
		}
		else
		{
			fcim.css({ 'background-color': '#ddd' });
			cimok = 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 && telok==true && cimok==true  && emailok==true && cimok==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>
	#content input, #content textarea, #content select{
		background: #ddd;
		width: 350px;
		border: 1px solid #ccc;
	}
</style>


<div style="padding: 5px 0 0 5px; margin-left: 170px;">

<h1>Contact us</h1>

<p>Please fill in the form below and press the Send button and we will get back to you as soon as possible.</p><br />


<form action="/contact/submit" method="post" name="urlap" id="urlap">
<table>
<tr>
	<td><strong><?=lang('name')?>: </strong></td>
	<td><input type="text" name="name" id="name" /></td>
</tr>
<tr>
	<td><strong><?=lang('events_form_company')?>: </strong></td>
	<td><input type="text" name="company" id="company" /></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="phone" id="phone" /></td>
</tr>
<tr>
	<td><strong><?=lang('address')?>: </strong></td>
	<td><input type="text" name="address" id="address" /></td>
</tr>
<tr class="rejtettelem">
	<td><strong>Link: </strong></td>
	<td><input type="text" name="url" id="url" /></td>
</tr>
<?if($this->uri->segment(3)=="demo"):?>
<tr>
<td></td><td><input type="hidden" name="subject" value="<?=lang('contact_req_demo')?>" /></td>
</tr>
<?else:?>
<tr>
	<td><strong><?=lang('subject')?>: </strong></td>
	<td>
		<select id="subject" name="subject">
			<option value="<?=lang('contact_req_call')?>" selected="selected"><?=lang('contact_req_call')?></option>
			<option value="<?=lang('contact_sign_newsletter')?>"><?=lang('contact_sign_newsletter')?></option>
			<option value="<?=lang('contact_other')?>"><?=lang('contact_other')?></option>
		</select>
	</td>
</tr>
<?endif;?>
<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>
	<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>

</div>