<?php
function mail_header() {
	$ContactPerson=getAdminname();
	$eMail=getAdminemail();
	$headers = "From: $ContactPerson<$eMail> \n";
	$headers .= "Reply-To: $eMail \r\n";
	$headers .= "X-Mailer: PHP/". phpversion();
	$headers .= "X-Priority: 3 \n";
	$headers .= "MIME-version: 1.0\n";
	$headers .= "Content-Type: text/html; charset=UTF-8\n";
	return $headers;
}

function smtp_mailer($to,$email,$name,$subject,$msg){
   
	$mail = new PHPMailer(); 
	$mail->SMTPDebug  = 0;
	$mail->IsSMTP(); 
	$mail->SMTPAuth = true; 
	$mail->SMTPSecure = 'tls'; 
	$mail->Host = "162.215.169.152";
	$mail->Port = 587; 
	$mail->IsHTML(true);
	$mail->CharSet = 'UTF-8';
	$mail->Username = "enquiry@webpulsesolution.net";
	$mail->Password = "aWj)lgpI5s5+";
	$mail->SetFrom("enquiry@webpulsesolution.net",'webpulsesolution.net');
	$mail->AddReplyTo($email,$name);
	$mail->Subject = $subject;
	$mail->Body =$msg;
	$mail->AddAddress($to);
    
    
	$mail->SMTPOptions=array('ssl'=>array(
		'verify_peer'=>false,
		'verify_peer_name'=>false,
		'allow_self_signed'=>false
	));
	if(!$mail->Send()){
      
		echo $mail->ErrorInfo;
	}else{
       
		return 'Sent';
	}
}


function checkpoint($from_start = false) {
	global $PREV_CHECKPOINT;
	if($PREV_CHECKPOINT=='') {
		$PREV_CHECKPOINT = SCRIPT_START_TIME;
	}
	$cur_microtime = getmicrotime();
	
	if($from_start) {
		return $cur_microtime - SCRIPT_START_TIME;
	}
	else {
		$time_taken = $cur_microtime - $PREV_CHECKPOINT;
		$PREV_CHECKPOINT = $cur_microtime;
		return $time_taken;
	}
}

//MailLazy Mailer
function sendEmailMailLazy($to, $subject, $message, $from = "") {
$from = ($from) ? $from : 'enquiry@webpulse.site';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.mailazy.com/v1/mail/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{' .
'"to": ["' . $to . '"],' .
'"from": "Webpulse <enquiry@webpulse.site>",' .
'"reply_to": "<' . $from . '>",' .
'"subject": "' . $subject . '",' .
'"content": [{"type": "text/html","value": "' . $message . '"}]' .
'}',
CURLOPT_HTTPHEADER => array(
"X-Api-Key: c7l8ftadc007534ffbd0eSlfYEoFWg",
"X-Api-Secret: pNrxHJsIymuDQmbzIwkyxBYvvAMFLhDjFmxJiebJ.FEPtaHxqm3eAj92PqDnK6H",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);
// echo $response;
// exit;
}

function mail_content($memberID="") {
	$res=getResult("logfile"," where 1");
	return $res['newsletterOther'];
}


function newsletter_content($memberID="") {
	$res=getResult("logfile"," where 1");
	return ms_htmlentities_decode($res['newsletter']);
}


function getAdminDetails() {
	$res=getResult("admin_details"," where 1");
	return $res;
}


function getAdminname() {
	$res=getResult("admin_details"," where 1");
	return $res['name'];
}


function getAdminStaffName($id) {
	$res=getResult("admin_details"," where slno='".$id."'","user_id, name");
	return $res['user_id']." (".$res['name'].")";
}


function getAdminphone() {
	$res=getResult("admin_details"," where 1");
	return $res['phone'];
}


function getAdminfax() {
	$res=getResult("admin_details"," where 1");
	return $res['fax'];
}


function getAdmincompany() {
	$res=getResult("admin_details"," where 1");
	return $res['companyName'];
}


function getAdminaddress() {
	$res=getResult("admin_details"," where 1");
	return $res['address'];
}


function getAdminemail() {
	$res=getResult("admin_details"," where 1");
	return $res['email'];
}


function getWebsite() {
	$res=getResult("admin_details"," where 1");
	return $res['website'];
}


function getClass() {
	$msg=explode("~",$_SESSION[opmsg]);
	if(count($msg)<2) {
		$class="msgadmin";	
	}else {
		$class=$msg[1];
	}
	return $class;	
}


function GetValidFileName($fname) {
	$pattern="[?()\/&#\,\;\.$+%]";
	$valid_file=mb_ereg_replace($pattern,"-",$fname);
	$valid_file=strtolower($valid_file);
	$valid_file=str_replace("  ","-",$valid_file);
	$valid_file=str_replace(" ","-",$valid_file);
	$valid_file=str_replace("_","-",$valid_file);
	$valid_file=str_replace("%","",$valid_file);
	$valid_file=str_replace("__","-",$valid_file);
	$valid_file=str_replace("--","-",$valid_file);
	return $valid_file;
}


function w3c_validate($content) {
	$content=str_replace("Width","width",$content);
	$content=str_replace("Height","height",$content);
	$content=str_replace("Align","align",$content);
	$content=str_replace("Cellspacing","cellspacing",$content);
	$content=str_replace("Cellpadding","cellpadding",$content);
	$content=str_replace("Style","style",$content);
	$content=str_replace('type="_moz"','',$content);
	return $content;
}
############  DB Functions ######################
function getCount($tableName, $cond="", $fields="*") {
	$sql=db_query("select $fields from $tableName $cond");
	return mysqli_num_rows($sql);
}


function updateTable($tableName,$cond="") {
	db_query("update $tableName set $cond");
}


function getResult($tableName, $cond="", $fields="*") {
    
	$sql=db_query("select $fields from $tableName $cond");
	$res=mysqli_fetch_array($sql);
	$res=ms_htmlentities_decode($res);	
	return $res;
}


function getRecord($fieldname,$tablename,$primayKey,$primayKeyvalue) {
	$res=mysqli_fetch_array(db_query("select $fieldname from $tablename where $primayKey='$primayKeyvalue'"));
	return $res[0];
}


function getCountryName($val) {
	$res=getResult("country"," where cont_code='$val'");
	return $res['cont_name'];
}


function getMember() {
	$res=explode("~",$_SESSION[sessionID]);
	return $res[0];
}


function getMemberName($memID) {
	$res=getResult("member_tbl"," where memberID='$memID'");
	return $res['nameTitle']." ".ucwords($res['memberName']);
}


function getMemberType($memID) {
	$res=getResult("member_tbl"," where memberID='$memID'");
	return $res['memberType'];
}


function getMemberFullName($memID) {
	$res=getResult("member_tbl"," where memberID='$memID'");
	return ucwords($res['memberName']);
}


function getMembershipType($memID){
	$res=getResult("member_tbl"," where memberID='$memID'");
	return $res[membershipType];
}


function getMembershipPlanName($id){
	return $GLOBALS[membership_type_array][$id];
}


function getAnnualTurnover($id){
	if ($id == 1) {
		$amt=$GLOBALS[annual_turnover_array][$id];
		return "Less than ".getCurrencySymbol().getCurrencyPrice($amt);
	}
	else if ($id == 11) {
		$amt=$GLOBALS[annual_turnover_array][$id];
		return "Above ".getCurrencySymbol().getCurrencyPrice($amt);
	}
	else {
		$amt=explode("^",$GLOBALS[annual_turnover_array][$id]);
		return getCurrencySymbol().getCurrencyPrice($amt[0])." to ".getCurrencySymbol().getCurrencyPrice($amt[1]);
	}
	//return getCurrencySymbol().$GLOBALS[annual_turnover_array_currency][$id];
}


function getCompanySize($id){
	return $GLOBALS[company_size_array][$id];
}


function getIndustryType($id){
	$industryType="";
	$ids=explode("^",$id);
	for ($i=0; $i<count($ids)-1;$i++) {
		$res=getResult("category_tbl"," where catID='$ids[$i]'");
		$industryType.=$res[catName].", ";		
	}
	$industryType=ucwords(substr($industryType,1,-2));
	return $industryType;
}


function getBusinessType($id){
	return $GLOBALS[business_type_array][$id];
}


function getBusinessNature($id){
	return $GLOBALS[business_nature_array][$id];
}


function validateSession() {
	if($_SESSION['sessionID']=="") {
		//$redirect_script=str_replace("/redapple","",$_SERVER['SCRIPT_NAME']);
		//$redirect_script=str_replace(".php",".htm",$redirect_script);
		header("Location: ".SITE_URL_PATH."/login.htm");		
		exit();
	}
}


function getTradeLeadType($id){
	return $GLOBALS[offer_type_array][$id];
}

function getTradeLeadType1($id){
	return $GLOBALS[offer_type_array1][$id];
}


###################################################### 
function send_email($fromPerson, $fromEmail, $to, $subject, $message) {
	$headers = "From:$fromPerson<$fromEmail> \n";
	$headers .= "Reply-To: $eMail \r\n";
	$headers .= "X-Mailer:PHP v".phpversion()."\r\n";
	$headers .= "X-Priority:3\n";
	$headers .= "MIME-version:1.0\n";
	$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
	$msg=$message;
	mail($to, $subject, $msg, $headers);
}

function show_message_front() {
	if($_SESSION['message']!="") {
		echo "<br /><center><font style=\"color:#ee0000;\"><b>".$_SESSION['message']."</b></font></center><br />";
		$_SESSION['message']="";
	}
	else {
		echo "";
	}
}


################################################
function getCategoryHierarchy($catid){
	$res=getResult("category_tbl"," where catID='$catid'  and status='Y'");
	$flag=0;
	$catparent=$catid;
	while($flag!=1){
		$res1=db_query("select * from category_tbl where catID='$catparent'  and status='Y'");
		$record=mysqli_fetch_array($res1);
		if($record[parentID]!=0){
			$catparent=$record[parentID];
			$array.="$record[catID]^";
		}
		else{
			if($record[catID]!=""){
				$array.="$record[catID]^";
			}
			$flag=1;
		}
	}
	return $array;
}


function anyreference($catID) {
	$cnt=getResult("product_tbl"," where allCategories like '%^".$catID."^%' and status!='D'");
	$cnt1=getResult("category_tbl"," where parentID='$catID'");
	if($cnt==0 && $cnt1==0) {
		return false;
	}else {
		return true;	
	}
}


function getallchild($catid) {
	$low_level	=	"";
	if($catid!='' or $catid==0) {
		$sql	=	"select catID from category_tbl where parentID ='$catid' ";
		$res	=	db_query($sql);
		$num	=	mysqli_num_rows($res);
		if($num>0) {
			$i=0;
		  while($row=mysqli_fetch_row($res)) {
			  $low_level	.=	$row[0].",".getallchild($row[0]);
			  $i++;
		  }
	  }
  }
  return $low_level;
}


function getMainCategory($cat_id) {
	$flag=0;
	$parentID=$cat_id;
	while($flag!=1) {
		$categoryRes=getResult("category_tbl"," where catID='".$parentID."' and status='Y'", "catID, parentID");
		if($categoryRes['parentID'] !=0 ) {
			$parentID=$categoryRes['parentID'];
			$mainCategory=$categoryRes['catID'];
		}
		else {
			if($categoryRes['catID'] !="" ) {
				$mainCategory=$categoryRes['catID'];
			}
			$flag=1;
		}
	}
	return $mainCategory;
}


function getParent($catid) {
	$res=getResult("category_tbl"," where catID='$catid'  and status='Y'");
	$flag=0;
	$catparent=$catid;
	while($flag!=1) {
		$res1=db_query("select * from category_tbl where catID='$catparent'  and status='Y'");
		$record=mysqli_fetch_array($res1);
		if($record['parentID']!=0) {
			$catparent=$record['parentID'];
			$array.=$record['catID']."~";
		}
		else {
			if($record['catID']!="") {
				$array.=$record['catID']."~";
			}
			$flag=1;
		}
	}
	$arr=explode("~",$array);
	$result = array_reverse($arr);
	return $result[1];
}
/*Home page meta */

function HomeMeta()
{
	$res_home=db_query("select * from static_pages where pageID='1' and pageTitle='Home' and status='Y'");
	$fetch_home=mysqli_fetch_assoc($res_home);

	return $fetch_home;
}

function getCategoryName($catID) {
	$res=getResult("category_tbl"," where catID='$catID'");
	return $res['catName'];
}

function getCategoryName1($catID) {
	$res=getResult("category_tbl"," where catID='$catID'");
	return $res['catgurl'];
}

function getProductName($id) {
	$res=getResult("product_tbl"," where productID='$id'");
	return $res['productName'];
}


function getCategoryDesc($catID) {
	$res=getResult("category_tbl"," where catID='$catID'");
	return $res['catDesc'];
}


function meta_details($page) {
	$tagCnt=getCount("meta_tags_tbl"," where pageName='$page'");
	if ($tagCnt > 0) {
		$res=getResult("meta_tags_tbl"," where pageName='$page'");
		@extract($res);
	}
	else {
		$tagCnt=getCount("meta_tags_tbl"," where pageName='default'");
		if ($tagCnt > 0) {
			$res=getResult("meta_tags_tbl"," where pageName='default'");
			@extract($res);
		}
		else {
			$pageTitle="Welcome to ".WEBSITE_NAME." ::";
			$pageKeywords="Welcome to ".WEBSITE_NAME." ::";
			$pageDescription="Welcome to ".WEBSITE_NAME." ::";
		}
	}	
	return array($pageTitle,$pageKeywords,$pageDescription);
}


function category_level($catid) {
	$res=db_fetch_array(db_query("select * from category_tbl where catID='$catid'"));
	$flag=0;
	$catparent=$catid;
	while($flag!=1) {
		$res1=db_query("select * from category_tbl where catID='$catparent'");
		$record=db_fetch_array($res1);
		if($record['parentID']!=0) {
			$catparent=$record['parentID'];
			$array.=$record['catID']."~";
		}else {
			if($record['catID']!="") {
				$array.=$record['catID']."~";
			}
			$flag=1;
		}
	}
	if (strlen($array)) {
		$arr=explode("~",$array);
		$result = count($arr);
	}
	else {
		$result = 0;
	}
	return $result;	
}


function show_date($date) {
	$split_time=explode(" ",$date);
	$cdate=explode("-",$split_time[0]);
	$month=$cdate[1];
	$day=$cdate[2];
	$year=$cdate[0];
	
	if($split_time[1]=="") {
		$hours=0;
		$minutes=1;
		$seconds=2;
	}
	else {
		$ctime=explode(":",$split_time[1]);
		$hours=$ctime[0];
		$minutes=$ctime[1];
		$seconds=$ctime[2];
	}
	#7 Jan, 2008 5:03 PM
	if($date!="") {
		return date('d F, Y ', mktime($hours, $minutes, $seconds, $month, $day, $year)); 
	}
	else {
		return "";
	}
}

function show_time($time) {
	
		$ctime=explode(":",$split_time[1]);
		$hours=$ctime[0];
		$minutes=$ctime[1];
		$seconds=$ctime[2];
	
	#7 Jan, 2008 5:03 PM
	if($date!="") {
		return date('d F, Y ', mktime($hours, $minutes, $seconds, $month, $day, $year)); 
	}
	else {
		return "";
	}
}


function page_nav($catid) {
	$res=getResult("category_tbl"," where catID='$catid'");
	$flag=0;
	$catparent=$catid;
	while($flag!=1) {
		$res1=db_query("select * from category_tbl where catID='$catparent'");
		$record=db_fetch_array($res1);
		if($record['parentID']!=0) {
			$catparent=$record['parentID'];
			$array.=$record['catID']."~";
		}
		else {
			if($record['catID']!="") {
				$array.=$record['catID']."~";
			}
			$flag=1;
		}
	}
	$arr=explode("~",$array);
	$result = array_reverse($arr);
	echo "<b><a href='manage_categories.php' class='menu2'>Manage Categories</a> ";
	for($i=1;$i<count($result);$i++) {
		$res=getResult("category_tbl"," where catID='$result[$i]'");
		$re=db_query("select * from category_tbl where catID='".$res['catID']."'");
		if(NumRows($re)==0) {
			if($res['catID']==$catid) {
				echo " <b>::</b> ".$res['catName'];
			}else {
				echo " <b>::</b> <a href='manage_categories.php?parentID=".$res['catID']."' class='menu2'>".$res['catName']."</a>";
			}
		}else {
			if($res['catID']==$catid) {
				echo " <b>::</b> ".$res['catName'];
			}else {
				echo " <b>::</b> <a href='manage_categories.php?parentID=".$res['catID']."' class='menu2'>".$res['catName']."</a>";
			}
		}
	}
	echo "</b>";
}

function page_nav1($catid) {
	$res=getResult("category_tbl"," where catID='$catid'");
	$flag=0;
	$catparent=$catid;
	while($flag!=1) {
		$res1=db_query("select * from category_tbl where catID='$catparent'");
		$record=db_fetch_array($res1);
		if($record['parentID']!=0) {
			$catparent=$record['parentID'];
			$array.=$record['catID']."~";
		}
		else {
			if($record['catID']!="") {
				$array.=$record['catID']."~";
			}
			$flag=1;
		}
	}
	$arr=explode("~",$array);
	$result = array_reverse($arr);
	echo "<b><a href='manage_pro_categories.php' class='menu2'>Manage Products Categories</a> ";
	for($i=1;$i<count($result);$i++) {
		$res=getResult("category_tbl"," where catID='$result[$i]'");
		$re=db_query("select * from category_tbl where catID='".$res['catID']."' and catgType='0'");
		if(NumRows($re)==0) {
			if($res['catID']==$catid) {
				echo " <b>::</b> ".$res['catName'];
			}else {
				echo " <b>::</b> <a href='manage_pro_categories.php?parentID=".$res['catID']."' class='menu2'>".$res['catName']."</a>";
			}
		}else {
			if($res['catID']==$catid) {
				echo " <b>::</b> ".$res['catName'];
			}else {
				echo " <b>::</b> <a href='manage_pro_categories.php?catID=".$res['catID']."' class='menu2'>".$res['catName']."</a>";
			}
		}
	}
	echo "</b>";
}

function page_nav2($catid) {
	$res=getResult("category_tbl"," where catID='$catid'");
	$flag=0;
	$catparent=$catid;
	while($flag!=1) {
		$res1=db_query("select * from category_tbl where catID='$catparent'");
		$record=db_fetch_array($res1);
		if($record['parentID']!=0) {
			$catparent=$record['parentID'];
			$array.=$record['catID']."~";
		}
		else {
			if($record['catID']!="") {
				$array.=$record['catID']."~";
			}
			$flag=1;
		}
	}
	$arr=explode("~",$array);
	$result = array_reverse($arr);
	echo "<b><a href='manage_ser_categories.php' class='menu2'>Manage services Categories</a> ";
	for($i=1;$i<count($result);$i++) {
		$res=getResult("category_tbl"," where catID='$result[$i]'");
		$re=db_query("select * from category_tbl where catID='".$res['catID']."' and catgType='1'");
		if(NumRows($re)==0) {
			if($res['catID']==$catid) {
				echo " <b>::</b> ".$res['catName'];
			}else {
				echo " <b>::</b> <a href='manage_ser_categories.php?parentID=".$res['catID']."' class='menu2'>".$res['catName']."</a>";
			}
		}else {
			if($res['catID']==$catid) {
				echo " <b>::</b> ".$res['catName'];
			}else {
				echo " <b>::</b> <a href='manage_ser_categories.php?catID=".$res['catID']."' class='menu2'>".$res['catName']."</a>";
			}
		}
	}
	echo "</b>";
}

function page_nav3($catid) {
	$res=getResult("category_tbl"," where catID='$catid'");
	$flag=0;
	$catparent=$catid;
	while($flag!=1) {
		$res1=db_query("select * from category_tbl where catID='$catparent'");
		$record=db_fetch_array($res1);
		if($record['parentID']!=0) {
			$catparent=$record['parentID'];
			$array.=$record['catID']."~";
		}
		else {
			if($record['catID']!="") {
				$array.=$record['catID']."~";
			}
			$flag=1;
		}
	}
	$arr=explode("~",$array);
	$result = array_reverse($arr);
	echo "<b><a href='manage_cou_categories.php' class='menu2'>Manage Courses Categories</a> ";
	for($i=1;$i<count($result);$i++) {
		$res=getResult("category_tbl"," where catID='$result[$i]'");
		$re=db_query("select * from category_tbl where catID='".$res['catID']."' and catgType='2'");
		if(NumRows($re)==0) {
			if($res['catID']==$catid) {
				echo " <b>::</b> ".$res['catName'];
			}else {
				echo " <b>::</b> <a href='manage_cou_categories.php?parentID=".$res['catID']."' class='menu2'>".$res['catName']."</a>";
			}
		}else {
			if($res['catID']==$catid) {
				echo " <b>::</b> ".$res['catName'];
			}else {
				echo " <b>::</b> <a href='manage_cou_categories.php?catID=".$res['catID']."' class='menu2'>".$res['catName']."</a>";
			}
		}
	}
	echo "</b>";
}

function breadCrumb($catid, $prdName="") {
	$baseurl=SITE_URL_PATH;
	$res=getResult("category_tbl"," where catID='$catid'");
	$flag=0;
	$catparent=$catid;
	while($flag!=1) {
		$res1=db_query("select * from category_tbl where catID='$catparent'");
		$record=mysqli_fetch_array($res1);
		if($record['parentID']!=0) {
			$catparent=$record['parentID'];
			$array.=$record['catID']."~";
		}else {
			if($record['catID']!="") {
				$array.=$record['catID']."~";
			}
			$flag=1;
		}
	}
	$result=explode("~",$array);
	//$result = array_reverse($arr);
	//for($i=1;$i<count($result);$i++) {
	if ($prdName !="") {
		echo ucwords($prdName).' <img src="'.SITE_URL_PATH.'/images/tree-arrow.jpg" alt="" class="vam" /> ';
	}
	
	for($i=0;$i<count($result)-1;$i++) {
		$res=getResult("category_tbl"," where catID='$result[$i]'");
		$re=db_query("select * from product_tbl where mainCategory='".$res['catID']."'");
		if(mysqli_num_rows($re)==0) {
			if($res['catID']==$catid) {
				if ($prdName !="") {
					echo '<a href="'.$baseurl.'/marketplace/'.$res['catID'].'p/'.getValidFileName($res['catName']).'.htm">'.ucfirst($res['catName']).'</a> <img src="'.SITE_URL_PATH.'/images/tree-arrow.jpg" alt="" class="vam" /> ';
				}
				else {
					echo ucfirst($res['catName']).' <img src="'.SITE_URL_PATH.'/images/tree-arrow.jpg" alt="" class="vam" /> ';
				}
			}
			else {
				echo '<a href="'.$baseurl.'/marketplace/'.$res['catID'].'p/'.getValidFileName($res['catName']).'.htm">'.ucfirst($res['catName']).'</a> <img src="'.SITE_URL_PATH.'/images/tree-arrow.jpg" alt="" class="vam" /> ';
			}
		}
		else {
			if($res['catID']==$catid) {
				if ($prdName !="") {
					echo '<a href="'.$baseurl.'/marketplace/'.$res['catID'].'p/'.getValidFileName($res['catName']).'.htm">'.ucfirst($res['catName']).'</a> <img src="'.SITE_URL_PATH.'/images/tree-arrow.jpg" alt="" class="vam" /> ';
				}
				else {
					echo ucfirst($res['catName']).' <img src="'.SITE_URL_PATH.'/images/tree-arrow.jpg" alt="" class="vam" /> ';
				}
			}
			else {
				echo '<a href="'.$baseurl.'/marketplace/'.$res['catID'].'p/'.getValidFileName($res['catName']).'.htm">'.ucfirst($res['catName']).'</a> <img src="'.SITE_URL_PATH.'/images/tree-arrow.jpg" alt="" class="vam" /> ';
			}
		}
	}
	echo "<a href='".$baseurl."/'>Home</a>";
}


function long_date_format($date) {
	$split_time=explode(" ",$date);
	$cdate=explode("-",$split_time[0]);
	$month=$cdate[1];
	$day=$cdate[2];
	$year=$cdate[0];

	$ctime=explode(":",$split_time[1]);
	$hours=$ctime[0];
	$minutes=$ctime[1];
	$seconds=$ctime[2];
	if($hours=="") {
		$hours="0";
		$minutes="0";
		$seconds="0";
	}
	#27 Feb, 2009
	if($date!="") {
		return date('d M, Y g:i A', mktime($hours, $minutes, $seconds, $month, $day, $year)); 
	}else {
		return "";
	}
}


function short_date_format($dt) {	
	$cdate=explode("-",$dt);
	$month=$cdate[1];
	$day=$cdate[2];
	$year=$cdate[0];
	return date('d M, Y', mktime(0,0,0, $month, $day, $year)); 		
}


function getShippingCharges() {
	$memID=getMember();	
}


function forgot_mail($email) {
	$baseurl=SITE_URL_PATH;
	$result=getResult("member_tbl"," where email='$email' and status='Y'");
	
	$ContactPerson=WEBSITE_NAME." Support Team";
	$admineMail=SITE_EMAIL;
	
	$subject="Your Password at ".WEBSITE_NAME;
	$msg="Dear ".$result['firstName']." ".$result['lastName'].",<br><br>Your password at ".WEBSITE_NAME." is given below.<br><br>Password:&nbsp;&nbsp;";
	$msg.=$result['pwd'];	
	$msg.="<br><br>Regards<br>Customer Support Team<br>".WEBSITE_NAME;	
	if($result['email']!="") {
		send_email($ContactPerson,$admineMail,$email,$subject,$msg);
	}
}


function showInvoicePrice($price,$symbol) {
	return $symbol." ".number_format($price,2);	
}


function invoice_mail($invoiceID) {
	$orderRes=getResult("order_tbl"," where orderID='$invoiceID'");	
	$memID=getMember();
	$result=getResult("member_tbl"," where memberID='$memID'");
	$adminRes=getResult("admin_details"," where 1");
	$var='
	<table width="100%"  border="0" cellspacing="0" cellpadding="5">
	 <tr class="">
	  <td width="81%"><span class="b">'.$adminRes['companyName'].'</span></td>
	  <td width="19%" rowspan="2" bgcolor="#FFFFFF"><img src="'.SITE_URL_PATH.'/images/ramsha-logo.gif" width="252" height="128" /></td>
	 </tr>
	 <tr><td valign="top">Address : '.$adminRes['address'].'</td></tr>
	 <tr><td colspan="2">&nbsp;</td></tr>
	 <tr>
	  <td colspan="2">
	    <table width="100%" cellspacing="0" cellpadding="3">
	     <tr>
	      <td align="left" valign="top"><strong>Billing Address </strong>
	      <br />'.$orderRes['billing'].'</td>
	      <td align="left" valign="top"><strong>Shipping Address </strong>
	      <br />'.$orderRes['shipping'].'</td>
	    </tr>
	   </table>
	  </td>
	 </tr>
	 <tr><td colspan="2">&nbsp;</td></tr>
	 <tr>
	  <td colspan="2" bgcolor="#F5F5F5" class=" ">
	   <table width="100%" cellspacing="0" cellpadding="3">
	    <tr class="bg_color00">
	     <td width="50%" align="left"><b>Invoice Date: </b>'.long_date_format($orderRes['recv_date']).'</td>
	     <td width="50%" align="left"><b>Invoice no: </b>'.$orderRes['orderID'].'</td>
	    </tr>
	   </table>
	  </td>
	 </tr>
	 <tr><td colspan="2">&nbsp;</td></tr>
	 <tr class="">
	  <td colspan="2">
	   <table width="100%" cellspacing="0" cellpadding="5" class="bdrAll">
	    <tr class="">
	     <td width="10%" align="left" bgcolor="#f5f5f5"><b>S. No.</b></td>
	     <td width="25%" align="left" bgcolor="#f5f5f5"><b>Product Name</b></td>
	     <td width="25%" align="left" bgcolor="#f5f5f5"><b>Product Size</b></td>
	     <td width="10%" align="left" bgcolor="#f5f5f5"><b>Quantity</b></td>
	     <td width="15%" align="left" bgcolor="#f5f5f5"><b>Rate</b></td>
	     <td width="15%" align="left" bgcolor="#f5f5f5"><b>Amount </b></td>
	    </tr>';
	    
	    $product_cart=explode("~",$orderRes['product_ids']);
	    $productqtys=explode("~",$orderRes['product_qtys']);
	    $productsizes=explode("~",$orderRes['product_sizes']);
	    $productprices=explode("~",$orderRes['product_prices']);
	    $product_names=explode("~",$orderRes['product_names']);
	    
	    $total=0;
	    $sub=0;	    
	    
	    for($i=1;$i<count($product_cart);$i++) {
		    $sub=$productprices[$i]*$productqtys[$i];
		    $var.='
		    <tr>
		     <td align="center">'.$i.'.</td>
		     <td align="left">'.$product_names[$i].'</td>
		     <td align="left">'.$productsizes[$i].'</td>
		     <td align="left">'.$productqtys[$i].'</td>
		     <td>'.CURRENCY_SYMBOL.$productprices[$i].'</td>
		     <td>'.CURRENCY_SYMBOL.$sub.'</td>
		    </tr>';
		    
		    $total=$total+$sub;
	    }
	    
	    $var.='
	   </table>
	   <table width="99%" cellspacing="0" cellpadding="3">
	    <tr><td height="8" align="right" ><img src="'.SITE_URL_PATH.'/images/spacer.gif" width="1" height="1" /></td></tr>
	    <tr><td align="right"><b>Subtotal : '.CURRENCY_SYMBOL.$total.'</b></td></tr>';
	    if ($orderRes['dealerDicount'] > 0) {
		    $dealerDicount=$orderRes['dealerDicount'];
		    $total=$total-$dealerDicount;
		    $var.='<tr><td align="right"><b>Dealer Discount : '.CURRENCY_SYMBOL.$dealerDicount.'</b></td></tr>';
	    }
	    $var.='
	    <tr><td align="right"><b>Shipping Charges : '.CURRENCY_SYMBOL.'0</b></td></tr>
	    <tr><td align="right" ><b>Total : '.CURRENCY_SYMBOL.$total.'</b></td></tr>	    
	   </table>
	  </td>
	 </tr>
	</table>';
	return $var;
}


function getPaymentStatus($status) {
	if ($status=="N") {
		$var="Not Paid";
	}
	if ($status=="Y") {
		$var="Paid";
	}
	if ($status=="") {
		$var="Not Paid";
	}	
	return $var;
}


function dispaly_date_time($date) {
	$split_time=explode(" ",$date);
	$cdate=explode("-",$split_time[0]);
	$month=$cdate[1];
	$day=$cdate[2];
	$year=$cdate[0];
	if($split_time[1]=="") {
		$hours=0;
		$minutes=0;
		$seconds=0;
	}
	else{
		$ctime=explode(":",$split_time[1]);
		$hours=$ctime[0];
		$minutes=$ctime[1];
		$seconds=$ctime[2];
	}
	#8 Jan, 2009
	if($date!="") {
		return date('d F, Y \<\b\r\> \[ H:s:i \]', mktime($hours, $minutes, $seconds, $month, $day, $year)); 
	}
	else{
		return "";
	}
}


function havesubcategory($catID) {
	$cnt=getCount("category_tbl"," where status='Y' and parentID='$catID'");
	if($cnt == 0) {
		return "N";
	}
	else {
		return "Y";
	}
}


function categoryList($catID="") {
	$low_level="";
	if($catid!='' or $catid==0) {
		$sql="select catID from category_tbl where parentID ='$catid' and status='Y' order by catName";
		$res=db_query($sql);
		$num=mysqli_num_rows($res);
		if($num>0) {
			$i=0;
			while($row=mysqli_fetch_row($res)) {
				$low_level	.=	$row[0].",".getallchild($row[0]);
				$i++;
			}
		}
	}
	$catarr=explode(",",$low_level);
	$var="";
	$var.="<select name='catID' ><option value=''>Select Department</option>";
	for($i=0;$i<count($catarr);$i++) {
		if(havesubcategory($catarr[$i])!='Y') {
			if($catID==$catarr[$i]) {
				$var.='<option value="'.$catarr[$i].'" selected>';
			}
			else {
				$var.='<option value="'.$catarr[$i].'">';
			}
			$var.=categorynav($catarr[$i]);
			$var.='</option>';
		}
	}
	$var.='</select>';
	return $var;
}


function categorynav($catid) {
	$res=getResult("category_tbl"," where catID='$catid' and status='Y' order by catName");
	$flag=0;
	$catparent=$catid;
	while($flag!=1) {
		$res1=db_query("select * from category_tbl where catID='$catparent' and status='Y' order by catName");
		$record=mysqli_fetch_array($res1);
		if($record['parentID']!=0) {
			$catparent=$record['parentID'];
			$array.=$record['catID']."~";
		}else {
			if($record['catID']!="") {
				$array.=$record['catID']."~";
			}
			$flag=1;
		}
	}
	$arr=explode("~",$array);
	$result = array_reverse($arr);
	$var="";
	for($i=1;$i<count($result);$i++) {
		$res=getResult("category_tbl"," where catID='$result[$i]'  and status='Y'");
		$var.=$res['catName']." -> ";		
	}
	$var=substr($var,0,-3);
	return $var;
}


function getExtension($str) {
	$i = strrpos($str,".");
	if (!$i) { return ""; }
	$l = strlen($str) - $i;
	$ext = substr($str,$i+1,$l);
	return $ext;
}


function upload_file($newname,$image,$folder) {
	$folder=SITE_DIR_PATH."/".$folder;
	if (!file_exists($folder)) {
		mkdir($folder, 0777);
		chmod($folder, 0777);
	}
	if($_FILES[$image]['name']!="") {
		$extension=getExtension($_FILES[$image]['name']);
		$image_name=$newname.".".$extension;		
		$uploadedfile=$_FILES[$image]['tmp_name'];
		$tmp_imagename=$_FILES[$image]['name'];
		if($tmp_imagename<>"" && $uploadedfile<>"" && $image_name<>"") {		
			move_uploaded_file($uploadedfile, $folder."/".$image_name);
		}
	}
	return $image_name;
}


function change_format($number) {//Number Formating
	return  number_format($number,2,'.','');
}


function payment_paypal($price,$orderId,$purpose) {
	?>
	<!--Redirecting to Paypal -->
	<form name="paypalfrm" method="post" action="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick">
	 <input type="hidden" name="business" value="big5hire@yahoo.co.uk">
	 <input type="hidden" name="amount" value="<?=change_format($price);?>" />
	 <input type="hidden" name="currency_code" value="<?=PRICE_CODE;?>">
	 <input type="hidden" name="item_name" value="<?=$orderId;?>">
	 <input type="hidden" name="usr_req" value="<?=$purpose;?>">
	 <input type="hidden" name="return" value="<?=SITE_URL_PATH;?>/index.htm" />
	 <input type="hidden" name="cancel_url" value="<?=SITE_URL_PATH;?>/index.htm">
	 <input type="hidden" name="status_url" value="<?=SITE_URL_PATH;?>/index.htm">
	</form>
	<script type="text/javascript" language="JavaScript">
	document.paypalfrm.submit();
	</script>
	<!--%%%%%%%%% -->
	<?php
}


function popFrontHeader($title1) {
	global $baseurl;
	?>
	<html>
	<head>
	<title><?=$title1;?></title>
	<link href="admin.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" type="text/css"  href="news.css">
	<style>
	.myTitle{font-family: "Trebuchet MS", Arial, sans-serif, helvetica, Verdana;font-size: 14px;font-weight: bold;color: #505050;text-decoration: none;}
	.myHead{font-family: Arial, Helvetica, sans-serif; font-size:16px; font-weight:bold; text-decoration:none; color:#003468;}
	td{font-size:11px;font-family:Verdana}
	</style>
	<script type="text/javascript" src="<?=$baseurl;?>/include_file/validation.js"></script>			
	</head>
	<body style="margin:0px,0px,0px,0px;background:#f2f2f2;">
	<center>
	<table cellpadding="2" cellspacing="0" border="0" width="100%" border="0">
	 <tr bgcolor="#43717E">
	  <td align="left" >&nbsp;<font style="color:#ffffff;font-weight:bold;"><?=$title1;?></font></td>
	  <td align=right colspan=2 width=13% valign=bottom nowrap><span class="myTitle"><font style="color:#ffffff;font-weight:bold;"></font><a href="javascript:window.close()"><img src="<?=SITE_URL_PATH;?>/images/logout.gif" align="absmiddle" border=0 title="Close Window"></a>&nbsp;</span></td>
	 </tr>
	</table>
	</center>
	<table width=100% cellpadding=0 cellspacing=0 border=0 style="background:#F2f2f2;">
	<tr><td style="border: 1px solid #dddddd;"  valign="top">
	<?php
}


function popFrontFooter() {
	global $baseurl;
	?>
	</td></tr></table>
	<center>
	<table width=100% cellpadding=2 cellspacing=0>
	 <tr bgcolor="#23717E">
	  <td align="left" ></td>
	  <td align=right colspan=2 width=13% valign=bottom nowrap><font style="color:#ffffff;font-weight:bold;">Close</font><a href="javascript:window.close()"><img src="<?=$baseurl;?>/images/logout.gif" align="absmiddle" border=0 title="Close Window"></a>&nbsp;</span></td>
	 </tr>
	</table>
	</center>
	</body></html>
	<?php
}


function pageNavigation($reccnt,$pagesize,$start,$link="") {
	if($reccnt>$pagesize) {
		$num_pages=$reccnt/$pagesize;
		$PHP_SELF=$_SERVER['PHP_SELF'];
		$qry_str=$_SERVER['argv'][0];
		$m=$_GET;
		unset($m['start']);
		$qry_str=qry_str($m);
		$j=$start/$pagesize-5;
		if($j<=0) {
			$j=0;
		}
		$k=$j+10;
		if($k>$num_pages)	{
			$k=$num_pages;
		}
		$j=intval($j);
		?>
		
		<div class="main_index" align="center" style="margin:auto; ">
		 <?php
		 if($start!=0) {
			 $s=$start-$pagesize;
			 $newUrl=$PHP_SELF."".$qry_str."&start=".$s."&pagesize=".$pagesize.$link;
			 $newUrl=str_replace("?&","?",$newUrl);
			 ?>
			 <a href="<?=$newUrl?>" ><img src="<?=SITE_ADMIN_URL?>/images/previous.gif" alt="Previous Page" width="69" height="17" border="0" class="left"/></a>
			 <?php
		 }
		 else {
			 ?>
			 <img src="<?=SITE_ADMIN_URL?>/images/previous.gif" alt="Previous Page" width="69" height="17" border="0" class="left" />
			 <?php
		 }
		 if($start+$pagesize < $reccnt) {
			 $s=$start+$pagesize;
			 $newUrl=$PHP_SELF."".$qry_str."&start=".$s."&pagesize=".$pagesize.$link;
			 $newUrl=str_replace("?&","?",$newUrl);
			 ?>
			 <a href="<?=$newUrl?>"><img src="<?=SITE_ADMIN_URL?>/images/next.gif" alt="Next Page" width="44" height="17" border="0"  class="right" /></a>
			 <?php
		 }
		 else {
			 ?>
			 <img src="<?=SITE_ADMIN_URL?>/images/next.gif" alt="Next Page" width="44" height="17" border="0"  class="right" />
			 <?php
		 }
		 $startfrom=$start+1;
		 $end=$start+$pagesize;
		 if($reccnt<$end) {
			 $end=$reccnt;
		 }
		 #echo "Showing	$startfrom - $end of Total $reccnt Records";
		 ?>
		 <div class="index">
		  <?php 
		  for($i=$j;$i<$k;$i++) {
			  if(($pagesize*$i)!=$start) {
				  $s=$pagesize*$i;
				  $newUrl=$PHP_SELF."".$qry_str."&start=".$s."&pagesize=".$pagesize.$link;
				  $newUrl=str_replace("?&","?",$newUrl);
				  ?>
				  <a href="<?=$newUrl?>"  class="navBarTxt"><?=$i+1?></a>
				  <?php
			  }
			  else {
				  ?>
				  <span class="navBarTxt"><?=$i+1?></span>
				  <?php
			  }
		  }
		  ?>
		 </div>
		</div>
		<?php
	}
}


function frontEndPagination($reccnt,$pagesize,$start,$link="") {
	if($reccnt>$pagesize) {
		$num_pages=$reccnt/$pagesize;
		$PHP_SELF=$_SERVER['PHP_SELF'];
		$qry_str=$_SERVER['argv'][0];
		$m=$_GET;
		unset($m['start']);
		$qry_str=qry_str($m);
		$j=$start/$pagesize-5;
		if($j<=0) {
			$j=0;
		}
		$k=$j+10;
		if($k>$num_pages)	{
			$k=$num_pages;
		}
		$j=intval($j);
		?>

		<table width="99%" border="0" align="left" cellpadding="0" cellspacing="0" class="paging_tab">
		 <tr>
		  <td width="57" align="left">
			<?php
			if($start!=0) {
				$s=$start-$pagesize;
				$newUrl=$PHP_SELF."".$qry_str."&start=".$s."".$link;
				$newUrl=str_replace("?&","?",$newUrl);
				?>
				<a href="<?=$newUrl?>" class="link1"><img src="<?=SITE_URL_PATH;?>/images/previous.gif" alt="Previous Page" width="69" height="17" border="0" class="left" /></a>
				<?php
			}
			?>
			</td>
			<td width="754" align="center">
			<?php
			$startfrom=$start+1;
			$end=$start+$pagesize;
			if($reccnt<$end) {
				$end=$reccnt;
			}
			#echo "Showing	$startfrom - $end of Total $reccnt Records";
			for($i=$j;$i<$k;$i++) {
				if(($pagesize*$i)!=$start) {
					$s=$pagesize*$i;
					$newUrl=$PHP_SELF."".$qry_str."&start=".$s."".$link;
					$newUrl=str_replace("?&","?",$newUrl);
					?>
					<a class="navBarTxt" href="<?=$newUrl?>"><?=$i+1;?></a>
					<?php
				
				}
				else {
					?>
					<span class="navBarTxt1"><?=$i+1;?></span>
					<?php
				}
			}
			?>
			</td>
			<td width="30" align="right">
			<?php
			if($start+$pagesize < $reccnt) {
				$s=$start+$pagesize;
				$newUrl=$PHP_SELF."".$qry_str."&start=".$s."".$link;
				$newUrl=str_replace("?&","?",$newUrl);
				?>
				<a href="<?=$newUrl?>" class="link1"><img src="<?=SITE_URL_PATH;?>/images/next.gif" alt="Next Page" width="44" height="17" border="0"  class="right" /></a>
				<?php
			}
			?>
			</td>			
		 </tr>
		</table>
		<?php
	}
}
#Paging HTML
function frontEndPagination1($reccnt,$pagesize,$start,$url) {
	
if($reccnt>$pagesize) {
		$num_pages=$reccnt/$pagesize;
		$PHP_SELF=$_SERVER['PHP_SELF'];
		
		$qry_str=$_SERVER['argv'][0];
		$m=$_GET;
		unset($m['start']);
		$qry_str=qry_str($m);
		$j=$start/$pagesize-5;
		if($j<=0) {
			$j=0;
		}
		$k=$j+10;
		if($k>$num_pages)	{
			$k=$num_pages;
		}
		$j=intval($j);
		
		
		
		?>

		<table width="99%" border="0" align="left" cellpadding="0" cellspacing="0" class="paging_tab">
		 <tr>
		  <td width="57" align="left">
			<?php
			if($start!=0) {
				$s=$start-$pagesize;
				$pagecount=$start/$pagesize;
				$pagecount='_'.$pagecount;
				if($pagecount=='_1'){
					$pagecount=str_replace("_1","",$pagecount);
					   }
					$url=$url.$pagecount;
				 $pagingurl=$url.".htm";
				$newUrl1=$pagingurl."".$qry_str."&start=".$s;
				$newUrl1=str_replace("?&","?",$newUrl1);
				
				?>
				<a href="<?=$newUrl1?>" class="link1"><img src="<?=SITE_URL_PATH;?>/images/previous.gif" alt="Previous Page" width="69" height="17" border="0" class="left" /></a>
				<?php
			}
			?>
			</td>
			<td width="754" align="center">
			<?php
			$startfrom=$start+1;
			$end=$start+$pagesize;
			if($reccnt<$end) {
				$end=$reccnt;
			}
			#echo "Showing	$startfrom - $end of Total $reccnt Records";
			
			for($i=$j;$i<$k;$i++) {
				if(($pagesize*$i)!=$start) {
					$s=$pagesize*$i;
					$pagecount=$i+1;
					$url = rtrim($url, '0123456789_'); 
					$pagecount='_'.$pagecount;
					if($pagecount=='_1'){
					$pagecount=str_replace("_1","",$pagecount);
					   }
					$url=$url.$pagecount;
					$pagingurl=$url.".htm";
					$newUrl1=$pagingurl."".$qry_str."&start=".$s;
					$newUrl1=str_replace("?&","?",$newUrl1);
					?>
					<a class="navBarTxt" href="<?=$newUrl1;?>"><?=$i+1;?></a>
					
					<?php
					
					
				}
				else {
					?>
					<span class="navBarTxt1"><?=$i+1;?></span>
					<?php
					
				}
			}
			?>
			</td>
			<td width="30" align="right">
			<?php
			if($start+$pagesize < $reccnt) {
				$s=$start+$pagesize;
				$pagecount=$s/$pagesize;
				$pagecount=$pagecount+1;
				$url = rtrim($url,'0123456789_'); 
				$pagecount='_'.$pagecount;
				if($pagecount=='_1'){
					$pagecount=str_replace("_1","",$pagecount);
					   }
				$url=$url.$pagecount;
				
				$pagingurl=$url.".htm";
				$newUrl1=$pagingurl."".$qry_str."&start=".$s;
				$newUrl1=str_replace("?&","?",$newUrl1);
				?>
				<a href="<?=$newUrl1?>" class="link1"><img src="<?=SITE_URL_PATH;?>/images/next.gif" alt="Next Page" width="44" height="17" border="0"  class="right" /></a>
				
				<?php
			}
			?>
			</td>			
		 </tr>
		</table>
		<?php
	}
}
#end Paging HTML




function frontEndHtmlPagination($reccnt,$pagesize,$start,$link="") {
	if($reccnt>$pagesize) {
		$num_pages=$reccnt/$pagesize;
		$PHP_SELF=$_SERVER['PHP_SELF'];
		$qry_str=$_SERVER['argv'][0];
		$m=$_GET;
		unset($m['start']);
		$qry_str=qry_str($m);
		$j=$start/$pagesize-5;
		if($j<=0) {
			$j=0;
		}
		$k=$j+10;
		if($k>$num_pages) {
			$k=$num_pages;
		}
		$j=intval($j);
		?>
		
		<table width="100%" align="center" cellpadding="0"  cellspacing="0">
		 <tr>
		  <td width="35%" align="left" class="bg-strip-color">
		   <?php
		   if($start!=0) {
			   $s=$start-$pagesize;
			   $newUrl=$PHP_SELF."".$qry_str."&start=".$s."".$link;
			   $newUrl=str_replace("?&","?",$newUrl);
			   ?>
			   <a href="<?=$newUrl?>&act=htm" class="link1"> Previous </a>
			   <?php
		   }
		   ?>
		  </td>
		  <td width="22%" class="bg-strip-color">
		   <div class="container">
		    <?php
		    $startfrom=$start+1;
		    $end=$start+$pagesize;
		    if($reccnt<$end) {
			    $end=$reccnt;
		    }
		    #echo "Showing	$startfrom - $end of Total $reccnt Records";
		    for($i=$j;$i<$k;$i++) {
			    if(($pagesize*$i)!=$start) {
				    $s=$pagesize*$i;
				    $newUrl=$PHP_SELF."".$qry_str."&start=".$s."".$link;
				    $newUrl=str_replace("?&","?",$newUrl);
				    ?>
				    <a href="<?=$newUrl?>&act=htm"><?=$i+1?></a>
				    <?php
			    }
			    else {
				    ?>
				    <a href="#" class="visit"><?=$i+1?></a>
				    <?php
			    }
		    }
		    ?>
		   </div>
		  </td>
		  <td width="29%" align="right" class="bg-strip-color">
		   <?php
		   if($start+$pagesize < $reccnt) {
			   $s=$start+$pagesize;
			   $newUrl=$PHP_SELF."".$qry_str."&start=".$s."".$link;
			   $newUrl=str_replace("?&","?",$newUrl);
			   ?>
			   <a href="<?=$newUrl?>&act=htm" class="link1"> Next </a>
			   <?php
		   }
		   ?>
		  </td>
		  <?php
		  if($_SERVER[PHP_SELF]=="/products.php" || $_SERVER[PHP_SELF]=="/qps/products.php") {
			  ?>
			  <td width="14%" align="right" class="bg-strip-color"><a href="products.php?catID=<?=$_REQUEST[catID]?>&pagesize=1000&sizeID=<?=$_REQUEST[sizeID]?>&colorID=<?=$_REQUEST[colorID]?>&priceRange=<?=$_REQUEST[priceRange]?>" class="link1"><strong>View all</strong></a></td>
			  <?php
		  }
		  ?>
		 </tr>
		</table>
		<?php
	}
}


function setImageToSize($dirNm, $imageName, $w1, $h1, $class, $alt,$vspace="",$align="") {
	$basedir=SITE_DIR_PATH;
	$baseurl=SITE_URL_PATH;
	if($class!="") {
		$cls=' class="'.$class.'" ';
	}
	if($align!="") {
		$ali=' align="'.$align.'" ';
	}
	if (strlen($imageName) and $size = @GetImageSize("$basedir/$dirNm/$imageName")) {
		$var='<img src="'.$baseurl.'/thumb.php?width_x='.$w1.'&amp;height_y='.$h1.'&amp;src='.$dirNm.'/'.$imageName.'&amp;f=0" border="0" alt="'.$alt.'" title="'.$alt.'" vspace="'.$vspace.'" '.$cls.' '.$ali.' />';		
	}
	else {
		$imageName="no_photo.jpg";
		$var='<img src="'.SITE_URL_PATH.'/images/'.$imageName.'" border="0" alt="'.$alt.'" title="'.$alt.'" vspace="'.$vspace.'" '.$cls.' '.$ali.' />';		
	}
	return $var;
}


function displayImage($dirNm, $imageName, $w1, $h1, $class, $alt, $stl="", $vspace="", $align="") {
	if($class!="") {
		$cls=' class="'.$class.'" ';
	}
	if($align!="") {
		$ali=' align="'.$align.'" ';
	}
	if($stl!="") {
		$stl=' style="'.$stl.'" ';
	}
	if($align!="") {
		$ali=' align="'.$align.'" ';
	}
	if (strlen($imageName) and $size = @GetImageSize(SITE_DIR_PATH."/".$dirNm."/".$imageName)) {
		$var='<img src="'.SITE_URL_PATH.'/'.$dirNm.'/'.$imageName.'" width="'.$w1.'" height="'.$h1.'" border="0" alt="'.$alt.'" title="'.$alt.'" vspace="'.$vspace.'" '.$cls.' '.$stl.' '.$ali.' />';
	}
	else {
		$imageName="no_photo.jpg";
		$var='<img src="'.SITE_URL_PATH.'/images/'.$imageName.'" width="'.$w1.'" height="'.$h1.'" border="0" alt="'.$alt.'" title="'.$alt.'" vspace="'.$vspace.'" '.$cls.' '.$stl.' '.$ali.' />';
	}
	return $var;
}


function checkHTTPREFERER() {
	$baseurl=SITE_URL_PATH;
	$referer=$_SERVER['HTTP_REFERER'];	
	$srch=$_SERVER['HTTP_HOST'];
		
	if(!strstr($referer,$srch)) {
		?>
		<html>
		<head><title>Error</title>
		<script language="javascript">
		function open_Window() {
			win = window.open("<?=$baseurl;?>/error.php?id=error","","width=480,height=40,top=0,left=0");
		}
		</script>
		</head>
		<body bgcolor="#ffffff" text="#000000" link="#0066FF" vlink="#666EB3" alink="#003399" onLoad="open_Window()">
		</body>
		</html>
		<?php
		exit;
	}
}


function print_message() {
	echo "<center><font style=\"color:#ee0000;\"><b>".$_SESSION['session_message']."</b></font></center><br />";
	$_SESSION['session_message']="";
}


function country($fieldname,$cname="",$width="") {
	if($width=="") {
		$width="220px";
	}
	$var='<select class="textbox" name="'.$fieldname.'" style="width: '.$width.'; padding:4px; color:#555;  font-size:14px; " id="NOBLANK~Please Select Country~DM~"><option value="" selected>----- Please Choose A Country -----</option>';
	$sql=db_query("select cont_name,cont_code from country order by cont_name");
	while($res=mysqli_fetch_array($sql)) {
		$res=ms_htmlentities_decode($res);
		if(trim($res['cont_name'])==trim($cname)) {
			$var.= "<option value='".$res['cont_name']."' selected>".$res['cont_name']."</option>";
		}
		else {
			$var.="<option value='".$res['cont_name']."'>".$res['cont_name']."</option>";
		}
	}
	$var.='</select>';
	return $var; 
}


function countryTopSearch($fieldname, $cname="") {
	
	$var='<select style="background:#eeeded; border:none; width:180px; padding:2px; margin-left:8px;" name="'.$fieldname.'" ><option value="" selected>- Please Choose A Country -</option>';
	$sql=db_query("select cont_name,cont_code from country order by cont_name");
	while($res=mysqli_fetch_array($sql)) {
		$res=ms_htmlentities_decode($res);
		if(trim($res['cont_name'])==trim($cname)) {
			$var.= "<option value='".$res['cont_name']."' selected>".$res['cont_name']."</option>";
		}
		else {
			$var.="<option value='".$res['cont_name']."'>".$res['cont_name']."</option>";
		}
	}
	$var.='</select>';
	return $var; 
}


function dynamic_check_form_values($elements_arr, $validation_arr) {
	$alert_message="";
	$retuned_val="";
	foreach($elements_arr as $key => $val) {
		$expld_name=explode("-",$key);
		$req_prob_st=trim("$expld_name[0]");
		$req_prob_id=trim("$expld_name[1]");
		$alert=trim("$expld_name[2]");
		$val=trim("$val");
		$html_head='<table><tr><td valign="top"><div><div style="color: #ff0000; font: normal 18px Arial, Helvetica, sans-serif; padding: 10px 15px 0px 5px;">ERROR!</div><div style="font:bold 12px arial; padding-left:50px; color:#bf0000;"><ul style="margin:4px; padding:2px;">';
		$html_foot='</ul></div></td></tr></table><br /><br />';

		if(!strlen($val)>0 and ($req_prob_st=="r" or $req_prob_st=="rp")) {
			$alert_message .= "<li>$alert</li>";
		}
		if(strlen($val)>0 and ($req_prob_st=="p" or $req_prob_st=="rp")) {
   			$exploded_exp=explode("^~~^", $validation_arr[$req_prob_id]);
   			$allowed_exp="$exploded_exp[0]";
			if (!preg_match("/$allowed_exp/", $val)) {   
				$alert_message .="<li>$alert, $exploded_exp[1]</li>";
			}
		}
	}
	if(strlen($alert_message)>0) {
		$msg=$alert_message;
		return $msg;
	}
	else {
		return "";
	}
}


function show_message() {
	if($_SESSION['message']!="") {
		echo "<center><font style=\"color:#ee0000;\"><b>".$_SESSION['message']."</b></font></center>";
		$_SESSION['message']="";
	}
	else {
		echo "";
	}
}


function get_time_difference( $start, $end ) {
	$uts['start']=strtotime( $start );
	$uts['end']=strtotime( $end );
	if( $uts['start']!==-1 && $uts['end']!==-1 ) {
		if( $uts['end'] >= $uts['start'] ) {
			$diff=$uts['end'] - $uts['start'];
			if( $days=intval((floor($diff/86400))) ) {
				$diff = $diff % 86400;
			}
			if( $hours=intval((floor($diff/3600))) ) {
				$diff = $diff % 3600;
			}
			if( $minutes=intval((floor($diff/60))) ) {
				$diff = $diff % 60;
			}
			$diff=intval( $diff );
			if($days!=0) {
				$hours=$hours+(24*$days);
			}
			return( array('days'=>$days, 'hours'=>$hours, 'minutes'=>$minutes, 'seconds'=>$diff) );
		}
	}
}


function Google_Currency($amount, $from, $to) {
	$matches = array();
	if (preg_match('~<b>.+? = (.+?)</b></h2>~', file_get_contents('http://www.google.com/search?q=' . urlencode(floatval($amount) . ' ' . strtoupper($from) . ' to ' . strtoupper($to))), $matches) > 0) {
		if (array_key_exists(1, $matches) === true) {
			return floatval($matches[1]);
		}
	}
	return false;
}


function xlsBOF() {
	echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
	return;
}


function xlsEOF() {
	echo pack("ss", 0x0a, 0x00);
	return;
}


function xlsWriteNumber($Row, $Col, $Value) {
	echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
	echo pack("d", $Value);
	return;
}


function xlsWriteLabel($Row, $Col, $Value ) {
	$L = strlen($Value);
	echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
	echo $Value;
	return;
}


function mail_attachment ($from ,$from_email, $to, $subject, $message, $attachment){
	$fileatt = $attachment; // Path to the file                  
	$fileatt_type = "application/octet-stream"; // File Type 
    $start=	strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
	$fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the 	attachment 

	$email_from = $from_email; // Who the email is from 
	$email_subject =  $subject; // The Subject of the email 
	$email_txt = $message; // Message that the email has in it 
	
	$email_to = $to; // Who the email is to

	$headers = "From: $from<$email_from>";;

	$file = fopen($fileatt,'rb'); 
	$data = fread($file,filesize($fileatt)); 
	fclose($file); 
	$msg_txt="\n\nMail created using free code from 4word systems : http://4wordsystems.com";

	$semi_rand = md5(time()); 
	$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
    
	$headers .= "\nMIME-Version: 1.0\n" . 
            "Content-Type: multipart/mixed;\n" . 
            " boundary=\"{$mime_boundary}\""; 

	#$email_txt .= $msg_txt;
	
	$email_message .= "This is a multi-part message in MIME format.\n\n" . 
                "--{$mime_boundary}\n" . 
                "Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
               "Content-Transfer-Encoding: 7bit\n\n" . 
	$email_txt . "\n\n"; 

	$data = chunk_split(base64_encode($data)); 

	$email_message .= "--{$mime_boundary}\n" . 
                  "Content-Type: {$fileatt_type};\n" . 
                  " name=\"{$fileatt_name}\"\n" . 
                  //"Content-Disposition: attachment;\n" . 
                  //" filename=\"{$fileatt_name}\"\n" . 
                  "Content-Transfer-Encoding: base64\n\n" . 
                 $data . "\n\n" . 
                  "--{$mime_boundary}--\n"; 


	$ok = mail($email_to, $email_subject, $email_message, $headers); 

	if($ok) { 
	} else { 
		die("Sorry but the email could not be sent. Please go back and try again!"); 
	} 
}

function getImage($file_name, $width, $height, $product_name,$source_folder1){
   
$product_name = str_replace(' ','-', $product_name);
$file_parts = explode('.',$file_name);
$file_name_to_store = $product_name.'-thumbs-'.$width.'X'.$height.'.'.$file_parts[1];
$source_folder=SITE_DIR_PATH.$source_folder1;
$destination_folder=$source_folder."thumbs";
    $file=SITE_DIR_PATH.$source_folder1."thumbs/".$file_name_to_store;
	
	if(file_exists($file)) {
		unlink($file);
	}
saveResizedImage($file_name, $width, $height, $source_folder, $destination_folder, $file_name_to_store);
return SITE_URL_PATH.$source_folder1."thumbs/".$file_name_to_store;

}

function saveResizedImage($file_name, $width, $height, $source_folder, $destination_folder,$file_name_to_store='') {
    if($file_name_to_store == ''){$file_name_to_store = $file_name;}
	
	if (!file_exists($destination_folder)) {
		mkdir($destination_folder, 0777);
		chmod($destination_folder, 0777);
	}
	
	$source_path=$source_folder."/".$file_name;
    $destination_path=$destination_folder."/".$file_name_to_store;
	$ext=explode(".",$file_name);
	
	if($ext[1]=="gif" or $ext[1]=="GIF") {
		$mainimage=imagecreatefromgif($source_path);
	}
	elseif($ext[1]=="png" or $ext[1]=="PNG") {
		$mainimage=imagecreatefrompng($source_path);
	}
	elseif($ext[1]=="jpg" or $ext[1]=="JPG") {
		$mainimage=imagecreatefromjpeg($source_path);
	}
    elseif($ext[1]=="jpeg" or $ext[1]=="JPEG") {
		$mainimage=imagecreatefromjpeg($source_path);
	}
	$mainwidth=imagesx($mainimage);
	$mainheight=imagesy($mainimage);
	
	if($mainwidth<=$width and $mainheight<=$height) {
		$thumbleheight=$mainheight;
		$thumblewidth=$mainwidth;	
	}
	else {
		if($mainwidth>$width) {
			$thumblewidth=$width;
			$thumbleheight=(($width/$mainwidth)*$mainheight);	
			if ($thumbleheight > $height) {
				$thumbleheight=$height;
				$thumblewidth=(($height/$mainheight)*$mainwidth);	
			}
		}
		else if($mainheight>$height) {
			$thumbleheight=$height;
			$thumblewidth=(($height/$mainheight)*$mainwidth);	
			if ($thumblewidth > $width) {
				$thumblewidth=$width;
				$thumbleheight=(($width/$mainwidth)*$mainheight);	
			}
		}
	}
	
	$thumbleimage=imagecreate($thumblewidth,$thumbleheight);
	$thumbleimage=@imagecreatetruecolor($thumblewidth,$thumbleheight);
	$my_temp_file= ImageCopyResampled($thumbleimage,$mainimage,0,0,0,0,$thumblewidth,$thumbleheight,$mainwidth,$mainheight);
	imagejpeg($thumbleimage,$destination_path,70);
	imagedestroy($thumbleimage);
	imagedestroy($mainimage);
}


function upload_video($image,$folder) {
	if($_FILES[$image]['name']!=""){ 
		$extension=getExtension($_FILES[$image]['name']);
		$extension=strtolower($extension);
		$newname="video_".date('Y_m_d_H_i_s');
		$uploadedfile=$_FILES[$image]['tmp_name'];
		$tmp_imagename=$_FILES[$image]['name'];

		if($extension=="mov" || $extension=="mpg" || $extension=="mpeg" || $extension=="wmv" || $extension=="aac" || $extension=="mp4" || $extension=="mp3" || $extension=="dat"){
			
			$image_name=$newname.".flv";	
			$uploadpath=SITE_DIR_PATH."/".$folder."/".$image_name;
			`/usr/local/bin/ffmpeg -i $uploadedfile -ar 22050 -s 400x200 $uploadpath`;			
		}
	}

	return $image_name;
}


function getFileName($str){//Determines Ext Of the file
	$i = strrpos($str,".");
	if (!$i) { return $str; }
	$name = substr($str,0,$i);
	return $name;
}


function getListingCategoriesDropDownAjax($fldName, $value, $width="") {
	if ($width=="") {
		$width="220";
	}
	$link="'".$_SERVER['PHP_SELF']."'";
	$var='<select name="'.$fldName.'" style="width: '.$width.'px; " onChange="javascript:dynshowHint(this.value,'.$link.',\'?id=show_sub_categories\',\'showSubCategories\');">
	<option value="" selected="selected" >----------- Select Listing Categories -----------</option>';
	$catQry=db_query("select catID, catName from  category_tbl where parentID='0' order by catOrder asc");
	while($catRes=mysqli_fetch_array($catQry)) {
		
		if(trim($catRes[catID])==trim($value)) {
			$var.= "<option value='".$catRes[catID]."' selected='selected'>".$catRes[catName]."</option>";
		}
		else {
			$var.="<option value='".$catRes[catID]."'>".$catRes[catName]."</option>";
		}
	}
	$var.='</select>';
	return $var; 
}

function getListingCategoriesDropDownAjax1($fldName, $value, $width="") {
	if ($width=="") {
		$width="220";
	}
	$link="'".$_SERVER['PHP_SELF']."'";
	$var='<select name="'.$fldName.'" style="width: '.$width.'px; " onChange="javascript:dynshowHint(this.value,'.$link.',\'?id=show_sub_categories\',\'showSubCategories\');">
	<option value="" selected="selected" >----------- Select Listing Categories -----------</option>';
	$catQry=db_query("select catID, catName from  category_tbl where parentID='0' and catgType='0' order by catOrder asc");
	while($catRes=mysqli_fetch_array($catQry)) {
		
		if(trim($catRes[catID])==trim($value)) {
			$var.= "<option value='".$catRes[catID]."' selected='selected'>".$catRes[catName]."</option>";
		}
		else {
			$var.="<option value='".$catRes[catID]."'>".$catRes[catName]."</option>";
		}
	}
	$var.='</select>';
	return $var; 
}
function getListingCategoriesDropDownAjax2($fldName, $value, $width="") {
	if ($width=="") {
		$width="220";
	}
	$link="'".$_SERVER['PHP_SELF']."'";
	$var='<select name="'.$fldName.'" style="width: '.$width.'px; " onChange="javascript:dynshowHint(this.value,'.$link.',\'?id=show_sub_categories\',\'showSubCategories\');">
	<option value="" selected="selected" >----------- Select Listing Categories -----------</option>';
	$catQry=db_query("select catID, catName from  category_tbl where parentID='0' and catgType='1' order by catOrder asc");
	while($catRes=mysqli_fetch_array($catQry)) {
		
		if(trim($catRes[catID])==trim($value)) {
			$var.= "<option value='".$catRes[catID]."' selected='selected'>".$catRes[catName]."</option>";
		}
		else {
			$var.="<option value='".$catRes[catID]."'>".$catRes[catName]."</option>";
		}
	}
	$var.='</select>';
	return $var; 
}

function getListingCategoriesDropDownAjax3($fldName, $value, $width="") {
	if ($width=="") {
		$width="220";
	}
	$link="'".$_SERVER['PHP_SELF']."'";
	$var='<select name="'.$fldName.'" style="width: '.$width.'px; " onChange="javascript:dynshowHint(this.value,'.$link.',\'?id=show_sub_categories\',\'showSubCategories\');">
	<option value="" selected="selected" >----------- Select Listing Categories -----------</option>';
	$catQry=db_query("select catID, catName from  category_tbl where parentID='0' and catgType='2' order by catOrder asc");
	while($catRes=mysqli_fetch_array($catQry)) {
		
		if(trim($catRes[catID])==trim($value)) {
			$var.= "<option value='".$catRes[catID]."' selected='selected'>".$catRes[catName]."</option>";
		}
		else {
			$var.="<option value='".$catRes[catID]."'>".$catRes[catName]."</option>";
		}
	}
	$var.='</select>';
	return $var; 
}


function getListingSubCategoriesDropDown($fldName, $catID, $sel, $width="") {
	if ($width=="") {
		$width="220";
	}
	
	$var="<div style='width:".$width."px; height:115px; overflow-x:hidden; overflow-y:scroll; border:1px solid gray'>";
	
	$low_level = "";
	if($catID!='') {
		$qry=db_query("select catID from category_tbl where parentID='$catID' and status='Y' order by catName");
		$num=NumRows($qry);
		if($num>0) {
			$i=0;
			while($row=mysqli_fetch_array($qry)) {
				$low_level.=	$row[0].",".getAllChilds($row[0]);
				$i++;
			}
		}
	}
	
	$catarr=explode(",",$low_level);
	if (count($catarr) > 1) {
		for($i=0;$i<count($catarr);$i++) {
			$catid2=$catarr[$i];
			$res2=getResult("category_tbl"," where catID='$catid2'");
			$space=parentCount($catid2);
			if(haveSubCategory($catid2)=='Y' && $i < count($catarr)-1) {
				if ($space!=0) {
					for ($p=1;$p<$space;$p++) {
						$var.='&nbsp;&nbsp;';
					}
				}
				$var.="<strong>".ucwords($res2[catName])."</strong><br/>";
			}
			
			if(haveSubCategory($catid2)=='N') {
				if ($space!=0) {
					for ($p=2;$p<=$space;$p++) {
						$var.='&nbsp;&nbsp;';					
					}
				}
				if (is_array($sel)) {
					if (in_array($catid2,$sel)) {
						$var.= "<input type='checkbox' name='".$fldName."[]' id='".$fldName."' value='".$catid2."' checked>".getCategoryName($catid2)."<br/>";
					}
					else {
						$var.= "<input type='checkbox' name='".$fldName."[]' id='".$fldName."' value='".$catid2."'>".getCategoryName($catid2)."<br/>";
					}
				}
				else {
					$catg="^".$catid2."^";
					if(strstr($sel,$catg)) {
						$var.= "<input type='checkbox' name='".$fldName."[]' id='".$fldName."' value='".$catid2."' checked>".getCategoryName($catid2)."<br/>";
					}
					else {
						$var.= "<input type='checkbox' name='".$fldName."[]' id='".$fldName."' value='".$catid2."'>".getCategoryName($catid2)."<br/>";
					}
				}								
			}
		}			
	}
	else {
		$res3=getResult("category_tbl"," where catID='$catID'");
		$var.= "<input type='checkbox' name='".$fldName."' id='".$fldName."' value='".$catid."' checked>".ucwords($res3[catName])."<br/>";
	}
	
	$var.='</div>';
	return $var; 
}


function parentCount($catID){
	$cnt1=0;
	$parent=1;
	
	while ($parent!=0) {
		$cnt=getCount("category_tbl"," where status='Y' and catID='$catID' and parentID!=0");
		if($cnt == 0){
			$parent=0;		
		}
		else{
			$cnt1++;
			$res=getResult("category_tbl"," where status='Y' and catID='$catID' and parentID!=0");
			$catID=$res[parentID];
		}		
	}	
	return $cnt1;
}


function getAllChilds($catid) {
	$low_level	=	"";
	if($catid!='' or $catid==0) {
		$qry=db_query("select catID from category_tbl where parentID ='$catid' ");
		$num=NumRows($qry);
		if($num>0) {
			$i=0;
		  while($row=mysqli_fetch_array($qry)) {
			  $low_level	.=	$row[0].",".getAllChilds($row[0]);
			  $i++;
		  }
	  }
  }
  return $low_level;
}


function view_member_details($slno){
	$res=getResult("member_tbl"," where memberID='$slno'");
	@extract($res);
	
	$var='';
	$var.='<table width="100%"  border="0" cellpadding="2" cellspacing="2" class="lightBorder">
	 <tr valign="top">
	  <td width="38%" align="right" valign="top" class="borderdotted form-txt">Member Name &rarr; </td>
	  <td align="left" valign="top" class=" borderdotted">'.$nameTitle.' '.ucwords($memberName).'</td>
	 </tr>
	 <tr valign="top">
	  <td width="35%" align="right" valign="top" class="borderdotted form-txt">E-Mail Address &rarr; </td>
	  <td align="left" valign="top" class=" borderdotted">'.$email.'</td>
	 </tr>
	 <tr valign="top">
	  <td width="35%" align="right" valign="top" class="borderdotted form-txt">Password &rarr; </td>
	  <td align="left" valign="top" class=" borderdotted">'.$pwd.'</td>
	 </tr>';
	 if($phone!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Telephone Number &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$countryCodePhone.'-'.$areaCodePhone.'-'.$phone.'</td>
		 </tr>';
	 }
	 if($mobile!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Mobile Number  &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$mobile.'</td>
		 </tr>';
	 }
	 if($fax!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Fax Number &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$countryCodeFax.'-'.$areaCodeFax.'-'.$fax.'</td>
		 </tr>';
	 }	 
	 if($address!=""){
		 $var.='<tr valign="top">
		  <td width="35%" align="right" valign="top" class="borderdotted form-txt">Street Address &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.ucwords($address).'</td>
		 </tr>';
	 }
	 if($city!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> City &rarr; </td>
			<td align="left" valign="top" class=" borderdotted">'.ucwords($city).'</td>
		 </tr>';
	 }
	 if($state!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> State &rarr; </td>
			<td align="left" valign="top" class=" borderdotted">'.ucwords($state).'</td>
		 </tr>';
	 }
	 if($zipcode!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Zipcode &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$zipcode.'</td>
		 </tr>';
	 }
	 if($country!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt">Country &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$country.'</td>
		 </tr>';
	 }
	 $var.='<tr><td colspan="2"><hr size="1" width="90%" align="center"></td></tr>';
	 
	 if($accountType!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Your Position &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$accountType.'</td>
		 </tr>';
	 }
	 if($membershipType!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Membership Type &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.getMembershipPlanName($membershipType).'</td>
		 </tr>';
	 }
	 $var.='<tr><td colspan="2"><hr size="1" width="90%" align="center"></td></tr>';
	 
	 if($companyName!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Company Name &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$companyName.'</td>
		 </tr>';
	 }
	 if($jobTitle!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Job Title &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.ucwords($jobTitle).'</td>
		 </tr>';
	 }	 
	 
	 if($annualTurnover!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Annual Turnover &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.getAnnualTurnover($annualTurnover).'</td>
		 </tr>';
	 }
	 if($businessType!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Business Type &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.getBusinessType($businessType).'</td>
		 </tr>';
	 }
	 
	 if($industryType!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Categories &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.getIndustryType($industryType).'</td>
		 </tr>';
	 }
	 
	 if($website!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Website &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$website.'</td>
		 </tr>';
	 }
	 
	 if($officeImage!=""){
		 $filenm1=SITE_DIR_PATH."/uploaded_files/office_images/".$officeImage;
		 if(file_exists($filenm1)) {
			 $dimens=GetImageSize($filenm1);
			 if($dimens[0]>130) {
				 $dimens[0]=$dimens[0]+50;
				 $dimens[1]=$dimens[1]+80;
			 }
			 else{
				 $dimens[0]=200;
				 $dimens[1]=200;
			 }
			 $office_image='&nbsp;<a href="javascript:void(0);" onClick="openwin(\''.SITE_URL_PATH.'/popup.php?img=office_images/'.$officeImage.'\', \''.$dimens[0].'\', \''.$dimens[1].'\')" class="linkgray fontbold"><b>View Office Image</b></a>';
		 }
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Office Image &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$office_image.'</td>
		 </tr>';
	 }
	 
	 if($companyLogo!=""){
		 $filenm1=SITE_DIR_PATH."/uploaded_files/company_logos/".$companyLogo;
		 if(file_exists($filenm1)) {
			 $dimens=GetImageSize($filenm1);
			 if($dimens[0]>130) {
				 $dimens[0]=$dimens[0]+50;
				 $dimens[1]=$dimens[1]+80;
			 }
			 else{
				 $dimens[0]=200;
				 $dimens[1]=200;
			 }
			 $logo_link='&nbsp;<a href="javascript:void(0);" onClick="openwin(\''.SITE_URL_PATH.'/popup.php?img=company_logos/'.$companyLogo.'\', \''.$dimens[0].'\', \''.$dimens[1].'\')" class="linkgray fontbold"><b>View Logo</b></a>';
		 }
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Company Logo &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$logo_link.'</td>
		 </tr>';
	 }
	 
	 if($companyKeywords!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Company Keywords &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$companyKeywords.'</td>
		 </tr>';
	 }
	 
	 if($companyDescription!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Company Description &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$companyDescription.'</td>
		 </tr>';
	 }
	 $var.='<tr><td colspan="2"><hr size="1" width="90%" align="center"></td></tr>';
	 
	 if($sourceType!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Source Type &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.getSourceType($sourceType).'</td>
		 </tr>';
	 }
	 
	 if($recommendedBy!=""){
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Recommended By &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.ucwords($recommendedBy).'</td>
		 </tr>';
	 }
	 	 
	$var.='</table>';
	return $var;
}


function tradeLeadDetailView($slno,$memID="",$catalog="") {
	$res=getResult("trade_leads_tbl"," where slno='$slno'");
	$res1=getResult("member_tbl"," where memberID='$res[memberID]'");
	$res2=getResult("country_tbl"," where countryName='$res1[country]'");
	if ($res[image1]) {
		$image_lnk=SITE_WS_PATH."/uploaded_files/trade_leads/".$res[image1];
	}
	else {
		$image_lnk=SITE_WS_PATH."/images/no_photo.jpg";
	}
	if ($res1[membershipType] == 1) {
		$bg_strip="bg-strip-color1";
	}
	else {
		$cnt=$res1[membershipType]+1;
		$bg_strip="bg-strip-color".$cnt;
	}
	
	$pgnm=$GLOBALS['basedir']."/trade_lead_dtl_images.js";
	$fp=fopen("$pgnm","w");
	$var='<!--
	var actualPhoto = 0; 
	photos   = new Array(4); 
	photosHR = new Array(4); 
	photosNM = new Array(4); ';
	
	$var.='photos[0]   = "'.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image1].'";
	photosHR[0] = "'.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image1].'";
	photosNM[0] = "'.$res[image1].'";';
	
	$var.='photos[1]   = "'.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image2].'";
	photosHR[1] = "'.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image2].'";
	photosNM[1] = "'.$res[image2].'";';
	
	$var.='photos[2]   = "'.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image3].'";
	photosHR[2] = "'.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image3].'";
	photosNM[2] = "'.$res[image3].'";';
	
	$var.='photos[3]   = "'.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image4].'";
	photosHR[3] = "'.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image4].'";
	photosNM[3] = "'.$res[image4].'";';
	
	$var.='function LoadIMG(zdj) {
	document.getElementById(\'product_img\').src = photos[zdj];
	actualPhoto = zdj;
	// alert(photosNM[zdj]);
	}
	
	function BigIMG() {
	zdj = photosNM[actualPhoto];
	newwindow = window.open(\''.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image1].'?pic=\' + zdj + \'&lng=en\', \'BigIMGwindow\', \'width=320,height=300,toolbar=no,menubar=no,scrollbars=no\');
	newwindow.focus();
	}
	
	function BigTech(zdj) {
	newwindow = window.open(\''.SITE_WS_PATH.'/uploaded_files/trade_leads/'.$res[image1].'?pic=tech/\' + zdj + \'&lng=en\', \'BigIMGwindow\', \'width=840,height=600,toolbar=no,menubar=no,scrollbars=no\');
	newwindow.focus();
	}
	//-->';
	
	fwrite($fp,$var);
	fclose($fp);
	?>
	
	<table width="100%" cellpadding="6" cellspacing="0" class="<?=$bg_strip;?>" style="margin:3px 0 25px 0;">
	 <tr>
	  <td colspan="2" valign="top" class="border-bot-footer">
	   <table width="100%" cellspacing="0" cellpadding="0">
	    <tr>
	     <td width="638"><span class="heading"><?=ucfirst($res[leadTitle]);?></span> (<?=short_date_format($res[recvDate]);?>)</td>
	     <td width="34" align="center">
	     <?
	      if ($res2[countryFlag]) {
		      ?>
		      <img src="<?=SITE_WS_PATH;?>/uploaded_files/flags/<?=$res2[countryFlag];?>" alt="" width="18" height="12" /><br />
		      <?
	      }
	      echo $res1[country];?>
	     </td>
	    </tr>
	   </table>
	  </td>
	 </tr>
	 <tr>
	  <td width="15%" valign="top">
	   <table cellspacing="0" cellpadding="0" width="356" align="center" border="0">
	    <tbody>
	     <tr bgcolor="#ffffff">
	      <td align="center" height="190"><a href="<?=$image_lnk;?>" title="<?=ucwords($res[leadTitle]);?>" rel="lightbox[roadtrip]"><img src="<?=$image_lnk;?>" width="300" height="249" border="0" align="middle" class="boder_pro" id="product_img"/></a></td>
	     </tr>
	     <script language="JavaScript" type="text/javascript">
	     <?
	     if ($catalog) {
		     include_once("../trade_lead_dtl_images.js");
	     }
	     else {
		     include_once("trade_lead_dtl_images.js");
	     }
	     ?>
	     </script>	     
	     <tr bgcolor="#ffffff">
	      <td align="middle">
	       <table width="100%" border="0">
	        <tbody>
	         <tr valign="center">
	          <td valign="center" align="center">
	           <table width="98%" border="0" cellspacing="3" cellpadding="3">
	            <tr>
	             <td align="center">
	              <div>
	               <?
	               if ($res[image1]) {
		               ?>
		               <a href="<?=SITE_WS_PATH;?>/uploaded_files/trade_leads/<?=$res[image1];?>" rel="lightbox[roadtrip]"><img onMouseOver="LoadIMG(0)" title="Click here to open high resolution image" style="CURSOR: pointer" alt="Click here to open high resolution image" src="<?=SITE_WS_PATH;?>/uploaded_files/trade_leads/<?=$res[image1];?>" width="70" border="1" height="50" /></a>
		               <?
	               }
	               if ($res[image2]) {
		               ?>
		               &nbsp;<a href="<?=SITE_WS_PATH;?>/uploaded_files/trade_leads/<?=$res[image2];?>" rel="lightbox[roadtrip]"><img onMouseOver="LoadIMG(1)" title="Click here to open high resolution image" style="CURSOR: pointer" alt="Click here to open high resolution image" src="<?=SITE_WS_PATH;?>/uploaded_files/trade_leads/<?=$res[image2];?>" width="70" border="1" height="50" /></a>
		               <?
	               }
	               if ($res[image3]) {
		               ?>
		               &nbsp;<a href="<?=SITE_WS_PATH;?>/uploaded_files/trade_leads/<?=$res[image3];?>" rel="lightbox[roadtrip]"><img onMouseOver="LoadIMG(2)" title="Click here to open high resolution image" style="CURSOR: pointer" alt="Click here to open high resolution image" src="<?=SITE_WS_PATH;?>/uploaded_files/trade_leads/<?=$res[image3];?>" width="70" border="1" height="50" /></a>
		               <?
	               }
	               if ($res[image4]) {
		               ?>
		               &nbsp;<a href="<?=SITE_WS_PATH;?>/uploaded_files/trade_leads/<?=$res[image4];?>" rel="lightbox[roadtrip]"><img onMouseOver="LoadIMG(3)" title="Click here to open high resolution image" style="CURSOR: pointer" alt="Click here to open high resolution image" src="<?=SITE_WS_PATH;?>/uploaded_files/trade_leads/<?=$res[image4];?>" width="70" border="1" height="50" /></a>
		               <?
	               }
	               ?>
	              </div>
	             </td>
	            </tr>
	           </table>
	          </td>
	         </tr>
	        </tbody>
	       </table>
	      </td>
	     </tr>
	    </tbody>
	   </table>
	  </td>
	  <td valign="top">
	   <table width="100%" cellspacing="0" cellpadding="4">
	    <tr>
	     <td width="36%" class="bold">Posted on :</td>
	     <td width="64%"><?=short_date_format($res[recvDate]);?></td>
	    </tr>
	    <tr>
	     <td valign="top" class="bold">&nbsp;</td>
	     <td>&nbsp;</td>
	    </tr>
	    <tr>
	     <td valign="top" class="bold">Member Details :</td>
	     <td>
	      <table width="100%" cellspacing="0" cellpadding="0">
	       <tr>
	        <td width="16%" rowspan="2">
	         <?
	         if ($res[companyLogo]) {
		         ?>
		         <img src="<?=SITE_WS_PATH;?>/uploaded_files/logos/<?=$res[companyLogo];?>" width="60" height="61" border="0">
		         <?
	         }
	         ?>
	        </td>
	        <td width="84%" height="25"><span class="blue-style1 bold"><?=$res1[nameTitle];?> <?=ucwords($res1[memberName]);?><br/><?=ucwords($res1[jobTitle]);?><br/><?=ucwords($res1[companyName]);?></span></td>
	       </tr>
	       <tr><td>&nbsp;</td></tr>
	       <?
	       if ($catalog!="sitepanel") {
		       $memID=getMember();
		       
		       $redirect_url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
		       $bookmark='<br/><form name="bookmark" method="post" action=\''.SITE_WS_PATH.'/login.htm\'"><input type="hidden" name="redirect_url" value="'.$redirect_url.'" /><input name="submit" type="submit" class="button-style1" value="Bookmark" /></form>';
		       
		       if ($memID != "") {
			       $bookmark='<br/><form name="bookmark" method="post" action=\''.SITE_WS_PATH.'/bookmark.php\'"><input type="hidden" name="trade_lead_id" value="'.$res[slno].'" /><input type="hidden" name="redirect_url" value="'.$redirect_url.'" /><input type="hidden" name="action_bookmark" value="bookmark" /><input name="submit" type="submit" class="button-style1" value="Bookmark" /></form>';
		       }
		       
		       $bookmarkCnt=getCount("bookmark_tbl", " where memberID='$memID' and tradeLeadID='".$res['slno']."'");
		       if ($bookmarkCnt > 0) {
			       $bookmark="<br/><br/><strong>My Bookmark</string>&nbsp;&nbsp;";
		       }
		       
		       if ($memID == $res['memberID']) {
			       $bookmark="";
		       }
		       ?>
		       <tr>
		        <td colspan="2" style="padding-top:10px;">
		         <a href="<?=SITE_WS_PATH;?>/search-result.php?memID=<?=$res1[memberID];?>" class="button-style1">View All Leads</a>
		         <?
		         if ($catalog=="") {
			         if ($res1[membershipType] < 3) {
				         ?>
				         &nbsp;&nbsp;<a href="catalog/index.php?memID=<?=$res1[memberID];?>" target="_blank" class="button-style1">View Website </a>
				         <?
			         }
			         else {
				         ?>
				         &nbsp;&nbsp;<a href="classified-details.php?memID=<?=$res1[memberID];?>" class="button-style1">View Details </a>
				         <?
			         }
		         }
		         echo $bookmark;
		         ?>
		        </td>
		       </tr>
		       <?
	       }
	       ?>
	      </table>
	     </td>
	    </tr>
	   </table>
	  </td>
	 </tr>
	 <tr><td colspan="2" valign="top"><span style="margin-top:5px;"><?=ucfirst($res[leadDescription]);?></span></td></tr>
	</table>
	<?
}


function view_trade_lead($slno){
	$tlRes=getResult("trade_leads_tbl"," where slno='$slno'","leadTitle, leadDescription, image1");
	@extract($tlRes);	
	/*
	$memberRes=getResult("member_tbl"," where memberID='$memberID'","nameTitle, memberName, companyName");
	@extract($memberRes);
	*/
	
	$var='<table width="100%"  border="0" cellpadding="2" cellspacing="2" class="lightBorder">
	 <tr valign="top">
	  <td width="38%" align="right" valign="top" class="borderdotted form-txt">Trade Lead Title &rarr; </td>
	  <td align="left" valign="top" class=" borderdotted">'.ucwords($leadTitle).'</td>
	 </tr>
	 <tr valign="top">
	  <td align="right" valign="top" class="borderdotted form-txt">Trade Lead Description &rarr; </td>
	  <td align="left" valign="top" class=" borderdotted">'.ucfirst($leadDescription).'</td>
	 </tr>';
	 
	 if($image1!=""){
		 $filenm1=SITE_DIR_PATH."/uploaded_files/trade_lead_images/".$image1;
		 if(file_exists($filenm1)) {
			 $dimens=GetImageSize($filenm1);
			 if($dimens[0]>130) {
				 $dimens[0]=$dimens[0]+50;
				 $dimens[1]=$dimens[1]+80;
			 }
			 else{
				 $dimens[0]=200;
				 $dimens[1]=200;
			 }
			 $office_image='&nbsp;<a href="javascript:void(0);" onClick="openwin(\''.SITE_URL_PATH.'/popup.php?img=trade_lead_images/'.$image1.'\', \''.$dimens[0].'\', \''.$dimens[1].'\')" class="linkgray fontbold"><b>View Trade Lead Image</b></a>';
		 }
		 $var.='<tr valign="top">
		  <td align="right" valign="top" class="borderdotted form-txt"> Office Image &rarr; </td>
		  <td align="left" valign="top" class=" borderdotted">'.$office_image.'</td>
		 </tr>';
	 }
	 	 	 
	$var.='</table>';
	return $var;
}

//for search data 

function search_data($keyword)
{ 
	$search_data = [];
$query = mysqli_query($GLOBALS['dbcon'],"select * from category_tbl where catName like '%$keyword%'");

if(mysqli_num_rows($query) > 0)
{
while($result_search = mysqli_fetch_assoc($query)){
	$search_data[] =  $result_search;
}
return $search_data;
}	 
}

function string_date($date)
{
	$date = new DateTime($date);
    $result = $date->format('d M, Y');
    return $result;
}
//all Blog
function blogData()
{
	$allBlog = [];
	$sql_blog=mysqli_query($GLOBALS['dbcon'],"select * from blog_tbl where status='Y' order by blogDate");
	while($res_blog = mysqli_fetch_assoc($sql_blog))
	{
	

		$allBlog[$res_blog[catName]]['catName'] = $res_blog['catName']; 
		$allBlog[$res_blog[catName]]['blogDname'] = $res_blog['blogDname']; 
		$allBlog[$res_blog[catName]]['blogDate'] = $res_blog['blogDate']; 
		$allBlog[$res_blog[catName]]['blog_written'] = $res_blog['blog_written']; 
		$allBlog[$res_blog[catName]]['catDesc'] = $res_blog['catDesc']; 
		$allBlog[$res_blog[catName]]['catDesc'] = $res_blog['catDesc'];
		$allBlog[$res_blog[catName]]['catDesc1'] = $res_blog['catDesc1'];
		$allBlog[$res_blog[catName]]['catImage'] = $res_blog['catImage'];
	}
  return $allBlog;
	
}
//blog by Name
function blogDataByName($name)
{
	$singleBlog;
	
	$sql_blog=mysqli_query($GLOBALS['dbcon'],"select * from blog_tbl where catName='$name' and status='Y'");
	while($res_blog = mysqli_fetch_assoc($sql_blog))
	{
		$singleBlog = $res_blog;

		
	}
  return $singleBlog;
	
}


function blogDataPopular()
{
	$allBlog = [];
	$sql_blog=mysqli_query($GLOBALS['dbcon'],"select * from blog_tbl where status='Y' order by catID desc");
	while($res_blog = mysqli_fetch_assoc($sql_blog))
	{
	

		$allBlog[$res_blog[catName]]['catName'] = $res_blog['catName']; 
		$allBlog[$res_blog[catName]]['blogDname'] = $res_blog['blogDname']; 
		$allBlog[$res_blog[catName]]['blogDate'] = $res_blog['blogDate']; 
		$allBlog[$res_blog[catName]]['blog_written'] = $res_blog['blog_written']; 
		$allBlog[$res_blog[catName]]['catDesc'] = $res_blog['catDesc']; 
		$allBlog[$res_blog[catName]]['catDesc'] = $res_blog['catDesc'];
		$allBlog[$res_blog[catName]]['catDesc1'] = $res_blog['catDesc1'];
		$allBlog[$res_blog[catName]]['catImage'] = $res_blog['catImage'];
	}
  return $allBlog;
	
}


function clients()
{
	$allClient= [];
	$sql_client=mysqli_query($GLOBALS['dbcon'],"select * from client_tbl");
	$count = mysqli_num_rows($sql_client);
	while($res_client = mysqli_fetch_assoc($sql_client))
	{
		$allClient[$res_client[slink_url]]['slink_url'] = $res_client['slink_url']; 
		$allClient[$res_client[slink_url]]['slink_icon'] = $res_client['slink_icon']; 
		
	}

	$allClient['count'] = $count; 
  return  $allClient;
}

function faqs()
{
	$allFaq= [];
	$sql_faq=mysqli_query($GLOBALS['dbcon'],"select * from faq_tbl where status='1'");
	while($res_faq= mysqli_fetch_assoc($sql_faq))
	{
		$allFaq[] = $res_faq;
		
	}

  return $allFaq;

}

function about_us()
{
	$sql_about=mysqli_query($GLOBALS['dbcon'],"select * from static_pages where pageID='2'");
	$res_about = mysqli_fetch_array($sql_about);
	return $res_about;

}


function getSortedCategoryDataSubdomain($qry,$loc_res){
	$subcat_result = [];
	while($sub_cat = mysqli_fetch_array($qry)){
		$subcategory_id = $sub_cat['catID'];
		$content_sql2 = mysqli_query($GLOBALS['dbcon'],"SELECT * FROM subcontent_tbl WHERE subcontent_subcat = '$subcategory_id' ");
		$content_sql3 = mysqli_query($GLOBALS['dbcon'],"SELECT * FROM subcontent_tbl WHERE product_subsubcat = '$subcategory_id'");
		if(mysqli_num_rows($content_sql2) > 0){
			$cat_sub = mysqli_fetch_array($content_sql2); 
			$content_sub = $cat_sub['short_desc'];
		}else{
			$cat_sub = mysqli_fetch_array($content_sql3); 
			$content_sub = $cat_sub['short_desc'];
		}
		$content_sub = str_ireplace('countryname',$loc_res['locationName'], $content_sub);
		$content_sub = str_ireplace('catname',$sub_cat['displayName'], $content_sub);
		$content_sub = substr(html_entity_decode($content_sub),0,250);

		

		 $subcat_img_opt = str_ireplace("Delhi", $loc_res['locationName'], $sub_cat['pageTitle']);
		
		$subcat_result[$sub_cat[catName]]['sub_cat_title'] = ($sub_cat['displayName'] != '')?$sub_cat['displayName']:$sub_cat['catName']; 
		$subcat_result[$sub_cat[catName]]['sub_cat_name'] = $sub_cat['catName']; 
		$subcat_result[$sub_cat[catName]]['sub_cat_image'] = ($sub_cat['catImage'] != '')?$sub_cat['catImage']:''; 
		$subcat_result[$sub_cat[catName]]['catIcon'] = ($sub_cat['catIcon'] != '')?$sub_cat['catIcon']:''; 
		$subcat_result[$sub_cat[catName]]['sub_cat_id'] = $sub_cat['catID']; 
		$subcat_result[$sub_cat[catName]]['subcat_img_opt'] = ($subcat_img_opt != '')?$subcat_img_opt:$sub_cat['displayName']; 
		$subcat_result[$sub_cat[catName]]['sub_cat_content'] = $content_sub; 
	}
	return $subcat_result;
}

function getSortedCategoryData($cat_qry){
	$subcat_result = [];
	while($sub_cat = mysqli_fetch_array($cat_qry)){
		$content_sub = substr(html_entity_decode($sub_cat['catDesc']),0,250);
//		$subcat_img_opt = $sub_cat['business'];
		$subcat_result[$sub_cat[catName]]['sub_cat_title'] = ($sub_cat['displayName'] != '')?$sub_cat['displayName']:$sub_cat['catName']; 
		$subcat_result[$sub_cat[catName]]['sub_cat_image'] = ($sub_cat['catImage'] != '')?$sub_cat['catImage']:''; 
		$subcat_result[$sub_cat[catName]]['catIcon'] = ($sub_cat['catIcon'] != '')?$sub_cat['catIcon']:''; 
		$subcat_result[$sub_cat[catName]]['sub_cat_name'] = $sub_cat['catName']; 
		$subcat_result[$sub_cat[catName]]['sub_cat_id'] = $sub_cat['catID']; 
		$subcat_result[$sub_cat[catName]]['sub_cat_content'] = $content_sub; 
		$subcat_result[$sub_cat[catName]]['subcat_img_opt'] = ($sub_cat['pageTitle'] != '')?$sub_cat['pageTitle']:$sub_cat['displayName']; 
	}
	return $subcat_result;
	
}

function getSortedProductData($pro_qry,$loc_res){
	$product_result = [];
	while($prod_res = mysqli_fetch_array($pro_qry)){
		$prod_desc = substr(html_entity_decode($prod_res['product_desc']),0,250).'...';
		
		if(IS_SUB_DOMAIN){
			$product_img_opt = "in ".$loc_res['locationName'];
		}
		else{
			$product_img_opt = "in Delhi";
		}
		//$product_id = $prod_res['product_id'];
		//$product_result[$sub_cat[product_title]]['sub_cat_title'] = ($sub_cat['displayName'] != '')?$sub_cat['displayName']:$sub_cat['product_title']; 
		$product_result[$prod_res[product_title]]['prod_image'] = ($prod_res['product_image'] != '')?$prod_res['product_image']:''; 
		$product_result[$prod_res[product_title]]['prod_name'] = ucwords($prod_res['product_title']);
		$product_result[$prod_res[product_title]]['prod_id'] = $prod_res['product_id'];
		$product_result[$prod_res[product_title]]['prod_desc'] = $prod_desc; 
		$product_result[$prod_res[product_title]]['prod_img_opt'] = ($product_img_opt != '')?$product_img_opt:''; 
	}
	return $product_result;
}

function getBannerData($banner_qry,$loc_res){
	$banner_result = [];
	while($banner = mysqli_fetch_array($banner_qry)){
		$ban_img_opt = $banner['optimisation'];
		if(IS_SUB_DOMAIN){
			$banner_img_opt = str_ireplace("Delhi", $loc_res['locationName'], $ban_img_opt);
		}
		else{
			$banner_img_opt = $ban_img_opt;
		}
		$banner_result[$banner[personName]]['banner_optimisation'] = ($banner_img_opt != '')?$banner_img_opt:''; 
		$banner_result[$banner[personName]]['banner_name'] = $banner['personName'];
		$banner_result[$banner[personName]]['bannerImage'] = $banner['bannerImage'];
		$banner_result[$banner[personName]]['bannerUrl'] = $banner['bannerUrl'];
	}
	return $banner_result;
}
function testimonial($sql_testi)
{

	$testi_result = [];
	while($sub_cats = mysqli_fetch_array($sql_testi)){
		$content = html_entity_decode($sub_cats['description']);
		$testi_result[$sub_cats[title]]['title'] = $sub_cats['title']; 	
		$testi_result[$sub_cats[title]]['person_city'] = $sub_cats['person_city']; 
		$testi_result[$sub_cats[title]]['description'] = $content; 
	
	 }
	return $testi_result;
}

function blogDetails($sql_blog)
{
	$blog_result = [];
	while($sub_blog = mysqli_fetch_array($sql_blog)){
		
		$blog_result[$sub_blog[catName]]['catName'] = $sub_blog['catName']; 
		$blog_result[$sub_blog[catName]]['blogDname'] = $sub_blog['blogDname']; 
		$blog_result[$sub_blog[catName]]['blogDate'] = $sub_blog['blogDate']; 
		$blog_result[$sub_blog[catName]]['blog_written'] = $sub_blog['blog_written']; 
		$blog_result[$sub_blog[catName]]['blog_image'] = $sub_blog['catImage']; 
		$short_content = substr($sub_blog['catDesc'],0,100).'...';
		$full_content = html_entity_decode($sub_blog['catDesc1']);
		$blog_result[$sub_blog[catName]]['short_content'] = $short_content; 
		$blog_result[$sub_blog[catName]]['full_content'] = $full_content; 
	
	 }
	return $blog_result;
}


function footer_cat_links()
{
	$res_cat_footer = [];
	$sql_footer=mysqli_query($GLOBALS['dbcon'],"select * from category_tbl where parentID='1' and status='Y' limit 0,6");
						while($footer_cat=mysqli_fetch_array($sql_footer))
						{

                            $res_cat_footer[] = $footer_cat;
						}
						return $res_cat_footer;
						
}

function get_products($cat_id,$product_cat)
{
    $res_product= [];
	// echo "select * from product_tbl where ".$product_cat."=".$cat_id;
	// exit;
	$sql_prodcut=mysqli_query($GLOBALS['dbcon'],"select * from product_tbl where ".$product_cat."=".$cat_id);
						while($footer_cat=mysqli_fetch_array($sql_prodcut))
						{

                            $res_product[] = $footer_cat;
						}
						return $res_product;
						
}

function photo_gallery()
{
	$gall_image = [];
	$sql_gallery=mysqli_query($GLOBALS['dbcon'],"select * from catalogue_tbl order by id desc");
						while($res_gallery=mysqli_fetch_array($sql_gallery))
						{

                            $gall_image[] = $res_gallery;
						}
						return $gall_image;
}

function get_youtube_link($id)
{
	$tmp = file_get_contents("http://youtube.com/watch?v=" . $id);

	$tmp2 = substr($tmp, (strpos($tmp, "<title>") + 7), 220);

	$tmp = substr($tmp2, 0, strpos($tmp2, "</title>") - 9);

	$video_title =  htmlspecialchars_decode($tmp);
	return $video_title;
}
  
?>
