<?php
mb_internal_encoding("UTF-8");
require_once($general_path . "microdata_pool.php");

/**
 * get youtube video ID from URL
 *
 * @param string $url
 * @return string Youtube video id or FALSE if none found. 
 */
function youtube_id_from_url($url) {
    $pattern = 
        '%^# Match any youtube URL
        (?:https?://)?  # Optional scheme. Either http or https
        (?:www\.)?      # Optional www subdomain
        (?:             # Group host alternatives
          youtu\.be/    # Either youtu.be,
        | youtube\.com  # or youtube.com
        | youtube-nocookie\.com  # or youtube-nocookie.com
          (?:           # Group path alternatives
            /embed/     # Either /embed/
          | /v/         # or /v/
          | /watch\?v=  # or /watch\?v=
          )             # End path alternatives.
        )               # End host alternatives.
        ([\w-]{10,12})  # Allow 10-12 for 11 char youtube id.
        $%x'
        ;
    /*$result = preg_match($pattern, $url, $matches);
    if (false !== $result) {
        return $matches[1];
    }
    return false;*/

	$url_string = parse_url($url, PHP_URL_QUERY);
	parse_str($url_string, $args);
	return isset($args['v']) ? $args['v'] : false;
}

$no_booking_adverts = array(
	'AD301407190158558DBE6BE34E163320'
);


$left_pool_empty = true;
$cf_show_left_side = false;

$authorized_advert = false;
$paying_advert = false;

// New Seo
$seo = false;

if(str_replace("www.", "", $ultra_domainname) == "cyprus-hotel.com") {
	$seo = true;
}

$adv_code = trim($linePopup['adv_code']);
$show_website = intval($linePopup['show_website']);
$video = trim($linePopup['video']);
$webpage_title_en = stripslashes($linePopup['short_title_en']);
$meta_params = array(
	"company"	=> stripslashes($linePopup['short_title_en']),
	"location"	=> "",
	"category"	=> stripslashes(trim($line_catdom_id["title_en"]))
);

$meta['keywords'] = stripslashes($linePopup['short_title_en']) . ', ' . $meta['keywords'];

$meta_replacements = array(
	'[COMPANY]',
	'[LOCATION]',
	'[CATEGORY]'
);


$optres ['js'][] = $path . "assets/js/moment.min.js";
$optres ['css'][] = $module_css_path . "amodules/client_stand/css/client_stand_x.css";

$optres['css'][] = $module_css_path . "amodules/client_stand/css/jquery.galleryview-dark.css";
$optres['js'][] = $path . "amodules/client_stand/js/jquery.galleryview-3.0-dev.js";
$optres['js'][] = $path . "amodules/client_stand/js/jquery.easing.1.3.js";
$optres['js'][] = $path . "amodules/client_stand/js/jquery.timers-1.2.js";

$optres['js'][] = $path . "amodules/client_stand/js/jquery.fancybox.js";

$optres['css'][] = $path . "assets/css/bootstrap-datetimepicker.min.css";
$optres['js'][] = $path . "assets/js/bootstrap-datetimepicker.min.js";

$optres['css'][] = $path . "assets/css/bootstrap-dialog.min.css";
$optres['js'][] = $path . "assets/js/bootstrap-dialog.min.js";

$optres ['css'][] = $module_css_path . "amodules/client_stand/css/booking-form.css";
$optres ['css'][] = $module_css_path . "amodules/client_stand/css/jquery.fancybox.css";
//$optres ['css'][] = $path . "css/smoothness/jquery-ui-1.8.19.custom.css";
//$optres ['js'][] = $path . "js/jquery-ui-1.8.23.custom.min.js";

/******************************************************************************************************/
$hotel_aff = false;
$show_disclaimer = array();
// Get Hotel prices
$from_price = 0;
$min_price = 0;
$max_price = 0;
$min_price_aff_code = '';
$aff = array();
$aff_data = array();
$q = "select r.*, a.* from hotel_affiliates_adverts a, hotel_affiliates r where a.adv_code='$adv_code' and a.aff_hotel_status='1' and a.aff_code=r.aff_code and r.aff_status='1'  and a.aff_code='BOOKING000000002' and a.aff_hotel_id not like '%NONE%' order by a.low_rate asc;";
//echo $q;
$r = @mysql_query($q);
if($r && mysql_num_rows($r) > 0) {
	
	$hotel_aff = true;
	
	while ($row = mysql_fetch_assoc($r)) {
		$aff_name = trim($row['aff_name']);

        if(stripos($aff_name, 'booking') !== false) {

            $aff_code = trim($row['aff_code']);


            $aff[$row['aff_code']] = array(
                "aff_name" => $row['aff_name'],
                "aff_display" => $row['aff_display'],
                "low_rate" => $row['low_rate'],
                "hight_rate" => $row['high_rate'],
                "hotelId" => $row['aff_hotel_id'],
                "deep_link_book" => '',
                "deep_link_hotel" => '',
                "deep_link_dates" => '',
                "deep_link_location" => '',
            );

            if (floatval($row['low_rate']) > 1) {
                if ($min_price == 0) $min_price = floatval($row['low_rate']);
                elseif ($min_price > floatval($row['low_rate'])) $min_price = floatval($row['low_rate']);
            }

            if (floatval($row['high_rate']) > 1) {
                if ($max_price == 0) $max_price = floatval($row['high_rate']);
                elseif ($max_price < floatval($row['high_rate'])) $max_price = floatval($row['high_rate']);
            }


            $aff_data[$aff_code] = array(
                "aff_name" => trim($row['aff_name']),
                "aff_display" => trim($row['aff_display']),
                "cid" => $row['cid'],
                "hotelId" => $row['aff_hotel_id'],
                "checkin" => date("m/d/Y", strtotime("+3day", time())),
                "checkout" => date("m/d/Y", strtotime("+5day", time())),
                "roomsCount" => 2,
                "rooms" => array(
                    array(
                        "adultsCount" => 2,
                        "childrenCount" => 2,
                        "children" => array(
                            4, 7
                        )
                    ),
                    array(
                        "adultsCount" => 0,
                        "childrenCount" => 1,
                        "children" => array(
                            12
                        )
                    )
                )
            );
        }
	}
	
	
	if(count($aff_data) > 0) {
	
		foreach ($aff_data as $aff_code=>$ad) {
		
			require_once(dirname(__FILE__) . "/aff/".$ad['aff_name'].".php");
			
			// Expedia.com
			if($ad['aff_name'] == "Expedia.com") {
				$expedia = new Expedia($ad, $ad['hotelId']);
				
				//echo '<pre>', var_export($expedia, true), '</pre>';
				
				$aff[$aff_code]['deep_link_book'] = $expedia->getDeepLinkHotelBook();
				$aff[$aff_code]['deep_link_hotel'] = $expedia->getDeepLinkHotel();
				$aff[$aff_code]['deep_link_dates'] = $expedia->getDeepLinkHotelDates();
				//$aff[$aff_code]['deep_link_location'] = $expedia->getDeepLinkHotelLocation();
			}
			
			// Booking.com
			if($ad['aff_name'] == "Booking.com") {
				$booking = new Booking($ad, $ad['hotelId']);
				
				//echo '<pre>', var_export($booking, true), '</pre>';
				
				$aff[$aff_code]['deep_link_book'] = $booking->getDeepLinkHotelBook();
				$aff[$aff_code]['deep_link_hotel'] = $booking->getDeepLinkHotel();
				$aff[$aff_code]['deep_link_dates'] = $booking->getDeepLinkHotelDates();
				//$aff[$aff_code]['deep_link_location'] = $expedia->getDeepLinkHotelLocation();
			}
		
		}
		
	}
	
	//echo '<pre>', var_export($aff, true), '</pre>';
	
}
else {
	// For this hotel we have no affiliates data
	$hotel_aff = false;
	$q = "select r.* from hotel_affiliates r where r.aff_status='1' order by r.aff_name asc;";
	//echo $q;
	$r = @mysql_query($q);
	if($r && mysql_num_rows($r) > 0) {
		while ($row = mysql_fetch_assoc($r)) {
            if(stripos($row['aff_name'], 'booking') !== false) {
                $aff[$row['aff_code']] = array(
                    "aff_name" => $row['aff_name'],
                    "aff_display" => $row['aff_display'],
                    "low_rate" => 0,
                    "hight_rate" => 0,
                    "hotelId" => '',
                    "deep_link_book" => '',
                    "deep_link_hotel" => '',
                    "deep_link_dates" => '',
                    "deep_link_location" => '',
                );
            }
		}
	}
}
/******************************************************************************************************/



$meta_loc = "";

$meta_phrase = "[COMPANY] is a Cyprus business located in [LOCATION]. It is operating in the field of [CATEGORY]";
$advert_meta_description = trim(stripslashes($linePopup["meta_description"]));
$advert_meta_keywords = trim(stripslashes($linePopup["meta_keywords"]));
$advert_use_meta = intval($linePopup["use_meta"]);

$microdata_domain = str_replace("www.", "", $ultra_domainname);
$microdata_host = $_SERVER['HTTP_HOST'];
if(str_replace('www.', '', $microdata_host) != str_replace('www.', '', $ultra_domainname)) {
	$microdata_host .= "/" . $ultra_addonname;
	
	require_once(dirname(__FILE__) . "/../../ageneral/functions.php");
}
else {
	require_once(dirname(__FILE__) . "/../../functions.php");
}
$have_microdata = (isset($microdata_domains) && in_array($microdata_domain, $microdata_domains));

// Get domain catdoms
$catdoms = array();
$catdoms_idx = array();
$wb_uid = "";
$catdoms [] = $domain_id;
$catdoms_idx [] = "'" . sprintf("%04.0f", $domain_id) . "'";
$result_sub = mysql_query ("SELECT * FROM  domaincategories WHERE parent_id='$domain_id';");
if (mysql_num_rows($result_sub) <> 0){			  
	while($line_sub = mysql_fetch_array($result_sub)){ 
		$catdoms [] = intval($line_sub["catdom_id"]);
		$catdoms_idx [] = "'" . sprintf("%04.0f", $line_sub["catdom_id"]) . "'";
		
		if(isset($town_friendly_url) && $town_friendly_url == $line_sub['friendly_url']) {
			$town_catdom_id = intval($line_sub['catdom_id']);
		}
		
	}
}

// Get domain category
$q = "select * from wb_categories_domains where wb_domainname='".(str_replace("www.", "", $ultra_domainname))."';";
$r = @mysql_query($q);
if($r && mysql_num_rows($r) == 1) {
	$row = mysql_fetch_assoc($r);
	$wb_uid = $row['wb_uid'];
}


// Check if advert belongs to this category
if(isset($wb_uid) && strlen($wb_uid) == 16) {
	$q = "select * from wb_categories_adverts where wb_uid='$wb_uid' and wb_advert_uid='{$linePopup['adv_code']}';";
	if(isset($_REQUEST['debug'])) echo "<br/>$q";
	$r = @mysql_query($q);
	if($r && mysql_num_rows($r) == 1) {
		$row = mysql_fetch_assoc($r);
		$wb_status = intval($row['wb_status']);
		
		if($wb_status == 1) $authorized_advert = true;
	}
}

// Get Main category and filter values *******************************************/
if(!isset($fm_uid) || $fm_uid == "") {
	$q = "select f.*, d.title as category_title from wb_filters_adverts_categs f, wb_filters_mains d  where f.wb_uid='$wb_uid' and f.adv_code='$adv_code' and f.fm_uid=d.fm_uid;";
	$r = @mysql_query($q);
	if($r && mysql_num_rows($r) == 1) {
		$row = mysql_fetch_assoc($r);
		$fm_uid = trim($row['fm_uid']);
		$fm_title = stripslashes($row['category_title']);
	}
}

$fmains = array();
$fcategs = array();
$felems = array();
$elms = array();

$q = "select * from wb_filters_mains where wb_uid='$wb_uid' order by pos asc;";
$r = @mysql_query($q);
if($r && mysql_num_rows($r) > 0) {
	while ($row = mysql_fetch_assoc($r)) {
		$fmains [$row['fm_uid']] = array_map('stripslashes', $row);
	}
}


if(isset($fm_uid) && $fm_uid != "") {

	$q = "select * from wb_filters_categs where wb_uid='$wb_uid' and fm_uid='$fm_uid' order by pos asc;";
	$r = @mysql_query($q);
	if($r && mysql_num_rows($r) > 0) {
		while ($row = mysql_fetch_assoc($r)) {
			if(!isset($fcategs[$row['fm_uid']])) {
				$fcategs[$row['fm_uid']] = array();
				$fcategs[$row['fm_uid']][$row['fc_uid']] = array_map('stripslashes', $row);
			}
			else {
				$fcategs[$row['fm_uid']][$row['fc_uid']] = array_map('stripslashes', $row);
			}
			
		}
	}
	
	
	$class_vars_classes = array(
		"star_rating" 	=> "rate", 
		"apt_class"		=> "class", 
		"class"			=> "class"
	);
	
	$rating = array(
		'class'			=> '',
		'var'			=> '',
		'uid'			=> '',
		'db'			=> array(),
		'value'			=> '',
		'text'			=> '',
		'display'		=> 1
	);
	
	
	$q = "select * from wb_filters_elems where wb_uid='$wb_uid' and fm_uid='$fm_uid' order by fc_uid asc, pos asc;";
	$r = @mysql_query($q);
	if($r && mysql_num_rows($r) > 0) {
		while ($row = mysql_fetch_assoc($r)) {
			//echo '<pre>', var_export($row, true), '</pre>';
			$f_value = $row['e_value'];
			$e_label_display = stripslashes($row['e_label_display']);
			$e_db = ($row['e_db'] != "") ? unserialize(base64_decode($row['e_db'])) : array();
			//echo '<pre>', var_export($row, true), '</pre>';
			
			if(in_array($row['e_name'], array_keys($class_vars_classes))) {
				$rating['var'] = $row['e_name'];
				$rating['class'] = $class_vars_classes[$row['e_name']];
				$rating['uid'] = $row['fe_uid'];
				$rating['db'] = unserialize(base64_decode($row['e_db']));
			}
			
			
			$elms[$row['e_name']] = array(
				'wb_uid'	=> $row['wb_uid'],
				'fm_uid'	=> $row['fm_uid'],
				'fc_uid'	=> $row['fc_uid'],
				'fe_uid'	=> $row['fe_uid'],
			);
			
			if(!isset($felems [$row['fc_uid']])) {
				$felems [$row['fc_uid']] = array();
				$felems [$row['fc_uid']][] = array_map('stripslashes', $row);
			}
			else {
				$felems [$row['fc_uid']][] = array_map('stripslashes', $row);
			}
		}
	}



	// Get already existing values
	$fvalues = array();
	$star_rating = '';
	$star_rating_text = '';
	$q = "select * from wb_filters_adverts where wb_uid='$wb_uid' and fm_uid='$fm_uid' and adv_code='$adv_code';";
	$r = @mysql_query($q);
	if($r && mysql_num_rows($r) > 0) {
		while ($row = mysql_fetch_assoc($r)) {
			$f_value = stripslashes(trim($row['f_value']));
			
			//echo '<pre>' . var_export($row, true), '</pre>';
			
			if($row['fe_uid'] == $rating['uid']) {
				if($rating['var'] == 'star_rating') {
					$star_rating = 0;
					$star_cnt = 5;
					foreach ($rating['db'] as $r_value=>$r_text) {
						if($f_value == $r_value) {
							$star_rating = $star_cnt;
							$rating['text'] = stripslashes($r_text);
						}
						$star_cnt--;
					}
					
					$rating['class'] .= '-' . $star_rating;
					$rating['display'] = 0;
				}
				else {
					foreach ($rating['db'] as $r_value=>$r_text) {
						if($f_value == $r_value) {
							$rating['text'] = stripslashes($r_text);
						}
					}
				}
			}
			
			if(isset($fvalues [$row['fe_uid']])) {
				$fvalues [$row['fe_uid']][] = stripslashes(trim($row['f_value']));
			}
			else {
				$fvalues [$row['fe_uid']] = array();
				$fvalues [$row['fe_uid']][] = stripslashes(trim($row['f_value']));
			}
		}
	}
	
	//echo '<pre>', var_export($rating, true), '</pre>';
	
}

/****************************************************/

$specific_locations = array();

// Check if advert is supposed to show because of active bindings
$q = "select * from domain_advertisment where advertisment_id='{$linePopup['advertisment_id']}' and catdom_id IN (".implode(",", $catdoms).");";
if(isset($_REQUEST['debug'])) echo "<br/>$q";
$r = @mysql_query($q);
if($r && mysql_num_rows($r) > 0) {
	$authorized_advert = true;
	while ($row = mysql_fetch_assoc($r)) {
		
		if($row['params'] != "") {
			$adv_params = unserialize(base64_decode($row['params']));
			if(isset($adv_params['locations']) && is_array($adv_params['locations']) && count($adv_params['locations']) > 0) {
				$specific_locations [$row['catdom_id']] = $adv_params['locations'];
			}
		}
		
		if($row['category_top'] == "yes" || $row['active'] == "yes") {
			$paying_advert = true;
		}
	}
}

if(str_replace('www.', '', $ultra_domainname) == "cyprusnet.com") $authorized_advert = true;

if(isset($_REQUEST['debug'])) echo "<br/>authorized_advert=" . var_dump($authorized_advert);

if($authorized_advert){
	$advertisment_id = $linePopup['advertisment_id'];
	$active = ($linePopup['active'] == "yes") ? "yes" : "no";
	$website = fix_url(trim($linePopup['website']));
	$shortNameURL = trim($linePopup['title_tr']);
    $logo_url = $full_uri . "images/advertisments/" . $linePopup['advertisment'];
	

	
	if(!isset($_SESSION['user_id']) && $paying_advert) {
		mysql_query("UPDATE advertisment SET views=views+1 WHERE advertisment_id='{$linePopup['advertisment_id']}'") or die (mysql_error());
		// e stands for search engine
		count_views('adverts_stats_views', 'advertisment_id', $linePopup['advertisment_id'], $domain_id, '', 'e');
		
		$_adverts_views [] = array(
			"adv_code"				=> $linePopup['adv_code'],
			"advertisment_id"		=> $linePopup['advertisment_id'],
			"domain_id"				=> $domain_id,
			"catdom_id"				=> $domain_id,
			"domainname"			=> $ultra_domainname,
			"date_short"			=> date("Y-m-d"),
			"date_long"				=> date("Y-m-d H:i:s"),
			"views"					=> 1,
			"view_from"				=> 'e'
		);
		
	}
	// get locations
	$locations = array();
	$disp_loc = array();
	
	$q = "select * from advertisment_locations where advertisment_id='$advertisment_id' and active='1' order by main_location desc;";
	
	//echo $q;
	
	$r = @mysql_query($q);
	if($r && mysql_num_rows($r)>0) {
		while ($row = mysql_fetch_assoc($r)) {
			$locations [] = $row;
			
			if(intval($row['main_location']) == 1) {
				$hotel_city = $row['lcode'];
				$hotel_district = $row['dcode'];
			}
		}
	}
	
	
	
	if(count($locations)>0) {
		$disp_loc = $locations[0];
	}
	
	if($paying_advert) {
		$click_count_path = "click_count.php?link={$linePopup["title_tr"]}&amp;type=www&amp;id={$linePopup['advertisment_id']}&amp;domain={$ultra_domainname}&amp;domain_id=$domain_id&amp;window=stand&amp;click_from=e";
	}
	else {
		$click_count_path = "click_count.php?link={$linePopup["title_tr"]}&amp;type=www&amp;id={$linePopup['advertisment_id']}&amp;domain={$ultra_domainname}&amp;domain_id=$domain_id&amp;window=stand&amp;click_from=e";
	}
	/*
	?>
	<div <?php echo ($have_microdata) ? 'itemscope="itemscope" itemtype="http://schema.org/'.$microdata_types[$microdata_domain]['adverts']['type'].'"' : '';?>>
	<?php
	*/
	
	/*******************************************************************************************************/
	// Set business address
	
	$business_address = '';
	$hotel_aff_location = '';
	$data = $disp_loc;
	$have_map = false;
	if(isset($data['lat']) && floatval($data['lat']) > 0) $have_map = true;
	
	
	// Change Page title
	// Hardcoded Logic For famagusta dcode (DA03E5C3AF8EF162)
	$page_title_location = "dcode";
	if($hotel_district == "DA03E5C3AF8EF162") {
		if($hotel_city == "L687EA66D2174CA9") $page_title_location = "lcode";
		if($hotel_city == "LC4C90BD4F64D59B") $page_title_location = "lcode";
	}
	
	if($page_title_location == "dcode") {
		$webpage_title_en = trim(str_ireplace($data['district'], '', $webpage_title_en));
		$webpage_title_en .= " " .$data['district'] . " - Cyprus Hotels";
	}
	elseif($page_title_location == "lcode") {
		$webpage_title_en = trim(str_ireplace($data['city'], '', $webpage_title_en));
		$webpage_title_en .= " " .$data['city'] . " - Cyprus Hotels";
	}
	
	ob_start();
	
	
	$address_have_street = false;
	$address_street = '';
	$address_locality = '';
	$address_region = '';
	$address_postalcode = '';
	$address_po = '';
	$address_country = '<span itemprop="addressCountry">Cyprus</span>';
	
	/* Street *****************************************************************************/
	$street_address = '';
	if(trim($data['street']) != '') {
		$address_have_street = true;
		$street_address .= trim($data['street']);
	}
	
	if(trim($data['street_no']) != '') {
		$street_address = trim($data['street_no']) . ' ' . $street_address;
	}
	
	if(trim($data['building_name']) != "") {
		$street_address .= ', ' . stripslashes(trim($data['building_name']));
	}
	
	if(trim($data['floor']) != "") {
		$street_address .= ', Floor ' . stripslashes(trim($data['floor']));
	}
	
	if(trim($data['flat']) != "") {
		$street_address .= ', Office/Flat '. stripslashes(trim($data['flat']));
	}
	
	if($street_address != '') {
		$address_street = '<span itemprop="streetAddress">' . $street_address . '</span>';
	}
	
	/* END Street *****************************************************************************/
	
	/* Locality *****************************************************************************/
	$tmp_locality = '';
	if(trim($data['city']) != "") {
		$hotel_aff_location = $data['city'];
		$tmp_locality = stripslashes($data['city']);
	}
	
	if($tmp_locality != '') {
		$address_locality = '<span itemprop="addressLocality">' . $tmp_locality . '</span>';
	}
	
	/* END Locality *****************************************************************************/
	
	
	/* Region *****************************************************************************/
	$tmp_region = '';
	if(trim($data['district']) != "") {
		if($hotel_aff_location == "" || $hotel_aff_location != $data['district']) {
			if($hotel_aff_location == "") $hotel_aff_location = $data['district'];
			else $hotel_aff_location .= ", " . $data['district'];
		}
		
		$tmp_region = trim(stripslashes($data['district']));
	}
	
	if($tmp_region != '') {
		$address_region = '<span itemprop="addressRegion">' .  $tmp_region . '</span>';
	}
	
	/* END Region *****************************************************************************/
	
	/* Postal Code *****************************************************************************/
	$tmp_postalcode = '';
	if(trim($data['postalcode']) != "") {
		$tmp_postalcode = trim($data['postalcode']);
	}
	
	if($tmp_postalcode != '') {
		$address_postalcode = '<span itemprop="postalCode">' . $tmp_postalcode . '</span>';
	}
	
	/* END Postal Code *****************************************************************************/
	
	/* PO Box *****************************************************************************/
	$tmp_po = '';
	if(trim($data['pobox']) != "") {
		$tmp_po .= 'P.O. Box <span itemprop="postOfficeBoxNumber">' . stripslashes($data['pobox']) . '</span>';
	}
			
	if(trim($data['pobox_postalcode']) != "") {
		if($address_postalcode != '') {
			$tmp_po .=  ', P.O. Box Postal Code ' . stripslashes($data['pobox_postalcode']);	
		}
		else {
			$address_postalcode = '<span itemprop="postalCode">' . stripslashes($data['pobox_postalcode']) . '</span>';
		}
	}
	
	if($tmp_po != '') {
		$address_po = $tmp_po;
	}
	
	/* END PO BOX *****************************************************************************/
	
	// Display Address
	
	if($address_have_street) {
		echo $address_street;
	}
	else {
		if($address_po != '') echo $address_po;
	}
	if($address_locality != '') echo ', ' . $address_locality;
	if($address_region != '') {
		if($address_postalcode != '') echo ', ' . $address_postalcode;
		echo ' ' . $address_region;
	}
	echo ', ' . $address_country;
	
	if($address_have_street) {
		if($address_po != '') echo ' | ', $address_po;
	}
	
	
	$business_address = ob_get_contents();
	ob_end_clean();
	
	/*******************************************************************************************************/

	$canonical_link = $real_path_http . $linePopup["title_tr"];

	?>

	<div id="<?=$canonical_link . "#organization";?>" class="main-data" <?php echo ($have_microdata) ? 'itemscope="itemscope" itemtype="' . $microdata_types[$microdata_domain]['adverts']['type'] . '"' : '';?>>
	    <meta itemprop="currenciesAccepted" content="EUR"/>
	    <meta itemprop="sameAs" content="<?=$website;?>"/>

        <?php
        // Social Plugin
        //include(dirname(__FILE__) . "/../sm/sm.php");
        /*********************************************************************************************/
        ?>

		<header id="org-header">
            <h1 id="">
                <span itemprop="name"><?php echo stripslashes($linePopup['short_title_en']);?></span>
                <?php
                if(isset($rating) && $rating['uid'] != '') {
                    if($rating['var'] == 'star_rating') {
                        echo '<span id="business_rating">';
                        //echo '<meta itemprop="worstRating" content="1"/>';
                        //echo '<meta itemprop="ratingValue" content="', intval($rating['text']), '"/>';
                        //echo '<meta itemprop="bestRating" content="5"/>';
                        echo '<span class="business_', $rating['var'] ,' ', $rating['class'], '" title="'.$rating['text'].'" itemprop="starRating" itemscope itemtype="http://schema.org/Rating"><meta itemprop="ratingValue" content="'.$star_rating.'">', (intval($rating['display']) == 1) ? $rating['text'] : '', '</span>';
                        echo '</span>';
                    }
                    else {
                        echo '<span id="business_rating" class="business_', $rating['var'] ,' ', $rating['class'], '" title="'.$rating['text'].'">', (intval($rating['display']) == 1) ? $rating['text'] : '';
                        echo '<meta content="', $rating['text'], '"/>';
                        echo '</span>';
                    }
                }
                ?>
            </h1>
            <meta itemprop="logo" content="<?=$logo_url?>">
            <!--[/SocialShareButtons/]-->
        </header>
        <div class="article-body cyprus">

		<div class="sm-org">
			<?php
			//include(dirname(__FILE__) . "/../sm/sm.php");
			?>
		</div>
		<div id="business-address" itemprop="address" itemscope="itemscope" itemtype="http://schema.org/PostalAddress">
			<?php
			echo $business_address;
			?>
		</div>
        <div id="website">

            <?php
            if ($website != "" && $show_website == 1) {
                echo ($have_microdata) ? '<meta itemprop="url" content="' . $full_uri . $shortNameURL . '">' : '';
                if ($active == "yes") {

                    if ($paying_advert) {
                        ?>
                        <a href="click_count.php?link=<?php echo $linePopup["title_tr"]; ?>&amp;type=www&amp;id=<?php echo $linePopup['advertisment_id']; ?>&amp;domain=<?php echo $ultra_domainname; ?>&amp;domain_id=<?php echo $domain_id; ?>&amp;window=stand&amp;click_from=e"
                           target="_blank" class="click-count btn btn-darkred btn-xs btn-flat"
                           title="<?php echo stripslashes($linePopup['short_title_en']); ?>"><i
                                class="fa fa-external-link"></i> Visit Website</a>
                        <?php
                    } else {
                        ?>
                        <a href="click_count.php?link=<?php echo $linePopup["title_tr"]; ?>&amp;type=www&amp;id=<?php echo $linePopup['advertisment_id']; ?>&amp;domain=<?php echo $ultra_domainname; ?>&amp;domain_id=<?php echo $domain_id; ?>&amp;window=stand&amp;click_from=e"
                           target="_blank" class="btn btn-darkred btn-xs btn-flat"
                           title="<?php echo stripslashes($linePopup['short_title_en']); ?>"><i
                                class="fa fa-external-link"></i> Visit Website</a>
                        <?php
                    }
                } else {
                    ?>
                    <a href="click_count.php?link=<?php echo $linePopup["title_tr"]; ?>&amp;type=www&amp;id=<?php echo $linePopup['advertisment_id']; ?>&amp;domain=<?php echo $ultra_domainname; ?>&amp;domain_id=<?php echo $domain_id; ?>&amp;window=stand&amp;click_from=e"
                       target="_blank" class="btn btn-darkred btn-xs btn-flat"
                       title="<?php echo stripslashes($linePopup['short_title_en']); ?>"><i
                            class="fa fa-external-link"></i> Visit Website</a>
                    <?php
                }

            }

            //if($website != "" && $active == "yes" && trim($linePopup['email']) != "") echo " | ";
            if ($linePopup['email']) {
                echo ($have_microdata) ? '<meta itemprop="email" content="' . $linePopup['email'] . '">' : '';
                ?><a href="mailto:<?= $linePopup['email']; ?>" class="mailto btn btn-info btn-xs btn-flat text-white"
                     rel="<?php echo str_replace('@', '[ at ]', $linePopup['email']); ?>"><i
                        class="fa fa-mail-forward"></i> Send Email</a><?php
            }
            ?>
        </div>
		<?php
		/**********************************************************************************/
        // Online booking search form
        if(isset($aff) && count($aff) > 0 && !in_array($adv_code, $no_booking_adverts)) {
            if($hotel_aff) {
                //$book_title = 'Enter dates & see best prices*';
                $book_title = '';
                $book_text = '';
            }
            else {
                $book_title = 'We are sorry but this hotel is not available for online booking at the moment.';
                //$book_text = 'Please check best rates on '.$hotel_aff_location.' hotels.';
                $book_text = 'Please check best rates on nearby hotels.';
            }
            ?>
            <div id="org-booking" class="chkRates">
                <?php
                /*
                <h2 class="wb_h2"><?php echo $book_title;?></h2>
                */
                if($book_title != "") {
                    ?>
                    <div class="alert alert-default">
                        <p>
                            <i class="fa fa-info-circle fa-2x pull-left text-danger"></i>
                            <span><?=$book_title?></span>
                            <?php
                            if($book_text != "") {
                                echo '<br><span>' . $book_text . '</span>';
                            }
                            ?>
                        </p>

                    </div>
                    <?php
                }


                ?>

                <form id="booking-form" action="" role="form">
                    <?php
                    $def_checkin = date("d/m/Y", strtotime("+1 day"));
                    $def_checkout = date("d/m/Y", strtotime("+2 day"));
                    $def_adults = 2;
                    $min_checkout_date = date("d/m/Y", strtotime("+2 day"));
                    $max_checkout_date = date("d/m/Y", strtotime("+29 day"));
                    if(isset($_SESSION['hotel_search']) && isset($_SESSION['hotel_search']['checkin']) && trim($_SESSION['hotel_search']['checkin']) != ""){
                        $def_checkin = $_SESSION['hotel_search']['checkin'];
                        $dt = DateTime::createFromFormat('d/m/Y', $def_checkin);
                        $dt_reg = strtotime($dt->format('Y-m-d'));
                        $min_checkout_date = date("d/m/Y", strtotime('+1 day', $dt_reg));
                        $max_checkout_date = date("d/m/Y", strtotime('+28 day', $dt_reg));

                    }
                    if(isset($_SESSION['hotel_search']) && isset($_SESSION['hotel_search']['checkout']) && trim($_SESSION['hotel_search']['checkout']) != ""){
                        $def_checkout = $_SESSION['hotel_search']['checkout'];
                    }
                    if(isset($_SESSION['hotel_search']['adults']) && intval($_SESSION['hotel_search']['adults']) >0){
                        $def_adults = intval($_SESSION['hotel_search']['adults']);
                    }
                    ?>
                    <div class="row">
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label id="lbl_checkIn" for="checkin" class="control-label">Check In</label>
                                <div class="input-group input-group-sm date" id="datetimepicker-1">
                                    <input type="text" name="checkin" id="checkin" value="<?php echo $def_checkin;?>" class="form-control" />
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                                </div>

                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label id="lbl_checkOut" for="checkout" class="control-label">Check Out</label>
                                <div class="input-group input-group-sm date" id="datetimepicker-2">
                                    <input type="text" name="checkout" id="checkout" value="<?php echo $def_checkout;?>" class="form-control" />
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="form-group">
                                <label for="adults" class="control-label">Adults</label>
                                <div>
                                    <select id="adults" name="adults" class="form-control input-sm">
                                        <?php
                                        $adults_array = array(1,2,3,4);

                                        foreach ($adults_array as $adults_cnt) {
                                            $selected = '';
                                            if($def_adults == $adults_cnt) {
                                                $selected = 'selected="selected"';
                                            }
                                            echo '<option value="'.$adults_cnt.'" '.$selected.'>'.$adults_cnt.'</option>';
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <?php
                    $aff_col = 'col-sm-5 col-xs-5';
                    if($hotel_aff) {
                        if($min_price > 0 || $max_price > 0) {
                            $aff_col = 'col-sm-3 col-xs-10';
                            $show_disclaimer['*'] = 'Prices displayed are based on the rates obtained from our network of booking partners. We do not guarantee any specific rates or prices. These rates are estimates therefore check with the specific booking site for the exact amount, currency and fees.';
                        }
                    }
                    ?>

                    <div class="aff_providers_container">
                        <ul class="aff_provider list-group no-padding no-margin">
                            <?php
                            $book_links = array();
                            foreach ($aff as $aff_code => $aff_data) {
                                if($hotel_aff) {
                                    ?>
                                    <li>
                                        <div class="aff-partner-search col-sm-3 col-xs-5 text-left">
                                            <?php
                                            /*<input type="checkbox" checked="checked" name="aff[]" value="<?php echo $aff_code .'|'. $aff_data['hotelId'] ?>" class="aff_chk" id="<?php echo str_replace(array('.', ' ', '-'), '', $aff_data['aff_display']) . '_' . $aff_data['hotelId'];?>"/>*/
                                            ?>
                                            <label title="<?php $aff_data['aff_display'];?>" for="<?php echo str_replace(array('.', ' ', '-'), '', $aff_data['aff_display']) . '_' . $aff_data['hotelId'];?>">
                                                <span id="<?php echo $aff_code . '_' . $aff_data['hotelId'];?>"><?php echo $aff_data['aff_display'];?></span>
                                            </label>
                                        </div>
                                        <?php
                                        if($hotel_aff) {
											if($min_price > 0) {
												$range_text = 'From';
												if($max_price > 0) $range_text = "Between";
												?>

												<div class="hotel_avg_rate col-sm-4 col-xs-5 text-right">
													<?=$range_text?> <sup style="font-size:13px;">*</sup>
													<span class="hotel_price" itemprop="priceRange">
                                        				&euro; <?php echo number_format($min_price, 0);?>
													<?php
													if($max_price > 0) {
														?>
														- &euro; <?php echo number_format($max_price, 0);?>
														<?php
													}
													?>
													</span>
                                    			</div>
												<?php


											}
											elseif($max_price > 0) {
												$range_text = 'Up to';
												?>
												<div class="hotel_avg_rate col-sm-4 col-xs-5 text-right">
													<?=$range_text?> <sup style="font-size:13px;">*</sup>
													<span class="hotel_price" itemprop="priceRange">
                                        				&euro; <?php echo number_format($max_price, 0);?>
													</span>
												</div>
												<?php
											}
											else {
												echo '<meta itemprop="priceRange" content="Check Availability">';
											}


                                        }

                                        ?>
                                        <div class="aff-partner-button <?=$aff_col;?> text-right">
                                            <button class="check-prices btn btn-primary btn-sm" rel="<?php echo $aff_code .'|'. $aff_data['hotelId'] ?>">
                                                Show Prices *
                                            </button>
                                        </div>


                                    </li>
                                    <?php
                                }
                                else {
                                    ?>
                                    <li>
                                        <div class="aff-partner-search col-xs-5 text-left">
                                            <?php
                                            /*<input type="checkbox" checked="checked" name="aff[]" value="<?php echo $aff_code;?>" class="aff_chk" id="<?php echo str_replace(array('.', ' ', '-'), '', $aff_data['aff_display']);?>"/>*/
                                            ?>
                                            <label title="<?php $aff_data['aff_display'];?>" for="<?php echo str_replace(array('.', ' ', '-'), '', $aff_data['aff_display']);?>">
                                                <span id="<?php echo $aff_code;?>"><?php echo $aff_data['aff_display'];?></span>
                                            </label>
                                        </div>
                                        <div class="aff-partner-button col-xs-5 text-right">
                                            <button class="find-hotels btn btn-primary btn-sm" rel="<?php echo $aff_code . '|' . $hotel_aff_location;?>">
                                                Find Hotels *
                                            </button>
                                            <meta itemprop="priceRange" content="Check Availability">
                                        </div>
                                    </li>
                                    <?php
                                }
                            }
                            ?>
                        </ul>
                        <?php
                        /*
                        <div class="disclaimer">*from our partners</div>
                        */
                        ?>
                    </div>
                    <div style="clear: both;"></div>
                    <?php
                    if(!$hotel_aff) {
                        echo '<div class="disclaimer">* from our partners</div>';
                    }
                    ?>
                </form>
            </div>
            <?php
        }
        // END Online booking search form
        /*******************************************************************************************/

		// Get photos
		$gallery = array();
		$gallery_folder = $path . "images/advertisments/gallery/$advertisment_id";
		$gallery_folder_th = $path . "images/advertisments/gallery/$advertisment_id/thumbs";
		$q = "select * from advertisment_gallery where advertisment_id='$advertisment_id' order by pos asc;";
		$r = @mysql_query($q);
		if($r && mysql_num_rows($r) > 0) {

            $optres['js'][] = $path . "assets/plugins/galleria/galleria.min.js";
			
			
			
			while ($row = mysql_fetch_assoc($r)) {
				$gallery [] = array_map("stripslashes", $row);
			}
		}

        //echo '<pre>', var_export($gallery, true), '</pre>';

		if(count($gallery) > 0) {
			$optres['css'][] = dirname(__FILE__) . "/css/inline_gallery.css";
			$show_disclaimer['**'] = 'Note: It is the responsibility of the hotel chain and/or the individual property to ensure the accuracy of the photos displayed. "' . str_replace('www.', '', $ultra_domainname) . '" is not responsible for any inaccuracies in the photos.';
			?>
			<div id="org-photo-map" class="row no-margin">
				<div id="business_gallery_container" class="<?php echo $have_map ? 'col-sm-5' : '';?>">
					<h2 class="wb_h2">Photo Gallery **</h2>
					<div id="business_gallery">
						<?php
						$www_root = $_SERVER['HTTP_HOST'];
						if(str_replace('www.', '', $www_root) != str_replace('www.', '', $ultra_domainname) ) {
							$www_root .= "/$ultra_addonname";
						}
						$cnt = 1;
						foreach ($gallery as $i=>$img) {
							$thumb_file = $_SERVER['DOCUMENT_ROOT'] . "/images/advertisments/gallery/$advertisment_id/thumbs/" . $img['filename'];
							$thumb_url = $protocol . $_SERVER['HTTP_HOST'] . "/images/advertisments/gallery/$advertisment_id/thumbs/" . $img['filename'];
							$image_file = $_SERVER['DOCUMENT_ROOT'] . "/images/advertisments/gallery/$advertisment_id/" . $img['filename'];
							$image_url = $protocol . $_SERVER['HTTP_HOST'] . "/images/advertisments/gallery/$advertisment_id/" . $img['filename'];
							
							if(intval( $img['iwt'] <= 16)) $img['iwt'] = 90;
							if(intval( $img['iht'] <= 16)) $img['iht'] = 90;
							
							$data_title = $img['title'];
							$data_description = isset($img['description']) ? $img['description'] : $data_title;
							
							if(file_exists($thumb_file) && file_exists($image_file)) {
								if($cnt == 1) {
									echo '<meta itemprop="image" content="'.$image_url.'"/>';
									echo '<div itemprop="photo" itemscope="itemscope" itemtype="http://schema.org/ImageObject"><a itemprop="contentURL" href="', $image_url, '" title="',$data_title,'"><img itemprop="thumbnailUrl" src="',$thumb_url,'" data-big="',$image_url,'" data-title="',$data_title,'" data-description="',$data_description,'"  alt="',$data_title,'" width="',$img['iwt'],'" height="',$img['iht'],'"/></a></div>';
								}
								else {
									echo '<div itemprop="photo" itemscope="itemscope" itemtype="http://schema.org/ImageObject"><a itemprop="contentURL" href="', $image_url, '" title="',$data_title,'"><img itemprop="thumbnailUrl" src="',$thumb_url,'" data-big="',$image_url,'" data-title="',$data_title,'" data-description="',$data_description,'"  alt="',$data_title,'" width="',$img['iwt'],'" height="',$img['iht'],'"/></a></div>';
								}
							}
							else {
								//echo "<br/>$thumb_file does not exists";
							}
							$cnt ++;
						}
						?>
					</div>
				</div>
				<?php
				if($have_map) {
					?>
					<div id="business_map_container" class="col-sm-5 no-padding">
						<h2 class="wb_h2">Map Location</h2>
						<div id="business_map" itemprop="geo" itemscope="itemscope" itemtype="http://schema.org/GeoCoordinates">
							
							<?php
							$lat = $data['lat'];
							$lng = $data['lng'];
							$zoom = $data['zoom'];
							
							$static_map_url = 'https://maps.googleapis.com/maps/api/staticmap?key=AIzaSyDxpjfVxlLazmPt1gkiw_wIy55ofWAUJvY&' . ('center=' . $lat . ',' . $lng .'&amp;zoom='.$zoom.'&amp;markers=%7C'.$lat . ',' . $lng.'');
                            $def_size = '&amp;size=358x280';
							?>
                            <picture>
                                <!--[if IE 9]><video style="display: none;"><![endif]-->
                                <source srcset="<?=$static_map_url;?>&size=720x300, <?=$static_map_url;?>&size=720x300&scale=2 2x" media="(min-width: 800px)">
                                <source srcset="<?=$static_map_url;?>&size=720x300, <?=$static_map_url;?>&size=720x300&scale=2 2x">
                                <!--[if IE 9]></video><![endif]-->
                                <img srcset="<?=$static_map_url;?>&size=720x300, <?=$static_map_url;?>&size=720x300&scale=2 2x" class="map_directions_link" rel="<?=$data['location_id'];?>" alt="<?=stripslashes($linePopup['short_title_en']);?> on Map">
                            </picture>
                            <!--img src="<?=$static_map_url;?>" class="map_directions_link" rel="<?=$data['location_id'];?>" alt="<?=stripslashes($linePopup['short_title_en']);?> on Map"/-->
							<meta itemprop="latitude" content="<?php echo $lat;?>" />
    						<meta itemprop="longitude" content="<?php echo $lng;?>" />
							
						</div>
					</div>
					<?php
				}
				?>
			</div>
			<?php
		}
		
		

		
		?>
		
		<div id="description">
			<h2><span>Hotel Description</span>
			<?php
			if($video != "") {
				?>
				<div class="video-container pull-right">
					<meta content="<?php echo $linePopup['short_title_en'];?> : Video"/>
					<?php
					$video_id = youtube_id_from_url($video);
					if($video_id) {
						?>
						<a class="fancyvideo fancybox.iframe pull-right" href="https://youtube-nocookie.com/embed/<?php echo $video_id;?>?autoplay=1" title="<?php echo $linePopup['short_title_en'];?> : Video"><i class="fa fa-youtube-play fa-lg"></i> Watch Video</a>
						<?php
					}
					else {
						$video = str_replace("http://www.youtube.com", "https://www.youtube-nocookie.com", $video);
						?>
						<a class="fancyvideo fancybox.iframe pull-right" href="<?php echo $video;?>" title="<?php echo $linePopup['short_title_en'];?> : Video"><i class="fa fa-youtube-play fa-lg"></i> Watch Video</a>
						<?php
					}
					?>
				</div>
				<?php
			}
			?>
            </h2>
			<div id="img" class="pull-right">
                <?php
				if($website != "" && $show_website == 1) {
					if($active == "yes" && $paying_advert) {
						?>
						<a href="click_count.php?link=<?php echo $linePopup["title_tr"];?>&amp;type=www&amp;id=<?php echo $linePopup['advertisment_id'];?>&amp;domain=<?php echo $ultra_domainname;?>&amp;domain_id=<?php echo $domain_id;?>&amp;window=stand&amp;click_from=e" rel="nofollow" class="click-count" target="_blank" title="<?php echo stripslashes($linePopup['short_title_en']);?>">
                            <img src="<?=$screenshot_url;?>w=200&h=150&url=<?php echo urlencode($website);?>" width="200" height="150" border="1" alt="<?php  echo $linePopup['short_title_en'] . ' Website Screenshot'; ?>" />
						</a>
						<?php
					}
					else {
						?>
						<a href="<?php echo fix_url($website);?>" target="_blank" rel="nofollow" class="click-count" title="<?php echo stripslashes($linePopup['short_title_en']);?> website">
                            <img src="<?=$screenshot_url;?>w=200&h=150&url=<?php echo urlencode($website);?>" width="200" height="150" border="1" alt="<?php  echo $linePopup['short_title_en'] . ' Website Screenshot'; ?>" />
						</a>
						<?php
					}
				}
				?>
			</div>
			<?php
				$description_class = 'adv-desc';
				$advert_desc_text = stripslashes(trim($linePopup['description_en']));
				$qv = "select * from advertisment_versions where advertisment_id='$advertisment_id' and domainname='$ultra_domainname';";
				if(isset($_REQUEST['debugv'])) {
					echo "<br/>$qv";
				}
				$rv = @mysql_query($qv);
				if($rv && mysql_num_rows($rv) == 1) {
					$rowv = mysql_fetch_assoc($rv);
					
					$description_class = 'adv-vdesc';
					
					$advert_desc_text = trim(stripslashes($rowv['description_en']));
					if(trim($rowv['meta_description_en']) != "") $advert_meta_description = stripslashes($rowv['meta_description_en']);
					if(trim($rowv['meta_keywords_en']) != "") $advert_meta_keywords = stripslashes($rowv['meta_keywords_en']);
				}
				
				
				
				
				
				
			?>
			<div id="description_content" class="<?php echo $description_class;?>" <?php echo ($have_microdata) ? 'itemprop="description"': '';?>>
				<?php
				$advert_desc_text = utf8_decode($advert_desc_text);
				
				$pattern = "/(<p[^>]*> <\\/p[^>]*>){2,}/"; 
				$advert_desc_text = trim(preg_replace($pattern, '<p> </p>', $advert_desc_text)); 
				
				
				echo $advert_desc_text;
				?>
			</div>
			
			<?php
			if(isset( $fm_uid) && $fm_uid != "") {
				?>
				<div id="org-details">
                    <b>Category</b>
                    <ul class="wb_ul" id="fm_category">
                        <?php
                        echo '<li>';
                        echo $fm_title;
                        echo '</li>';
                        ?>

                    </ul>

					<?php
					foreach ($fcategs[$fm_uid] as $fc_uid=>$fc) {
						if(isset($felems[$fc_uid])) {
							foreach ($felems[$fc_uid] as $i=>$fe) {
								$req = intval($fe['required']) == 1 ? true : false;
								$e_label_admin = $fe['e_label_display'];
								$e_type = $fe['e_type'];
								$e_name = $fe['e_name'];
								$e_id = $fe['e_id'];
								$e_class = $fe['e_class'];
								$e_style = $fe['e_style'];
								$e_db = $fe['e_db'];
								$e_def = $fe['e_def'];
								$fe_uid = $fe['fe_uid'];
								
								// Get the options
								$have_options = false;
								$elem = array();
								$elem['e_db'] = array();
								$options = trim($e_db);
								if($options != "") {
									$opts = unserialize(base64_decode($options));
									if(is_array($opts)) {
										$opts = array_map('stripslashes', $opts);
										$have_options = true;
									}
								}
								
								if($have_options) $elem['e_db'] = $opts;
								
								if($have_options) {
									$show_advert_amenity_content = false;
									ob_start();
									//echo '<pre>', var_export($elem['e_db'], true),'</pre>';
									?>

									<?php
									if($fc['friendly_url'] != "default") {
										?>
                                        <b><?php echo $fc['title'];?></b>
										<?php
									}
									?>
                                    <b><?php echo $e_label_admin;?></b>
                                    <ul class="wb_ul" id="<?php echo $e_name;?>">
                                        <?php
                                        foreach ($elem['e_db'] as $val=>$label) {
                                            if(isset($fvalues[$fe_uid]) && in_array($val, $fvalues[$fe_uid])) {;
                                                echo '<li>';
                                                echo $label;
                                                echo '</li>';
                                                $show_advert_amenity_content = true;
                                            }
                                        }
                                        ?>

                                    </ul>
									<?php
									
									$advert_amenity_content = ob_get_contents();
									ob_end_clean();
									
									if($show_advert_amenity_content) echo $advert_amenity_content;
								}
								
								
							}
						}
						?>
					</div>
					<?php
				}
			}
			?>
			</div>
		<div id="org_tabs">
			<div id="contact">
				<?php
				$cnt = 1;
				$location_title = trim(stripslashes($data['location_title']));
				if($location_title != "") {
					if($location_title == "Address Details") $location_title = '';
				}
				
				ob_start();
				?>
                <div class="table-responsive"></div>
				<table class="table table-bordered">
                    <thead>
					<tr>
                        <th colspan="2">Contact Details</th>
                    </tr>
                    </thead>
                    <tbody>
					<?php
					if(trim($data['street']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>Street</b></td>
							<td>
								<?php
								echo stripslashes($data['street']), ' ', $data['street_no'];
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['building_name']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>Building</b></td>
							<td>
								<?php
								echo stripslashes($data['building_name']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['floor']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>Floor</b></td>
							<td>
								<?php
								echo stripslashes($data['floor']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['flat']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>Flat</b></td>
							<td>
								<?php
								echo stripslashes($data['flat']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['city']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>Location</b></td>
							<td>
								<?php
								echo stripslashes($data['city']);
								if($cnt == 1) {
									$meta_loc = trim(stripslashes($data['city']));
								}
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['area']) != "" && $data['lcode'] == "") {
						?>
						<tr>
							<td class="col-xs-4"><b>Area</b></td>
							<td>
								<?php
								echo stripslashes($data['area']);
								if($cnt == 1) {
									if($meta_loc == "") {
										$meta_loc = trim(stripslashes($data['area']));
									}
								}
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['postalcode']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>Postal Code</b></td>
							<td>
								<?php
								echo stripslashes($data['postalcode']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['district']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>District</b></td>
							<td>
								<?php
								echo stripslashes($data['district']);
								if($cnt == 1) {
									if($meta_loc == "") {
										$meta_loc = trim(stripslashes($data['district']));
									}
									elseif($meta_loc != trim(stripslashes($data['district']))) {
										$meta_loc .= ", " . trim(stripslashes($data['district']));
									}
								}
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['country']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>Country</b></td>
							<td>
								<?php
								echo "CYPRUS";
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['pobox']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>P.O. Box</b></td>
							<td>
								<?php
								echo stripslashes($data['pobox']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['pobox_postalcode']) != "") {
						?>
						<tr>
							<td class="col-xs-4"><b>P.O. Box Postal Code</b></td>
							<td>
								<?php
								echo stripslashes($data['pobox_postalcode']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['contact_name']) != "" || trim($data['tel1']) != "") {
						
						if(trim($data['contact_name']) != "") {
							?>
							<tr>
								<td class="col-xs-4"><b>Contact Name</b></td>
								<td>
									<?php
									echo stripslashes($data['contact_name']);
									if(trim($data['contact_title']) != "") echo '&nbsp;(', stripslashes($data['contact_title']), ')';
									?>
								</td>
							</tr>
							<?php
						}
						
						if(trim($data['email']) != "") {
							?>
							<tr>
								<td class="col-xs-4"><b>E-mail</b></td>
								<td>
									<span class="email-str">
									<?php
									echo str_replace('@', '[ at ]', stripslashes($data['email']));
									?>
									</span>
								</td>
							</tr>
							<?php
						}
						
						if($website != "" && $show_website == 1) {
							?>
							<tr>
								<td class="col-xs-4"><b>Website</b></td>
								<td>
									<?php
									if($seo) {
										echo wordwrap($website, 33, "\n", true); 
									}
									else {
										echo wordwrap($website, 33, "\n", true); 
									}
									?>
								</td>
							</tr>
							<?php
						}
						
						if(trim($data['mobile1']) != "" || trim($data['mobile2']) != "") {
							?>
							<tr>
								<td class="col-xs-4"><b>Mobile #</b></td>
								<td>
                                    <span itemprop="telephone">
									<?php
									if($data['mobile1'] != "") {
										echo '(+357) ' . number_format($data['mobile1'], null, null, ' ');
										if($data['mobile2'] != "") echo '; '. '(+357) ' . number_format($data['mobile2'], null, null, ' ');
									}
									else {
										if($data['mobile2'] != "") echo '(+357) ' . number_format($data['mobile2'], null, null, ' ');
									}
									?>
                                    </span>
								</td>
							</tr>
							<?php
						}
						
						if(trim($data['tel1']) != "" || trim($data['tel2']) != "") {
							?>
							<tr>
								<td class="col-xs-4"><b>Phone #</b></td>
								<td>
                                    <span itemprop="telephone">
									<?php
									if($data['tel1'] != "") {
										echo '(+357) ' . number_format($data['tel1'], null, null, ' ');
										if($data['tel2'] != "") echo '; '. '(+357) ' . number_format($data['tel2'], null, null, ' ');
									}
									else {
										if($data['tel2'] != "") echo '(+357) ' . number_format($data['tel2'], null, null, ' ');
									}
									?>
                                    </span>
								</td>
							</tr>
							<?php
						}
						
						if(trim($data['fax']) != "") {
							?>
							<tr>
								<td class="col-xs-4"><b>Fax #</b></td>
								<td>
									<?php
									echo '(+357) ' . number_format($data['fax'], null, null, ' ');
									?>
								</td>
							</tr>
							<?php
						}
						
					}
					?>
                    </tbody>
				</table>
				
				<?php
				$location_details = ob_get_contents();
				ob_end_clean();
				echo $location_details;
				?>
			</div>
			<div id="general">
				<?php
				if(trim($linePopup['YearOfEstablishment']) != "" || trim($linePopup['Directors']) != "" 
					|| trim($linePopup['NumberOfEmployees']) != "" || trim($linePopup['MemberOf']) != "") { 
					?>
					<table class="table table-bordered">
						<thead>
                        <tr>
                            <th colspan="2">Company Information</th>
                        </tr>
                        </thead>
                        <tbody>
						<?php 
					 
						if(trim($linePopup['YearOfEstablishment']) != ""){ 
							?>
							<tr>
								<td class="col-xs-4"><b>Year of Establishment</b></td>
								<td><?php echo $linePopup['YearOfEstablishment']; ?></td>
							</tr>
							<?php 
						} 
						if(trim($linePopup['Directors']) != ""){ 
							?>
							<tr>
								<td class="col-xs-4"><b>Directors</b></td>
								<td><?php echo $linePopup['Directors']; ?></td>
							</tr>
							<?php 
						} 
						if(trim($linePopup['MemberOf']) != ""){ 
							?>
							<tr>
								<td class="col-xs-4"><b>Member of</b></td>
								<td><?php echo $linePopup['MemberOf']; ?></td>
							</tr>
							<?php 
						} 
						if(trim($linePopup['NumberOfEmployees']) != ""){ ?>
							<tr>
								<td class="col-xs-4"><b>Number of Employees</b></td>
								<td><?php echo $linePopup['NumberOfEmployees']; ?></td>
							</tr>
							<?php 
						}
						?>
                        </tbody>
					</table>
					<?php
				}
				?>
			</div>
		</div>
		
		

    </div>
	<?php
	// Get the nearby places
	$lat = $data['lat'];
	$lng = $data['lng'];
	$nearby_places_query = "SELECT 
				dest.*,
				(3956 * 2 * ASIN(SQRT(POWER(SIN(($lat - abs( dest.lat)) * pi()/180 / 2),2) + COS($lat * pi()/180 ) * COS( abs(dest.lat) *  pi()/180) * POWER(SIN(($lng - dest.lng) *  pi()/180 / 2), 2) ))) * 1.60934 as distance
			FROM 
				main_article dest
			WHERE
				dest.catdom_id='$domain_id'
				and dest.lat!=''
			HAVING distance < 30
			ORDER BY distance limit 0,12;";
	
	//echo $nearby_places_query;
	
	$r_nearby_places_query = @mysql_query($nearby_places_query);
	if($r_nearby_places_query && mysql_num_rows($r_nearby_places_query) > 0) {
		$nearby_places = array();
		while ($row_place = mysql_fetch_assoc($r_nearby_places_query)) {
			$nearby_places [] = array_map('stripslashes', $row_place);
		}

        //echo '<pre>$nearby_places = ', var_export($nearby_places, true), '</pre>';
		
		if(count($nearby_places) > 0) {
			echo '<br/>';
			require_once(dirname(__FILE__) . "/../nearby_places/nearby_places.php");
		}
	}
	
	// Get the nearby hotels
	if(isset($data['lat']) && floatval($data['lat']) > 0) {
		$hlat = $data['lat'];
		$hlng = $data['lng'];
		$nearby_hotels_query = " SELECT 
				dest.adv_code,
				dest.lat,
				dest.lng,
				(3956 * 2 * ASIN(SQRT(POWER(SIN(($hlat - abs( dest.lat)) * pi()/180 / 2),2) + COS($hlat * pi()/180 ) * COS( abs(dest.lat) *  pi()/180) * POWER(SIN(($hlng - dest.lng) *  pi()/180 / 2), 2) ))) * 1.60934 as distance
			FROM 
				advertisment_locations dest,
				wb_categories_adverts w
			WHERE
				dest.main_location='1'
				AND dest.adv_code=w.wb_advert_uid
				AND w.wb_uid='$wb_uid'
				AND dest.adv_code!='$adv_code'
			HAVING distance < 30
			ORDER BY distance limit 10;";
		
		if(isset($_REQUEST['nearby'])) echo $nearby_hotels_query;
	
	}
	
	if($meta_loc != "") {
		$meta_params['location'] = $meta_loc;
		$meta_description_temp = str_replace($meta_replacements, $meta_params, $meta_phrase);
		/*
		$meta_description_count = mb_strlen(trim($meta_description_temp), 'UTF-8');
		if($meta_description_count < 10) {
			$meta['description'] = $meta_description_temp . '. ' . mb_substr(trim(strip_tags($advert_meta_description)), 0, (150 - $meta_description_count));
		}
		else {
			$meta['description'] = $meta_description_temp;
		}
		*/
		
		if($advert_use_meta == 1 && trim($advert_meta_description) != "") {
			$meta['description'] = $advert_meta_description;
			$meta['keywords'] = $advert_meta_keywords;
		}
		else {
			$meta['description'] = $meta_description_temp;
		}
	}
	
	if(isset($show_disclaimer) && count($show_disclaimer) > 0) {
        ?>
        <div class="article-body">
            <div class="alert alert-info">
            <?php
            echo '<p><strong>Disclaimer:</strong> Hotel descriptions are provided by third parties. Cyprus-Hotel.com is not responsible for any inaccuracies in these descriptions.</p>';
            foreach ($show_disclaimer as $dstar=>$dtext) {
                echo '<p><strong>', $dstar, '</strong> ', $dtext, '</p>';
            }
            ?>
            </div>
        </div>
        <?php
	}

	
	
	// Add to the right_pool the vertical hotels
	if(isset($req_modules['vhotels'])) {
		$module_vhots_display = 1;
		$rc = array (
			  'module_id' => $req_modules['vhotels']['module_id'],
			  'module_params' => '',
			  'module_active' => 'yes',
			  'type' => 'module',
			  'location' => 'right',
			  'home_page' => '1',
			  'sec_page' => '1',
			);
			
		$right_pool [] = $rc;
	}

    $optres['js'][] = $path . 'amodules/client_stand/js/client_stand_x_loader.js';
	?>
    </div>
    <script type="text/javascript">
        var client_stand_x_init = '<?php echo $path . 'amodules/client_stand/js/client_stand_x.js'; ?>';
        var click_link = '<?php echo $click_count_path;?>';
        var minDate = '<?php echo (isset($_SESSION['hotel_search']['checkin'])) ? $_SESSION['hotel_search']['checkin'] : date("d/m/Y", strtotime("+1 day"));?>';
        var min_checkout_date = '<?php echo (isset($_SESSION['hotel_search']['checkin'])) ? $min_checkout_date : date("d/m/Y", strtotime("+2 day"));?>';
        var max_checkout_date = '<?php echo (isset($_SESSION['hotel_search']['checkin'])) ? $max_checkout_date : date("d/m/Y", strtotime("+29 day"));?>';
    </script>
	<?php
}
else{
	$send404 = true;
	require_once(dirname(__FILE__) . "/../404/404.php");
}

//echo '<pre>', var_export($optres['css'], true), '</pre>';

?>