
/**
 * Product: Katyshop
 * @version 0.3.2.1
 * @author Catalin Hulea - huleacatalin@users.sourceforge.net
 * @copyright Copyright (C) 2007 Catalin Hulea
 * @license GNU General Public License version 3
 * 			You can find a copy of GNU GPL v3 at this path: /docs/LICENSE
 * @link https://sourceforge.net/projects/katyshop
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

function validateInt(str, min, max)
{
	if(min + "" == "undefined")
		min = -1;
	if(max + "" == "undefined")
		max = -1;
	if(parseInt(str) != str)
		return false;
	str *= str;
	if((str < min && min != -1) || (str > max && max != -1))
		return false;
	return true;
}

function validateFloat(str, min, max)
{
	if(min + "" == "undefined")
		min = -1;
	if(max + "" == "undefined")
		max = -1;
	if(parseFloat(str) != str)
		return false;
	str *= 1;
	if((str < min && min != -1) || (str > max && max != -1))
		return false;
	return true;
}

function defined(x)
{
	return (x + "" != "undefined");
}

function httpGetAllParams(excludeKeys)
{
	if(excludeKeys + "" == "undefined")
		excludeKeys = new Array();
	
	var s = "";
	var href = window.location.href;
	if(href.indexOf("?") == -1)
		return "";
	// return only the part of querystring after the question mark:
	href = href.substr(href.indexOf("?") + 1);
	if(href.indexOf("&") == -1)
		return href;
	var arr = href.split("&");
	for(var i = 0; i < arr.length; i++)
	{
		var temp = arr[i];
		if(temp.indexOf("=") != -1)
			temp = temp.substring(0, temp.indexOf("="));
		if(!in_array(temp, excludeKeys))
		{
			if(s.length > 0)
				s += "&";
			s += arr[i];
		}
	}
	return s;
}

// kinda' print_r()
function showObjectMembers(ob)
{
	var s = "";
	for(var i in ob)
	{
		s += "\r\n" + i + ": " + ob[i];
	}
	alert(s);
}
