// JavaScript Document

function in_array (needle, haystack, argStrict) {
    var key = '',
        strict = !! argStrict;

    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }

    return false;
}


function removeItem(originalArray, itemToRemove) {
var j = 0;
while (j < originalArray.length) {
// alert(originalArray[j]);
if (originalArray[j] == itemToRemove) {
originalArray.splice(j, 1);
} else { j++; }
}
// assert('hi');
return originalArray;
}

function popBlack(){
	$('#screen').css({	"display": "block", opacity: 0.7, "width":$(document).width(),"height":$(document).height()});
	$('body').css({"overflow":"hidden"});
	$('#loading-content').css({"display": "block"});
}


function addSeparatorsNF(nStr, inD, outD, sep)
{
	nStr += '';
	var dpos = nStr.indexOf(inD);
	var nStrEnd = '';
	if (dpos != -1) {
		nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
		nStr = nStr.substring(0, dpos);
	}
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(nStr)) {
		nStr = nStr.replace(rgx, '$1' + sep + '$2');
	}
	return nStr + nStrEnd;
}


	function toolTip(element,text){
   		element.qtip({
                  overwrite: false,
                  content: text,
                  show: {
                     event: false,
                     ready: true
                  },
				  hide: {
                        target: element,
                        fixed: false,
                        delay: 1000
                    },
				  position: {
					  my: 'left bottom',
					  at: 'right top',
				      target: element 
			   },
                  style: {
                     classes: 'ui-tooltip-red' // Make it red... the classic error colour!
                  }
				});
		element.qtip('option', 'content.text', text);
		element.qtip('show');
	}
