<?php
class Interior extends Controller
{
	function Interior()
	{
		parent::Controller();
	}
	
	function index()
	{
		if(true || !hun()){
			$this->indexv3();
			return;
		}
		
		$this->load->model('minterview');
		
		if(hun())
			$data['page'] = $this->mpages->get_row(508);
		elseif(esp())
			$data['page'] = $this->mpages->get_row(683);
		else
			$data['page'] = $this->mpages->get_row(502);
		
		$data['mobilink'] = "/mobile/interior";
		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program' : 'ARCHLine.XP Interior Design Software';
		$data['tartalom'] = 'interior/index';
		$data['javascript'] = array(
	         					'fancybox/jquery-1.3.2.min',
								'fancybox/jquery.easing.1.3',
								'fancybox/jquery.fancybox-1.2.1.pack'/*,
								'fancybox/fancy'*/
							);
		$data['style'] = array('fancybox_gal');
		
		$data['csik']=array('home','products');
		
		$this->load->view('site',$data);
	}
	
	function indexv2(){
		$this->load->model('minterview');
		
		if(hun())
			$data['page'] = $this->mpages->get_row(793);
		else
			$data['page'] = $this->mpages->get_row(781);
		
		$data['mobilink'] = "/mobile/interior";
		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program' : 'ARCHLine.XP Interior Design Software';
		$data['tartalom'] = 'interior/index_v2';
		$data['javascript'] = array(
	         					'fancybox/jquery-1.3.2.min',
								'fancybox/jquery.easing.1.3',
								'fancybox/jquery.fancybox-1.2.1.pack',
								'fancybox/fancy'
							);
		$data['style'] = array('fancybox_gal');
		
		$data['csik']=array('home','products');
		
		$this->load->view('site',$data);
	}
	
	function indexv3(){
		$this->load->model('minterview');
		
		if(hun())
			$data['page'] = $this->mpages->get_row(793);
		else
			$data['page'] = $this->mpages->get_row(818);
		
		$data['mobilink'] = "/mobile/interior";
		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program' : 'ARCHLine.XP Interior Design Software';
		$data['tartalom'] = 'interior/index_v2';
		$data['javascript'] = array(
	         					'fancybox/jquery-1.3.2.min',
								'fancybox/jquery.easing.1.3',
								'fancybox/jquery.fancybox-1.2.1.pack'/*,
								'fancybox/fancy'*/
							);
		$data['style'] = array('fancybox_gal');
		
		$data['csik']=array('home','products');
		
		$this->load->view('site',$data);
	}
	
	function workshopgetdates(){
		$this->load->model('mevents');
		$this->load->library('dateclass');
		
		$data['event1'] = $this->db->query("SELECT * FROM events_new_main WHERE urlname = 'csoport' AND language_id = 2")->row();
		$data['event2'] = $this->db->query("SELECT * FROM events_new_main WHERE urlname = 'haladokurzus' AND language_id = 2")->row();

		$data['dates1'] = $this->db->query("SELECT * FROM events_new WHERE csoport IN ('A','B','C','D') AND start_ts > ".time()." AND active = 1 AND deleted = 0 ORDER BY csoport, start_ts")->result();
		$data['dates2'] = $this->db->query("SELECT * FROM events_new WHERE csoport IN ('HK','HK_A','HK_B','HK_C','HK_D') AND start_ts > ".time()." AND active = 1 AND deleted = 0 ORDER BY csoport, start_ts")->result();

		$results1 = $this->mevents->getEventDatesByDay($data['event1']->event_main_id, true);
		$results2 = $this->mevents->getEventDatesByDay($data['event2']->event_main_id, true);

		foreach($data['dates1'] as $date){
			print $this->dateclass->getDateString($date->start_ts);
		}
		foreach($data['dates2'] as $date){
			print $this->dateclass->getDateString($date->start_ts);
		}
	}
	
	function workshop(){
		$this->load->model('mevents');
		$this->load->library('dateclass');
		
		$kezdo = array('nappali','konyhatervezes','furdoszoba_tervezes','virtual_staging','alapozo');
		
		if($this->muser->user['lang'] == "hun")
			$lang = 1;
		else
			$lang = 2;
		
		//$main_events = $this->mevents->getWorkshop($lang, true);
		
		$urlveg = $this->uri->segment(3); //print "SELECT * FROM events_new WHERE csoport = '".$this->uri->segment(4)."' AND start_ts > ".time()." AND active = 1 AND deleted = 0 ORDER BY start_ts";
		
		$data['event'] = $this->db->query("SELECT * FROM events_new_main WHERE urlname = '".$urlveg."' AND language_id = ".$lang)->row();
		
		if( $data['event'] || $urlveg=="csoport" || $urlveg=="haladokurzus" ){
			if($urlveg=="csoport")
				$data['dates'] = $this->db->query("SELECT * FROM events_new WHERE csoport IN ('A','B','C','D') AND start_ts > ".time()." AND active = 1 AND deleted = 0 ORDER BY csoport, start_ts")->result();
			elseif($urlveg=="haladokurzus"){
				$data['dates'] = $this->db->query("SELECT * FROM events_new WHERE csoport IN ('HK','HK_A','HK_B','HK_C','HK_D') AND start_ts > ".time()." AND active = 1 AND deleted = 0 ORDER BY csoport, start_ts")->result();
			}else
				$data['dates'] = $this->db->query("SELECT * FROM events_new WHERE event_main_id = '".$data['event']->event_main_id."' AND start_ts > ".time()." AND (online IS NULL OR online = '0') AND active = 1 AND deleted = 0 ORDER BY start_ts")->result();
			$data['datesonline'] = $this->db->query("SELECT * FROM events_new WHERE event_main_id = '".$data['event']->event_main_id."' AND start_ts > ".time()." AND online = '1' AND active = 1 AND deleted = 0 ORDER BY start_ts")->result();
			
			
			$results = $this->mevents->getEventDatesByDay($data['event']->event_main_id, true);
			$resultsonline = $this->mevents->getEventDatesByDay($data['event']->event_main_id, true, true);
			
			//print_r($data['dates']);
			
			$data['dates']->events = $results['events'];
			$data['dates']->times = $results['times'];
			//print_r($data['dates']);
			$data['datesonline']->events = $resultsonline['events'];
			$data['datesonline']->times = $resultsonline['times'];
			foreach($data['dates'] as $date){
				$foglaltak = $this->db->query("SELECT sum(gep) as gep, sum(parkolo) as parkolo FROM events_new_registrations WHERE event_id=".$date->event_id." AND deleted=0")->row();
				$date->times->able_to_reg = $this->mevents->checkEventLimit($date->event_id);
				$date->times->parkolo     = $foglaltak->parkolo;
				$date->times->gep         = $foglaltak->gep;
			}
			foreach($data['datesonline'] as $date){
				$date->times->able_to_reg = $this->mevents->checkEventLimit($date->event_id);
			}
			
			//print_r($data['dates']);
			
			$data['altalanos'] = false;
			
			if( $this->uri->segment(4) == "register" ){
				$data['mobilink'] = "/mobile/ws/{$urlveg}/register/".$this->uri->segment(5);
				if( isset($_SESSION['default']['wshiba']) && $_SESSION['default']['wshiba'] == "" )
					$this->phpsession->save('wshiba'," ");
			}elseif(!$this->uri->segment(4)){
				$data['mobilink'] = "/mobile/ws/".$urlveg;
			}
			
			if(in_array($urlveg,$kezdo))
				$data['arkat'] = 'event_arkezdo';
			else
				$data['arkat'] = 'event_arhalado';
			
		} // Ha nem workshop tema
		else{
			$data['event'] = $this->db->query("SELECT * FROM pages WHERE page_url = '".$urlveg."' AND page_lang = '".$this->muser->user['lang']."'")->row();
			
			$data['altalanos'] = true;
		}
		
		$data['akt'] = $urlveg;
		
	//	if( !strstr($_SERVER['REQUEST_URI'],"ujws") )
	//		$data['tartalom'] = 'interior/workshop';
	//	else
		if($urlveg=="csoport" || $urlveg=="haladokurzus")
			$data['tartalom'] = 'interior/workshopcsoport';
		else
			$data['tartalom'] = 'interior/workshopmod';
		
		
		$cimfolyt = $data['event']->name;
		if( strstr($_SERVER[ 'REQUEST_URI'], "/hu/") )
			$cimfolyt = str_replace(array("(1-es szint)","(2-es szint)","(3-as szint)"),array("","",""),$data['event']->name);
		
		$data['title'] = hun() ? 'ARCHLine.XP Interior Workshop - '.$cimfolyt : 'ARCHLine.XP Interior - '.$data['event']->name;
		$data['javascript'] = array(/*'jquery_ui',*/'fancybox/jquery-1.3.2.min','fancybox/jquery.easing.1.3','fancybox/jquery.fancybox-1.2.1.pack'/*,'fancybox/fancy'*/,'regformcheck');
		$data['style'] = array(/*'jquery.ui',*/'fancybox2','workshop_min');
		$data['csik'] = array('home', 'courses');
		//print_r($data['dates']);
		
		$this->load->view('site',$data);
	}
	
	function workshop2(){
		$this->load->model('mclusers');
		
		$urlname = $this->uri->segment(3);
		$level = $this->db->query("SELECT * FROM `cadline2`.`events_new_main` WHERE urlname = '".$urlname."'")->row();
		
		// email atalakitasa
		$temptomb = explode("/", $_SERVER[ 'REQUEST_URI'] );
		$email = str_replace("%40","@",end($temptomb));
		
		$egyezes = "interior/workshop/".$urlname;
		if(hun())
			$info = "Workshop megtekintve: ".$level->name." (http://archline.hu/interior/workshop/".$urlname.")";
		else
			$info = "Workshop viewed by: ".$level->name." (http://archlinexp.com/interior/workshop/".$urlname.")";
		$hibainfo = $urlname;
		
		if(hun()){
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "interior", "workshop2", 74, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "interior", "workshop2", 131, $egyezes, $info, "hun", $hibainfo);
		}
		else{
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "interior", "workshop2", 188, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "interior", "workshop2", 151, $egyezes, $info, "eng", $hibainfo);
		}
		
		
		// atiranyitas a workshop oldalra
		if($this->uri->lang == "hu" || hun()){
			//redirect("hu/interior/workshop/".$urlname);
			header("Location: http://www.archline.hu/interior/workshop/".$urlname);
			exit;
		}
		else
			redirect("interior/workshop/".$urlname);
		return;
	}
	
	function lakberendezo_iskolak(){
		$data['page'] = $this->mpages->get_row(625);
		
		$data['title'] = 'Lakberendező iskolák';
		$data['tartalom'] = 'page/show';
		
		$data['style'] = array('style_2011');
		$data['notitle'] = true;
		
		$this->load->view("site_new",$data);
	}
	
	function workflow()
	{
        if(hun())
		    $data['cimlap'] = $this->mpages->get_row(289);
		elseif(jap())
		    $data['cimlap'] = $this->mpages->get_row(300);
  		elseif(be())
		    $data['cimlap'] = $this->mpages->get_row(361);
		else
			$data['cimlap'] = $this->mpages->get_row(288);

		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - Munkamenet' : 'ARCHLine.XP Interior Design Software - Workflow';
        $data['tartalom'] = '/interior/workflow';
        $data['javascript'] = array('intkit/JavaScriptFlashGateway', 'interior_menu', 'interior_banner');
        
		$this->load->view('site',$data);
	}
	
	function powerful()
	{
		if(hun())
		    $data['cimlap'] = $this->mpages->get_row(285);
        elseif(be())
		    $data['cimlap'] = $this->mpages->get_row(354);
		elseif(jap())
		    $data['cimlap'] = $this->mpages->get_row(302);
		else
			$data['cimlap'] = $this->mpages->get_row(284);

		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - Kiemelkedő Jellemzők' : 'ARCHLine.XP Interior Design Software - Powerful Features';
        $data['tartalom'] = 'interior/powerful';
        $data['javascript'] = array('intkit/JavaScriptFlashGateway', 'interior_menu', 'interior_banner');
        
		$this->load->view('site',$data);
	}
	
	function comparison()
	{
        if(hun())
		    $data['cimlap'] = $this->mpages->get_row(290);
        elseif(be())
		    $data['cimlap'] = $this->mpages->get_row(362);
		elseif(jap())
		    $data['cimlap'] = $this->mpages->get_row(301);
		else
			$data['cimlap'] = $this->mpages->get_row(292);

        $data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - Összehasonlítás' : 'ARCHLine.XP Interior Design Software - Comparison';
        $data['tartalom'] = 'interior/comparison';
        $data['javascript'] = array('intkit/JavaScriptFlashGateway', 'comparison', 'interior_menu', 'interior_banner');
        
		$this->load->view('site',$data);
	}
	
	function videos()
	{
		if(!hun()){
			Header("HTTP/1.1 301 Moved Permanently");
			Header("Location: http://www.archlinexp.com/videos/beginner");
			exit;
		}
		
		
		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - Videók' : 'ARCHLine.XP Interior Design Software - Videos';
		$data['tartalom'] = 'interior/videos';
		$data['javascript'] = array('intkit/JavaScriptFlashGateway', 'interior_menu', 'show_slide', 'tooltip', 'interior_banner');
		
		if(hun()){
			$data['cimlap'] = $this->mpages->get_row(475);
		} else {
			$data['cimlap'] = $this->mpages->get_row(476);
		}
		
		$data['csik']=array('home','videos');
		
		$this->load->view('site',$data);
	}
	
	function tutorials()
	{
		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - Oktatóvideók' : 'ARCHLine.XP Interior Design Software - Tutorials';
		$data['tartalom'] = 'interior/tutorials';
        $data['javascript'] = array('intkit/JavaScriptFlashGateway', 'interior_menu', 'show_slide', 'tooltip', 'interior_banner');
        
		$this->load->view('site',$data);
	}
	
	function buy()
	{
		if( !hun() ){
			//data['cimlap'] = $this->mpages->get_row(733);	// 733 - akció // 742 - akció nélkül
			
			if(time()<strtotime('2014-06-01'))
				$data['cimlap'] = $this->mpages->get_row(733);
			else
				$data['cimlap'] = $this->mpages->get_row(742);
			
			$data['title'] = 'ARCHLine.XP Interior Design Software - Purchase';
			$data['tartalom'] = 'interior/buy2';
			$data['javascript'] = array('jquery.corner');
			/*$data['csik']=array('home','buy');*/
			
			$this->load->view('site',$data);
			return;
		}
		
		
		if(hun())
		    //$data['cimlap'] = $this->mpages->get_row(287);		// 2011-es
			$data['cimlap'] = $this->mpages->get_row(649);
        elseif(be())
		    $data['cimlap'] = $this->mpages->get_row(360);
		elseif(jap())
		    $data['cimlap'] = $this->mpages->get_row(299);
		else
			$data['cimlap'] = $this->mpages->get_row(446);
		
		if( !hun() )
			$data['style']=array('workshop');

        $data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - Vásárlás' : 'ARCHLine.XP Interior Design Software - Purchase';
        $data['tartalom'] = 'interior/buy';
        $data['javascript'] = array('interior_menu');
		$data['csik']=array('home','buy');
		
        
		$this->load->view('site',$data);
	}
	
	function buynew(){
		if( !hun() ){
			$data['cimlap'] = $this->mpages->get_row(721);
			$data['title'] = 'ARCHLine.XP Interior Design Software - Purchase';
			$data['tartalom'] = 'interior/buy2';
			$data['javascript'] = array('jquery.corner');
			$data['csik']=array('home','buy');
			
			$this->load->view('site',$data);
		}
	}
	
	
	function download()
	{
		if( $this->uri->segment(3) == "esp" ){
			redirect('settings/lang2/esp');
		}
		
		$this->load->model('mctr');
		
		$data['ctr'] = hun() ? $this->mctr->get_all_ctr('ctrNameHun') : $this->mctr->get_all_ctr();
		
		if(hun())
		    $data['cimlap'] = $this->mpages->get_row(291);
		else
			$data['cimlap'] = $this->mpages->get_row(630);
		
		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítészeti tervező program - Letöltés' : 'ARCHLine.XP Interior Design Software - Download';
		$data['tartalom']='interior/downloadv3';
		//$data['javascript'] = array('downloads_int');
		$data['javascript'] = array(
								'regformcheck',
	         					'fancybox/jquery-1.3.2.min',
								'fancybox/jquery.easing.1.3',
								'fancybox/jquery.fancybox-1.2.1.pack'/*,
								'fancybox/fancy'*/
								);
		$data['style'] = array('fancybox_gal');
		
		$data['csik']=array('home','downloads');
		$this->load->view('site',$data);
	}
	
	function downloadreader(){
		$this->load->model('mctr');
		
		$data['ctr'] = hun() ? $this->mctr->get_all_ctr('ctrNameHun') : $this->mctr->get_all_ctr();
		
		$data['title']      = hun() ? 'ARCHLine.XP Reader letöltés' : 'ARCHLine.XP Reader download';
		$data['tartalom']   = 'interior/downloadreader';
		$data['javascript'] = array( 'regformcheck' );
		$data['style']      = array('fancybox_gal');
		$data['csik']       = array('home','downloads');
		
		$this->load->view('site',$data);
	}
	
	function updates()
	{
		$this->load->model('mdownloads');
		$this->load->model('mctr');
		
		$data['heading']=$this->mdownloads->get_heading('updates');
		$data['downloads']=$this->mdownloads->get_category('updates',$this->muser->user['lang']);
		$data['aktiv']=2;
		
		$data['lang']=$this->muser->user['lang'];
		$data['tartalom']='interior/list2';
		$data['csik']=array('home','interior','updates');
		$data['title']='ARCHline.XP CAD Software - Download Updates';
		$this->load->view('site',$data);
	}
	
	function drivers()
	{
		$this->load->model('mdownloads');
		$this->load->model('mctr');
		
		$data['heading']=$this->mdownloads->get_heading('drivers');
		$data['downloads']=$this->mdownloads->get_category('drivers',$this->muser->user['lang']);
		$data['aktiv']=3;
		
		$data['lang']=$this->muser->user['lang'];
		
		$data['title'] = hun() ? 'ARCHLine.XP Driverek' : 'ARCHLine.XP Drivers';
		$data['tartalom']='interior/list2';
		$data['csik']=array('home','interior','drivers');
		$this->load->view('site',$data);
	}
	
	function support()
	{
		//if(hun())
		    $data['page'] = $this->mpages->get_row(682);	//589
        /*elseif(be())
		    $data['cimlap'] = $this->mpages->get_row(355);
		else
			$data['cimlap'] = $this->mpages->get_row(274);*/
			
		$data['title'] = hun() ? 'ARCHLine.XP Támogatás' : 'ARCHLine.XP Support';
		//$data['tartalom'] = 'page/show';
		$data['tartalom'] = 'interior/support';
		
		$data['csik']=array('home','interior','support');
		
		$this->load->view('site', $data);
		
		
		/*$this->load->model('mdownloads');
		$this->load->model('mctr');
		
		$data['heading']=$this->mdownloads->get_heading('support');
		$data['downloads']=$this->mdownloads->get_category('support',$this->muser->user['lang']);
		$data['aktiv']=4;
		
		$data['lang']=$this->muser->user['lang'];
		$data['title'] = hun() ? 'ARCHLine.XP Támogatás' : 'ARCHLine.XP Support';
		$data['tartalom']='interior/list2';
		$data['csik']=array('home','interior','support');
		$this->load->view('site',$data);*/
	}
	
	function learn()
	{
		$data['learn_url'] = base64_decode($this->uri->segment(4));
        $data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - Oktatás' : 'ARCHLine.XP Interior Design Software - Learn';
        $data['tartalom'] = 'interior/learn';
        $data['javascript'] = array('prototype', 'base64', 'anchor.jquery', 'learn', 'interior_menu', 'tooltip');
        !hun() ? $data['javascript'][3] = 'learn_eng' : '';

		$this->load->view('site',$data);
	}
	
	function system()
	{
        if(hun())
		    $data['cimlap'] = $this->mpages->get_row(275);
        elseif(be())
		    $data['cimlap'] = $this->mpages->get_row(355);
		else
			$data['cimlap'] = $this->mpages->get_row(274);
			
		$data['title'] = hun() ? 'ARCHLine.XP - Rendszerkövetelmények PC és Mac esetén' : 'ARCHLine.XP Interior Design Software - System Requirements for PC and Mac';
        $data['tartalom'] = 'interior/system';
        $data['javascript'] = array('interior_menu');
        
        $data['csik']=array('home', 'rendszer');

		$this->load->view('site', $data);
	}
	
	function gallery()
	{
		$this->load->model('mgallery');
		
		
		if(!$this->uri->segment(3))
		{
            $data['lang']=$this->muser->user['lang'];
			$data['csik']=array('home','gallery');
			
			$data['mobilink'] = "/mobile/galleryinterior";
			$data['title'] = hun() ? 'ARCHLine.XP Belsőépítészet galéria' : 'ARCHLine.XP Gallery of Interior';
			$data['javascript'] = array('interior_menu');
			$data['tartalom'] = 'interior/gallery';
			
			if(hun())
				$nyelv = "hun";
			else
				$nyelv = "eng";
			$data['galeriak'] = $this->mgallery->get_all($nyelv,'interior');
			$this->load->view('site_new',$data);
		}
		else
		{
			$folder = $this->uri->segment(3);
			if($folder && $this->mgallery->checkFolder($folder))
			{
				//create thumbs if they are missing
				$this->mgallery->prepImages($folder);
				$data['leiras'] = $this->mgallery->get_rowMappa("gallery/".$folder,$this->muser->user['lang']);
				
				if($folder=="interior")
					$metadesc = hun() ? "ARCHLine.XP Interior tervezőprogrammal készült belsőépítészeti látványtervek" : "Gallery of ARCHLine.XP Interior projects";
				elseif($folder=="thea")
					$metadesc = hun() ? "ARCHLine.XP Interior tervezőprogrammal és THEA renderelővel készült belsőépítészeti látványtervek" : "Gallery of ARCHLine.XP Interior projects with THEA render";
				else
					$metadesc = hun() ? $data['leiras']->cim." felhasználónk ARCHLine.XP tervezőprogrammal készült látványtervei" : "Gallery of ".$data['leiras']->cim.", ARCHLine.XP software plans";
				
				
		        $data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - Galéria' : 'ARCHLine.XP Interior Design Software - Gallery';

	            $data['tartalom'] = 'interior/gallery';
				$data['javascript'] = array(
										'interior_menu',
	         							'fancybox/jquery-1.3.2.min',
										'fancybox/jquery.easing.1.3',
										'fancybox/jquery.fancybox-1.2.1.pack',
										'fancybox/fancy'
										);
				
				//set the folder's name
				$data['folder'] = $folder;

				//load images from the folder
				$data['images'] = $this->mgallery->getImages($folder);

				$data['style'] = array('fancybox_gal');
				$data['meta']['desc'] = $metadesc;
				
				$data['title'] .= " - " . $data['leiras']->cim;
				$data['mobilink'] = "/mobile/gallerydetail/".$folder;
				
				$this->load->view('site_new',$data);
				
			}
			else
			{
				redirect('interior');
			}
		}
	}
	
	function gallery2(){
		$this->load->model('mclusers');
		
		$temptomb = explode("/", $_SERVER[ 'REQUEST_URI'] );
		$email = str_replace("%40","@",end($temptomb));
		$tema = $this->uri->segment(3);
		
		$egyezes = "/interior/gallery/".$tema;
		$info    = "Galéria megtekintve: archline.hu/interior/gallery/".$tema;
		$infoeng = "Gallery viewed: archlinexp.com/interior/gallery/".$tema;
		$hibainfo = "Galéria, ".$tema;
		
		if(UJUGYFELKEZELO===true){
			if(hun())
				$this->mclusers->levelesemeny($email, "interior", "gallery2", 63, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "interior", "gallery2", 178, $egyezes, $infoeng, "eng", $hibainfo);
		}
		else{
			if(hun())
				$this->mclusers->levelesemeny($email, "interior", "gallery2", 134, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "interior", "gallery2", 163, $egyezes, $infoeng, "eng", $hibainfo);
		}
		
		if($tema=="no")
			$tema = "";
		
		redirect("interior/gallery/".$tema);
	}
	
	function gallery2esp(){
		$this->load->model('mclusers');
		
		$temptomb = explode("/", $_SERVER[ 'REQUEST_URI'] );
		$email = str_replace("%40","@",end($temptomb));
		$tema = $this->uri->segment(3);
		
		$egyezes = "/interior/gallery/".$tema;
		$info = "Galéria megtekintve: archlinexp.com/interior/gallery/".$tema;
		$hibainfo = "Galéria, ".$tema;
		
		if(UJUGYFELKEZELO===true)
			$this->mclusers->levelesemeny($email, "interior", "gallery2esp", 252, $egyezes, $info, "esp", $hibainfo);
		else
			$this->mclusers->levelesemenyEsp($email, "interior", "gallery2esp", 131, $egyezes, $info, "esp", $hibainfo);
		
		if($tema=="no")
			$tema = "";
		
		redirect("interior/gallery/".$tema);
	}
	
	function events()
	{
		if(hun()){
			Header("HTTP/1.1 301 Moved Permanently");
			Header("Location: http://www.archline.hu/interior/workshop/nappali");
		}else{
			Header("HTTP/1.1 301 Moved Permanently");
			Header("Location: http://www.archlinexp.com/interior/workshop/reception_room");
		}
		
		
		$this->load->model('mevents');

		$data['counties'] = array(
						-1 => '-- válasszon --',
						'Bács-Kiskun' => 'Bács-Kiskun',
						'Baranya' => 'Baranya',
						'Békés' => 'Békés',
						'Borsod-Abaúj-Zemplén' => 'Borsod-Abaúj-Zemplén',
						'Budapest' => 'Budapest',
						'Csongrád' => 'Csongrád',
						'Fejér' => 'Fejér',
						'Győr-Moson-Sopron' => 'Győr-Moson-Sopron',
						'Hajdú-Bihar' => 'Hajdú-Bihar',
						'Heves' => 'Heves',
						'Jász-Nagykun-Szolnok' => 'Jász-Nagykun-Szolnok',
						'Komárom-Esztergom' => 'Komárom-Esztergom',
						'Nógrád' => 'Nógrád',
						'Pest' => 'Pest',
						'Somogy' => 'Somogy',
						'Szabolcs-Szatmár-Bereg' => 'Szabolcs-Szatmár-Bereg',
						'Tolna' => 'Tolna',
						'Vas' => 'Vas',
						'Veszprém' => 'Veszprém',
						'Zala' => 'Zala'
						);

		$data['lang']=$this->muser->user['lang'];
		$data['title'] = hun() ? 'ARCHLine.XP CAD Software - Bemutatók' : 'ARCHLine.XP CAD Software - Events';
		$data['tartalom']='interior/events';
		$data['csik']=array('home','support');

		if(hun())
			$data['javascript'] = array('events');

		$data['events'] = $this->mevents->get_latest('30',$this->muser->user['lang']);

		$data['aktiv']=2;

		$data['faqs'] = $this->mevents->get_latest('faq_date');

		$error = false;

		if($this->input->post('do')!=false)
		{
			if(hun())
			{
				$arr = array('event_id','nev','cegnev','varos','irsz','tel','kamsz','county','fax','email','comment','cim');
				foreach($arr as $a)
				{
					$tomb[$a] = $this->input->post($a);

					if($tomb[$a]==false && $a!='fax' && $a !='comment' && $a!='cegnev' && $a!='kamsz' && $a!='county')
					{
						$error = "Minden vastaggal jelölt mezőt ki kell tölteni ($a hiányzik)";
					}
					else
					{
						$event_id = explode('|',$tomb['event_id']);
						$event_id = $event_id[0];

						if($a=='event_id' && !is_numeric($event_id))
						{
							$error = 'Hibás azonosító: '.$a;
						}
					}
				}

				if($tomb['kamsz']!='' && $tomb['county']==-1)
				{
					$error = "A kamarai névjegyzéki számhoz meg kell adnia a megyét is.";
				}

				$event_id = explode('|',$tomb['event_id']);
				$event_id = $event_id[0];

				if(!is_numeric($event_id))
				{
					$error = 'Hiábás esemény azonosító';
				}
				else
				{
					$tomb['esemeny']=$this->mevents->get_row($event_id);
				}
			}
			elseif(jap())
			{
				$arr = array('event_id','nev','pron','cegnev','cim','tel','fax','email','comment','other');
				foreach($arr as $a)
				{
					$tomb[$a] = $this->input->post($a);

					if($tomb[$a]==false && $a=='tel' && $a =='nev' && $a=='cegnev')
					{
						$error = "You have to fill all form fields marked with bold text ($a is missing)";
					}
					else
					{
						if($a=='event_id' && !is_numeric($tomb[$a]))
						{
							$error = 'Invalid id: '.$a;
						}
					}
				}

				if(!is_numeric($tomb['event_id']))
				{
					$error = 'You have not selected an event, please select one!';
				}
				else
				{
					$tomb['esemeny']=$this->mevents->get_row($tomb['event_id']);
				}


				$egyebcad = array('AutoCAD','VectorWorks','ArchiCAD','JWCAD','ARCHITREND','GoogleSketchup','DRACAD','SuperSoft','その他');

				$valasztott = array();

				foreach($egyebcad as $key => $cad)
				{
					$no = $key+1;
					$keres = 'cb'.$no;

					if($this->input->post($keres)=='on')
					{
						$valasztott[]=$cad;
					}
				}

				if(count($valasztott)==0)
				{
					$tomb['egyebcad']=false;
				}
				else
				{
					$tomb['egyebcad']=$valasztott;
				}
			}
			else
			{
				$arr = array('event_id','nev','cegnev','varos','irsz','tel','fax','email','comment','cim');
				$names = array('event_id' => 'event id', 'nev' => 'name', 'cegnev' => 'company name', 'varos' => 'city', 'irsz' => 'zip code', 'tel' => 'phone number', 'fax' => 'fax number', 'email' => 'e-mail', 'comment' => 'comment', 'cim' => 'address');
				foreach($arr as $a)
				{
					$tomb[$a] = $this->input->post($a);

					if($tomb[$a]==false && $a!='fax' && $a !='comment' && $a!='cegnev')
					{
						$error = "Fill out every bold field ({$names[$a]} missing)";
					}
					else
					{
						$event_id = explode('|',$tomb['event_id']);
						$event_id = $event_id[0];

						if($a=='event_id' && !is_numeric($event_id))
						{
							$error = 'Wrong identifier: '.$a;
						}
					}
				}

				$event_id = explode('|',$tomb['event_id']);
				$event_id = $event_id[0];

				if(!is_numeric($event_id))
				{
					$error = 'You have to specify an event!';
				}
				else
				{
					$tomb['esemeny']=$this->mevents->get_row($event_id);
				}
			}



			if(!$error)
			{
				$this->load->library('email');
				$this->load->helper('email');
				$this->email->initialize();
				$this->email->addOfficialImages();


				if(hun())
				{

					$e = explode('|',$tomb['event_id']);

					$tomb['egyeb'] = $e[1];
					$tomb['mailcontent'] = 'support/eventmail';

					$this->email->from('info@cadline.hu', 'Cadline Weboldal');
					$this->email->subject('Esemenyek jelentkezes');
					$this->email->message($this->load->view('mail',$tomb,true));
					$this->email->send('info@cadline.hu','smtp');
					
					//Kintre:
					$this->email->clear();
					$mailnek['mailcontent'] = 'support/eventmail_ki';
					
					$mailnek['esemeny']=$tomb['esemeny'];
					
					$e = explode('|',$tomb['event_id']);
					$bem = $this->mevents->get_row($e[0]);
					$mailnek['datum'] = $bem->event_ev.'-'.$bem->event_ho.'-'.$bem->event_nap;
					$mailnek['datum'] = $e[1];
					
					$this->email->from('info@cadline.hu', 'Cadline Weboldal');
					$this->email->subject('Regisztracio bemutatora');
					$this->email->message($this->load->view('mail',$mailnek,true));
					$this->email->send($tomb['email'],'smtp');
				}
				elseif(jap())
				{
					$this->email->from('info@cadline.hu', 'Cadline Weboldal');
					$this->email->subject('Event SignUp Notification');
					$this->email->message($this->load->view('support/eventmail',$tomb,true));
					$this->email->send('living-cg@leaf.ocn.ne.jp','smtp');
				}
				
				elseif(eng()){
					$e = explode('|',$tomb['event_id']);

					$tomb['egyeb'] = $e[1];
					$mailnek=$tomb;
					$tomb['mailcontent'] = 'support/eventmail';

					$this->email->from('info@cadline.hu', 'Cadline Weboldal');
					$this->email->subject('Esemenyek jelentkezes');
					$this->email->message($this->load->view('mail',$tomb,true));
					$this->email->send('info@archlinexp.com','smtp');
					
					//Kintre
					/*
					$this->email->clear();
					$mailnek['mailcontent'] = 'support/eventmail_ki';
					
					$bem = $this->mevents->get_row($e[0]);
					$mailnek['datum'] = $bem->event_ev.'-'.$bem->event_ho.'-'.$bem->event_nap;
					
					$this->email->from('info@cadline.hu', 'Cadline Weboldal');
					$this->email->subject('Registration for free traning session at BIDA');
					$this->email->message($this->load->view('mail_eng',$mailnek,true));
					//$this->email->send($tomb['email'],'smtp');
					*/
					
				}
				else
				{

					$e = explode('|',$tomb['event_id']);

					$tomb['egyeb'] = $e[1];
					$tomb['mailcontent'] = 'support/eventmail';

					$this->email->from('info@cadline.hu', 'Cadline Weboldal');
					$this->email->subject('Esemenyek jelentkezes');
					$this->email->message($this->load->view('mail',$tomb,true));
					$this->email->send('info@archlinexp.com','smtp');
				}

				redirect('interior/eventok');
			}

		}

		$data['error']=$error;
		$this->load->view('site',$data);
	}

	function eventok()
	{
		$data['lang']=$this->muser->user['lang'];
		$data['javascript'] = array('interior_menu');
		$data['tartalom']='interior/eventok';
		$data['csik']=array('home','support');
		$data['aktiv']=2;

		$this->load->view('site',$data);
	}
	
	function reasons()
	{
		if(hun())
			$data['cimlap'] = $this->mpages->get_row(369);
		else
			$data['cimlap'] = $this->mpages->get_row(370);
		
		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - 10 ok a vásárlásra' : 'ARCHLine.XP Interior Design Software - 10 reasons to buy';
		$data['tartalom'] = '/interior/reasons';
		$data['javascript'] = array('interior_menu');
		
		$data['csik']=array('home','10ok');
		
		$this->load->view('site',$data);
	}
	
	function interview()
	{
		$id = $this->uri->segment(3);
		
		$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program - Interjúk' : 'ARCHLine.XP Interior Design Software - Interviews';
		
		if($id)
		{
			$data['kategoria'] = $this->uri->segment(4);
			$data['interview'] = $this->load->view('interview/' . $id, $data, true);
			$data['tartalom'] = 'interview/index';
			if($id=="tervezz_szabadon")
				$data['javascript'] = array();
			else
				$data['javascript'] = array('intkit/JavaScriptFlashGateway', 'interview', 'interior_menu', 'interview/loader');
		}
		else
		{
			$data['cimlap'] = $this->mpages->get_row(368);
			$data['tartalom'] = 'interior/interview';
			$data['javascript'] = array('jquery.color', 'interview', 'interior_menu');
		}
		
		$data['style'] = array('interview');
		$data['csik']=array('home','interview');
		
		$this->load->view('site', $data);
	}
	
	function sentint()
	{
		if( !hun() ){
			include('application/helpers/video.php');
			//$videohtml = video_html('workshop_beginner_level');
			$videok = $this->db->query("SELECT * FROM videos WHERE csoport='workshop_beginner_level' AND sorszam > 0 ORDER BY sorszam")->result();
			$csoport2 = $this->db->query("SELECT * FROM videogroups WHERE azon='workshop_beginner_level'")->row();
			$videohtml = video_strcsere('workshop_beginner_level',$csoport2,$videok);
			
			$data['videohtml']   = $videohtml;
			$data['style']       = array( 'jquery.jscrollpane' );
			$data['javascript']  = array( 'jquery.mousewheel.min', 'jscrollpane/jquery.jscrollpane.min' );
		}
		
        $data['title'] = hun() ? 'ARCHLine.XP Interior Letöltés - Sikeres' : 'ARCHLine.XP Interior Download - Successful';
		$data['tartalom']='downloads/sentint';
		$data['csik']=array('home','downloads');
		$data['lang']=$this->muser->user['lang'];

		$this->load->view('site',$data);
	}
	
	function ticket()
	{
		$do = $this->input->post('do');

		if($do && $do=='ticket')
		{
			$fajlnev = "ticket_a.txt";
			$fa = fopen( $fajlnev, "r" ) or die("$fajlnev nem nyitható meg");
			$db = fgets( $fa, 1024);
			fclose($fa);
			
			if($db > 0){
				
				$fajlnev = "ticket_a.txt";
				chmod($fajlnev, 0777);
				$fa = fopen( $fajlnev, "w" ) or die("$fajlnev nem nyitható meg");
				fwrite ( $fa, ($db-1));
				fclose( $fa );
				
				$name = $this->input->post('name');
				$address = $this->input->post('address');
				$city = $this->input->post('city');
				$zip = $this->input->post('zip');
				$email = $this->input->post('email');
				
				if(!$name || !$address || !$city || !$zip || !$email || $name=='' || $address=='' || $city=='' || $zip=='' || $email=='')
					redirect('interior/ticket');
				
				$mail_vars['event'] = "Awards Preview Evening Invitation ";
				$mail_vars['name'] = $name;
				$mail_vars['address'] = $address;
				$mail_vars['city'] = $city;
				$mail_vars['zip'] = $zip;
				$mail_vars['email'] = $email;
				$mail_vars['jegydb'] = $db-1;
	
				$this->load->library('email');
				$this->email->clear();
				$this->email->initialize();
	
				$this->email->from('info@cadline.hu', 'CadLine');
				$this->email->subject('ARCHLine.XP Kedvezmenyes Belepo');
				$this->email->message($this->load->view('mail/interior_ticket', $mail_vars, true));
	
				//$this->email->send('margo.flaisz@cadline.hu', 'smtp');
				$this->email->send('rita.vasifodor@archlinexp.com', 'smtp');
				//$this->email->send('sztikee@gmail.com', 'smtp');
				
				
				$this->email->clear();
				$this->email->initialize();
	
				$this->email->from('info@cadline.hu', 'CadLine');
				$this->email->subject('ARCHLine.XP Kedvezmenyes Belepo');
				$this->email->message($this->load->view('mail/interior_ticket', $mail_vars, true));
				$this->email->send('info@cadline.hu', 'smtp');
				//$this->email->send('sztikee@gmail.com', 'smtp');
				
				
				$data['tartalom'] = 'interior/ticket_sent';
			}else{
				print "Nincs tobb jegy";
				$data['tartalom'] = 'interior/ticket_sent_0';
			}
			
			
			
            $this->load->view('site', $data);
            
            
		}
		else
		{
            $data['tartalom'] = 'interior/ticket';

			$this->load->view('site', $data);
		}
	}
	
	function ticketcomp()
	{
		$do = $this->input->post('do');

		if($do && $do=='ticket')
		{
			$fajlnev = "ticket_c.txt";
			$fa = fopen( $fajlnev, "r" ) or die("$fajlnev nem nyitható meg");
			$db = fgets( $fa, 1024);
			fclose($fa);
			
			if($db > 0){
				
				$fajlnev = "ticket_c.txt";
				chmod($fajlnev, 0777);
				$fa = fopen( $fajlnev, "w" ) or die("$fajlnev nem nyitható meg");
				fwrite ( $fa, ($db-1));
				fclose( $fa );
				
				$name = $this->input->post('name');
				$address = $this->input->post('address');
				$city = $this->input->post('city');
				$zip = $this->input->post('zip');
				$email = $this->input->post('email');
				
				if(!$name || !$address || !$city || !$zip || !$email || $name=='' || $address=='' || $city=='' || $zip=='' || $email=='')
					redirect('interior/ticketcomp');
				
				$mail_vars['event'] = "Complimentary Ticket ";
				$mail_vars['name'] = $name;
				$mail_vars['address'] = $address;
				$mail_vars['city'] = $city;
				$mail_vars['zip'] = $zip;
				$mail_vars['email'] = $email;
				$mail_vars['jegydb'] = ($db-1);
	
				$this->load->library('email');
				$this->email->clear();
				$this->email->initialize();
	
				$this->email->from('info@cadline.hu', 'CadLine');
				$this->email->subject('ARCHLine.XP Kedvezmenyes Belepo');
				$this->email->message($this->load->view('mail/interior_ticket', $mail_vars, true));
	
				//$this->email->send('margo.flaisz@cadline.hu', 'smtp');
				$this->email->send('rita.vasifodor@archlinexp.com', 'smtp');
				//$this->email->send('sztikee@gmail.com', 'smtp');
				
				
				$this->email->clear();
				$this->email->initialize();
	
				$this->email->from('info@cadline.hu', 'CadLine');
				$this->email->subject('ARCHLine.XP Kedvezmenyes Belepo');
				$this->email->message($this->load->view('mail/interior_ticket', $mail_vars, true));
				$this->email->send('info@cadline.hu', 'smtp');
				//$this->email->send('sztikee@gmail.com', 'smtp');
				
				
				$data['tartalom'] = 'interior/ticket_sent';
			}else{
				//print "Nincs tobb jegy";
				$data['tartalom'] = 'interior/ticket_sent_0';
			}
			$this->load->view('site', $data);
		}
		else
		{
            $data['tartalom'] = 'interior/ticketcomp';

			$this->load->view('site', $data);
		}
	}
	
	function special_offer()
	{
        $data['title'] = 'ARCHLine.XP Interior - Special Offer';
		$data['tartalom']='interior/special_offer';
		$data['cimlap'] = $this->mpages->get_row(430);
		$data['csik']=array('home','interior');

		$this->load->view('site',$data);
	}
	
	function academic(){
		$data['title'] = 'ARCHLine.XP Academic';
		$data['tartalom']='academic/index';
		$data['csik']=array('home','academic');
		
		/*if(hun())
			$data['cimlap'] = $this->mpages->get_row(304);
		elseif(be())
			$data['cimlap'] = $this->mpages->get_row(364);
		else*/
			$data['cimlap'] = $this->mpages->get_row(452);
		
		$this->load->view('site',$data);
	}
	
	function pro(){
		if( $this->uri->segment(3) == "buydo" ){
			$temp = "=".$_POST['darab'];
			
			
			//RODUCT_ID=300161531
			if( $this->input->post('valuta') == "eur" )
				$head = "https://secure.shareit.com/shareit/cart.html?DELIVERY[300158265]=EML&PRODUCT[300161531]{$temp}&language=English&js=-1";
			elseif( $this->input->post('valuta') == "usd" )
				$head = "https://secure.shareit.com/shareit/cart.html?DELIVERY[300158265]=EML&PRODUCT[300500918]{$temp}&language=English&js=-1";
			else
				$head = "https://secure.shareit.com/shareit/cart.html?DELIVERY[300158265]=EML&PRODUCT[300300559]{$temp}&language=English&js=-1";
			
			
		//	$temp .= '&language=English';
		//	$head = "https://secure.shareit.com/shareit/checkout.html?productid=300300559".$temp;
		//	$head = "https://secure.shareit.com/shareit/checkout.html?PRODUCT[300300559]".$temp;
		//	$head = "https://secure.shareit.com/shareit/cart.html?DELIVERY[300158265]=EML&PRODUCT[300300559]{$temp}&language=English&js=-1";
			header("Location: ".$head);
			exit;
		}
		
		$data['title'] = 'ARCHLine.XP Interior PRO, interior design software';
		$data['tartalom']='interior/pro';
		$data['csik']=array('home','interior','Interior PRO');
		
		$data['style']=array('workshop');
		
		$this->load->view('site',$data);
	}
	
	// 2010 nov. 13-a elotti interior fooldal
	function old(){
		$this->load->model('minterview');
		
		if(eng()){
			$data['page'] = $page=$this->mpages->get_row(474);
		}
		
    	$data['title'] = hun() ? 'ARCHLine.XP Interior Belsőépítész program' : 'ARCHLine.XP Interior Design Software';
        $data['tartalom'] = 'interior/index_old';
        $data['javascript'] = array('intkit/JavaScriptFlashGateway', 'interior_menu', 'interior_banner');
        
        $data['csik']=array('home','products');

		$this->load->view('site',$data);
	}
	
	function oktatoivizsga(){
		
		// időpontok összegyűjtése
		$csoport_id = 3;
		$idopontok  = array();
		$vizsga_idk = $this->db->query("SELECT * FROM `tcexam`.`tce_testgroups` WHERE tstgrp_group_id = {$csoport_id}")->result();
		
		foreach($vizsga_idk as $v_id){
			$v_id = $v_id->tstgrp_test_id;
			$vizsga = $this->db->query("SELECT * FROM `tcexam`.`tce_tests` WHERE test_id = {$v_id} AND test_end_time>'".date('Y-m-d H:i:s',(time()+30*60))."'")->row();
			if($vizsga)
				$idopontok[] = $vizsga;
		}
		$data['idopontok'] = $idopontok;

		
		$data['cimlap'] = $this->mpages->get_row(697);

		$data['title'] = 'ARCHLine.XP Oktatói vizsga';
		$data['tartalom'] = '/interior/oktatoivizsga';
		$data['javascript'] = array(
								'interior_menu',
	         					'fancybox/jquery-1.3.2.min',
								'fancybox/jquery.easing.1.3',
								'fancybox/jquery.fancybox-1.2.1.pack',
								'fancybox/fancy'
							);
		$data['style'] = array('fancybox');

		$this->load->view('site',$data);
	}
	
	function felhasznaloivizsga(){
		
		// időpontok összegyűjtése
		$csoport_id = 5;
		$idopontok  = array();
		$vizsga_idk = $this->db->query("SELECT * FROM `tcexam`.`tce_testgroups` WHERE tstgrp_group_id = {$csoport_id}")->result();
		
		foreach($vizsga_idk as $v_id){
			$v_id = $v_id->tstgrp_test_id;
			$vizsga = $this->db->query("SELECT * FROM `tcexam`.`tce_tests` WHERE test_id = {$v_id} AND test_end_time>'".date('Y-m-d H:i:s',(time()+30*60))."'")->row();
			if($vizsga)
				$idopontok[] = $vizsga;
		}
		$data['idopontok'] = $idopontok;

		
		$data['cimlap'] = $this->mpages->get_row(723);

		$data['title'] = 'ARCHLine.XP Felhasználói vizsga';
		$data['tartalom'] = '/interior/felhasznaloivizsga';
		$data['javascript'] = array(
								'interior_menu',
	         					'fancybox/jquery-1.3.2.min',
								'fancybox/jquery.easing.1.3',
								'fancybox/jquery.fancybox-1.2.1.pack',
								'fancybox/fancy'
							);
		$data['style'] = array('fancybox');

		$this->load->view('site',$data);
	}
	
}
?>