<?//$this->load->view('interior/tabs')?>

<div>
<?if(!hun()):?>

<a href="/interior"><div id="banner"></div></a>

<?else:?>

<a href="/interior"><div id="banner"></div></a>

<?endif;?>

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



<div class="float-50">

	<p style="margin: 0px 0px 0px 0px;">

		<?=form_open('downloads/validate', array('id' => 'downloadForm'))?>
		<?=form_hidden('do','free')?>
			<table width="100%">
				<tr>
					<td width="75">
						<strong><?=lang('name')?></strong>
					</td>
					<td width="auto">
						<input type="text" size="27" name="first" id="first" />
					</td>
				</tr>
				<tr>
					<td width="100">
						<strong><?=lang('country')?></strong>
					</td>
					<td>
						<select name="country" id="country" style="width:188px;">
						    <?if(eng()):?>
						    <option value="-1" selected="selected">--Choose--</option>
						    <?endif;?>
						<?foreach($ctr as $row):?>
							<option value="<?if(hun()):?><?=$row->ctrNameHun?><?else:?><?=$row->ctrNameEng?><?endif;?>" <?if(hun()):?><?if($row->ctrNameHun=='Magyarország'):?><?='selected="selected"'?><?endif;?><?elseif(jap()):?><?if($row->ctrNameEng=='Japan'):?><?='selected="selected"'?><?endif;?><?endif;?>
							<?if( esp() && $row->ctrNameEng=='Spain'){ print'selected="selected"'; }?>
							>
								<?if(hun()):?>
									<?=$row->ctrNameHun?>
								<?else:?>
									<?=$row->ctrNameEng?>
								<?endif;?>
							</option>
						<?endforeach;?>
						</select>
					</td>
				</tr>
				<tr>
					<td width="100">
						<strong><?=lang('tel')?></strong>
					</td>
					<td>
						<input type="text" size="27" name="tel" id="tel" />
					</td>
				</tr>
				<tr>
					<td width="100">
						<strong><?=lang('address')?></strong>
					</td>
					<td>
						<input type="text" size="27" name="cim" id="cim" />
					</td>
				</tr>
				<tr>
					<td width="100">
						<strong><?=lang('email')?></strong>
					</td>
					<td>
						<input type="text" size="27" name="email" id="email" />
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center">
						<input type="checkbox" name="public" id="public" /><?=lang('public')?>
					</td>
				</tr>
			</table>
			<br />

			<center>

				<img id="btnDown" src="/public/img/gombok/download_button_int_<?=$this->muser->user['lang']?>.png" height="30" width="250" alt="Submit Form" />

				<br />

				<div style="padding:20px 10px;color:#e8670c;font-weight:bold;"><?=$this->load->view('downloads/consent', true)?></div>

				<div id="message"></div>

			</center>



		</form>

	</p>

</div>

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


<?=$cimlap->page_body ?>



<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 firstnameok = false;
		var emailok = false;
		var telok = false;
		var cimok = false;
		var publicCBok = false;
		var countryok = false;
		var at = '@';
		var dot = '.';


		var country = jQuery('#country');
		var firstname = jQuery('#first');
		var email = jQuery('#email');
		var tel = jQuery('#tel');
		var cim = jQuery('#cim');
		var message = jQuery('#message');
		var publicCB = jQuery('#public');


		message.html('<?=$this->lang->line('downloads_wait')?>');


		if(firstname.val() == '' || firstname.val() == '<?=$this->lang->line('downloads_error_empty_field')?>')
		{
			firstname.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			firstname.css({ 'background-color': '#F9D3D3' });
		}
		else{
            firstname.css({ 'background-color': '#EEEEEE' });
			firstnameok = 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': '#F9D3D3' });
		}
		else if( !telefonCheck(tel.val()) ){
			tel.val('<?=$this->lang->line('downloads_error_tel_field')?>');
			tel.css({ 'background-color': '#F9D3D3' });
		}
		else
		{
			tel.css({ 'background-color': '#EEEEEE' });
			telok = true;
		}

		if(cim.val() == '' || cim.val() == '<?=$this->lang->line('downloads_error_empty_field')?>')
		{
			cim.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			cim.css({ 'background-color': '#F9D3D3' });
		}
		else
		{
			cim.css({ 'background-color': '#EEEEEE' });
			cimok = true;
		}
/*
        if(publicCB.attr('checked') == 1 && (cim.val() == '<?=$this->lang->line('downloads_error_empty_field')?>' || cim.val() == ''))
		{
			cim.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			cim.css({ 'background-color': '#F9D3D3' });
		}
		else{
            cim.css({ 'background-color': '#EEEEEE' });
			publicCBok = true;
		}
*/
		publicCBok = true;

		if(email.val() == '' || email.val() == '<?=$this->lang->line('downloads_error_empty_field')?>')
		{
			email.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			email.css({ 'background-color': '#F9D3D3' });
		}
		else{
			if(email.val().indexOf(at)==-1 || email.val().indexOf(at)==0 || email.val().indexOf(at)==email.val().length-1 || email.val().indexOf(dot)==-1 || email.val().indexOf(dot)==0 || email.val().indexOf(dot)>=email.val().length-2)
			{
				email.val('<?=$this->lang->line('downloads_error_email_field')?>');
				email.css({ 'background-color': '#F9D3D3' });
			}
			else{
				email.css({ 'background-color': '#EEEEEE' });
				emailok = true;
			}
		}
		
		if(country.val()==-1)
		{
			country.css({ 'border': '1px red solid', 'background-color': '#F9D3D3' });
		}
		else
		{
			countryok = true;
			country.css({ 'border': '1px red none', 'background-color': '#EEEEEE' });
		}


		if(firstnameok==true && telok==true && cimok==true  && emailok==true && publicCBok==true && countryok==true)
		{
			jQuery('#downloadForm').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")){
		//	alert("Ez nem jó telefonszám!");
			return false;
		}
		else{
			return true;
		}
	}

</script>

</div>