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

$left_pool_empty = true;

$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']);
$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 ['css'][] = $path . "client_stand_x.css";
//$optres ['css'][] = $path . "css/prettyPhoto.css";
//$optres ['js'][] = $path . "js/jquery.prettyPhoto.js";

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


$optres ['css'][] = $path . "modules/client_stand/css/booking-form.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";

/******************************************************************************************************/
$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' 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']);
		$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)) {
			$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("../general/functions.php");
}
else {
	require_once($general_path . "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 = '';
	$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 = trim($linePopup['website']);
	$shortNameURL = trim($linePopup['title_tr']);
	
	$protocol = "http://";
	if(strpos($website, "https://") !== false) $protocol = "https://";
	$website = str_replace("$protocol", "", $website);
	if($website != "") {
		$website = $protocol . $website;
	}
	
	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&amp;cc=1";
	}
	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;
	
	ob_start();
	
	if(trim($data['street']) != "") {
		?>
		<span <?php echo ($have_microdata) ? 'itemprop="streetAddress"':'';?>>
		<?php
		echo stripslashes($data['street']), ' ', $data['street_no'];
		?>
		</span>
		<?php
	}
			
	if(trim($data['building_name']) != "") {
		echo ', ', stripslashes($data['building_name']);
	}
			
	if(trim($data['floor']) != "") {
		echo ', Floor ' . stripslashes($data['floor']);
	}
			
	if(trim($data['flat']) != "") {
		echo ', Flat ', stripslashes($data['flat']);
	}
	
	if(trim($data['pobox']) != "") {
		echo ', P.O. Box <span itemprop="postOfficeBoxNumber">', stripslashes($data['pobox']), '</span>';
	}
			
	if(trim($data['pobox_postalcode']) != "") {
		echo ', P.O. Box Postal Code ', stripslashes($data['pobox_postalcode']);
	}
	
		
	if(trim($data['city']) != "") {
		$hotel_aff_location = $data['city'];
		echo ', <span itemprop="addressLocality">', stripslashes($data['city']), '</span>';
	}
	
	if(trim($data['postalcode']) != "") {
		echo ' <span itemprop="postalCode">', stripslashes($data['postalcode']), '</span>';
	}
	elseif(trim($data['pobox_postalcode']) != "") {
		echo ' <span itemprop="postalCode">', stripslashes($data['pobox_postalcode']), '</span>';
	}
	
	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'];
		}
		
		echo ', <span itemprop="addressRegion">', trim(stripslashes($data['district'])), '</span> District';
	}
	
	echo ', <span itemprop="addressCountry">CYPRUS</span>';
	
	$business_address = ob_get_contents();
	ob_end_clean();
	
	/*******************************************************************************************************/
	
	?>
	<div id="popup" <?php echo ($have_microdata) ? 'itemscope="itemscope" itemtype="' . $microdata_types[$microdata_domain]['adverts']['type'] . '"' : '';?>>
	<meta itemprop="currenciesAccepted" content="EUR"/>
	<?php
	if(isset($aff) && count($aff) > 0) {
		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 != "") {
				echo '<span class="book_title">' . $book_title . '</span><br/>';
			}
			
			if($book_text != "") {
				echo '<span class="book_text">' . $book_text . '<br/></span>';
			}
			?>
			<form id="booking-form" action="">
				<?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="checkinout">
					<span class="fldst first">
						<label id="lbl_checkIn" for="checkin">Check In</label>
						<input type="text" id="checkin" value="<?php echo $def_checkin;?>" class="sprite-calendar-ylw text datepicker checkin" name="checkin"/>
					</span>
						<span class="fldst chk-out cal ">
						<label id="lbl_checkOut" for="checkout">Check Out</label>
						<input type="text" id="checkout" value="<?php echo $def_checkout;?>" class="sprite-calendar-ylw text datepicker checkout" name="checkout"/>
					</span>
					<span class="fldst adults">
						<label for="adults">Adults</label> 
						<select id="adults" name="adults" onchange="">
						<?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>
					</span>
				</div>
				
				<?php
				if($hotel_aff) {
					?>
					<div id="check-prices">
						Show Prices *
					</div>
					<?php
					
					if($min_price > 0) {
						
						$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="hotel_avg_rate" itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/AggregateOffer">
							From<sup style="font-size:13px;">*</sup> <span class="hotel_price" itemprop="lowPrice">&euro; <?php echo number_format($min_price, 0);?></span>
							<meta itemprop="highPrice" content="&euro; <?php echo number_format($max_price, 0);?>"/>
							<meta itemprop="offerCount" content="<?php echo count($aff);?>" />
						</div>
						<?php
					}
				}
				else {
					?>
					<div id="find-hotels">
						Find Hotels *
					</div>
					<input type="hidden" name="destination" id="destination" value="<?php echo $hotel_aff_location;?>"/>
					<?php
				}
				?>
				<div style="clear: both;"></div>
				
				<div class="aff_providers_container">
					<ul class="aff_provider">
						<?php
						$book_links = array();
						foreach ($aff as $aff_code => $aff_data) {
							if($hotel_aff) {
								?>
								<li>
									<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>
								</li>
								<?php
							}
							else {
								?>
								<li>
									<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>
								</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>
			<?php
			/*
			$book_links = array();
			foreach ($aff as $aff_code => $aff_data) {
				
				if($aff_data['aff_name'] == "Expedia.com") {
					$book_links [] = 'From under <strong>&euro; '. number_format($aff_data['low_rate'], 2, '.', ' ') .'</strong> on <a href="'. $aff_data['deep_link_book']. '" target="_blank">'. $aff_data['aff_name']. '</a>';
				}
				
				if($aff_data['aff_name'] == "Booking.com") {
					$book_links [] = 'From under <strong>&euro; '. number_format($aff_data['low_rate'], 2, '.', ' ') .'</strong> on <a href="'. $aff_data['deep_link_dates']. '" target="_blank">'. $aff_data['aff_name']. '</a>';
				}
			}
			echo implode("<br/>", $book_links);
			*/
			?>
		</div>
		<?php
	}
	/*******************************************************************************************/
	// Social Plugin
	//include(dirname(__FILE__) . "/../sm/sm.php");
	
	
	/*********************************************************************************************/
	?>
	
		<div id="org-header"></div>
		<h1 id="businessName" <?php echo ($have_microdata) ? 'itemprop="name"': '';?>><?php 
			if($seo) {
				?>
				<a href="<?php echo $linePopup["title_tr"];?>" target="_self" class="h1-link"><?php echo stripslashes($linePopup['short_title_en']);?></a>
				<?php

			}
			else {
				echo stripslashes($linePopup['short_title_en']); 
			}
			?></h1>
		<?php
		if(isset($rating) && $rating['uid'] != '') {
			if($rating['var'] == 'star_rating') {
				echo '<span id="business_rating" class="stars_rating_bk">';
				echo '<meta itemprop="rating" content="', $rating['text'], '"/>';
				echo '<span class="business_', $rating['var'] ,' ', $rating['class'], '" title="'.$rating['text'].'">', (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 itemprop="rating" content="', $rating['text'], '"/>';
				echo '</span>';
			}
		}
		?>
		<div class="sm-org">
			<?php
			include(dirname(__FILE__) . "/../sm/sm.php");
			?>
		</div>
		<div style="clear: both;"></div>
		<div id="business-address" itemprop="address" itemscope="itemscope" itemtype="http://schema.org/PostalAddress">
			<?php
			echo $business_address;
			?>
		</div>
		<div id="business-tools">
			<?php
			if($website != ""){ 
				echo ($have_microdata) ? '<meta itemprop="url" content="http://'. $_SERVER['HTTP_HOST'] . '/' . $linePopup["title_tr"].'"/>': '';
				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" target="_blank" rel="nofollow" title="<?php echo stripslashes($linePopup['short_title_en']);?>">Hotel Website</a>
					<?php 
					
				}
				else {
					?>
					<a href="<?php echo $website;?>" target="_blank" rel="nofollow" title="<?php echo stripslashes($linePopup['short_title_en']);?>">Hotel Website</a>
					<?php
				}
				
				
			}
			
			if($website != "" && trim($linePopup['email']) != "") echo " | "; 
			if($linePopup['email']){
				echo ($have_microdata) ? '<meta itemprop="email" content="'.$linePopup['email'].'"/>': '';
				?><a href="javascript:;" class="mailto" rel="<?php echo str_replace('@', '[ at ]', $linePopup['email']); ?>">Send Email</a><?php 
			} 
			?>
		</div>

		<?php
		
		// 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'][] = $_SERVER['DOCUMENT_ROOT'] . "/js/galleria-1.2.9.min.js";
			
			
			
			while ($row = mysql_fetch_assoc($r)) {
				$gallery [] = array_map("stripslashes", $row);
			}
		}
		
		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">
				<div id="business_gallery_container">
					<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 = "http://" . $_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 = "http://" . $_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'] : '';
							
							if(file_exists($thumb_file) && file_exists($image_file)) {
								if($cnt == 1) {
									echo '<a href="', $image_url, '"><img itemprop="image" 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>';
								}
								else {
									echo '<a href="', $image_url, '"><img 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>';
								}
							}
							else {
								//echo "<br/>$thumb_file does not exists";
							}
							$cnt ++;
						}
						?>
					</div>
				</div>
				<?php
				if($have_map) {
					?>
					<div id="business_map_container">
						<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 = 'http://maps.google.com/maps/api/staticmap?' . ('center=' . $lat . ',' . $lng .'&amp;zoom='.$zoom.'&amp;size=358x280&amp;markers=%7C'.$lat . ',' . $lng.'&amp;sensor=false');
							echo '<img src="', $static_map_url,'" border="0" width="358" height="280" 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 style="clear: both;"></div>
			</div>
			<?php
		}
		
		
		/*
		// Get images if it has 
		$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) {
			while ($row = mysql_fetch_assoc($r)) {
				$gallery [] = array_map("stripslashes", $row);
			}
		}
		
		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">
				<div id="business_gallery_container">
				<h2 class="wb_h2">Photo Gallery **</h2>
					<ul id="business_gallery">
						<?php
						if(is_array($gallery) && count($gallery) > 0) {
							$photo_path = $path . "images/advertisments/gallery/" . $advertisment_id . "/";
							$cnt = 0;
							foreach ($gallery as $i=>$photo) {
								$photo_location = $photo_path . $photo['filename'] . '';
								$photo_location_th = $photo_path . "thumbs/" . $photo['filename'];
								if($cnt == 0) {
									?>
									<li>
										<img itemprop="image" data-frame="<?php echo $photo_location_th;?>" src="<?php echo $photo_location;?>" alt="<?php echo stripslashes($photo['title']);?>" title="<?php echo stripslashes($linePopup['short_title_en']);?>" data-description="<?php echo stripslashes($photo['title']);?>" />
									</li>
									<?php
								}
								else {
									?>
									<li>
										<img data-frame="<?php echo $photo_location_th;?>" src="<?php echo $photo_location;?>" alt="<?php echo stripslashes($photo['title']);?>" title="<?php echo stripslashes($linePopup['short_title_en']);?>" data-description="<?php echo stripslashes($photo['title']);?>" />
									</li>
									<?php
								}
								$cnt++;
							}
						}
						?>
					</ul>
				</div>		
				<?php
				if($have_map) {
					?>
					<div id="business_map_container">
						<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 = 'http://maps.google.com/maps/api/staticmap?' . ('center=' . $lat . ',' . $lng .'&amp;zoom='.$zoom.'&amp;size=370x367&amp;markers=%7C'.$lat . ',' . $lng.'&amp;sensor=false');
							echo '<img src="', $static_map_url,'" border="0" width="370" height="367" 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 style="clear: both;"></div>
			</div>
			<?php
		}
		
		*/
		
		
		?>
		
		<div id="org-description">
			<h2 class="wb_h2">About <em><?php echo $linePopup['short_title_en'];?></em></h2>
			<div id="img"><?php
				if($website != "") {
					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="http://simple.thumbshots.com/image.pxf?cid=843&amp;v=1&amp;w=200&amp;h=150&amp;url=<?php echo $website;?>" width="200" height="150" border="0" alt="<?php  echo $linePopup['short_title_en']; ?>" />
						</a>
						<?php
					}
					else {
						?>
						<a href="<?php echo $website;?>" target="_blank" rel="nofollow" class="click-count" title="<?php echo stripslashes($linePopup['short_title_en']);?> website">
							<img src="http://simple.thumbshots.com/image.pxf?cid=843&amp;v=1&amp;w=200&amp;h=150&amp;url=<?php echo $website;?>" width="200" height="150" border="0" alt="<?php  echo $linePopup['short_title_en']; ?> website" />
						</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="org-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">
					<h2 class="wb_h2">Category</h2>
					<ul class="wb_ul" id="fm_category">
						<?php
								echo '<li>';
								echo $fm_title;
								echo '</li>';
						?>
						
					</ul>
					<div class="clear-all"></div>
					<?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>';
									?>
									<div style="clear: both"></div>
									<?php
									if($fc['friendly_url'] != "default") {
										?>
										<h2><?php echo $fc['title'];?></h2>
										<?php
									}
									?>
									<h2 class="wb_h2"><?php echo $e_label_admin;?></h2>
									<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>
									<div class="clear-all"></div>
									<?php
									
									$advert_amenity_content = ob_get_contents();
									ob_end_clean();
									
									if($show_advert_amenity_content) echo $advert_amenity_content;
								}
								
								
							}
						}
						?>
					</div>
					<?php
				}
			}
			?>
			</div>
		<div style="clear: both;"></div>
		<div id="org_tabs">
			<div id="contact">
				<h2 class="wb_h2">Contact Details</h2>
				<?php
				$cnt = 1;
				$location_title = trim(stripslashes($data['location_title']));
				if($location_title != "") {
					if($location_title == "Address Details") $location_title = '';
				}
				
				ob_start();
				?>
				<table cellpadding="0" cellspacing="0" border="0" width="100%" class="org-details-tb">
					
					<?php
					if(trim($data['street']) != "") {
						?>
						<tr>
							<td class="label" nowrap="nowrap">Street</td>
							<td align="left">
								<?php
								echo stripslashes($data['street']), ' ', $data['street_no'];
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['building_name']) != "") {
						?>
						<tr>
							<td class="label" nowrap="nowrap">Building</td>
							<td align="left">
								<?php
								echo stripslashes($data['building_name']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['floor']) != "") {
						?>
						<tr>
							<td class="label" nowrap="nowrap">Floor</td>
							<td align="left">
								<?php
								echo stripslashes($data['floor']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['flat']) != "") {
						?>
						<tr>
							<td class="label" nowrap="nowrap">Flat</td>
							<td align="left">
								<?php
								echo stripslashes($data['flat']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['city']) != "") {
						?>
						<tr>
							<td class="label" nowrap="nowrap">Location</td>
							<td align="left">
								<?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="label" nowrap="nowrap">Area</td>
							<td align="left">
								<?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="label" nowrap="nowrap">Postal Code</td>
							<td align="left">
								<?php
								echo stripslashes($data['postalcode']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['district']) != "") {
						?>
						<tr>
							<td class="label" nowrap="nowrap">District</td>
							<td align="left">
								<?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="label" nowrap="nowrap">Country</td>
							<td align="left">
								<?php
								echo "CYPRUS";
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['pobox']) != "") {
						?>
						<tr>
							<td class="label" nowrap="nowrap">P.O. Box</td>
							<td align="left">
								<?php
								echo stripslashes($data['pobox']);
								?>
							</td>
						</tr>
						<?php
					}
					
					if(trim($data['pobox_postalcode']) != "") {
						?>
						<tr>
							<td class="label" nowrap="nowrap">P.O. Box Postal Code</td>
							<td align="left">
								<?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="label" nowrap="nowrap">Contact Name</td>
								<td align="left">
									<?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="label" nowrap="nowrap">E-mail</td>
								<td align="left">
									<span class="email-str">
									<?php
									echo str_replace('@', '[ at ]', stripslashes($data['email']));
									?>
									</span>
								</td>
							</tr>
							<?php
						}
						
						if($website != "") {
							?>
							<tr>
								<td class="label" nowrap="nowrap">Website</td>
								<td align="left">
									<?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="label" nowrap="nowrap">Mobile #</td>
								<td align="left">
									<?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, ' ');
									}
									?>
								</td>
							</tr>
							<?php
						}
						
						if(trim($data['tel1']) != "" || trim($data['tel2']) != "") {
							?>
							<tr>
								<td class="label" nowrap="nowrap">Phone #</td>
								<td align="left">
									<?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, ' ');
									}
									?>
								</td>
							</tr>
							<?php
						}
						
						if(trim($data['fax']) != "") {
							?>
							<tr>
								<td class="label" nowrap="nowrap">Fax #</td>
								<td align="left">
									<?php
									echo '(+357) ' . number_format($data['fax'], null, null, ' ');
									?>
								</td>
							</tr>
							<?php
						}
						
					}
					?>
				</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']) != "") { 
					?>
					<h2 class="wb_h2">Company Information</h2>
					<table cellpadding="0" cellspacing="0" border="0" width="100%" class="org-details-tb">
						
						<?php 
					 
						if(trim($linePopup['YearOfEstablishment']) != ""){ 
							?>
							<tr>
								<td class="label" nowrap="nowrap">Year of Establishment</td>
								<td><?php echo $linePopup['YearOfEstablishment']; ?></td>
							</tr>
							<?php 
						} 
						if(trim($linePopup['Directors']) != ""){ 
							?>
							<tr>
								<td class="label" nowrap="nowrap">Directors</td>
								<td><?php echo $linePopup['Directors']; ?></td>
							</tr>
							<?php 
						} 
						if(trim($linePopup['MemberOf']) != ""){ 
							?>
							<tr>
								<td class="label" nowrap="nowrap">Member of</td>
								<td><?php echo $linePopup['MemberOf']; ?></td>
							</tr>
							<?php 
						} 
						if(trim($linePopup['NumberOfEmployees']) != ""){ ?>
							<tr>
								<td class="label" nowrap="nowrap">Number of Employees</td>
								<td><?php echo $linePopup['NumberOfEmployees']; ?></td>
							</tr>
							<?php 
						}
						?>
					</table>
					<?php
				}
				?>
			</div>
		</div>
		
		<?php
		if(isset($show_disclaimer) && count($show_disclaimer) > 0) {
			echo '<div class="general-disclaimer">';
			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>';
			}
			echo '</div>';
		}
		?>
	</div>
	<?php
	
	// Get the nearby hotels
	if(isset($data['lat']) && floatval($data['lat']) > 0) {
		$hlat = $data['lat'];
		$hlng = $data['lng'];
		$q = " 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;";
		
		//echo $q;
	
	}
	
	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;
		}
	}
	
	// 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;
	}
	
	?>
<script type="text/javascript">
//<![CDATA[	
	var map_gmap = null;
	var myLatlng = null;
	var infoWindow = null;
	var markerArray = [];
	var infowindows = [];
	
	function openDirections(loc_id) {
		var $directions_dialog = $('<div id="directions_dialog"></div>');
		$directions_dialog.dialog({
			autoOpen: false,
			position: 'top',
			modal: true,
			dialogClass: "company_dialog",
			title: 'Get Map Directions',
			width: $(document).width() - 20,
			height: <?php echo ( isset($_REQUEST['page']) ? '$(window.parent).height()-20' : '$(window).height()-20'); ?>,
			open: function(event, ui) {
				//$('#stamp').val(new Date.getTime());
				var $frm = $('<iframe id="process_frm" name="process_frm"></iframe>');
				$frm.attr('src', '<?php echo $path;?>modules/adverts_map/map_directions.php?location_id=' + loc_id);
				$frm.attr('width', '100%');
				$frm.attr('height', '98%');
				$frm.css('border', '1px solid #000000');
				$frm.css('overflow-y', 'hidden');
				$('#directions_dialog').append($frm);
				
			},
			close: function(event, ui) {
				$('#process_frm').remove();
				$directions_dialog.dialog('destroy');
				$directions_dialog.remove();
			},
			buttons: {
				'Close': function(event, ui) {
					$(this).dialog('close');
				}
			}
		});
		$directions_dialog.dialog('open');
	}
	
	function openBigMap(loc_id) {
		var $directions_dialog = $('<div id="directions_dialog"></div>');
		$directions_dialog.dialog({
			autoOpen: false,
			position: 'top',
			modal: true,
			dialogClass: "company_dialog",
			title: 'Get Map Directions',
			width: $(document).width() - 20,
			height: <?php echo ( isset($_REQUEST['page']) ? '$(window.parent).height()-20' : '$(window).height()-20'); ?>,
			open: function(event, ui) {
				//$('#stamp').val(new Date.getTime());
				var $frm = $('<iframe id="process_frm" name="process_frm"></iframe>');
				$frm.attr('src', '<?php echo $path;?>modules/adverts_map/map_enlarge.php?location_id=' + loc_id);
				$frm.attr('width', '100%');
				$frm.attr('height', '98%');
				$frm.css('border', '1px solid #000000');
				$frm.css('overflow-y', 'hidden');
				$('#directions_dialog').append($frm);
				
			},
			close: function(event, ui) {
				$('#process_frm').remove();
				$directions_dialog.dialog('destroy');
				$directions_dialog.remove();
			},
			buttons: {
				'Close': function(event, ui) {
					$(this).dialog('close');
				}
			}
		});
		$directions_dialog.dialog('open');
	}
	
	
	function init_gmap(lat, lng, zoom) {

		myLatlng = new google.maps.LatLng(lat * 1, lng * 1);
	    var myOptions = {
	      zoom: zoom * 1 - 1,
	      center: myLatlng,
	      mapTypeId: google.maps.MapTypeId.ROADMAP
	    }
		map_gmap = new google.maps.Map(document.getElementById("gmap_canvas"), myOptions);
		
		
		// Creating a marker and positioning it on the map
		var marker = new google.maps.Marker({
			position: myLatlng,
			map: map_gmap
		});
		
		markerArray.push(marker);
		
		google.maps.event.trigger(map_gmap, 'resize');
		map_gmap.setZoom( map_gmap.getZoom() );
		//AutoCenter();
	}
	
	function AutoCenter() {
		//  Create a new viewpoint bound
		var bounds = new google.maps.LatLngBounds();
		//  Go through each...
		$.each(markerArray, function (index, marker) {
			bounds.extend(marker.position);
		});
		//  Fit these bounds to the map
		map_gmap.fitBounds(bounds);
	}

	
	
	function resizeMap(){
		google.maps.event.trigger(map_gmap, "resize");
		map_gmap.setCenter(myLatlng);
	}
	
	function init_gmap_null() {
		return true;
	}
	
	
	function appendBootstrap() {
		var script = document.createElement("script");
		script.type = "text/javascript";
		script.src = "http://maps.google.com/maps/api/js?v=3.4&sensor=false&callback=init_gmap_null&language=en&region=CY";
		//document.body.appendChild(script);
		$('head').append(script);
	}
	
	function makeMarker(options, info_content){
		var pushPin = new google.maps.Marker({map:map_gmap});
		pushPin.setOptions(options);
		markerArray.push(pushPin);
		google.maps.event.addListener(pushPin, 'click', function(){
			var infowindow = new google.maps.InfoWindow({
			    content: info_content
			});
			
			infowindows.push(infowindow);
			infowindow.open(map_gmap, pushPin);
		});
		
		
		return pushPin;
	}
	
	function showMarker(i){
		google.maps.event.trigger(markerArray[i], 'click');
	};
	
	function open_popup(url, win, specs) {
		var new_win = window.open(url, win, specs + "menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes");
	}
	
	$(document).ready(function(){
		
		/*
		$('#business_gallery').galleryView({
			enable_overlays: true,
			overlay_position: 'top',
			panel_width: 400,
			panel_height: 300,
			frame_width: 60,
			frame_height: 60,
			show_infobar: true,	//BOOLEAN - flag to show or hide infobar
			infobar_opacity: 1,
			show_captions: false //BOOLEAN - flag to show or hide frame captions 
		});
		*/
		
		Galleria.loadTheme('http://<?php echo $_SERVER['HTTP_HOST']?>/css/themes/classic/galleria.classic.js');
		Galleria.run('#business_gallery', {
			height: 300,
			width: 410,
			lightbox: true,
			imageCrop: true
		});
		
		
		var click_link = '<?php echo $click_count_path;?>';
		$('.click-link').each(function(){
			var sub_content = '<a href="' + click_link + '" target="_blank">' + $(this).html() + '</a>';
			$(this).replaceWith(sub_content);
		});
		
		//appendBootstrap();
		
		$('a.mailto').each(function(){
			var email = $(this).attr('rel');
			email = email.replace('[ at ]', '@');
			$(this).attr('href', 'mailto:' + email);
		});
		
		$('.email-str').each(function(){
			var email = $(this).html();
			email = email.replace('[ at ]', '@');
			$(this).html(email);
		});
		
		
		$('.map_directions_link').live('click', function(e){
			e.preventDefault();
			var loc_id = $(this).attr('rel');
			openDirections(loc_id);
			return false;
		});
		
		$('.map_enlarge_link').live('click', function(e){
			e.preventDefault();
			var loc_id = $(this).attr('rel');
			openBigMap(loc_id);
			return false;
		});
		
		$('a.click-count').each(function(i){
			var field = "cc";
			var href = $(this).attr('href');
			var cc_type = -1;
			
			
			if(href.indexOf('?' + field + '=') != -1) {
			    cc_type = 1;
			}
			else if(href.indexOf('&' + field + '=') != -1) {
			    cc_type = 2;
			}
			else if(href.indexOf('?') != -1) {
			    cc_type = 0;
			    $(this).attr('href', href + '&cc=1');
			}
			else {
				cc_type = -1;
			    $(this).attr('href', href + '?cc=1');
			}
		});
		
		// Dates
		$( "#checkin" ).datepicker({
			//defaultDate: "+1w",
			minDate: '<?php echo (isset($_SESSION['hotel_search']['checkin'])) ? $_SESSION['hotel_search']['checkin'] : date("d/m/Y", strtotime("+1 day"));?>',
			changeMonth: true,
			numberOfMonths: 2,
			dateFormat: 'dd/mm/yy',
			onSelect: function( selectedDate, dtp ) {
				var curDate = $(this).datepicker( "getDate" );
				var chekout_min_date = new Date();
				var chekout_max_date = new Date();
				chekout_min_date.setTime(curDate.getTime()+ 1 * 24 * 60 * 60 * 1000);
				chekout_max_date.setTime(curDate.getTime()+ 28 * 24 * 60 * 60 * 1000);
				
				setTimeout(function(){
		            $( "#checkout" ).datepicker("show");
		        }, 16); 
				
				/*
				console.log(selectedDate);
				console.log(curDate);
				console.log(chekout_min_date);
				console.log(chekout_max_date);
				*/
				
				$( "#checkout" ).datepicker( "option", "minDate", chekout_min_date );
				$( "#checkout" ).datepicker( "option", "maxDate", chekout_max_date );
			}
		});
		$( "#checkout" ).datepicker({
			//defaultDate: "+1w",
			minDate: '<?php echo (isset($_SESSION['hotel_search']['checkin'])) ? $min_checkout_date : date("d/m/Y", strtotime("+2 day"));?>',
			maxDate: '<?php echo (isset($_SESSION['hotel_search']['checkin'])) ? $max_checkout_date : date("d/m/Y", strtotime("+29 day"));?>',
			changeMonth: true,
			numberOfMonths: 2,
			dateFormat: 'dd/mm/yy',
			onSelect: function( selectedDate, dtp ) {
				//$( "#checkin" ).datepicker( "option", "maxDate", selectedDate );
			}
		});
		
		$('#ui-datepicker-div').wrap('<div class="booking-form"></div>');
		
		
		// Check prices on Affiliate
		$('#check-prices').click(function(){
			
			var $frm = $('#booking-form');
			var num_win = $('input.aff_chk:checked').length;
			if(num_win > 0) {
				
				var win_width = Math.floor($(window).width() / num_win);
				var win_height = $(window).height();
				
				$('input.aff_chk').each(function(index){
					var open_left = index * win_width;
					if(index > 0) open_left += 10;
					$.ajax({
						url: 'http://<?php echo $_SERVER['HTTP_HOST'];?>/modules/client_stand/aff/aff_jump.php',
						data: $frm.serialize() + '&current_affiliate=' + $(this).val() + '&act=check-prices',
						async: false,
						cache: false,
						dataType: 'json',
						type: 'post',
						success: function(r) {
							if(r != null) {
								$.each(r, function(win, url){
									open_popup(url, win, 'left=' + open_left + ',width=' + win_width + ',height=' + win_height + ',top=0,');
								});
							}
						}
					});
				});
			}
		});
		
		// Find other Affiliate hotels
		$('#find-hotels').click(function(){
			
			var $frm = $('#booking-form');
			var num_win = $('input.aff_chk').length;
			if(num_win > 0) {
				
				var win_width = Math.floor($(window).width() / num_win);
				var win_height = $(window).height();
				
				$('input.aff_chk').each(function(index){
					var open_left = index * win_width;
					if(index > 0) open_left += 10;
					$.ajax({
						url: 'http://<?php echo $_SERVER['HTTP_HOST'];?>/modules/client_stand/aff/aff_jump.php',
						data: $frm.serialize() + '&current_affiliate=' + $(this).val() + '&act=find-hotels',
						async: false,
						cache: false,
						dataType: 'json',
						type: 'post',
						success: function(r) {
							if(r != null) {
								$.each(r, function(win, url){
									open_popup(url, win, 'left=' + open_left + ',width=' + win_width + ',height=' + win_height + ',top=0,');
								});
							}
						}
					});
				});
			}
		});
		
		
	});
//]]>	
</script>
	<?php
}
else{
	$send404 = true;
	require_once(dirname(__FILE__) . "/../404/404.php");
}

?>