
	// is int
	function isInt(x) {
		var y = parseInt(x);
		if (isNaN(y)) return false;
		return x == y && x.toString() == y.toString();
	} 
 
	// str_replace
	function str_replace(search, replace, subject) {
		return subject.split(search).join(replace);
	}

	// is floating number
	function isFloat (id) {
		var el = document.getElementById(id);
		if (el.value == '')
			el.value = 1;
		el.value = str_replace (',','.',el.value);
		if (el.value.indexOf('.') == -1) {
			el.value = el.value + '.00';
		} else {
			if (el.value.substr(el.value.indexOf('.')).length == 1)
					el.value = el.value + '0';
			if (el.value.substr(el.value.indexOf('.')).length == 2)
					el.value = el.value + '00';
			if (el.value.substr(el.value.indexOf('.')).length > 2)
					el.value = el.value.substr(0, el.value.indexOf('.') +3);
		}
		if (!isFinite (el.value)) {
			alert('Dieser Eintrag muss eine Zahl sein!');
			el.value = 0;
		}
	}
	
	// center horizontal
	function centerH(width) {
		return screen.availWidth / 2 - width / 2;
	}
	
	//center vertical
	function centerV(height) {
		return screen.availHeight / 2 - height / 2;
	}
	
	// popup window
	function popup(path, name, width, height, scrollbars, ret) {
		name = window.open( path, name, "width=" + width + ",height=" + height + ",left=" + centerH(width) + ",top=" + centerV(height) + ",scrollbars=" + scrollbars);
		name.focus();
		return ret;
	}

	// re convert file content
	function reConvert(str) {
		
		str = str_replace( '--##--10--##--', '\n', str );
		str = str_replace( '--##--13--##--', '\t', str );
		str = str_replace( '--##--39--##--', '\'', str );
		str = str_replace( '--##--34--##--', '\"', str );
		str = str_replace( '--##--59--##--', ';', str);
		str = str_replace( '--##--91--##--', '[', str);
		str = str_replace( '--##--93--##--', ']', str);
		str = str_replace( '--##--123--##--', '{', str);
		str = str_replace( '--##--125--##--', '}', str);
		
		return str;
		
	}
	
	// sure
	function sure() {
		
		if( confirm ('Sind sie sicher?'))
			return true;
		else
			return false;
		
	}
	
	// check email syntax
	function validEmail(email) {
		var strReg = "^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";
		var regex = new RegExp(strReg);
		return(regex.test(email));
	}	
	
	// check forms
	function checkForms (ids) {
		
		for (var i=0; i < ids.length; i++) {
			if (document.getElementById(ids[i]).value == '') {
				alert ('Es wurden nicht alle benötigten Felder gewählt bzw. ausgefüllt!');
				document.getElementById(ids[i]).focus();
				return false;
			}
		}
		
		return true;
		
	}
	
	// get categories
	function getCategories (type, id, value, sid, clear) {
		if (value != 0) {
			
			for (var i=0; i<clear.length; i++)
				$("#" + clear[i]).empty();
			
			$.getJSON("db.php?" + sid + "get_categories",
			  { parent: value },
			  function(json) {
				alert(json.category_id);
			  }
			);			
			
		}
	}
	
	// show item images
	function showImage (path, width, height) {
		return popup(path, 'ItemWindow', Number(width) + 16, Number(height) + 16, 'no', false);
	}

