<?php

/**
* YOOholidays Joomla! Module
*
* @author    yootheme.com
* @copyright Copyright (C) 2007 YOOtheme Ltd. & Co. KG. All rights reserved.
* @license	 GNU/GPL
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

class modYOOholidaysHelper {

	function setFCParams($i) {

		switch ($i) {
			case 1 :
?><script type="text/javascript">fc.setParams(100,100,1,null,50,100,50,50,false,true,false);</script><?php

				break;
			case 2 :
?><script type="text/javascript">fc.setParams(11,30,3,4,null,null,null,null,false,true,false);</script><?php

				break;
			case 3 :
?><script type="text/javascript">fc.setParams(25,187,5,1,null,null,null,null,false,true,false);</script><?php

				break;
			case 4 :
?><script type="text/javascript">fc.setParams(66,139,4,5,1,1,97,96,true,true,false);</script><?php

				break;
			case 5 :
?><script type="text/javascript">fc.setParams(38,128,2,null,49,2,50,100,false,true,false);</script><?php

				break;
			case 6 :
?><script type="text/javascript">fc.setParams(100,800,8,5,1,100,50,50,false,false,false);</script><?php

				break;
			case 7 :
?><script type="text/javascript">fc.setParams(null,null,null,null,null,null,null,null,null,null,true);</script><?php

				break;
		}
	}

	function isDateBetween($from, $until) {

		$config =& JFactory::getConfig();
		$offset = $config->getValue('config.offset');

		$now 	= JFactory::getDate();
		$from 	= JFactory::getDate($from);
		$until 	= JFactory::getDate($until);

		$from->setOffset(-$offset);
		$until->setOffset(-$offset);

		$now = $now->toUnix(false);
		$from = $from->toUnix(true);
		$until = $until->toUnix(true);

		if ($from > $until){
			list($from, $until) = array($until, $from);
		}

		$from = mktime(date('H', $from), date('i', $from), date('s', $from), date('n', $from), date('j', $from), 2000);
		$until = mktime(date('H', $until), date('i', $until), date('s', $until), date('n', $until), date('j', $until), 2000);
		$now = mktime(date('H', $now), date('i', $now), date('s', $now), date('n', $now), date('j', $now), 2000);

		return (($from <= $until && $now >= $from && $now <= $until) || ($from >= $until && ($now < $until || $now > $from)));

	}
}