
function popUpWindow(URLStr, left, top, width, height) {
	popUpWin = open(URLStr, '_blank', 'toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left=0, top=0,screenX='+left+',screenY='+top+'');
//	popUpWin.resizeTo(screen.availWidth,screen.availHeight);
//	popUpWin.moveTo(0,0);

 temp = popUpWin;
}



function setAndGetNextHighestDepth(x) { return (!x && document._zIndex && document._zIndex > 0 ? document._zIndex+= 1 : document._zIndex = (x ? x : 1001)); }
function getFirstChildElement(elm) { if (elm && elm.childNodes) { for (var i = 0; i < elm.childNodes.length; i++) if (elm.childNodes[i].nodeType === 1) return elm.childNodes[i]; } return null; }
function getChildElements(elm) { var arr = []; if (elm && elm.childNodes) { for (var i = 0; i < elm.childNodes.length; i++) if (elm.childNodes[i].nodeType === 1) arr.push(elm.childNodes[i]); } return arr; }
function getNextSibling(elm) { if (elm && elm.nextSibling) { do elm = elm.nextSibling; while (elm && elm.nodeType != 1); return elm; } return null; }
function getPreviousSibling(elm) { if (elm && elm.previousSibling) { do elm = elm.previousSibling; while (elm && elm.nodeType != 1); return elm; } return null; }






function textAreaMaximizeInput(obj) {
	if (!obj) return true; var len = parseInt(obj.getAttribute('maxlength')); if (isNaN(len)) return true;
	obj.onkeypress = setTimeoutClosure(function(x) { if (x.o.value.length >= x.l) x.o.value = x.o.value.substr(0,x.l); }, 10, { o: obj, l: len }); // useable with 'onkeypress'
	if (obj.value.length >= len) obj.value = obj.value.substr(0,len); // usable with 'onkeyup'
}








function hideElement( args ) {
	if (!args || !args.object || !args.object.style) return;
	var style = (args.style ? args.style.toString().toLowerCase() : false);

	if (style == 'visibility') { args.object.style.visibility = 'hidden'; }
	else if (style == 'size') { args.object.style._wdth = args.object.offsetWidth; args.object.style._hght = args.object.offsetHeight; args.object.style.width = '1px'; args.object.style.height = '1px'; }
	else { args.object.style.display = 'none'; }
}



function displayElement( args ) {
	if (!args || !args.object || !args.object.style) return;
	var style = (args.style ? args.style.toString().toLowerCase() : false);

	if (style == 'visibility') { args.object.style.visibility = 'visible'; }
	else if (style == 'size') { args.object.style.width = ''; args.object.style.height = ''; }
	else { args.object.style.display = 'block'; }
}








function csDropDownInitialize( args ) {
	if (!args || !args.object) return;

	var d = document;
	var objSelect = args.object;
	var objParent = objSelect.parentNode; if (!objParent) return;
	var objSelected = getFirstChildElement(objSelect); if (!objSelected) return;
	var optionsObj = getFirstChildElement(objParent); if (!optionsObj) return;
			optionsObj.optionsParent = objSelect; // register parent object of this

		objSelect.options = {}; // start with empty object
		if(d.csDropDownClickHandler != true) { d.csDropDownClickHandler = true; attachEventListener(d, (d.attachEvent ? 'onclick' : 'click'), clickSelect); }

		objSelect.onChange = (args.onChange ? args.onChange : false);


		objSelect.visible = (function(b) { this.parentNode.style.display = (b == true ? 'block' : 'none'); }); // custom function
		objSelect.changeIndex = (function(i) { if (this.options && this.options[i]) csDropDownChangeSelection( this.options[i], true); }); // custom function


		optionsObj.onmouseover = function() { this.style.cursor = 'pointer'; };
		optionsObj.onmouseout = function() { this.style.cursor = ''; };

		var optionSelected = false;
		var optionsObjNodes = getChildElements(optionsObj);
		var optionCount = count(optionsObjNodes);
		var optionVisibleCount = 0;
		var optionMouseOver = function() { this.style.background = '#eaf0fb'; };
		var optionMouseOut = function() { this.style.background = ''; };


		for (var i = 0;  i <= optionCount; i++) {
			obj = optionsObjNodes[i]; if (!obj) continue; // shortcut
			objSelect.options[i] = obj; // create options object
			obj.optionParent = objSelect; // register parent object of option
			obj.value = obj.getAttribute('value'); // register option value from attribute (not .innerHTML)
			obj.index = i; // register option index
			obj.visible = ('NO|FALSE|0'.indexOf((obj.getAttribute('visible')+'').toUpperCase()) != -1 ? false : true); // mark as visible / not visible
			obj.style.width = (objParent.offsetWidth - 9) + 'px'; // adjust width to parent
			if (obj.visible) { optionVisibleCount++; obj.onmouseover = optionMouseOver; obj.onmouseout = optionMouseOut; } else { obj.style.display = 'none'; } // count visible only
			obj.style.margin = (i > optionVisibleCount ? 0 : 2)+ 'px 2px ' +(i < optionCount ? 0 : 2)+ 'px 2px'; // adjust margin according to position in list
			obj.style.padding = (i > optionVisibleCount ? 2 : 1)+ 'px 0px ' +(i < optionCount ? 3 : 2)+ 'px 3px'; // adjust padding according to position in list
			if ('YES|TRUE|1'.indexOf((obj.getAttribute('selected')+'').toUpperCase()) != -1) optionSelected = obj; // if true mark this option as selected
		}

		if (optionVisibleCount < 2) {
			objSelected.style.color = '#777';
			var objSelectNodes = getChildElements(objSelect); var objSelectIcon = objSelectNodes[1]; // select icon object
					if (objSelectIcon && objSelectIcon.src) objSelectIcon.src = './img/page_icon_select_grey.png';
		}

		objSelect.clickable = (optionVisibleCount > 1 ? true : false);

		if (optionVisibleCount > 1) objSelect.onmouseover = setTimeoutClosure(function(x) { x.padding = '0px'; x.border = '2px solid #f9b73a'; x.cursor = 'pointer'; }, 10, objSelect.style);
		if (optionVisibleCount > 1) objSelect.onmouseout = setTimeoutClosure(function(x) { x.border = '0px'; x.padding = '2px'; x.cursor = ''; }, 10, objSelect.style);
		//if (optionCount > 0) objSelect.onmouseover = function() { var x = this.style; x.padding = '0px'; x.border = '2px solid #f9b73a'; x.cursor = 'pointer'; };
		//if (optionCount > 0) objSelect.onmouseout = function() { var x = this.style; x.border = '0px'; x.padding = '2px'; x.cursor = ''; };

		objSelect.style.visibility = (optionVisibleCount == 0 ? 'hidden' : 'visible'); // just now make select body visible (if at least 1 option)
		csDropDownChangeSelection( (optionSelected ? optionSelected : optionsObjNodes[0]), true); // change marked selected, but do not fire onChange event yet
		objParent.style.display = (args.visible === false ? 'none' : 'block'); // set whole select as visible / not visible
}





function setTimeoutClosure(f, m, a) { return function() { setTimeout(function(){f(a);}, m); }; } // function must be reference not a string (f = function, m = milliseconds, a = argument)







function clickSelect(e) {
	e = (e ? e : event);
	var eSource = (e.target ? e.target : e.srcElement); if (!eSource) return;
	var d = document, className, option = false, obj = false;

	// browse for classNames (but only need to go through 5 parentNodes)
	for (var i = 0;  i != 5; i++) {
		className = (eSource.className ? eSource.className.toString().toUpperCase() : '');
		if (className == 'CSDROPDOWNDISPLAY') { obj = eSource; break; }
		if (className == 'CSDROPDOWNLISTOPTION') { option = eSource; obj = option.optionParent; break; }
		if (eSource.parentNode) eSource = eSource.parentNode;
	}

	if (obj) {
		var objSelect = obj;
				if (objSelect.clickable === false) return;
		var objParent = objSelect.parentNode; if (!objParent) return;
		var objSelected = getFirstChildElement(objSelect); if (!objSelected) return;
		var optionsObj = getFirstChildElement(objParent); if (!optionsObj) return;
	}


	var selectOpen = (d.csDropDownActive ? true : false); // select open or closed
	var selectClick = (obj ? true : false); // select box clicked or not

	if (option) csDropDownChangeSelection(option); // if option selected then change selection
	if (selectOpen) { d.csDropDownActive.style.display = 'none'; } // if something open then close first

	if (selectClick && optionsObj != d.csDropDownActive && !option) {
		d.csDropDownActive = optionsObj; // remember current opened dropdown options
		optionsObj.style.display = 'block'; // open up this selects dropdown options object
		csDropDownSetPosition(optionsObj); // position new opened dropdown options object
	} else {
		d.csDropDownActive = null; // remember there is no current opened dropdown options
	}
}









function csDropDownSetPosition(obj) {
	if (!obj || !obj.style || !obj.parentNode) return;

	var objParent = obj.parentNode;
	var objParentTop = getTop(objParent);
	obj.style.left  = (getLeft(objParent) + 0) + 'px';
	obj.style.top  = (objParentTop + 28) + 'px';

	var objHeight = obj.offsetHeight;
	var objBottom = getTop(obj) + objHeight;
	var viewportBottom = getViewportHeight(document) + getScrollTop(document);
	var objTop = (objBottom > viewportBottom ? objParentTop - objHeight : objParentTop + 28);
	if (objTop > getScrollTop(document)) obj.style.top = objTop + 'px';
	obj.style.zIndex = setAndGetNextHighestDepth(); // set on top
}









function csDropDownChangeSelection(option, noEvent) {
	if (!option) return;

	var objSelect = option.optionParent; if (!objSelect) return;
	var objSelected = getFirstChildElement(objSelect); if (!objSelected) return;

	objSelected.innerHTML = option.innerHTML; // update selected option by .innerHTML
	objSelect.selectedIndex = option.index; // update option index number
	objSelect.selectedValue = option.value; // update option value (shortcut to current selected value)
	if (option.parentNode) option.parentNode.style.cursor = ''; // remove cursor style on options object
	if (noEvent != true && objSelect.onChange) { try{ objSelect.onChange(objSelect); } catch(err){ return true; }; }; // fire onChange event
}










// --------------------------------------------------------------------------------------------------------------


function setTimeoutLiteral(msecs, func, v1, v2, v3, v4, v5, v6) { setTimeout((function(){func(v1,v2,v3,v4,v5,v6)}) , msecs); }
function makeFunctionLiteral(func, v1, v2, v3, v4, v5, v6) { return (function(){return func(v1,v2,v3,v4,v5,v6)}); }



function scrollToAnchor(n) { var obj = document.getElementById(n); if (obj) { var top = getTop(obj) - 25; if (top > 0) window.scrollTo(0, top); } }
function scrollToTop() { window.scrollTo(0, 0); }

function layerShow(n) { var obj = document.getElementById(n); if (obj && obj.style) obj.style.display = "block"; }
function layerHide(n) { var obj = document.getElementById(n); if (obj && obj.style) obj.style.display = "none"; }






function setOpacity(obj, opacity) {
	if (!obj) return; var clear = (!opacity || opacity == 100 ? true : false);
	obj.style.filter = (clear ? '' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' +opacity+ ')'); // IE (Win)
  obj.style.opacity = (clear ? '' : opacity/100); // Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.KHTMLOpacity = (clear ? '' : opacity/100); // Safari<1.2, Konqueror
	obj.style.MozOpacity = (clear ? '' : opacity/100); // Older Mozilla and Firefox
}





function getBrowserDimensions( srcDocument ) {
	srcDocument = (srcDocument) ? srcDocument : document; // source document (ex. parent, top), (default = document)
	var w = window, de = srcDocument.documentElement, db = srcDocument.body; // set shortcuts

	var documentWidth = (db && db.clientWidth ? db.clientWidth : (de && de.clientWidth ? de.clientWidth : (w.innerWidth ? w.innerWidth : 0)));
	var documentHeight = (db && db.clientHeight ? db.clientHeight : (de && de.clientHeight ? de.clientHeight : (w.innerHeight ? w.innerHeight : 0)));
	var scrollLeft = (de && de.scrollLeft ? de.scrollLeft : (db && db.scrollLeft ? db.scrollLeft : (w.pageXOffset ? w.pageXOffset : (w.scrollX ? w.scrollX : 0))));
	var scrollTop = (de && de.scrollTop ? de.scrollTop : (db && db.scrollTop ? db.scrollTop : (w.pageYOffset ? w.pageYOffset : (w.scrollY ? w.scrollY : 0))));
	var viewportWidth = (w.innerWidth ? w.innerWidth - 18 : (de && de.clientWidth ? de.clientWidth : (db && db.clientWidth ? db.clientWidth : 0)));
	var viewportHeight = (w.innerHeight ? w.innerHeight - 18 : (de && de.clientHeight ? de.clientHeight : (db && db.clientHeight ? db.clientHeight : 0)));
	var viewportRight = viewportWidth + scrollLeft;
	var viewportBottom = viewportHeight + scrollTop;

	return {
						documentWidth					: documentWidth,
						documentHeight				: documentHeight,
						viewportWidth					: viewportWidth,
						viewportHeight				: viewportHeight,
						viewportLeft					: scrollLeft,
						viewportRight					: viewportRight,
						viewportTop						: scrollTop,
						viewportBottom				: viewportBottom,
						scrollLeft						: scrollLeft,
						scrollTop							: scrollTop
				 }
}


function is(v) { var w = (typeof(v)+'').toLowerCase(); return (w != 'undefined' ? (w == 'object' && v == null ? false : true) : false); }
function isnot(v) { return !is(v); }

function getLeft(i) {	if (i) { if (i.offsetParent) { return (i.offsetLeft + getLeft(i.offsetParent)); } else { return (i.offsetLeft); } } }
function getTop(i) { if (i) { if (i.offsetParent) { return (i.offsetTop + getTop(i.offsetParent)); } else { return (i.offsetTop); } } }


function convert_TextareaValueToString(str, del) { return (str && str.length ? ((((str+'').split('\r')).join('')).split('\n')).join(del ? del : '<br>') : ''); } // ie, firefox & opera
function convert_StringToTextareaValue(str, del) { return (str ? ((str+'').split(del ? del : '<br>')).join('\n') : ''); } // ie, firefox & opera


function antiCacheString() { var d = new Date(); return d.getTime(); }


function roundToFixed(a, d) { var factor = Math.pow(10, d); return Math.round(a * factor) / factor; }
function isRoundNumber(x) { return (Math.ceil(x) == x); }


function zeroFillLeft(a, n) {
	if (!a) return ""; a = a.toString(); if (a.length >= n) return a;
	return new Array(n - (a.length - 1)).join("0") + a; // return leftside zerofilled value as string
}


function zeroFillAndFloat(a, n, v, s) {
	// a = value, n = positions after decimal, v = valuta sign, s= decimal seperator

	v = (v && v == "euro") ? "&euro; " : "";
	s = (s) ? s : ".";
	if (isNaN(parseFloat(a))) return v + "??" + s + "??";
	var b = roundToFixed(a,n).toString().split("."); var c = (b[1] ? b[0] : b);
	var d = (b[1] ? (b[1]).substring(0,2) : "");
	return v + c + s + d + new Array(n - (d.length - 1)).join("0"); // return rightside (after dot) zerofilled value as string
}


function floatToDecimal(a, n) {
	a = parseFloat(a);
	if (!a || isNaN(a)) return 0;
	n = (n) ? (n < 0 ? 0 : n) : 2; // .00 default
	var d = parseInt('1' + new Array(n + 1).join("0")); // example: 100 --> .00
	return Math.round(a * d) / d; // round to n decimals
}


function percentageOf(v, p) { v = parseFloat(v); p = parseFloat(p); return (isNaN(v + p)) ? 0 : (v / 100) * p; }




function count(x) { return (is(x) && x.length ? x.length - 1 : 0); }


function arraySplice(a, x, y) {
	// a == array, x == begin (zero-based), y == how much
	// ie fix: array.splice does not work inside iframe, NOT multi-dimensional!
	if (!a || isNaN(parseInt(a.length))) return [];
	if (isNaN(parseInt(y)) || y < 1) return a;

	var b = [], cnt = 0;
	for (var i = 0; i < (a.length); i++) { if (i >= x && i < x + y) continue; b[cnt] = a[i]; cnt++; }
	return b;
}



function arrayPush(a, x) {
	// ie fix: array.push does not work inside iframe, NOT multi-dimensional!
	//if ( !a || !isArray(a) ) return []; // return empty array
	if (!a || isNaN(parseInt(a.length))) return [];

	a[(a.length == -1 ? 0 : a.length)] = x;
	return a;
}



function onTextSelect(evt) {
	evt = (evt) ? evt : event;
	if (evt) {
		var tagName = (evt.target ? evt.target : evt.srcElement).tagName;
		if (tagName != "INPUT" && tagName != "TEXTAREA") { evt.cancelBubble = true; evt.returnValue = false; return false; }
		else if (tagName != "INPUT" && tagName != "TEXTAREA") { evt.stopPropagation(); return false; }
	}
}





function getViewportWidth(src) {
	src = (src) ? src : document;
	var dd = src.documentElement, db = src.body;
	if ( top.innerWidth ) { return top.innerWidth; }
	else if ( dd && dd.clientWidth ) { return dd.clientWidth; }
	else if ( db && db.clientWidth ) { return db.clientWidth; }
	return 0; // instead of undefined
}

function getViewportHeight(src) {
	src = (src) ? src : document;
	var dd = src.documentElement, db = src.body;
	if ( top.innerHeight ) { return top.innerHeight; }
	else if ( dd && dd.clientHeight ) { return dd.clientHeight; }
	else if ( db && db.clientHeight ) { return db.clientHeight; }
	return 0; // instead of undefined
}

function getScrollTop(src) {
	src = (src) ? src : document;
	var dd = src.documentElement, db = src.body;
	if( dd && dd.scrollTop ) { return dd.scrollTop; }
	else if( db && db.scrollTop ) { return db.scrollTop; }
	return 0; // instead of undefined
}







function focusNext(elemName, evt, func) {
	var evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
	if (charCode == 13 || charCode == 3) {
		var elm = getElementById(elemName);
		//elm.setAttribute('autocomplete', 'off'); // firefox focus() bug fix, not working (so now hardcoded in html)
		elm.focus();
		if (func) func(); // if function, execute it
		return false;
	}
	return true;
}



function resetTab(elemName, evt) {
	var evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
	if (charCode == 9) {
		evt.cancelBubble = true;
		evt.returnValue = false;
		if (evt.preventDefault) evt.preventDefault();
		if (evt.stopPropagation) evt.stopPropagation();
		var elm = getElementById(elemName);
		elm.focus();
		return false;
	}
	return true;
}




function findRowInArrayByUniqueKey( args ) {
	if (!args || !args.array || !args.key || !args.needle ) return;
	var result = null;
	for (var x in args.array) {	if (args.array[x]) { if (args.array[x][args.key] == args.needle) { result = x; break; }  } 	}
	return result;
}








function updatePageHeight() {
	var src = getIframeBodyObjectById('simsalaboek', parent);
	var tgt = parent.document.getElementById("simsalaboek");
			tgt.style.height = "100%";

	var browser = getBrowserDimensions( parent.document );
	var offsetheight = src.offsetHeight;
	var scrollheight = src.scrollHeight;
	var newheight = (src.offsetHeight > src.scrollHeight ? src.offsetHeight : src.scrollHeight) + 25 + (firefox ? 125 : 0);
	var staheight = (ie ? browser.viewportHeight : tgt.clientHeight); // standard
	if (isNaN(newheight) || newheight < staheight) newheight = staheight;

	tgt.style.height = (newheight) + "px"; tgt.style.height = (newheight) + "px"; // just to be sure
}



function getIframeBodyObjectById(id, where) {
	var elById = (where) ? where.document.getElementById(id) : document.getElementById(id);
	if (!elById) return null;
	if (elById.contentWindow && elById.contentWindow.document.body) { return elById.contentWindow.document.body; }
	else if (elById.contentDocument && elById.contentDocument.body) { return elById.contentDocument.body; }
	else { return (where ? where.frames[id] : frames[id]).document.body; }
	return null;
}









function mRepl(txt, str, wit) { return txt.split(str).join(wit); } // multi replace


function removeNewLines(_s) {
  var _t = "";
  for (_i=0;_i<_s.length;_i++) { if (_s.charCodeAt(_i) != 13 && _s.charCodeAt(_i) != 10) _t += _s.charAt(_i); }
  return _t;
}





function getElementById(id) { return document.getElementById(id); }


function fileToFullPath(args) {
	if (!args) return null;
	if (!args.filename) return null;
	if (!args.path) args.path = "";
	
	var url = mRepl("./img/" + args.path + "/" + args.filename, "//", "/");
	return url;
}




function setBackgroundColor(args) {
 if (!args || !args.color) return;
 var obj = (args.id) ? document.getElementById(args.id) : args.object;
 if (!obj) return;
 obj.style.backgroundColor2 = obj.style.backgroundColor;
 obj.style.backgroundColor = args.color;
}

function resetBackgroundColor(args) {
 if (!args) return;
 var obj = (args.id) ? document.getElementById(args.id) : args.object;
 if (!obj || !obj.style.backgroundColor) return;
 obj.style.backgroundColor = obj.style.backgroundColor2;
}



function getObjectFromArrayById(args) {
	if (!args) return null;
	if (!args.key) return null;
	if (!args.array) return null;

	var key = args.key;
	var array = args.array;
	var i, el, x;

	for (i = 0; i < array.length; i++) {
		el = array[i];
		for (var x in el) { if (el[x] == key && x == args.keyname) return el; }
	}
	return null;
}





function convertToGrid(r,cols,mod,align, cellpadding, tablewidth) {
 //     r: array of content (to be divided over the cells)
 //  cols: number of columns, before breaking to new row (1 or more)
 //   mod: 'lefttoright' or 'toptobottom'
 // align: 'left' , 'center' or 'right'
 var total = r.length-1;
 var from = 0;
 var to = 0;
 var i, j, x = '', y;
 if (!total || total < 1) return ""; // quit here
 if (!align) align = 'left'; // if none, default to 'left'
 cols*= 1; // make always a number (if not a number, cols becomes NaN)
 if (!cols || cols <= 0) cols = 1; // if no cols or NaN, zero or less, then default to 1
 if (!mod || cols == 1 || total == cols) mod = 'lefttoright'; // if none, default to 'lrtb', faster too
 if (!cellpadding) cellpadding = '0px';
 tablewidth = (tablewidth) ? 'width:' + tablewidth + ';' : '';

 switch (mod) {

  // left to right
  case 'lefttoright':
   for (j = 0; j < Math.ceil(total / cols); j++) { // run (total / cols) times
    from = to + 1; // calculate 'from'
    to = (total < to + cols) ? total : to + cols; // calculate 'to'

    y = "";
    for (i = from; i <= to; i++) { // run (cols) times
     y+= '<td valign="top" style="padding:' + cellpadding + ';">' + r[i] + '</td>';
    }
    if (y != "") x+= '<tr align="' + align + '">' + y + '</tr>'; // if not empty
   }
   x = '<table style="' +(tablewidth)+ '" cellspacing="0" cellpadding="0">' + x + '</table>';
  break;

  // top to bottom
  case 'toptobottom':
   for (j = 0; j < cols; j++) { // run (cols) times
    from = to + 1; // calculate 'from'
    to+= Math.ceil((total - to) / (cols - j)); // calculate 'to'

    y = '';
    for (i = from; i <= to; i++) { // run (cols) times
     y+= '<tr><td valign="top" style="padding:' + cellpadding + ';">' + r[i] + '</td></tr>';
    }
    if (y != '') x+= '<td align="' + align + '" valign="top"><table style="width:100%;" cellspacing="0" cellpadding="0">' + y + '</table></td>'; // if not empty
   }

   x = '<table style="' +(tablewidth)+ '" cellspacing="0" cellpadding="0"><tr>' + x + '</tr></table>';
  break;
 }

 return x;
}








function isArray() {
	if (typeof arguments[0] == 'object') {
		var criterion = arguments[0].constructor.toString().match(/array/i); return (criterion != null);
	} else { return false; }
}

function isValid(parm,val) {
  if (!parm || parm.length < 1) return false;
  for (var i = 0, parm = parm.toString(); i < parm.length; i++) {
    if (val.indexOf(parm.charAt(i),0) == -1) return false;
  }
  return true;
}

function isAlpha(str) { return isValid(str, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); }
function isNumber(v) { return (parseInt(v).toString() == v.toString()) ? true : false; }
function isEmpty(v) { return (v.toString().length < 1) ? true : false; }

function isString() {
	if (typeof arguments[0] == 'string') return true;
	if (typeof arguments[0] == 'object') {
		var criterion = arguments[0].constructor.toString().match(/string/i); return (criterion != null);
	} else { return false; }
}

function isStringAlpha(v) { return (isString(v) && isNaN(parseInt(v))) ? true : false; }
function makeNumber(v) { return (v) ? parseInt(v) : 0; }
function makeString(v) { return (v) ? v.toString() : ""; }
function countArray(v) { return (v && isArray(v) && v.length > 0) ? v.length - 1 : 0; }
function countString(v) { return (v && isString(v) && v.length > 0) ? v.length : 0; }

function ucFirst(v) { return v.charAt(0).toUpperCase() + v.substring(1); }
function ucWords(v) { return v.toLowerCase().replace( /^(.)|\s(.)|\-(.)/gim, function ($1) {return $1.toUpperCase();} ); }

function remove_spaces(str) { return str.replace( /\s+/g, "" ); } // remove all spaces
function trim(str) { str = str.replace( /^\s+/g, "" ); return str.replace( /\s+$/g, "" ); } // strip leading, then strip trailing

function myRegExp(str, pattern, flags) {
	flags = (is(flags)) ? flags : "gim"; // standard; global, case-insensitive, multi-line
	var regex = new RegExp(pattern, flags);
  var array = str.toString().match(regex);
	if (array && isArray(array)) { return array.join(""); } else { return ""; }
}


