<?php
/**
* @version	$Id: globals.php 14258 2011-03-16 21:43:52Z alex $
* @package	In-Commerce
* @copyright	Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license	Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/

defined('FULL_PATH') or die('restricted access!');

function bracket_comp($elem1, $elem2)
{
	if( ($elem1['End']>$elem2['End'] || $elem1['End'] == -1) && $elem2['End'] != -1 )
	{
		return 1;
	}
	elseif ( ($elem1['End']<$elem2['End'] || $elem2['End'] == -1) && $elem1['End'] != -1 )
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

function bracket_id_sort($first_id, $second_id)
{
	$first_abs = abs($first_id);
	$second_abs = abs($second_id);
	$first_sign = ($first_id == 0) ? 0 : $first_id / $first_abs;
	$second_sign = ($second_id == 0) ? 0 : $second_id / $second_abs;
	if($first_sign != $second_sign)
	{
		if($first_id > $second_id) {
			$bigger =& $first_abs;
			$smaller =& $second_abs;
		}
		else {
			$bigger =& $second_abs;
			$smaller =& $first_abs;
		}
		$smaller = $bigger + $smaller;
	}

	if($first_abs > $second_abs) {
		return 1;
	}
	elseif ($first_abs < $second_abs)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}