<?php
/*
Project Name: JPC
File Name: frontpages_controller.php. Controller File
Description: The file handles all front end side page function requests.
*/

require_once './lib/simplemvcwf/view_data.php';
require_once './lib/simplemvcwf/controller_base.php';
require_once './model/frontpages_model.php';
require_once './utility/date_time_utility.php';

class FrontpagesController Extends ControllerBase {
	function index($actionValues=array()) {	
	
			if($this->checkSiteMode())			
			{	
			$this->viewData['footerlinks'] = FrontpagesModel::create()->getCommonpages($_POST);	
			// Look for any action called for front page. Call action related function.			
					/*print_r($actionValues);
					print_r($_REQUEST);
					exit;*/
				if(count($actionValues) > 0){
					
					$ctrlAction=$actionValues[0];
					$args=array();
					if(count($actionValues) > 1){	
						$args = array_slice($actionValues,1,count($actionValues));					
					}	
						$adminphoto = FrontpagesModel::create()->getAdminPhoto();	
						$_SESSION['adminphoto'] = $adminphoto->simage;	
						
						$topbanner = FrontpagesModel::create()->getTopBanner();	
						$this->viewData['topbanner'] = $topbanner;	
						$homebanner = FrontpagesModel::create()->getHomeBanner();	
						$this->viewData['homebanner'] = $homebanner;	
						$leftbanner = FrontpagesModel::create()->getLeftBanner();	
						$this->viewData['leftbanner'] = $leftbanner;
						$bottombanner = FrontpagesModel::create()->getBottomBanner();	
						$this->viewData['bottombanner'] = $bottombanner;
						$rightbanner = FrontpagesModel::create()->getRightBanner();	
						$this->viewData['rightbanner'] = $rightbanner;
						$updates = UpdatesModel::create()->getUpdates();
						$this->viewData['updates'] = $updates;
						$events = EventsModel::create()->getEvents();	
						$this->viewData['events'] = $events;
						$quotes = ExpquotesModel::create()->getQuotes();	
						$this->viewData['quotes'] = $quotes;
						$galleryphotos = GalleriesModel::create()->getPhotos();	
						$this->viewData['galleryphotos'] = $galleryphotos;	
						$welcome = SectionsModel::create()->getWelcomeText();
						$this->viewData['welcome'] = $welcome;	
						$birthdays = MembersModel::create()->getBirthday();
						$this->viewData['birthdays'] = $birthdays;
						$missyous = MembersModel::create()->getMissyou();
						$this->viewData['missyous'] = $missyous;
						
						$menuCnt=0;
						$menusections = SectionsModel::create()->getMenuSections();
						$menuhtml = '
						<nav id="cssmenu">
							<div id="head-mobile"></div>
							<div class="button"></div>
							<ul>';
						foreach($menusections as $db){
							$menuCnt++;
							$menusubsections_count = SubsectionsModel::create()->getMenuSubSections_count($db->id);
							//print_r($menusubsections);
							$cnt_sec = $menusubsections_count->cnt;
							$menupages = PagesModel::create()->getMenuPages($db->id,0);
							$sec_cnt_pd = count($menupages);
							$target  = "";	
							if($menuCnt > 5){
								$rightMenu="rightmenu";
							}else{
								$rightMenu="";
							}
							if($db->pagelink!=''){
							$href_sec = " href=\"#\" onClick=\"location.href='".$db->pagelink."'\"";
							}else{
								if($db->page_alias != ""){
									//$href_sec = "onClick=\"location.assign('".$db->f("page_name").".html');\"";
									$href_sec = " href=\"#\" onClick=\"location.href='".$db->page_alias.".html'\"";
								}else{
									//$href_sec = "onClick=\"location.assign('sectioncontent.php?id=".$db->f("id")."');\"";
									$href_sec = " href=\"#\" onClick=\"gotolink('sectioncontent','".$db->id."','','')\"";
								}
							}
							$menuhtml .= '<li><a '.$href_sec.'>'.$db->name.'</a>';
							if($cnt_sec > 0 ||  $sec_cnt_pd > 0){
								$menusubsections = SubsectionsModel::create()->getMenuSubSections($db->id);
								$menuhtml.='<ul>';
								foreach($menusubsections as $mdb){
									$menupages_count = PagesModel::create()->getMenuPages_count($db->id,$mdb->id);
									$cnt_subSec = $menupages_count->cnt;
									if($mdb->pagelink != ""){
										$onClick_subsec = " href=\"#\" onClick=\"location.href='".$mdb->pagelink."'\"";
									}else{
										if($mdb->page_alias!=''){
											$onClick_subsec = " href=\"#\" onClick=\"location.href='".$mdb->page_alias.".html'\"";
										}else{
											$onClick_subsec = " href=\"#\" onClick=\"gotolink('subsectioncontent','".$db->id."','".$mdb->id."','')\"";
										}
									}
									$menuhtml.='<li><a '.$onClick_subsec.'>'.$mdb->name.'</a>';
									if($cnt_subSec > 0){
										$menupages='';
										$menupages = PagesModel::create()->getMenuPages($db->id,$mdb->id);
										$menuhtml.='<ul>';
										foreach($menupages as $ndb){
											$pagelink = $ndb->pagelink;
											if(!empty($pagelink))
											{
												$onClick_page = " href=\"#\" onClick=\"location.href='".$pagelink."'\"";
											}else{
												if($ndb->page_alias != ""){
													$onClick_page = " href=\"#\" onClick=\"location.href='".$ndb->page_alias.".html'\"";
												}else{
													$onClick_page = " href=\"#\" onClick=\"gotolink('content','".$db->id."','".$mdb->id."','".$ndb->id."')\"";
												}
											}
											$menuhtml.='<li ><a '.$onClick_page.' >'.$ndb->name.'</a></li>';
										}
										$menuhtml.='</ul>';
									}
									$menuhtml.='</li>';
								}
								$menuhtml.='</ul>';
							}
							$menuhtml.='</li>';
						}		
						$menuhtml.='</ul></nav>';
						$this->viewData['menuhtml'] = $menuhtml;	
					if(!empty($ctrlAction)){										
						$this->frontActions($ctrlAction,$args);
					}
					else{	
						
						$this->renderWithTemplate('frontpages/index', 'frontpage_base_template');
					}
					
					
					
				}	
				
			}
			else
			{
			$this->viewData['maintenance_msg'] = FrontpagesModel::create()->getSettings('MAINTENANCE_MODE_MESSAGE');
			// Render the maintenance Mode Template
			$this->renderWithTemplate('frontpages/maintenance', 'maintenance_base_template');
			}
    }  
	function checkSiteMode()
	{
		// Get Site Mode
		//return $sitemode = FrontpagesModel::create()->getSettings('WEBSITE_MODE');
		return 1;
	}
	function frontActions($ctrlAction){
		$action_arr = explode(".",$ctrlAction);
		$ctrlAction=strtolower($action_arr[0]); 	// Deciding Action to perform.
		$this->viewData['ctrlAction'] =$ctrlAction ; 
		switch($ctrlAction){	 
			case "eventlist":
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$eventlist = EventsModel::create()->selectEvents_all($_REQUEST);
					$this->viewData['eventlist'] =$eventlist ;
					$this->renderWithTemplate('frontpages/eventlist', 'frontpage_content_template'); 
			break;
			case "pastevents":
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$eventlist = EventsModel::create()->selectEvents_past($_REQUEST);
					$this->viewData['eventlist'] =$eventlist ;
					$this->renderWithTemplate('frontpages/eventlist', 'frontpage_content_template'); 
			break;
			case "eventdetails":
					if($_REQUEST["event_id"]==''){
						$this->redirectto("eventlist");
					}
					$eventdetail = EventsModel::create()->selectEventDetail($_REQUEST["event_id"]);
					$this->viewData['eventdetail'] =$eventdetail ;
					$this->renderWithTemplate('frontpages/eventdetails', 'frontpage_content_template'); 
			break;
			case "printevent":
					$eventdetail = EventsModel::create()->selectEventDetail($_REQUEST["event_id"]);
					$this->viewData['eventdetail'] =$eventdetail ;
					$this->renderWithTemplate('frontpages/printevent', 'frontpage_popup_template'); 
			break;
			case "emailevent":
					if(isset($_REQUEST['frnd_email']) && $_REQUEST['frnd_email'] != "")
					  {
							
					   $ur_name = $_REQUEST['ur_name'];
					   $frnd_name = $_REQUEST['frnd_name'];
					   $frnd_email = $_REQUEST['frnd_email'];
					   $notes = $_REQUEST['notes'];
					   $URL = $_REQUEST['URL'];
						$subject = "JPC Event";
						$TO=$frnd_email;
						$adminMail = FrontpagesModel::create()->getSettings('MAIL_SEND_FROM_EMAIL');
						
						$BODY='<table width="619" border="1">
					  <tr>
						<td width="609">Dear '.$frnd_name.', Your Friends '.$ur_name.' posted a link for JPC Event. </td>
					  </tr>
					  
					  <tr>
						<td>URL:<a href="'.$URL.'">'.$URL.'</a></td>
					  </tr>
					  <tr>
						<td>'.nl2br($notes).'</td>
					  </tr>
					</table>
					';
						$header="MIME-Version: 1.0\r\n";
						$header.="Content-type: text/html \r\n";
						$header .= "From: ".$adminMail." \r\n";
						
						$fname = "JPC";
						
						
						//echo $BODY;
						mail($TO,$subject,$BODY,$header);	
						echo $msg = "<font color=red>URL Link has been Send Successfully</font>";exit;
					  }
					$eventdetail = EventsModel::create()->selectEventDetail($_REQUEST["event_id"]);
					$this->viewData['eventdetail'] =$eventdetail ;
					$this->renderWithTemplate('frontpages/emailevent', 'frontpage_popup_template'); 
			break;
			case "updatelist":
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$updatelist = UpdatesModel::create()->selectUpdates_all($_REQUEST);
					$this->viewData['updatelist'] =$updatelist;
					$this->renderWithTemplate('frontpages/updatelist', 'frontpage_content_template'); 
			break;
			case "pastupdates":
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$updatelist = UpdatesModel::create()->selectUpdates_past($_REQUEST);
					$this->viewData['updatelist'] =$updatelist ;
					$this->renderWithTemplate('frontpages/updatelist', 'frontpage_content_template'); 
			break;
			case "updatedetails":
					if($_REQUEST["update_id"]==''){
						$this->redirectto("updatelist");
					}
					$updatedetail = UpdatesModel::create()->selectUpdateDetail($_REQUEST["update_id"]);
					$this->viewData['updatedetail'] =$updatedetail ;
					$this->renderWithTemplate('frontpages/updatedetails', 'frontpage_content_template'); 
			break;
			case "printupdate":
					$updatedetail = UpdatesModel::create()->selectUpdateDetail($_REQUEST["update_id"]);
					$this->viewData['updatedetail'] =$updatedetail ;
					$this->renderWithTemplate('frontpages/printupdate', 'frontpage_popup_template'); 
			break;
			case "emailupdate":
					if(isset($_REQUEST['frnd_email']) && $_REQUEST['frnd_email'] != "")
					  {
							
					   $ur_name = $_REQUEST['ur_name'];
					   $frnd_name = $_REQUEST['frnd_name'];
					   $frnd_email = $_REQUEST['frnd_email'];
					   $notes = $_REQUEST['notes'];
					   $URL = $_REQUEST['URL'];
						$subject = "JPC News";
						$TO=$frnd_email;
						$adminMail = FrontpagesModel::create()->getSettings('MAIL_SEND_FROM_EMAIL');
						
						$BODY='<table width="619" border="1">
					  <tr>
						<td width="609">Dear '.$frnd_name.', Your Friends '.$ur_name.' posted a link for JPC News. </td>
					  </tr>
					  
					  <tr>
						<td>URL:<a href="'.$URL.'">'.$URL.'</a></td>
					  </tr>
					  <tr>
						<td>'.nl2br($notes).'</td>
					  </tr>
					</table>
					';
								
						$header="MIME-Version: 1.0\r\n";
						$header.="Content-type: text/html \r\n";
						$header .= "From: ".$adminMail." \r\n";
						
						$fname = "JPC";
						
						
						//echo $BODY;
						mail($TO,$subject,$BODY,$header);	
						echo $msg = "<font color=red>URL Link has been Send Successfully</font>";exit;
					  }
					$updatedetail = UpdatesModel::create()->selectUpdateDetail($_REQUEST["update_id"]);
					$this->viewData['updatedetail'] =$updatedetail ;
					$this->renderWithTemplate('frontpages/emailupdate', 'frontpage_popup_template'); 
			break;
			case "shareexp":
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$explist = ExpquotesModel::create()->selectExpquotes($_REQUEST);
					$this->viewData['explist'] =$explist ;
					$this->renderWithTemplate('frontpages/explist', 'frontpage_profile_template'); 
			break;
			case "expdetails":
					if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$explist = ExpquotesModel::create()->selectExpMessages($_REQUEST);
					$this->viewData['explist'] =$explist ;
					$this->renderWithTemplate('frontpages/msglist', 'frontpage_profile_template'); 
					/*if($_REQUEST["exp_id"]==''){
						$this->redirectto("shareexp");
					}
					$explist = ExpquotesModel::create()->selectExpquoteDetail($_REQUEST["exp_id"]);
					$this->viewData['explist'] =$explist ;
					$this->renderWithTemplate('frontpages/expdetails', 'frontpage_profile_template');*/ 
			break;
			case "msgdetail":
					if($_REQUEST["msg_id"]==''){
						$this->redirectto("shareexp");
					}
					$msgdetail = ExpquotesModel::create()->selectMsgDetail($_REQUEST);
					$this->viewData['msgdetail'] =$msgdetail ;
					$this->renderWithTemplate('frontpages/msgdetail', 'frontpage_content_template'); 
			break;
			case "printexp":
					$explist = ExpquotesModel::create()->selectExpquoteDetail($_REQUEST["exp_id"]);
					$this->viewData['explist'] =$explist ;
					$this->renderWithTemplate('frontpages/printexp', 'frontpage_popup_template'); 
			break;
			case "printmsg":
					$explist = ExpquotesModel::create()->selectMsgDetail($_REQUEST);
					$this->viewData['explist'] =$explist ;
					$this->renderWithTemplate('frontpages/printmsg', 'frontpage_popup_template'); 
			break;
			case "emailexp":
					if(isset($_REQUEST['frnd_email']) && $_REQUEST['frnd_email'] != "")
					  {
							
					   $ur_name = $_REQUEST['ur_name'];
					   $frnd_name = $_REQUEST['frnd_name'];
					   $frnd_email = $_REQUEST['frnd_email'];
					   $notes = $_REQUEST['notes'];
					   $URL = $_REQUEST['URL'];
						$subject = "JPC News";
						$TO=$frnd_email;
						$adminMail = FrontpagesModel::create()->getSettings('MAIL_SEND_FROM_EMAIL');
						
						$BODY='<table width="619" border="1">
					  <tr>
						<td width="609">Dear '.$frnd_name.', Your Friends '.$ur_name.' posted a link for JPC Experience. </td>
					  </tr>
					  
					  <tr>
						<td>URL:<a href="'.$URL.'">'.$URL.'</a></td>
					  </tr>
					  <tr>
						<td>'.nl2br($notes).'</td>
					  </tr>
					</table>
					';
								
						$header="MIME-Version: 1.0\r\n";
						$header.="Content-type: text/html \r\n";
						$header .= "From: ".$adminMail." \r\n";
						
						$fname = "JPC";
						
						
						//echo $BODY;
						mail($TO,$subject,$BODY,$header);	
						echo $msg = "<font color=red>URL Link has been Send Successfully</font>";exit;
					  }
					$explist = ExpquotesModel::create()->selectExpquoteDetail($_REQUEST["exp_id"]);
					$this->viewData['explist'] =$explist ;
					$this->renderWithTemplate('frontpages/emailexp', 'frontpage_popup_template'); 
			break;
			case "emailmsg":
					if(isset($_REQUEST['frnd_email']) && $_REQUEST['frnd_email'] != "")
					  {
							
					   $ur_name = $_REQUEST['ur_name'];
					   $frnd_name = $_REQUEST['frnd_name'];
					   $frnd_email = $_REQUEST['frnd_email'];
					   $notes = $_REQUEST['notes'];
					   $URL = $_REQUEST['URL'];
						$subject = "JPC News";
						$TO=$frnd_email;
						$adminMail = FrontpagesModel::create()->getSettings('MAIL_SEND_FROM_EMAIL');
						
						$BODY='<table width="619" border="1">
					  <tr>
						<td width="609">Dear '.$frnd_name.', Your Friends '.$ur_name.' posted a link for JPC Experience. </td>
					  </tr>
					  
					  <tr>
						<td>URL:<a href="'.$URL.'">'.$URL.'</a></td>
					  </tr>
					  <tr>
						<td>'.nl2br($notes).'</td>
					  </tr>
					</table>
					';
								
						$header="MIME-Version: 1.0\r\n";
						$header.="Content-type: text/html \r\n";
						$header .= "From: ".$adminMail." \r\n";
						
						$fname = "JPC";
						
						
						//echo $BODY;
						mail($TO,$subject,$BODY,$header);	
						echo $msg = "<font color=red>URL Link has been Send Successfully</font>";exit;
					  }
					$explist = ExpquotesModel::create()->selectMsgDetail($_REQUEST);
					$this->viewData['explist'] =$explist ;
					$this->renderWithTemplate('frontpages/emailmsg', 'frontpage_popup_template'); 
			break;
			case "login":
					if($_REQUEST["uname"]!=''){
						$action_msg = FrontpagesModel::create()->userLogin($_POST);
						if($action_msg=="true")
						{
								
							if(isset($_SESSION["redirect_to"]) && $_SESSION["redirect_to"] != ""){
								$redirect_to = $_SESSION["redirect_to"];
								$_SESSION["redirect_to"]=false;
								$_SESSION["redirect_to"]="";
								$this->redirectto($redirect_to);
							}else{
								$this->redirectto("WelcomeMember");
							}
						}else{
							$this->viewData['error_msg'] = $action_msg;	
							session_destroy();
						}
					}
					$this->renderWithTemplate('frontpages/login', 'frontpage_content_template');	
			break;
			case "logout":
					session_destroy();
					$this->redirectto("login");
			break;
			case "welcomemember":
					if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = 10; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$memberlist = MembersModel::create()->selectMembers($_REQUEST);
					$this->viewData['memberlist'] =$memberlist ;
					$this->renderWithTemplate('frontpages/members', 'frontpage_profile_template'); 
			break;
			case "listfamily":
					if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = 10; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$memberlist = MembersModel::create()->listfamily($_REQUEST);
					$this->viewData['memberlist'] =$memberlist ;
					$this->renderWithTemplate('frontpages/listfamily', 'frontpage_profile_template'); 
			break;
			case "addfamily":
					if($this->checkMember()){
			
						if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){
								$action_msg = MembersModel::create()->insertRecord_family($_POST,$_FILES);
								$this->viewData['error_msg'] = $action_msg;
							
						}
						$countries = CountriesModel::create()->getAllCountries();
						$this->viewData['countries'] = $countries;
						$this->renderWithTemplate('frontpages/addfamily', 'frontpage_profile_template'); 
					}
			break;
			case "editfamily":
					if($this->checkMember()){
			
						if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){
								$action_msg = MembersModel::create()->editRecord_family($_POST,$_FILES);
								$this->viewData['error_msg'] = $action_msg;
							
						}
						$id = $_REQUEST['family_id'];
						$countries = CountriesModel::create()->getAllCountries();
						$this->viewData['countries'] = $countries;
						
						$userDetails = MembersModel::create()->selectPagesByPageId_family($id);	
						//exit;
						$this->viewData['userDetails'] = $userDetails;		
						$this->renderWithTemplate('frontpages/addfamily', 'frontpage_profile_template'); 
					}
			break;
			case "ChangePassword":
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$memberlist = MembersModel::create()->selectMembers($_REQUEST);
					$this->viewData['memberlist'] =$memberlist ;
					$this->renderWithTemplate('frontpages/members', 'frontpage_profile_template'); 
			break;
			case "memberdetails":
					if($_REQUEST["member_id"]==''){
						$this->redirectto("welcomemember");
					}
					$memberlist = MembersModel::create()->selectMemberDetail($_REQUEST["member_id"]);
					$this->viewData['memberlist'] =$memberlist ;
					$othermembers = MembersModel::create()->listfamily($_REQUEST);
					$this->viewData['othermembers'] =$othermembers ;
					$this->renderWithTemplate('frontpages/memberdetails', 'frontpage_profile_template'); 
			break;
			case "viewfamily":
					if($_REQUEST["family_id"]==''){
						$this->redirectto("welcomemember");
					}
					$memberlist = MembersModel::create()->selectFamilyDetail($_REQUEST["family_id"]);
					$this->viewData['memberlist'] =$memberlist ;
					$othermembers = MembersModel::create()->listfamily($_REQUEST);
					$this->viewData['othermembers'] =$othermembers ;
					$this->renderWithTemplate('frontpages/viewfamily', 'frontpage_profile_template'); 
			break;
			case "profile":
					if($_SESSION["member_id"]==''){
						$this->redirectto("index.php");
					}
					$memberlist = MembersModel::create()->selectMemberDetail($_SESSION["member_id"]);
					$this->viewData['memberlist'] =$memberlist ;
					$this->renderWithTemplate('frontpages/memberdetails', 'frontpage_profile_template'); 
			break;
			case "postupdates":
					if($this->checkMember()){
			
						if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){
							if(UpdatesModel::create()->checkEvent($_POST["title"])){
								$action_msg = UpdatesModel::create()->insertRecord($_POST,$_FILES);
								$this->viewData['error_msg'] = $action_msg;
							}else{
								$userDetails = new stdClass();
								foreach ($_POST as $key => $value){
										$userDetails->$key = $value;
									}
								$this->viewData['userDetails'] =$userDetails ;
								$this->viewData['error_msg'] = CommonModel::create()->getSettings('UPDATE_NAME_EXISTS');;
							}
						}
						//$totalpages = UpdatesModel::create()->selectCount();
						//$this->viewData['nume'] = $totalpages->cnt;		
						//echo $this->viewData['totalpages'];
						$this->renderWithTemplate('frontpages/postupdates', 'frontpage_profile_template'); 
					}
					
			break;
			case "postevents":
					if($this->checkMember()){
			
						if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){
							if(EventsModel::create()->checkEvent($_POST["title"])){
								$action_msg = EventsModel::create()->insertRecord($_POST,$_FILES);
								$this->viewData['error_msg'] = $action_msg;
							}else{
								$userDetails = new stdClass();
								foreach ($_POST as $key => $value){
										$userDetails->$key = $value;
									}
								$this->viewData['userDetails'] =$userDetails ;
								$this->viewData['error_msg'] = CommonModel::create()->getSettings('EVENT_NAME_EXISTS');;
							}
						}
						//$totalpages = UpdatesModel::create()->selectCount();
						//$this->viewData['nume'] = $totalpages->cnt;		
						//echo $this->viewData['totalpages'];
						$this->renderWithTemplate('frontpages/postevents', 'frontpage_profile_template'); 
					}
					
			break;
			case "postexp":
					if($this->checkMember()){
			
						if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){
								$action_msg = ExpquotesModel::create()->insertRecord_msg($_POST,$_FILES);
								$this->viewData['error_msg'] = $action_msg;
						}
						//$totalpages = UpdatesModel::create()->selectCount();
						//$this->viewData['nume'] = $totalpages->cnt;		
						//echo $this->viewData['totalpages'];
						$this->renderWithTemplate('frontpages/postexp', 'frontpage_profile_template'); 
					}
					
			break;
			case "downloadcat":
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$downlist = DownloadsModel::create()->selectDownloadCats($_REQUEST);
					$this->viewData['downlist'] =$downlist;
					$this->renderWithTemplate('frontpages/downcat', 'frontpage_content_template'); 
			break;
			case "downlist":
					if($_REQUEST['download_id']==''){
						$this->redirectto("downloadcat");
					}
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$downlist = DownloadsModel::create()->selectDownloads($_REQUEST);
					$this->viewData['downlist'] =$downlist;
					$this->renderWithTemplate('frontpages/downlist', 'frontpage_content_template'); 
			break;
			case "gallery":
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = PAGING_LIMIT; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$gallerylist = GalleriesModel::create()->selectGalleries($_REQUEST);
					$this->viewData['gallerylist'] =$gallerylist;
					$this->renderWithTemplate('frontpages/gallerylist', 'frontpage_content_template'); 
			break;
			case "photos":
					if($_REQUEST['gallery_id']==''){
						$this->redirectto("gallery");
					}
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = 100; 
										}
										$_REQUEST["limit"] = 100; 
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$photolist = GalleriesModel::create()->selectPhotos($_REQUEST);
					$this->viewData['photolist'] =$photolist;
					$this->renderWithTemplate('frontpages/photolist', 'frontpage_content_template'); 
			break;
			case "searchmember":
			
					if((isset($_POST['submit']) && $_POST['submit'] == "Search") or $_POST["act"]=='search'){
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = 30; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										
							$memberlist = MembersModel::create()->selectMembers_search($_REQUEST);
							$this->viewData['memberlist'] =$memberlist ;
							$this->renderWithTemplate('frontpages/searchmemberres', 'frontpage_profile_template'); 
					}else{
						$cities = CitiesModel::create()->getAllCities();
						$this->viewData['cities'] = $cities;
						$countries = CountriesModel::create()->getAllCountries();
						$this->viewData['countries'] = $countries;
						$complexes = ComplexesModel::create()->getAllComplexes();
						$this->viewData['complexes'] = $complexes;
						$plants = PlantsModel::create()->getAllPlants();
						$this->viewData['plants'] = $plants;
						$departments = DepartmentsModel::create()->getAllDepartments();
						$this->viewData['departments'] = $departments;	
						$this->renderWithTemplate('frontpages/searchmember', 'frontpage_profile_template'); 
					}	
					
			break;
			case "searchexp":
					if((isset($_POST['submit']) && $_POST['submit'] == "Search") or $_POST["act"]=='search'){
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = 5; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
							$explist = ExpquotesModel::create()->selectExpquotes_search($_REQUEST);
							$this->viewData['explist'] =$explist ;
							$this->renderWithTemplate('frontpages/searchexpres', 'frontpage_profile_template'); 
					}else{
						
						$this->renderWithTemplate('frontpages/searchexp', 'frontpage_profile_template'); 
					}	
					
			break;
			case "sitemap":
				$menusections = SectionsModel::create()->getMenuSections();
				$i=0;		
				$numrows = count($menusections);						
				$rows = ceil($numrows / 4);						
				//echo $rows;						
				$i =0;						
				$j = 0;	
				$sitemaphtml .= '<table width="80%" border="0" align="center" cellpadding="2" cellspacing="2">';
				if($numrows > 0){
					foreach($menusections as $db){
						if($j % 3 == 0 && $j !=0)						
						{						
							$i=0;						
							$sitemaphtml .= "</tr>";						
							$sitemaphtml .= "<tr><td colspan='8'>&nbsp;</td></tr>";						
							$sitemaphtml .= "<tr>";						
						}						
						if($j == 0)						
						{						
							$sitemaphtml .= "<tr>";						
						}
						if($db->pagelink!=''){
							$href_sec = " href=\"#\" onClick=\"location.href='".$db->pagelink."'\"";
						}else{
							if($db->page_alias != ""){
								//$href_sec = "onClick=\"location.assign('".$db->f("page_name").".html');\"";
								$href_sec = " href=\"#\" onClick=\"location.href='".$db->page_alias.".html'\"";
							}else{
								//$href_sec = "onClick=\"location.assign('sectioncontent.php?id=".$db->f("id")."');\"";
								$href_sec = " href=\"#\" onClick=\"gotolink('sectioncontent','".$db->id."','','')\"";
							}
						}
						
						
						$menupages = PagesModel::create()->getMenuPages($db->id,0);
						$cnt_Sec_pages = count($menupages);
						
						$menusubsections = SubsectionsModel::create()->getMenuSubSections($db->id);			
						$cnt_Sec = count($menusubsections);
						
						if($cnt_Sec > 0){
							$submenuHeader="submenuheader";				
						}else{
							$submenuHeader="";
						}	
						$sitemaphtml .= '<td width="33%" valign="top"><table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">';
						$sitemaphtml .= '<tr>';
						$sitemaphtml .= '<td width="35%" height="28" align="left" class="brd"><a '.$href_sec.' class="morebtn1"><strong>'.$db->name.'</strong></a></td>';
						$sitemaphtml .= '</tr>';
						$sitemaphtml .= '<tr><td align="left">';
						if($cnt_Sec > 0 || $cnt_Sec_pages > 0){
							$sitemaphtml .= '<div class="glossymenu">';
							if($cnt_Sec > 0 ){
								foreach($menusubsections as $mdb){
									if($mdb->pagelink != ""){
										$onClick_subsec = " href=\"#\" onClick=\"location.href='".$mdb->pagelink."'\"";
									}else{
										if($mdb->page_alias!=''){
											$onClick_subsec = " href=\"#\" onClick=\"location.href='".$mdb->page_alias.".html'\"";
										}else{
											$onClick_subsec = " href=\"#\" onClick=\"gotolink('subsectioncontent','".$db->id."','".$mdb->id."','')\"";
										}
									}
									$menupages = PagesModel::create()->getMenuPages($db->id,$mdb->id);
									$cnt_SubSec = count($menupages);
									if($cnt_SubSec > 0){
										$submenuHeader=" submenuheader";
										$headerIndex='headerindex="'.$subInd.'h"';
										$contentIndex='contentindex="'.$subInd.'c"';
										//$plusImg='&nbsp;<a '.$headerIndex.' href="#" class="menuitem'.$submenuHeader.'"><img src="./js/sitemap/plus.gif" class="statusicon"></a>';									
										$onClick_subsec="";
										$subInd++;
									}else{
										$submenuHeader="";
										$headerIndex='';
										$contentIndex='';
										$plusImg='';
									}
									$sitemaphtml .= '<a class="menuitem '.$submenuHeader.'" '.$onClick_subsec.'>'.$mdb->name.'</a>'.$plusImg;
									if($cnt_SubSec > 0){
										$sitemaphtml .= '<div style="display: none;" '.$contentIndex.' class="submenu">';
										foreach($menupages as $ndb){
											$pagelink = $ndb->pagelink;
											if(!empty($pagelink))
											{
												$onClick_page = " href=\"#\" onClick=\"location.href='".$pagelink."'\"";
											}else{
												if($ndb->page_alias != ""){
													$onClick_page = " href=\"#\" onClick=\"location.href='".$ndb->page_alias.".html'\"";
												}else{
													$onClick_page = " href=\"#\" onClick=\"gotolink('content','".$db->id."','".$mdb->id."','".$ndb->id."')\"";
												}
											}
											$sitemaphtml .= '<li><a '.$onClick_page.' class="nav">'.$ndb->name.'</a></li>';
										}
										$sitemaphtml .= '</ul></div>';
									}
								}
							}
							if($cnt_Sec_pages > 0){
								$onClick_page="";
								foreach($menupages as $pdb){
									$pagelink = $pdb->page_link;
										
										if(!empty($pagelink))
										{
											$onClick_page='onClick="location.assign(\"'.$pagelink.'?id='.$pdb->id.'\")"';
										}else{
											if($pdb->f("page_alias") != ""){	
												$onClick_page='href="'.$pdb->page_alias.'.html"';
											}else{
												$onClick_page='href="content.php?id='.$pdb->id.'&catid='.$db->id.'&subcatid=0"';
											}
										}
										$sitemaphtml .= '<a class="menuitem" '.$onClick_page.'>'.$pdb->f("name").'</a>';
								}
							}
							$sitemaphtml .= '</div>';
						}
						else{
							
						}
						$sitemaphtml .= '</td></tr></table></td>';
						if($j == $numrows-1)  
						  {
										 if($i==0)
										   {
											
											$sitemaphtml .= "<td width='25%' valign='top' align='center'><a href='".$sitemapLinks[$indLink]."'><b>".$sitemapTitle[$indLink]."</b></a></td>";$indLink++;
											$sitemaphtml .= "<td width='25%' valign='top' align='center'><a href='".$sitemapLinks[$indLink]."'><b>".$sitemapTitle[$indLink]."</b></a></td>";$indLink++;
											$sitemaphtml .= "<td width='25%' valign='top' align='center'><a href='".$sitemapLinks[$indLink]."'><b>".$sitemapTitle[$indLink]."</b></a></td>";$indLink++;
											//echo "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
										   }
										   if($i==1)
										   {
											$sitemaphtml .= "<td width='25%' valign='top' align='center'><a href='".$sitemapLinks[$indLink]."'><b>".$sitemapTitle[$indLink]."</b></a></td>";$indLink++;
											$sitemaphtml .= "<td width='25%' valign='top' align='center'><a href='".$sitemapLinks[$indLink]."'><b>".$sitemapTitle[$indLink]."</b></a></td>";$indLink++;
											//echo "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
										   }
										   if($i==2)
										   {
										   $sitemaphtml .= "<td width='25%' valign='top' align='center'><a href='".$sitemapLinks[$indLink]."'><b>".$sitemapTitle[$indLink]."</b></a></td>";$indLink++;
											//echo "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
										   }
										   if($i==3)
										   {
											$sitemaphtml .= "<td width='14%'>&nbsp;</td>";
											$sitemaphtml .= "<td width='14%'>&nbsp;</td>";
											$sitemaphtml .= "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
										   }					   
										   if($i==4)
										   {
											$sitemaphtml .= "<td width='14%'>&nbsp;</td>";
											$sitemaphtml .= "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
										   }	
										  if($i==5)
										   {
											$sitemaphtml .= "<td width='14%'>&nbsp;</td>";
											$sitemaphtml .= "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
										   }	 
										  if($i==6)
										   {
											$sitemaphtml .= "<td width='14%'>&nbsp;</td>";
											//echo "<td width='14%'>&nbsp;</td>";
										   }	 
										   if($i==7)
										   {
										   // echo "<td width='14%'>&nbsp;</td>";						
										   }					   
						  $sitemaphtml .= "</tr>";
						  }
						  	$j++;
      						$i++;
					}
				}
				$sitemaphtml .= '</tr></table>';
				$this->viewData['sitemaphtml'] = $sitemaphtml;		
				$this->renderWithTemplate('frontpages/sitemap', 'frontpage_content_template'); 
			break;
			case "sectioncontent":
				$secid = $_REQUEST['secid'];
				$db = SectionsModel::create()->selectPagesByPageId($secid);
				$this->viewData['db'] =$db ;
 				$sdb = SubsectionsModel::create()->getMenuSubSections($secid);
				$this->viewData['sdb'] =$sdb ;
				if(empty($secid)){
  					$this->redirectto("index.php");
				}
				$this->renderWithTemplate('frontpages/sectioncontent', 'frontpage_content_template');
			break;
			case "aboutus":
				$db = SectionsModel::create()->selectWelcomeText(1);
				$this->viewData['db'] =$db ;
				$this->renderWithTemplate('frontpages/aboutus', 'frontpage_content_template');
			break;
			case "subsectioncontent":
				$secid = $_REQUEST['secid'];
				$subsecid = $_REQUEST['subsecid'];
				$db = SubsectionsModel::create()->selectPagesByPageId($subsecid);
				$this->viewData['db'] =$db ;
				$secdetail = SectionsModel::create()->selectPagesByPageId($secid);
				$this->viewData['secdetail'] =$secdetail;
 				$sdb = PagesModel::create()->getMenuPages($secid,$subsecid);
				$this->viewData['sdb'] =$sdb ;
				if(empty($secid)){
  					$this->redirectto("index.php");
				}
				$this->renderWithTemplate('frontpages/subsectioncontent', 'frontpage_content_template');
			break;
			case "content":
				$secid = $_REQUEST['secid'];
				$subsecid = $_REQUEST['subsecid'];
				$pageid = trim($_REQUEST['pageid'],".");
				$subsecdetail = SubsectionsModel::create()->selectPagesByPageId($subsecid);
				$this->viewData['subsecdetail'] =$subsecdetail ;
				$secdetail = SectionsModel::create()->selectPagesByPageId($secid);
				$this->viewData['secdetail'] =$secdetail;
 				$db = PagesModel::create()->selectPagesByPageId($pageid);
				$this->viewData['db'] =$db ;
				if(empty($secid)){
  					$this->redirectto("index.php");
				}
				$this->renderWithTemplate('frontpages/content', 'frontpage_content_template');
			break;
			case "content_seo":
				$PageTitle=$_REQUEST['pageTitle'];
	
				if(empty($PageTitle))
				{
					$this->redirectto("index.php");
				}
				
				$tbl_arr= array("hi_sections","hi_subsections","hi_pages");

				for($i=0;$i<count($tbl_arr);$i++){	
								$data = PagesModel::create()->contentseo_id($tbl_arr[$i],$PageTitle);
								if(count($data) > 0){
								$pid = $data->id;
								$pageid = $data->id;
								$secid = $data->secid;
								$subsecid = $data->subsecid;
								$section = $data->name;
								
								$tableName = $tbl_arr[$i];
				
								break;
				
								}	
				
				}
				$this->viewData['tableName'] =$tableName;
				if(empty($pid))
				{
					$this->redirectto("index.php");
				}
				if($tableName=='hi_sections'){
					$db = SectionsModel::create()->selectPagesByPageId($pid);
					$this->viewData['db'] =$db ;
					$sdb = SubsectionsModel::create()->getMenuSubSections($pid);
					$this->viewData['sdb'] =$sdb ;
					if(empty($pid)){
						$this->redirectto("index.php");
					}
				}
				if($tableName=='hi_subsections'){
					$db = SubsectionsModel::create()->selectPagesByPageId($pid);
					$this->viewData['db'] =$db ;
					$secdetail = SectionsModel::create()->selectPagesByPageId($secid);
					$this->viewData['secdetail'] =$secdetail;
					$sdb = PagesModel::create()->getMenuPages($secid,$pid);
					$this->viewData['sdb'] =$sdb ;
					if(empty($secid)){
						$this->redirectto("index.php");
					}
				}
				if($tableName=='hi_pages'){
					$subsecdetail = SubsectionsModel::create()->selectPagesByPageId($subsecid);
					$this->viewData['subsecdetail'] =$subsecdetail ;
					$secdetail = SectionsModel::create()->selectPagesByPageId($secid);
					$this->viewData['secdetail'] =$secdetail;
					$db = PagesModel::create()->selectPagesByPageId($pageid);
					$this->viewData['db'] =$db ;
					if(empty($secid)){
						$this->redirectto("index.php");
					}
				}
				//$db = PagesModel::create()->contentseo_data($tableName,$pid);
				//$this->viewData['db'] =$db;
				$this->renderWithTemplate('frontpages/content_seo', 'frontpage_content_template');
			break;
			case "searchresult":
						if(!isset($_REQUEST['start_client'])) {                         
						$start_client = 0;
						}
						else
						{
						 $start_client = $_REQUEST['start_client'];
						}
						
						$eu = ($start_client - 0); 
						$limit = 10;                                 
						$th = $eu + $limit; 
						$back = $eu - $limit; 
						$next = $eu + $limit; 	
						$this->viewData['eu'] =$eu;
						$this->viewData['limit'] =$limit;
						$this->viewData['th'] =$th;
						$this->viewData['back'] =$back;
						$this->viewData['next'] =$next;
						$this->viewData['start_client'] =$start_client;
					$keyword = trim($_REQUEST['keyword']);
					$this->viewData['keyword'] =$keyword ;
					$keyword = strtolower($keyword);
					if(empty($keyword)){
						$this->redirectto("index.php");
					}
					$SearchLinks = array();
					$SearchTitles = array();				  
					$SearchText = array();
					$SearchArea = array();	
					$SearchImage = array();

					$keyword_search = strtolower($keyword);
					$menusections = SectionsModel::create()->selectSections();
					foreach($menusections as $db){
						$content = strip_tags($db->description);
						$content_search = strtolower($content);
						$pos = strpos($content_search,$keyword_search);
						if($pos === false)
						{	   
						}
						else
						{
							if($db->pagelink!=''){
							$href_sec = " href=\"#\" onClick=\"location.href='".$db->pagelink."'\"";
							}else{
								if($db->page_alias != ""){
									//$href_sec = "onClick=\"location.assign('".$db->f("page_name").".html');\"";
									$href_sec = " href=\"#\" onClick=\"location.href='".$db->page_alias.".html'\"";
								}else{
									//$href_sec = "onClick=\"location.assign('sectioncontent.php?id=".$db->f("id")."');\"";
									$href_sec = " href=\"#\" onClick=\"gotolink('sectioncontent','".$db->id."','','')\"";
								}
							}
							
							
							// $link = $host."sectioncontent.php?id=".$db->f("id")."&keyword=".$keyword;
							$title_link = $db->name;
							
							$text = strip_tags($db->description);		  
							$text  = substr($text,0,300);
							
							$SearchLinks[]=$href_sec;
							$SearchTitles[]=$title_link;
							$SearchText[]=$text;
							$SearchArea[] = "Sections";   
							$SearchImage[]='';
						}
					}
					$menusubsections = SubsectionsModel::create()->selectSubsections();
					foreach($menusubsections as $db){
						$content = strip_tags($db->description);
						
						$content_search = strtolower($content); 
						$pos = strpos($content_search,$keyword_search);
						if($pos === false)
						{	   
						}
						else
						{ 
							if($db->pagelink != ""){
								$onClick_subsec = " href=\"#\" onClick=\"location.href='".$db->pagelink."'\"";
							}else{
								if($db->page_alias!=''){
									$onClick_subsec = " href=\"#\" onClick=\"location.href='".$db->page_alias.".html'\"";
								}else{
									$onClick_subsec = " href=\"#\" onClick=\"gotolink('subsectioncontent','".$db->id."','".$db->secid."','')\"";
								}
							}
							
							
							$title_link = $db->name;
							$text = strip_tags($db->description);		  
							$text  = substr($text,0,300);
							
							$SearchLinks[]=$onClick_subsec;
							$SearchTitles[]=$title_link;
							$SearchText[]=$text;
							$SearchArea[] = "Sub Sections";   
							$SearchImage[]='';
						}
					}
					$menupages = PagesModel::create()->selectPages_();
					foreach($menupages as $db){
						$content = strip_tags($db->name);
						$content_search = strtolower($content); 
						$pos = strpos($content_search,$keyword_search);
						
						$content = strip_tags($db->description);
						$content_search = strtolower($content); 
						$pos1 = strpos($content_search,$keyword_search);
						if($pos === false && $pos1 === false)
						{	   
						}
						else
						{
							$pagelink = $db->pagelink;
							if(!empty($pagelink))
							{
								$onClick_page = " href=\"#\" onClick=\"location.href='".$pagelink."'\"";
							}else{
								if($db->page_alias != ""){
									$onClick_page = " href=\"#\" onClick=\"location.href='".$db->page_alias.".html'\"";
								}else{
									$onClick_page = " href=\"#\" onClick=\"gotolink('content','".$db->secid."','".$db->subsecid."','".$db->id."')\"";
								}
							}
							
							$title_link = $db->name;
							$text = strip_tags($db->description);		  
							$text  = substr($text,0,300);
							
							$SearchLinks[]=$onClick_page;
							$SearchTitles[]=$title_link;
							$SearchText[]=$text;
							$SearchArea[] = "Pages";   
							$SearchImage[]='';
						}
					}
					$this->viewData['SearchLinks'] =$SearchLinks;
					$this->viewData['SearchTitles'] =$SearchTitles;
					$this->viewData['SearchText'] =$SearchText;
					$this->viewData['SearchArea'] =$SearchArea;
					
					$nume = count($SearchLinks);
					$RecLimit = $start_client + $limit;
					
					if($RecLimit > $nume){
					$RecLimit = $nume;
					}
					$this->viewData['nume'] =$nume;
					$this->viewData['RecLimit'] =$RecLimit;
					
					$this->renderWithTemplate('frontpages/searchresult', 'frontpage_content_template'); 
			break;
			case "reqmember":
				if($_REQUEST["security_code"]!=$_SESSION[securimage_code_value][quick_form]){
					$msg = "Invalid security code";
					$this->viewData['msg'] =$msg;
				}else{
								$action_msg = FrontpagesModel::create()->insertMemberRequest($_POST);
								$this->viewData['error_msg'] = $action_msg;
					$adminMail = FrontpagesModel::create()->getSettings('MAIL_SEND_FROM_EMAIL');
					$subject = 'New Membership Request';
					$header = "MIME-Version: 1.0\r\n";
					$header .= "Content-type: text/html \r\n";
					$header .= "From:".$adminMail;
					$body = '<table><tr><td>New Membership request received, below is a detail</td></tr>';
					$body .= '<tr><td>Name:</td><td>'.$_REQUEST["name"].'</td></tr>';
					$body .= '<tr><td>Email:</td><td>'.$_REQUEST["email"].'</td></tr>';
					$body .= '<tr><td>Mobile:</td><td>'.$_REQUEST["mobile"].'</td></tr>';
					$body .= '<tr><td>Message:</td><td>'.$_REQUEST["message"].'</td></tr></table>';
					@mail($adminMail,$subject,$body,$header);
					$subject = 'Thank you for your Request: JPC';
					$body = '<table><tr><td>Dear '.$_REQUEST["name"].'</td></tr><tr><td><br>We have received your Request for Member, we will contact you soon.</td></tr><tr><td><br>Thank you<br>JPC</td></tr></table>';
					@mail($_REQUEST["email"],$subject,$body,$header);
					$msg = "Thank you for your request";
					$this->viewData['msg'] =$msg;
				}
				$this->renderWithTemplate('frontpages/reqmember', 'frontpage_content_template');
			break;
			case "forgotpwd":   
					if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){	
						$action_msg = FrontpagesModel::create()->forgotPassword($_POST);	// Update Password
						$this->viewData['error_msg'] =$action_msg ;		
					}
					$this->renderWithTemplate('frontpages/forgotpwd', 'frontpage_content_template');
			break;
			case "resetpassword":  
					if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){	
						$action_msg = FrontpagesModel::create()->resetPassword($_POST);	// Update Password
						//echo $action_msg;
								if($action_msg=="true")
								{ // Check if user alreay login. If yes redirect user to suitable welcome page.
										$this->redirectto("index.php");
								}
								else if($action_msg=="false"){
										$this->viewData['error_msg'] = FrontpagesModel::create()->getSettings('INVALID_LOGIN_MSG');								
								}
								else{
									session_destroy();
								}
						$this->viewData['error_msg'] =$action_msg ;		
					}
					$this->renderWithTemplate('frontpages/resetpassword', 'frontpage_content_template');
			break;	
			case "pagecontent":
					$id=$_REQUEST["id"];
					$userDetails = SinglepagesModel::create()->selectPagesByPageId($id);	
					$this->viewData['db'] = $userDetails;		
					$this->renderWithTemplate('frontpages/pagecontent', 'frontpage_content_template');
			break;
			case "memberreg":
					if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){
						if(MembersModel::create()->checkMember($_POST["email"])){
							if($_FILES["simage"]["name"]=='' or CommonModel::create()->checkuploadfileext($_FILES["simage"],VALID_EXT_MEMBERS)){
								$width = CommonModel::create()->getSettings('MEMBER_UPLOAD_WIDTH');
								$height = CommonModel::create()->getSettings('MEMBER_UPLOAD_HEIGHT');
								//if($_FILES["simage"]["name"]=='' or CommonModel::create()->checkuploadfilesize($_FILES["simage"],$width,$height,true)){
									$action_msg = MembersModel::create()->insertRecord($_POST,$_FILES);
									$this->viewData['error_msg'] = $action_msg;
								/*}else{
									$userDetails = new stdClass();
									foreach ($_POST as $key => $value){
											$userDetails->$key = $value;
										}
									$this->viewData['userDetails'] =$userDetails ;
									$this->viewData['error_msg'] = CommonModel::create()->getSettings('MEMBER_INVALID_FILE');
								}*/
							}else{
								$userDetails = new stdClass();
								foreach ($_POST as $key => $value){
										$userDetails->$key = $value;
									}
								$this->viewData['userDetails'] =$userDetails ;
								$this->viewData['error_msg'] = CommonModel::create()->getSettings('MEMBER_INVALID_FILE');
							}
						}else{
							$userDetails = new stdClass();
							foreach ($_POST as $key => $value){
									$userDetails->$key = $value;
								}
							$this->viewData['userDetails'] =$userDetails ;
							$this->viewData['error_msg'] = CommonModel::create()->getSettings('MEMBER_EMAIL_EXISTS');
						}
					}
					$cities = CitiesModel::create()->getAllCities();
					$this->viewData['cities'] = $cities;
					$countries = CountriesModel::create()->getAllCountries();
					$this->viewData['countries'] = $countries;
					$gams = GamsModel::create()->getAllGams();
					$this->viewData['gams'] = $gams;
					$complexes = ComplexesModel::create()->getAllComplexes();
					$this->viewData['complexes'] = $complexes;
					$plants = PlantsModel::create()->getAllPlants();
					$this->viewData['plants'] = $plants;
					$departments = DepartmentsModel::create()->getAllDepartments();
					$this->viewData['departments'] = $departments;		
					$totalpages = MembersModel::create()->selectCount();
					$this->viewData['nume'] = $totalpages->cnt;		
					//echo $this->viewData['totalpages'];
					$this->renderWithTemplate('frontpages/memberreg', 'frontpage_content_template');
			break;
			case "editprofile":
					$id = $_REQUEST['member_id'];
					if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit" && $_POST['member_id'] != ""){
						if(MembersModel::create()->checkMember($_POST["email"],$_POST["member_id"])){
							if($_FILES["simage"]["name"]=='' or CommonModel::create()->checkuploadfileext($_FILES["simage"],VALID_EXT_MEMBERS)){
								$width = CommonModel::create()->getSettings('MEMBER_UPLOAD_WIDTH');
								$height = CommonModel::create()->getSettings('MEMBER_UPLOAD_HEIGHT');
								//if($_FILES["simage"]["name"]=='' or CommonModel::create()->checkuploadfilesize($_FILES["simage"],$width,$height,true)){
									$action_msg = MembersModel::create()->editRecord($_POST,$_FILES);
									$this->viewData['error_msg'] = $action_msg;
								/*}else{
									$userDetails = new stdClass();
									foreach ($_POST as $key => $value){
											$userDetails->$key = $value;
										}
									$this->viewData['userDetails'] =$userDetails ;
									$this->viewData['error_msg'] = CommonModel::create()->getSettings('MEMBER_INVALID_FILE');
								}*/
							}else{
								$userDetails = new stdClass();
								foreach ($_POST as $key => $value){
										$userDetails->$key = $value;
									}
								$this->viewData['userDetails'] =$userDetails ;
								$this->viewData['error_msg'] = CommonModel::create()->getSettings('MEMBER_INVALID_FILE');
							}
						}else{
							$userDetails = new stdClass();
							foreach ($_POST as $key => $value){
									$userDetails->$key = $value;
								}
							$this->viewData['userDetails'] =$userDetails ;
							$this->viewData['error_msg'] = CommonModel::create()->getSettings('MEMBER_EMAIL_EXISTS');
						}
					}
					$cities = CitiesModel::create()->getAllCities();
					$this->viewData['cities'] = $cities;
					$countries = CountriesModel::create()->getAllCountries();
					$this->viewData['countries'] = $countries;
					$complexes = ComplexesModel::create()->getAllComplexes();
					$this->viewData['complexes'] = $complexes;
					$plants = PlantsModel::create()->getAllPlants();
					$this->viewData['plants'] = $plants;
					$departments = DepartmentsModel::create()->getAllDepartments();
					$this->viewData['departments'] = $departments;		
					$userDetails = MembersModel::create()->selectPagesByPageId($id);	
					$totalpages = MembersModel::create()->selectCount();
					$this->viewData['nume'] = $totalpages->cnt;	
					//exit;
					$this->viewData['userDetails'] = $userDetails;		
					//echo $this->viewData['totalpages'];
					
					$this->renderWithTemplate('frontpages/memberreg', 'frontpage_profile_template');
			break;
			case "changepassword":
				if($this->checkMember()){  
					if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){	
						$action_msg = FrontpagesModel::create()->changePassword($_POST);	// Update Password
						//echo $action_msg;
								if($action_msg=="true")
								{ // Check if user alreay login. If yes redirect user to suitable welcome page.
										//$this->redirectto("index.php");
								}
								else if($action_msg=="false"){
										$this->viewData['error_msg'] = FrontpagesModel::create()->getSettings('INVALID_LOGIN_MSG');								
								}
								else{
									session_destroy();
								}
						$this->viewData['error_msg'] =$action_msg ;		
					}
					$this->renderWithTemplate('frontpages/changepassword', 'frontpage_profile_template');
				}
			break;	
			case "clickcount":
					$bannerid=$_REQUEST["bannerid"];
					$ipaddr=$_REQUEST["ipaddr"];
					$WebUrl=$_REQUEST["WebUrl"];
					$ttype=$_REQUEST["ttype"];
					$success = BannersModel::create()->saveClicks($_REQUEST);	
					echo $success;
			break;
			case "hpbirthday":
					$birthdays = MembersModel::create()->getBirthday();
					$this->viewData['birthdays'] = $birthdays;
					$this->renderWithTemplate('frontpages/hpbirthday', 'frontpage_empty_template');
			break;
			case "birthdaydetail":
					if($_REQUEST['checkLogin'] == 1){
						if($this->checkMember('birthdaydetail',$_REQUEST)){
						}
					}else{
						//if($this->checkMember('birthdaydetail',$_REQUEST)){
				
							if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){
								$action_msg = MembersModel::create()->insertWish($_POST);
								$this->viewData['error_msg'] = $action_msg;							
							}
							$this->viewData['msg'] =$action_msg ;		
								if(isset($_SESSION['pass_vars']) and $_SESSION['pass_vars']!=''){
									$_REQUEST=$_SESSION['pass_vars'];
									$_SESSION['pass_vars']='';
								}
						
											if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
												$_REQUEST['start'] = 0;
											}
											else
											{
											// $start = $_POST['start'];
											}
											$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
											if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
											{
												$_REQUEST["limit"] = 5; 
											}
											$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
											$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
											$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
						$birthdaydetail = MembersModel::create()->getBirthdayDetail($_REQUEST);
						$this->viewData['birthdaydetail'] = $birthdaydetail;
						
						$wishlist = MembersModel::create()->getWishList($_REQUEST);
						$this->viewData['wishlist'] = $wishlist;
						$this->renderWithTemplate('frontpages/birthdaydetail', 'frontpage_profile_template');
						
						//}
					}
					//$_SESSION['pass_vars']='';
					//unset($_SESSION['pass_vars']);
			break;
			case "missyoudetail":
					if($this->checkMember('missyoudetail',$_REQUEST)){
			
						if(isset($_POST['Submit']) && $_POST['Submit'] == "Submit"){
								$action_msg = MembersModel::create()->insertMsg($_POST);
								$this->viewData['error_msg'] = $action_msg;
							
						}
						$this->viewData['msg'] =$action_msg ;		
						if(isset($_SESSION['pass_vars']) and $_SESSION['pass_vars']!=''){
								$_REQUEST=$_SESSION['pass_vars'];
								$_SESSION['pass_vars']='';
							}
										if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = 5; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
						$missyoudetail = MembersModel::create()->getMissyouDetail($_REQUEST);
						$this->viewData['missyoudetail'] = $missyoudetail;
						
						$msglist = MembersModel::create()->getMsgList($_REQUEST);
						$this->viewData['msglist'] = $msglist;
						$this->renderWithTemplate('frontpages/missyoudetail', 'frontpage_profile_template');
					}
			break;
			case "birthdaylist":
						if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = 5; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$birthdaylist = MembersModel::create()->getBirthday();
					$this->viewData['birthdaylist'] = $birthdaylist;
					$this->renderWithTemplate('frontpages/birthdaylist', 'frontpage_profile_template');
			break;
			case "missyoulist":
						if(!isset($_REQUEST['start']) or !is_numeric($_REQUEST['start'])) {                        
											$_REQUEST['start'] = 0;
										}
										else
										{
										// $start = $_POST['start'];
										}
										$_REQUEST["eu"] = ($_REQUEST['start'] - 0); 
										if($_REQUEST["limit"]=='' or !is_numeric($_REQUEST["limit"]))
										{
											$_REQUEST["limit"] = 5; 
										}
										$_REQUEST["th"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
										$_REQUEST["back"] = $_REQUEST["eu"] - $_REQUEST["limit"];
										$_REQUEST["next"] = $_REQUEST["eu"] + $_REQUEST["limit"]; 
					$missyoulist = MembersModel::create()->getMissyou();
					$this->viewData['missyoulist'] = $missyoulist;
					$this->renderWithTemplate('frontpages/missyoulist', 'frontpage_profile_template');
			break;
			case "sendmessage":
				if((isset($_POST['submit']) && $_POST['submit'] == "Send") or $_POST["act"]=='search' and $_REQUEST["memberemail"]!=''){
					$security_code=$_REQUEST["security_code"];
					include("./utility/security/securimage.php");
					$img = new Securimage();
					$img->namespace = 'feedback_form';
					$valid = $img->check($security_code);
					if($valid == true) {
						
						$headers  = 'MIME-Version: 1.0' . "\r\n";
						$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
						// Additional headers
						$headers .= "From: ".$_REQUEST["memail"]. "\r\n";
						$subject = 'Someone has sent you a message: JPC';
						$subject_member = 'Your message has been sent: JPC';
						$body = '<table align="center" width="50%" height="50%" border="0" cellpadding="10" cellspacing="10" ><tr><td height="200" align="left" valign="middle" bgcolor="">
														Hi, 								
														</td>
														</tr>
														<tr><td>Name</td><td>'.$_REQUEST["name"].'</td></tr>
														<tr><td>Mobile</td><td>'.$_REQUEST["mobile"].'</td></tr>
														<tr><td>Email</td><td>'.$_REQUEST["memail"].'</td></tr>
														<tr><td>Message</td><td>'.$_REQUEST["message"].'</td></tr>
														</table>';
						@mail($_REQUEST["memail"], $subject_member, $body, $headers);
						if($_REQUEST["memberemail"]!=''){
							@mail($_REQUEST["memberemail"], $subject, $body, $headers);
						}else{
							if($_REQUEST["family_id"]!='' and $_REQUEST["memberemail"]==''){
								$memberemail  = MembersModel::create()->getMemberEmail($_REQUEST["family_id"]);
								@mail($memberemail->email, $subject, $body, $headers);
							}else if($_REQUEST["member_id"]!='' and $_REQUEST["memberemail"]==''){
								$memberemail  = MembersModel::create()->getMemberEmail_($_REQUEST["family_id"]);
								@mail($memberemail->email, $subject, $body, $headers);
							}
							if($memberemail->email==''){
								$subject = "Someone trying to message to member but no email id found";
								if($_REQUEST["member_id"]!=''){
									$memberlist = MembersModel::create()->selectMemberDetail($_REQUEST["member_id"]);
								}else{
									$memberlist = MembersModel::create()->selectFamilyDetail($_REQUEST["family_id"]);
									
									$body.='<table><tr><td colspan=2>Member Detail</td><tr>
									<tr><td>Name</td><td>'.$memberlist->fam_fullname.'</td><tr>
									<tr><td>Family No.</td><td>'.$memberlist->familyno.'</td><tr>
									';
									@mail("chetna@aiindia.com", $subject, $body, $headers);
								}
								
							}
						}
						$msg= "Message has been sent.";
						 //header("location:inquire.php?mag=$msg");
						 $this->viewData['msg'] = $msg;
					}else{
						 $msg= "Sorry, the code you entered was invalid. Please enter valid code .";
						 //header("location:inquire.php?mag=$msg");
						 $this->viewData['msg'] = $msg;
					}
				}
				$this->renderWithTemplate('frontpages/sendmessage', 'frontpage_content_template');
			break;
		}
		
	}
	function checkMember($redirect_to='',$pass_vars=array()){
		if(isset($_SESSION["member_id"]) && $_SESSION["member_id"] != ""){
			return true;
		}else{
			if(!empty($redirect_to)){
				$_SESSION['redirect_to']=$redirect_to;
				$_SESSION['pass_vars']=$pass_vars;
				//$this->redirectto("login?redirect_to=".$redirect_to."&recordid=".$recordid);
				$this->redirectto("login");
			}else{
				$this->redirectto("login");
			}
		}
	}
}