<?php	 	 session_start(); ?>
<?php	 	
global $selected_object_id, $selected_object_type, $meniu, $object_id, $object_id_child, $object_id_child_child, $ascunde_services, $selected_department, $selected_department_name;
wp_reset_query();
$languages = function_exists('icl_get_languages')?icl_get_languages():array();
if (is_page()) {
    $selected_object_id = get_the_ID();
    $selected_object_type = 'page';
    $imagine_header = get_post_meta($selected_object_id, 'wpcf-header-image', true);
    $header_link = get_post_meta($selected_object_id, 'wpcf-header-link', true);
    if (is_page(array(70, function_exists('icl_object_id') ? icl_object_id(70, 'page', false) : 70))) {
        $selected_object_type = 'home';
    }
}
else if (is_category()) {
    $ascunde_services = true;
    $selected_object_id = get_cat_id(single_term_title("", false));
    //dv($selected_object_id);
    //dv(get_term_by('id', $selected_object_id, 'category'));
    $selected_object_type = 'category';
    if ($selected_object_id == 1 || $selected_object_id == 25 || $selected_object_id == 26) $imagine_header = '/wp-content/uploads/2012/05/header-case-study.png';
        else { 
            $imagine_header = '/wp-content/uploads/2012/05/header-careers.png';
            $selected_department = $selected_object_id;
            $selected_department_name = get_term_by('id', $selected_object_id, 'category')->name;
            $selected_object_id = get_term_by('id', $selected_object_id, 'category')->parent;
        }
}
else if (is_single()) {
    $ascunde_services = true;
    if (get_queried_object()->post_type == 'post') {
        $taxonomy = get_the_terms(get_the_ID(),'category');
        $selected_object_type = 'category';
        $title_bread = get_queried_object()->post_title;
        if ($taxonomy[1]->term_id == 1) $selected_object_id = 1;
        else {
            $pas = 0;
            foreach ($taxonomy as $tax) {
                $pas++;
                if ($pas==1) {
                    $selected_object_id = $tax->term_id;    
                }
                else {
                    $selected_department = $tax->term_id;
                    $selected_department_name = $tax->name;
                }
            }
        }
    }
}
else if (is_search()) {
    
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<?php	 	 if (!defined('WPSEO_VERSION')) { ?><title><?php	 	 wp_title('&laquo;', true, 'right'); ?> <?php	 	 bloginfo('name'); ?> | <?php	 	 bloginfo('description'); ?></title><?php	 	 } ?>
<?php	 	 wp_head(); ?>
<link rel="stylesheet" type="text/css" href="<?php	 	 bloginfo('template_directory'); ?>/css/style.css?v=<?php	 	 fileVersion(ABSPATH.CSS_URL.'/style.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php	 	 bloginfo('template_directory'); ?>/css/fonts/fonts.css?v=<?php	 	 fileVersion(ABSPATH.CSS_URL.'/fonts/fonts.css'); ?>" />
<?php	 	 if ($selected_object_id == 12 && $selected_object_type == 'page') { ?>
<link rel="stylesheet" type="text/css" href="<?php	 	 bloginfo('template_directory'); ?>/css/jquery.realperson.css?v=<?php	 	 fileVersion(ABSPATH.CSS_URL.'/jquery.realperson.css'); ?>" />
<script type="text/javascript" src="<?php	 	 bloginfo('template_directory'); ?>/js/jquery.realperson.min.js?v=<?php	 	 fileVersion(ABSPATH.JS_URL.'/jquery.realperson.min.js'); ?>"></script>
<?php	 	 } ?>
</head>
<body>
<a class="skip-link" href="#content">Skip to content</a>
<div id="line" class="<?php	 	 if ($selected_object_type == 'home') { ?>line-homepage<?php	 	 }?>"></div>
<div id="wrapper">
    <div id="header">
        <div id="logo">
            <a href="<?php	 	 echo function_exists('icl_get_home_url') ? icl_get_home_url() : home_url(); ?>" title="<?php	 	 bloginfo('name'); ?>"><img src="<?php	 	 bloginfo('template_directory'); ?>/images/logo.png"  alt="<?php	 	 bloginfo('name'); ?>" /></a>
        </div>
        <div id="search">
            <form action="<?php	 	 bloginfo('url'); ?>" method="GET" id="searchForm">
                <input type="text" value="<?php	 	 echo isset($_GET['s']) ? $_GET['s'] : '';?>" data-default="Search" name="s" />
                <input type="submit" value="GO" class="submit" />
            </form>
        </div>
 <?php
function language_selector_flags(){
    $languages = function_exists('icl_get_languages') ? icl_get_languages('skip_missing=0&orderby=code') : array();
    if(!empty($languages)){
        foreach($languages as $l){
            if(!$l['active']) echo '<a href="'.$l['url'].'">';
            echo '<img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /> ';
            if(!$l['active']) echo '</a>';
        }
    }
}
?>
<div id="flags_language_selector" style="margin:10px;text-align:right"><?php language_selector_flags(); ?></div >	
    </div>
    <div id="menu"><?php	 	 include 'meniu.php'; ?></div>
    <?php	 	 if ($selected_object_type == 'home') { ?>
        <div id="header-image-home">
            <?php	 	 if ($header_link) { ?><a href="<?=$header_link;?>"><?php	 	 } ?>
                <img src="<?=$imagine_header;?>" alt="IQON" />
            <?php	 	 if ($header_link) { ?></a><?php	 	 } ?>
        </div>
    <?php	 	 } else { ?>
        <div id="breadcrumb">
        &raquo; <a href="<?php	 	 echo function_exists('icl_get_home_url') ? icl_get_home_url() : home_url(); ?>" title="IQON">Home</a>
        <?php	 	 if ($object_id) { ?>
         / <a href="<?php	 	 echo $meniu[$object_id]->url;?>" <?php	 	 if (!$object_id_child) echo 'class="last"'; ?>><?php	 	 echo $meniu[$object_id]->title;?></a>
        <?php	 	 } ?>
        <?php	 	 if ($object_id_child) { ?>
         / <a href="<?php	 	 echo $meniu[$object_id]->childrens[$object_id_child]->url;?>"><?php	 	 echo $meniu[$object_id]->childrens[$object_id_child]->title;?></a>
        <?php	 	 } ?>
         <?php	 	 if ($object_id_child_child) { ?>
         / <a href="<?php	 	 echo $meniu[$object_id]->childrens[$object_id_child]->childrens[$object_id_child_child]->url;?>"><?php	 	 echo $meniu[$object_id]->childrens[$object_id_child]->childrens[$object_id_child_child]->title;?></a>
        <?php	 	 } ?>
        <?php	 	 if (!empty($selected_department_name)) { ?>
        / <?php	 	 if (empty($title_bread)) { ?><strong><?php	 	 echo $selected_department_name; ?></strong><?php	 	 } else { ?><a href="<?php	 	 echo get_category_link($selected_department);?>"><?php	 	 echo $selected_department_name; ?></a><?php	 	 } ?>
        <?php	 	 } ?>
        <?php	 	 if (!empty($title_bread)) { ?>
        / <strong><?php	 	 echo $title_bread; ?></strong>
        <?php	 	 } ?>
        </div>
        <div id="linie-interior"></div>
        <?php	 	 if ($imagine_header) { ?>
            <div id="header-image">
                <img src="<?=$imagine_header;?>" alt="IQON" />
            </div>
        <?php	 	 } ?>
    <?php	 	 } ?>
    <?php	 	 if (!$ascunde_services) { ?>
    <div id="menu-services">
        <?php	 	 include 'meniu-services.php'; ?>
        <div class="clear"></div>
    </div>
    <?php	 	 } ?>
    <?php	 	 if ($imagine_header) { ?>
    <div id="linie-interior" class="margintop10"></div>
    <?php	 	 } ?>
    <div id="content">
