<script type="text/javascript">
jQuery(document).ready(function($){
	$('.newbrand').click(function(){ 
		var url = $(this).attr('href')+'/form';
		//jQuery('#addbrand').load(url, function(){$('#addbrand').dialog('open')});
		$('#addbrand').dialog('open');
		return false;
	});
	$('#addbrand').dialog({
		autoOpen: false,
		modal: true,
		width: 800,
		minHeight: 500
	});
	
	var gombmagassag = <?if($this->uri->segment(1)=="collection2"):?>56<?else:?>46<?endif;?>;
	
	//mrgtop = 362 - $('.newbrand').height();
	mrgtop = $('.colljobb').height() - $('#collullist').height() - gombmagassag; //(2*$('.newbrand').height());
	$('.newbrand').css('top',mrgtop+'px');
	
	//alert("colljobb: "+$('.colljobb').height()+"\nullist: "+$('#collullist').height()+"\ngomb: "+$('.newbrand').height()+" mrgtop: "+mrgtop);
	
	/*$(window).bind("resize", function(){
		mrgtop = 362 - 63; //$(this).height();
		$('.newbrand').css('top',mrgtop+'px');
	});*/
	
});

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 jobok   = false;
		var compok  = false;
		var emailok = false;
		var telok   = false;
		var messageok = false;
		var at = '@';
		var dot = '.';
		
        var fname  = jQuery('#name');
		var fjob   = jQuery('#job');;
		var fcomp  = jQuery('#company');;
		var femail = jQuery('#email');
		var ftel   = jQuery('#phone');
		var fmessage = jQuery('#comment');
		
		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(fjob.val() == '' || fjob.val() == '<?=$this->lang->line('downloads_error_empty_field')?>'){
			fjob.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			fjob.css({ 'background-color': '#F9E3D3' });
		}
		else{
			fjob.css({ 'background-color': '#ddd' });
			jobok = true;
		}
		
		if(fcomp.val() == '' || fcomp.val() == '<?=$this->lang->line('downloads_error_empty_field')?>'){
			fcomp.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			fcomp.css({ 'background-color': '#F9E3D3' });
		}
		else{
			fcomp.css({ 'background-color': '#ddd' });
			compok = true;
		}
		
		if(fmessage.val() == '' || fmessage.val() == '<?=$this->lang->line('downloads_error_empty_field')?>'){
			fmessage.val('<?=$this->lang->line('downloads_error_empty_field')?>');
			fmessage.css({ 'background-color': '#F9E3D3' });
		}
		else{
			fmessage.css({ 'background-color': '#ddd' });
			messageok = 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(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 && jobok==true && compok==true && emailok==true && telok==true && messageok==true )
		{
			jQuery('#addbrandform').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 type="text/css">
.newbrand{
	background: url(/public/img/collection/stilus/add_brand_button.png) 0 0 no-repeat transparent;
	font-size: 14px;
	text-align: center;
	padding: 13px 4px;
	width: 230px;
	position: relative;
	cursor: pointer;
	top: 232px;
}
</style>

<div id="collectionheader" <?if(hun()):?>style="background: url(/public/img/collection/stilus/header_bemutatoterem.png)"<?else:?>style="background: url(/public/img/collection/stilus/header_showroom.png)"<?endif;?>>
	<div class="collbal">
		<?/*<div class="collheadbal">
			<img src="/public/img/collection/stilus/menu_dropdown.png" alt="" class="nyille" />
			<h1 class="markak"><?=lang('collec2_types')?></h1>
		</div>*/?>
		<div class="collheadbal3">
			<img src="/public/img/collection/cadline/logo.png" alt="cadline logo" width="237" height="122" />
			<img src="/public/img/collection/stilus/menu_dropdown.png" alt="" class="nyille2" />
		</div>
	</div>
	<div class="collheadbal2">
		<span class="colheadback">&nbsp;</span>
		<?=$this->load->view('collection2/searchform')?>
	</div>
</div>


<div class="collbal" style="height: auto;">
<ul id="collullist">
<?foreach($types as $type):?>
<li class="colli"><a href="/<?=$this->uri->segment(1)?>/types/<?=$type->type?>"><?=$type->name?></a></li>
<?endforeach;?>
</ul>

<div class="newbrand">
<?=lang('collec2_addbrandbtn')?>
</div>
<?if(hun()):?>
	<?$lap = $this->mpages->get_row(825)?>
<?else:?>
	<?$lap = $this->mpages->get_row(824)?>
<?endif;?>
<div id="addbrand" title="<?=$lap->page_title?>" style="display: none; text-align: left;">
	<table>
	<tr>
	<td>
		<?=$lap->page_body?>
	</td>
	<td>
		<img src="/public/img/collection/montage_300.png" alt="ARCHLine.XP Showroom brands" title="ARCHLine.XP Showroom brands">
	</tr>
	</table>
	<br />
	<form id="addbrandform" action="/contact/addbrandsubmit/<?=$this->uri->segment(1)?>" method="post">
	<table>
		<tr>
			<td><label for="name">* <?=lang('name')?>:</label></td>
			<td><input type="text" name="name" id="name" style="width: 250px;"></td>
		</tr>
		<tr>
			<td><label for="job">* <?=lang('jobtitle')?>:</label></td>
			<td><input type="text" name="job" id="job" style="width: 250px;"></td>
		</tr>
		<tr>
			<td><label for="company">* <?=lang('company')?>:</label></td>
			<td><input type="text" name="company" id="company" style="width: 250px;"></td>
		</tr>
		<tr>
			<td><label for="email">* <?=lang('email')?>:</label></td>
			<td><input type="text" name="email" id="email" style="width: 250px;"></td>
		</tr>
		<tr>
			<td><label for="phone">* <?=lang('events_form_phone')?>:</label></td>
			<td><input type="text" name="phone" id="phone" style="width: 250px;"></td>
		</tr>
		<tr>
			<td valign="top"><label for="comment">* <?=lang('collec2_addbrandmsg')?>:</label></td>
			<td><textarea name="comment" id="comment" rows="4" cols="30" style="width: 250px; overflow: auto;"></textarea></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td align="right"><input type="button" value="<?=lang('send')?>" onclick="checkForm()"></td>
		</tr>
	</table>

	</form>
	</table>
</div>
</div>


<div class="colljobb">
	<img src="/public/img/collection/stilus/startpic_logos_01.jpg" alt="ARCHLine.XP Showroom" title="ARCHLine.XP Showroom" width="733" height="468px" />
	<div style="text-align: right; padding-right: 10px; position: relative; top: -450px; font-size: 1.4em; height: 0px;">
		<?=lang('collec2_welc')?>
	</div>
	
	<div style="text-align: right; padding-right: 10px; position: relative; top: -20px; height: 0px;">
		<span style="font-size: 12px; color: #3a3a3a;">
			<?=lang('collec2_viewdb')?>: <b><?=($stat->views)?></b>, <?=lang('collec2_downldb')?>: <b><?=$stat->downloads?></b>
		</span>
	</div>
</div>