<?php
$module_dir = "adverts";
$bound_district_code = null;
$bound_district_name = null;
$districts = [];
$q = "SELECT * FROM cyprus_districts WHERE active='1' ORDER BY pos ASC;";
$r = @mysql_query($q);
if($r && mysql_num_rows($r) > 0) {
    while($row = mysql_fetch_assoc($r)) {
        $districts[$row['dcode']] = stripslashes($row['district']);
    }
}

if(isset($catdom_id) && intval($catdom_id)>0){
    $catdom_id_adv = $catdom_id;
}
else {
    $catdom_id_adv = $domain_id;
    $catdom_id = $domain_id;
}

if($catdom_id_adv != $domain_id) {
    // Try to find if maybe the catdom_id_adv reprezents a district
    $catdom_title = stripslashes($line_catdom_id['title_en']);
    //echo '<pre>', var_export($line_catdom_id, true), '</pre>';
    if(count($districts) > 0) {
        $_catdom_title = strtolower($catdom_title);
        foreach($districts as $d_code=>$d_name) {
            $_dname = strtolower($d_name);
            if(strpos($_catdom_title, $_dname) !== false) {
                $bound_district_code = $d_code;
                $bound_district_name = $d_name;
                break;
            }
        }
    }

}

//echo '<br>bound_district_name = ' . $bound_district_name;

if(str_replace('www.', '', $ultra_domainname) != "cyprus-hotel.com") {
    require_once(dirname(__FILE__) . "/functions.php");
    include(dirname(__FILE__) . "/adverts_init.php");

    if(str_replace('www.', '', $ultra_domainname) != "xxxx-cyprusfurniture.com") {
        // Include the old style adverts file
        include(dirname(__FILE__) . "/adverts_o.php");
    }
    else {
        // Only for furniture
        include(dirname(__FILE__) . "/adverts_responsive.php");
    }
	
	//include(dirname(__FILE__) . "/adverts_default.php");
}
else {
	// Include de specific file for cyprus-hotel.com
	include(dirname(__FILE__) . "/../adverts_hotels/adverts_hotels.php");
}
?>