<script type="text/javascript">
jQuery(document).ready(function($){
	
	$('.szamlaadat').css({'display': 'none'});
	
	
	$(".csoport").click(function(){
		var ez = $(this);
		if($(this).attr("checked") == true){
			var csoportja = $(this).attr("rel");
			
			$(".csoport:checked").each(function(){
				if( $(this).attr("rel") != csoportja ){
					ez.attr("checked","");
					alert("Csak egy csoportból választhat időpontokat!");
					return false;
				}
			});
			
			
			$(".csoport:not(:checked)").each(function(){
				var thistitle = $(this).attr("title");
				// azonos rel(csoport) es cim eseten a masikat inaktivva tenni
				if( ez.attr("id")!=$(this).attr("id") && ez.attr("rel")==$(this).attr("rel") && ez.attr("title")==$(this).attr("title") ){
					$(this).attr("disabled", true);
				}
				
		//		alert("ezid: "+parseInt(ez.val(),10)+", thisid: "+parseInt($(this).val(),10));
				// ha ez furdo vagy konyha, akkor korabbi alapozot/nappalit ne jeloljon
				if( (ez.attr("title")=="Fürdőszoba tervezés" || ez.attr("title")=="Konyhatervezés") &&
					(thistitle=="Nappali tervezés" || thistitle=="ARCHLine.XP Alapozó") && 
					(parseInt(ez.attr("sorszam"),10)) < parseInt($(this).attr("sorszam"),10) && 
					ez.attr("rel")==$(this).attr("rel")
				)
				{
						$(this).attr("disabled", true);
				}
				
				// ha nappali vagy alapozo, akkor ne jelöljön be korabbi furdot vagy konyhat
				if( (ez.attr("title")=="Nappali tervezés" || ez.attr("title")=="ARCHLine.XP Alapozó") && 
					(thistitle=="Fürdőszoba tervezés" || thistitle=="Konyhatervezés") && 
					(parseInt(ez.attr("sorszam"),10)) > parseInt($(this).attr("sorszam"),10) && 
					ez.attr("rel")==$(this).attr("rel")
				){
					$(this).attr("disabled", true);
				}
				
			});
			
		}
		else{
			
			var voltkezdo = false;
			var volthalado = false;
			
			$(".csoport:checked").each(function(){
				var thistitle = $(this).attr("title");
				
				if( (thistitle=="Nappali tervezés" || thistitle=="ARCHLine.XP Alapozó") &&
					ez.attr("rel")==$(this).attr("rel")
				){
					voltkezdo = true;
				}
				
				if( (thistitle=="Fürdőszoba tervezés" || thistitle=="Konyhatervezés") &&
					ez.attr("rel")==$(this).attr("rel")
				){
					volthalado = true;
				}
				
			});
			
			if(!voltkezdo && !volthalado)
				$(".csoport").removeAttr("disabled");
			
			
			// a masikat felszabaditani
			/*$(".csoport:not(:checked)").each(function(){
				var thistitle = $(this).attr("title");
				
				if( ez.attr("id")!=$(this).attr("id") && ez.attr("rel")==$(this).attr("rel") && ez.attr("title")==$(this).attr("title") && !voltkezdo && !volthalado ){
					$(this).removeAttr("disabled");
				}
				
				// ha nappali vagy alapozo, akkor ne jelöljön be korabbi furdot vagy konyhat
				if( voltkezdo == false &&
					(ez.attr("title")=="Nappali tervezés" || ez.attr("title")=="ARCHLine.XP Alapozó") && 
					(thistitle=="Fürdőszoba tervezés" || thistitle=="Konyhatervezés") &&
					ez.attr("rel")==$(this).attr("rel")
				){
					$(this).removeAttr("disabled");
				}
				
				// ha furdo vagy konyha, akkor ne jelöljön be kesobbi nappailt vagy alapozot
				if( volthalado == false &&
					(ez.attr("title")=="Fürdőszoba tervezés" || ez.attr("title")=="Konyhatervezés") && 
					(thistitle=="Nappali tervezés" || thistitle=="ARCHLine.XP Alapozó") &&
					ez.attr("rel")==$(this).attr("rel")
				){
					$(this).removeAttr("disabled");
				}
				
			});*/
		}
	});
	
	
	$('#elteroszamlaadat').click(function(){
		$('.szamlaadat').css({'display': ''});
		return false;
	});
	
	$('#mehet').click(function(){
		
		var error = "";
		var errorki = "";
		
		var nyelv = <?if(hun()):?>'hun'<?else:?>'eng'<?endif;?>;
		if( !checkFormPersonal(nyelv) ){
			error += "hiba";
		}
		
		
		if( !$('#policy').is(':checked') ){
			error += "Missing the accept!";
			errorki += "<?=lang('event_elkellfog')?>";
			$('#policyspan').css({ 'background-color': '#FFAA44' });
		}else
			$('#policyspan').css({ 'background-color': '' });
		
		var darab = 0;
		$(".csoport:checked").each(function(){
			darab = darab+1;
		});
		if(darab < 1){
			error += "\nAz érvényes jelentkezéshez legalább 1 workshopot kell kiválasztania";
			errorki += "\n\nAz érvényes jelentkezéshez legalább 1 workshopot kell kiválasztania";
		}
		
		if( errorki != "" )
			alert(errorki);
		
		
		if(error == "")
			$('#registration_form').submit();
		
		return false;
	});
	
	aktmenu();
	
	function aktmenu(){
		$('a.tema').each(function(){
			
			var reg = /<?=$akt?>$/;
			if( reg.test($(this).attr('href')) ){
				if( "<?=trim($akt)?>" != "" )
					$(this).parent().css({'background': '#b9b9b9'});
			}
			
		});
	}
	
	<?if( isset($_SESSION['default']['wshiba'],$_SESSION['default']['wshibaadatok']) &&  $_SESSION['default']['wshiba']!=" " ):?>
	$('#nev').val('<?=$_SESSION['default']['wshibaadatok']['nev']?>');
	$('#varos').val('<?=$_SESSION['default']['wshibaadatok']['varos']?>');
	$('#cegnev').val('<?=$_SESSION['default']['wshibaadatok']['cegnev']?>');
	$('#irsz').val('<?=$_SESSION['default']['wshibaadatok']['irsz']?>');
	$('#cim').val('<?=$_SESSION['default']['wshibaadatok']['cim']?>');
	$('#tel').val('<?=$_SESSION['default']['wshibaadatok']['tel']?>');
	$('#email').val('<?=$_SESSION['default']['wshibaadatok']['email']?>');
	$('#comment').val('<?=$_SESSION['default']['wshibaadatok']['comment']?>');
	
	<?endif;?>
	
//	alert("betoltve");
});

function mutat(mit){
	kivdiv = document.getElementById(mit);
	if(kivdiv.style.display == "" )
		kivdiv.style.display = "none";
	else
		kivdiv.style.display = "";
}
</script>

<div id="baloldal" style="width: 252px; float: left; margin: 0 5px 0 -20px;">
<div class="ws-cim-top"></div>
<div class="keret">
<h1 style="margin: 0px; border: none; color: #454545; font-size: 1.2em; font-weight: normal;"><?=lang('event_ws_cim')?></h1><br />
<?$this->load->view('interior/ws_menu');?>
</div>
<div class="ws-cim-bottom"></div>


<div class="ws-focim"><?=lang('event_ws_cim')?></div>

<div class="ws-cim-top"></div>
<div class="ws-cim" onclick="location.href='/interior/workshop/why_to_choose'" style="cursor: pointer;"><?=lang('event_whychoose')?></div>
<div id="choose" class="keret" style="display: none;">
	<?/*	if(!hun()) $info = $this->mpages->get_row(604);
		else $info = $this->mpages->get_row(604);
		if($info) print $info->page_body;*/
	?>
</div>
<div class="ws-cim-bottom2"></div>

<div class="ws-cim-top2"></div>
<div class="ws-cim" onclick="location.href='/interior/workshop/workshop_information'" style="cursor: pointer;"><?=lang('event_geninf')?></div>
<div id="generalinf" class="keret" style="display: none;">
	<?/*	if(!hun()) $info = $this->mpages->get_row(603);
		else $info = $this->mpages->get_row(603);
		if($info) print $info->page_body;*/
	?>
</div>
<div class="ws-cim-bottom2"></div>

<div class="ws-cim-top2"></div>
<div class="ws-cim" onclick="location.href='/interior/workshop/our_customers_say'" style="cursor: pointer;"><?=lang('event_custsay')?></div>
<div class="ws-cim-bottom"></div>


</div>


<div id="kozepsooldal" style="width: 460px; float: left; margin-right: 0px; padding: 0 0px;">
<div class="keret-kozep-top"></div>
<div class="keret-kozep">
<?	
	if($this->uri->segment(3)=="haladokurzus") $info = $this->mpages->get_row(808);
	else $info = $this->mpages->get_row(800);
	print $info->page_body;
?>
</div>
<div class="keret-kozep-bottom"></div>

<?if(!$altalanos):?>
<div style="padding: 0 7px;">
<h2><?=$event->name?></h2>
</div>
<?if( $event->fokep != "" && file_exists("public/img/workshop/ENG/subjects/".$event->fokep) && $this->uri->segment(4) != "register" ):?>
<a href="/public/img/workshop/ENG/subjects/<?if(file_exists("public/img/workshop/ENG/subjects/big_".$event->fokep)):?>big_<?endif;?><?=$event->fokep?>" class="fancy" title="<?=$event->name?>" rel="group">
	<img src="/public/img/workshop/ENG/subjects/<?=$event->fokep?>" style="padding-left: 1px;" alt="<?=$event->name?>" />
</a>
<?endif;?>
<?
//$xx = $this->phpsession->get('wshiba');
$xx = $_SESSION['default']['wshiba'];
unset($_SESSION['default']['wshiba']);
$esemid = $this->uri->segment(5);
$vanparkolo = $vangep = false;
?>
<div style="padding: 0 7px 0 0;">
<div id="regdiv">
	<?if($xx!==""):?><div style="color: #f00; text-align: center;"><?=$xx?></div><?endif;?>
	<?=form_open('events/csoportosregisztracio', array('id' => 'registration_form'))?>
	<?=form_hidden('do', 'OK')?>
	<?=form_hidden('event_main_id', $this->uri->segment(3))?>
	<div class="event_chooser_list" style="margin: 20px 0px;">
		<ul><?//print_r($dates)?>
			<?if( count($dates) > 0 ):?>
			<?$i=10;?>
			<?foreach($dates as $date):?>
			<?
			if(!$csoport){
				$csoport = $date->csoport;
				
				print "<div class=\"keret-kozep-top\"></div><div class=\"keret-kozep\">";
				//if($this->uri->segment(3)!="haladokurzus")
					print "<b>"/*.substr($date->csoport,-1)*/." Kurzus</b>";
			}
			elseif($csoport != $date->csoport){
				print "</div><div class=\"keret-kozep-bottom\" style=\"margin-top: -5px;\"></div><div class=\"keret-kozep-top\"></div><div class=\"keret-kozep\">";
				//if($this->uri->segment(3)!="haladokurzus")
					print "<b>"/*.substr($date->csoport,-1)*/." Kurzus</b>";
				$csoport = $date->csoport;
			}
			
			$aktivhet = date('W',$date->start_ts);
			if(!$het){
				$het = $aktivhet;
			}
			elseif($het != $aktivhet){
				print "<br>";
				$het = $aktivhet;
			}
			//print_r($date);
			?>
				
			<li style="margin-left: 7px;">
				<input type="checkbox" name="event_ids[]" value="<?=$date->event_id?>" id="ip<?=$date->event_id?>" <?if(!$date->times->able_to_reg):?> disabled="disabled"<?endif;?> class="csoport" rel="<?=$date->csoport?>" title="<?=$date->name?>" sorszam="<?=$i?>" />
				<label for="ip<?=$date->event_id?>">
				<b>
				<?=$this->dateclass->getDateString($date->start_ts)?> 
				<?=date('H:i',$date->start_ts)?> - <?=date('H:i',$date->end_ts)?>
				<?if(!$date->times->able_to_reg && hun()):?> (betelt)<?endif;?>
				
				<?=$date->name?>
				</b>
				</label>
				
				<br />
				
				<?if( $date->times->parkolo<3 || (!in_array($date->event_main_id,array(10,13)) && $date->times->parkolo<4)):?>
				<input name="parkolo[<?=$date->event_id?>]" id="parkolo<?=$date->event_id?>" type="checkbox" style="margin-left: 35px;" /> <label for="parkolo<?=$date->event_id?>">Parkolóhelyet kérek</label>
				<?endif;?>
				
				<?if($date->times->gep<2):?>
				<input name="gep[<?=$date->event_id?>]" id="gep<?=$date->event_id?>" type="checkbox" style="margin-left: 35px;" /> <label for="gep<?=$date->event_id?>">Gépet kérek</label>
				<?endif;?>
				
			</li>
			<?$i++;?>
			<?endforeach;?>
			
			</div><div class="keret-kozep-bottom" style="margin-top: -5px;"></div>
			<?endif;?>
		</ul>
	</div>
	
	<table cellpadding="5" cellspacing="0" align="center" width="450px">
		<?=$this->load->view('form_general')?>
		
		<tr>
			<td><?=lang('events_form_comment')?>:</td>
			<td><input type="text" name="comment" id="comment" value="<?=$this->input->post('comment')?>" /></td>
		</tr>
		<?if(hun()):?>
		<tr id="elteroszamlaadat" style="cursor: pointer">
			<td colspan="2">Számlázási adatok (ha eltér a fentiektől)</td>
		</tr>
		<tr class="szamlaadat">
			<td>Név, Cégnév:</td>
			<td><input type="text" name="sz_nev" id="sz_nev" value="<?=$this->input->post('nev')?>" /></td>
		</tr>
		<tr class="szamlaadat">
			<td><?=lang('events_form_city')?>:</td>
			<td><input type="text" name="sz_varos" id="sz_varos" value="<?=$this->input->post('varos')?>" /></td>
		</tr>
		<tr class="szamlaadat">
			<td><?=lang('events_form_zip')?>:</td>
			<td><input type="text" name="sz_irsz" id="sz_irsz" value="<?=$this->input->post('irsz')?>" /></td>
		</tr>
		<tr class="szamlaadat">
			<td><?=lang('events_form_address')?>:</td>
			<td><input type="text" name="sz_cim" id="sz_cim" value="<?=$this->input->post('cim')?>" /></td>
		</tr>
		<?endif;?>
		<tr>
			<td align="center" colspan="4">
				<span id="policyspan"><input type="checkbox" id="policy" name="policy" /><label for="policy"> <?=lang('event_feltelfog')?> </label><a href="<?if(!hun()):?>http://www.archlinexp.com/page/show/ws-policy-conditions<?else:?>http://www.archline.hu/page/show/workshop-feltetelek<?endif;?>" target="_blank" class="mutat" style="color: #f00"><?=lang('event_feltelek')?></a></span>
			</td>
		</tr>
		<tr class="rejtettelem">
			<td>Link:</td>
			<td><input type="text" name="url" /></td>
		</tr>
		<tr>
			<td align="center" colspan="4"><button name="mehet" type="submit" id="mehet" ><?=lang('events_form_sub_reg')?></button>
</td>
		</tr>
	</table>
	<?=form_close()?>
</div> <?/* END regdiv */?>
<br /><br /><br />
</div>
<?else:?>
<div class="ws-text" style="padding: 0 7px;">
	<h2><?=$event->page_title?></h2>
	<?=$event->page_body?>
</div>
<?endif;?>


</div>


<div id="jobboldal" style="width: 252px; float: left; margin-right: -20px;">

<div class="ws-focim"><?=lang('event_relinf')?></div>
<div class="ws-cim-top"<?if( !hun() ):?> style="height: 2px; background-position: 0 6px; margin-top: -2px;"<?endif;?>></div>
<div class="ws-cim" onclick="mutat('location')" style="cursor: pointer;"><?=lang('event_locationcal')?></div>
<div id="location" class="keret" style="display: none;">
	<br /><strong>CadLine Kft.</strong><br />
	1037 Budapest, Montevideo u. 3/B.<br /><br />
</div>
<div class="ws-cim-bottom2"></div>



<div class="ws-cim-top2"></div>
<div class="ws-cim" onclick="mutat('bring')" style="cursor: pointer;"><?=lang('event_bringwithme')?></div>
<div id="bring" class="keret" style="display: none;">
	<?	if(!hun()) $info = $this->mpages->get_row(606);
		else $info = $this->mpages->get_row(607);
		if($info) print $info->page_body;
	?>
</div>
<div class="ws-cim-bottom2"></div>

<div class="ws-cim-top2"></div>
<div class="ws-cim ws-cim-link" onclick="location.href='/interior/download'">Trial <?=lang('download')?></div>
<div class="ws-cim-bottom2"></div>

<div class="ws-cim-top2"></div>
<div class="ws-cim ws-cim-link" onclick="location.href='/public/downloads/hun/workshop/Hun_Workshop_Kezdo_2013_setup.exe'"><?=lang('download_ws_ke')?></div>
<div class="ws-cim-bottom2"></div>

<div class="ws-cim-top2"></div>
<div class="ws-cim ws-cim-link" onclick="location.href='/public/downloads/hun/workshop/Hun_Workshop_Halado_2013_setup.exe'"><?=lang('download_ws_ha')?></div>
<div class="ws-cim-bottom"></div>


</div>
