<?php
/**
* @package   yoo_neo Template
* @file      template.config.php
* @version   5.5.8 October 2010
* @author    YOOtheme http://www.yootheme.com
* @copyright Copyright (C) 2007 - 2010 YOOtheme GmbH
* @license   YOOtheme Proprietary Use License (http://www.yootheme.com/license)
*/

// init vars
$config =& $this->warp->getHelper('config');
$color  = $config->get('color');
		
// set template css
$css = '.wrapper { width: '.intval($config->get('template_width')).$config->get('template_width_unit')."; }\n";
        
// 3-column-layout
if ($this->warp->modules->count('left')) {
    $css .= '#main-shift { margin-left: '.(intval($config->get('left_width')) + intval($config->get('left_space')))."px; }\n";
    $css .= '#left { width: '.intval($config->get('left_width'))."px; }\n";
}

if ($this->warp->modules->count('right')) {
    if (!$this->warp->modules->count('left'))  { $config->set('left_width', '0'); }
    $css .= '#main-shift { margin-right: '.(intval($config->get('right_width')) + intval($config->get('right_space')))."px; }\n";
    $css .= '#right { width: '.intval($config->get('right_width')).'px; margin-left: -'.(intval($config->get('left_width')) + intval($config->get('right_width')))."px; }\n";
}

// inner 3-column-layout
if ($this->warp->modules->count('contentleft')) {
    $css .= '#content-shift { margin-left: '.(intval($config->get('contentleft_width')) + intval($config->get('contentleft_space')))."px; }\n";
    $css .= '#contentleft { width: '.intval($config->get('contentleft_width'))."px; }\n";
}		

if ($this->warp->modules->count('contentright')) {
    if (!$this->warp->modules->count('contentleft')) { $config->set('contentleft_width', '0'); }
    $css .= '#content-shift { margin-right: '.(intval($config->get('contentright_width')) + intval($config->get('contentright_space')))."px; }\n";
    $css .= '#contentright { width: '.intval($config->get('contentright_width')).'px; margin-left: -'.(intval($config->get('contentleft_width')) + intval($config->get('contentright_width')))."px; }\n";
}

// drop down menu
$css .= '#menu .dropdown { width: '.intval($config->get('menu_width'))."px; }\n";
$css .= '#menu .columns2 { width: '.(2*intval($config->get('menu_width')))."px; }\n";
$css .= '#menu .columns3 { width: '.(3*intval($config->get('menu_width')))."px; }\n";
$css .= '#menu .columns4 { width: '.(4*intval($config->get('menu_width')))."px; }\n";

$this->warp->stylesheets->addDeclaration($css);
$this->warp->stylesheets->add('css:template.css');

if ($config->get('direction') == 'rtl') {
	$this->warp->stylesheets->add('css:rtl.css');
}

if ($color != '' && $color != 'default') {
    $this->warp->stylesheets->add("css:variations/{$color}.css");
}

$this->warp->stylesheets->add('css:custom.css');

// set google fonts
if ($config->get('load_googlefonts', false)) {
	
	$this->warp->config->set('webfonts','webfonts');
		
	if(in_array($color, array('retrobeige','retrolandscape','retropaper'))){
		$this->warp->stylesheets->add('http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,light|Lobster');
	}
	
	if(in_array($color, array('gradientblue','gradientbusiness','gradientred','gradientribbon','gradientspace'))){
		$this->warp->stylesheets->add('http://fonts.googleapis.com/css?family=Nobile:regular,bold');
	}
}

// javascripts
$this->warp->javascripts->addDeclaration('Warp.Settings = '.json_encode(array('color' => $config->get('color'), 'itemColor' => $config->get('itemcolor'))).';');
$this->warp->javascripts->add('js:warp.js');
$this->warp->javascripts->add('js:accordionmenu.js');
$this->warp->javascripts->add('js:menu.js');
$this->warp->javascripts->add('js:fancymenu.js');
$this->warp->javascripts->add('js:template.js');

// ie7 hacks
if ($this->warp->useragent->browser() == 'msie' && $this->warp->useragent->version() == '7.0') {
	$css = '<link rel="stylesheet" href="%s" type="text/css" />';
	$ie7[] = sprintf($css, $this->warp->path->url('css:ie7hacks.css'));
	$head[] = '<!--[if IE 7]>'.implode("\n", $ie7).'<![endif]-->';
}

// ie6 hacks
if ($this->warp->useragent->browser() == 'msie' && $this->warp->useragent->version() == '6.0') {
	$css = '<link rel="stylesheet" href="%s" type="text/css" />';
	$js = '<script type="text/javascript" src="%s"></script>';
	$ie6[] = sprintf($css, $this->warp->path->url('css:ie6hacks.css'));

	$ie6[] = sprintf($js, $this->warp->path->url('js:ie6fix.js'));
	$ie6[] = sprintf($js, $this->warp->path->url('js:ie6png.js'));
	$ie6[] = sprintf($js, $this->warp->path->url('js:ie6.js'));
	$head[] = '<!--[if IE 6]>'.implode("\n", $ie6).'<![endif]-->';
}

// add $head
if (isset($head)) {
	$this->warp->template->set('head', implode("\n", $head));
}

// set css class for specific columns
$columns = null;
if ($this->warp->modules->count('left')) $columns .= 'column-left';
if ($this->warp->modules->count('right')) $columns .= ' column-right';
if ($this->warp->modules->count('contentleft')) $columns .= ' column-contentleft';
if ($this->warp->modules->count('contentright')) $columns .= ' column-contentright';

$config->set('columns', $columns);

// add class="nofrontpage" to body tag if frontpage, category blog or section blog
if (JRequest::getCmd('option') == 'com_content') {
	if (JRequest::getCmd('view') == 'article' || JRequest::getCmd('view') == 'frontpage' || (in_array(JRequest::getCmd('view'), array('section', 'category')) && JRequest::getCmd('layout') == 'blog')) {
		$config->set('frontpage', true);
	}
}
if ($this->warp->config->get('custom') == 'nobox') {
	$config->set('frontpage', true);
}
$config->set('frontpage', ($config->get('frontpage',false)) ? '' : 'nofrontpage');