<script type="text/javascript">
    // <![CDATA[
    $(document).ready(function() {
      $('#file_upload').uploadify({
        'uploader'  : '/public/uploadify-v2.1.4/uploadify.swf',
        'script'    : '/order/uploadswf/<?=$infix?>',
    /*    'cancelImg' : '/public/uploadify-v2.1.4/cancel.png',*/
        'folder'    : '<?=$azonosito?>',
        'auto'      : true,
		'removeCompleted' : false,
		'multi'          : true,
		<?if($infix=="re"):?>
		'queueSizeLimit' : 1,
		<?else:?>
		'queueSizeLimit' : 4,
		<?endif;?>
		<?if($infix=="re"):?>
		'fileDesc'    : 'ARCHLine Project',
		'fileExt'     : '*.pro',
		<?else:?>
		'fileDesc'    : 'Image Files',
		'fileExt'     : '*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.dwg',
		<?endif;?>
	/*	'hideButton'  : true,*/
		<?if($infix=="re"):?>
		'buttonImg'   : '/public/img/services/button_upload_project<?if(hun()):?>_HUN<?endif;?>.png',
		<?elseif($infix=="sk"):?>
		'buttonImg'   : '/public/img/services/button_upload_picture<?if(hun()):?>_HUN<?endif;?>.png',
		<?else:?>
		'buttonImg'   : '/public/img/services/button_upload_photo<?if(hun()):?>_HUN<?endif;?>.png',
		<?endif;?>
		'width'		  : 164,
		'height'	  : 41,
		'buttonText'  : 'Select file to upload!',
	/*	'sizeLimit'   : 8388608,*/
		'onProgress'  : function(event,ID,fileObj,data) {
			var bytes = Math.round(data.bytesLoaded / 1024);
			$('#' + $(event.target).attr('id') + ID).find('.percentage').html( '<p style="margin-right: 10px; margin-top: 1px; float: left;">'+ bytes + 'KB Uploaded</p> <img src="/public/img/services/icons_uploading.png" />');
			return false;
		},
		'onError'     : function (event,ID,fileObj,errorObj) {
			//alert(errorObj.type + ' Error: ' + errorObj.info);
			if( errorObj.type == "File Size" ){
				$('#file_upload'+ID).children('.percentage').html('<img src="/public/img/services/icon_error.png" />');
				return false;
			}else{
				$('#file_upload'+ID).children('.percentage').html('<img src="/public/img/services/icon_error.png" />');
				return false;
			}
			//alert("An error!"+errorObj.type);
			//$('.percentage').html('<img src="/public/img/services/icons_uploading.png" />');
			//return false;
		},
		'onComplete' : function(event, ID, fileObj, response, data){
		  if( response != "ERROR" ){
			$('#azonosito2').val(response);
			$('#file_upload'+ID).children('.percentage').html('<img src="/public/img/services/icon_done.png" />');
			return false;
		  }
		  else{
			//alert(fileObj.name+" is not uploaded "+response);
			alert("Error!");
			$('#file_upload'+ID).children('.percentage').html('<img src="/public/img/services/icon_error.png" />');
			return false;
		  }
		}/*,
		'onCancel'  : function(event,ID,fileObj,data) {
			//alert('The upload of has been canceled! '+fileObj.name);
		}*/
      });
      
    });
    // ]]>
</script>

<style>

	/*
	#file_uploadUploader{
		background: url('/public/img/services/button_choose.png') no-repeat;
	}
	*/
	
	td{
		padding: 2px 0 2px 20px;
		vertical-align: top;
		color: #555;
	}
	
	input[type=text], select, textarea{
		border: 1px solid #555;
		padding: 3px;
		width: 280px;
		background: #ddd;
	}
	
	
	
	.cancel{
		display: none;
    }
	.cancel a img{
		margin-top: 0px !important;
	}
    #file_uploadQueue{
		margin-top: 5px;
 
		/*border: 2px solid black;
		width: 500px;
		padding: 5px;
		border-radius: 5px 5px 5px 5px;*/
    }
	
	.uploadifyQueueItem {
		background: url(/public/img/services/box_fileupload.png);
		padding: 13px 15px 0 15px;
		margin-top: -5px;
		width: 454px;
		height: 28px;
	}
	
	.percentage{
		float: right;
	}
	
	.percentage img{
		margin: 0 !important;
	}
	
	.s-jobbratav{
		padding-right: 20px;
	}
	
</style>

<div style="width: 872px;">
<form action="/services/submit<?=$infix?>" method="post" id="uploadForm">


<h2 class="s-h2"><span class="services-kek"><?=lang('services_'.$infix)?></span> <span style="color: #c0c0c0;">&#8211;</span> <?=lang('services_upload')?></h2>

<input type="hidden" value="<?=$azonosito?>" name="azonosito" />
<input type="hidden" value="" name="azonosito2" id="azonosito2" />
<div class="bigstep-box-top1">
<span class="s-h2"><?=lang('services_signup')?></span> <span class="services-vilagos__" style="font-size: 14px; margin-left: 15px; color: #707070;"><?=lang('services_fillform')?></span>
</div>
<div class="bigstep-box">
<table>
<tr>
	<td><?=lang('name')?>: *</td>
	<td class="s-jobbratav"><input type="text" name="name" id="name" /></td>
	<td><?=lang('events_form_zip')?>:</td>
	<td><input type="text" name="zip" id="zip" /></td>
</tr>
<tr>
	<td><?=lang('services_from_com')?>:</td>
	<td class="s-jobbratav"><input type="text" name="company" id="company" /></td>
	<td><?=lang('events_form_city')?>:</td>
	<td><input type="text" name="city" id="city" /></td>
</tr>
<tr>
	<td><?=lang('email')?>: *</td>
	<td class="s-jobbratav"><input type="text" name="email" id="email" /></td>
	<td><?=lang('services_from_str')?>:</td>
	<td><input type="text" name="street" id="street" /></td>
</tr>
<tr>
	<td><?=lang('services_from_pho')?>: *</td>
	<td class="s-jobbratav"><input type="text" name="tel" id="tel" /></td>
	<td><?=lang('message')?>:</td>
	<td>
		<textarea rows="6" cols="30" name="comment" id="comment"></textarea>
	</td>
</tr>
</table>
</div>
<div class="bigstep-box-bottom"></div>

<div class="bigstep-box-top2">
<span class="s-h2"><?=lang('services_'.$infix.'_sendmit')?></span> <span class="services-vilagos__" style="font-size: 14px; margin-left: 15px; color: #707070;"><?=lang('services_'.$infix.'_sendmitleiras')?></span>
</div>
<div class="bigstep-box">
<br /><br />
<input type="file" id="file_upload" name="file_upload" /><br /><br />
</div>
<div class="bigstep-box-bottom"></div>

<div id="btnsend" class="bt-start" onclick="checkForm()"><?=lang('services_finorder')?></div>

</form>
</div>



<script type="text/javascript">

	function checkForm()
	{
		var nameok  = false;
		var emailok = false;
		var telok   = false;
		var fajlok  = false;
		var at = '@';
		var dot = '.';


		var name  = jQuery('#name');
		var email = jQuery('#email');
		var tel   = jQuery('#tel');
		var cim   = jQuery('#city');
		var fajl  = jQuery('#azonosito2');

		if(name.val() == '' || name.val() == '<?=$this->lang->line('downloads_error_empty_field')?>')
		{
			name.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			name.css({ 'background-color': '#F9D3D3' });
		}
		else{
			name.css({ 'background-color': '#EEEEEE' });
			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': '#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(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(fajl.val() == '')
		{
			alert("Missing the file");
		}
		else{
			fajlok = true;
		}
		
		
		if(nameok==true && telok==true && emailok==true && fajlok==true)
		{
			jQuery('#uploadForm').submit();
		}

    }



	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>

	