//shows the loading screen
function showLoadingScreen()
{
	document.getElementById('loadingIndicatorWrap').style.display = '';
	document.getElementById('loadingCover').style.display = '';
}
function hideLoadingScreen()
{
	document.getElementById('loadingIndicatorWrap').style.display = 'none';
	document.getElementById('loadingCover').style.display = 'none';
}

//initiates the XMLHttpRequest object
function getHTTPObject() 
{
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
  return xmlhttp;
}

//gets the current browser size
function n__getWindowState()
{
	var n__windowDimensions = new Array();
	
	n__windowDimensions[0] = n__windowWidth();
	n__windowDimensions[1] = n__windowHeight();

	function n__windowWidth() {
		return n__handleResults (
			window.innerWidth ? window.innerWidth : 0,
			document.documentElement ? document.documentElement.clientWidth : 0,
			document.body ? document.body.clientWidth : 0
		);
	}
	function n__windowHeight() {
		return n__handleResults (
			window.innerHeight ? window.innerHeight : 0,
			document.documentElement ? document.documentElement.clientHeight : 0,
			document.body ? document.body.clientHeight : 0
		);
	}

	function n__handleResults(n__win, n__docel, n__body) {
		var n__n_result = n__win ? n__win : 0;
		if (n__docel && (!n__n_result || (n__n_result > n__docel)))
			n__n_result = n__docel;
		return n__body && (!n__n_result || (n__n_result > n__body)) ? n__body : n__n_result;
	}

	return n__windowDimensions;
}

function n__getElementPosition(n__elementToCheck)
{
	var pos = {left:0,top:0};

	var el = n__elementToCheck;
	while(el)
	{
		pos.left += el.offsetLeft;
		pos.top += el.offsetTop;
		el = el.offsetParent;
	}
	return pos;
}

function n__addEventListener( element, n__event_name, n__observer, n__capturing ) 
{
	if ( element.addEventListener )  // the DOM2, W3C way
		{  element.addEventListener( n__event_name, n__observer, n__capturing );  }
	else if ( element.attachEvent )  // the IE way
		{  element.attachEvent( "on" + n__event_name, n__observer );  }
}
function n__removeEventListener( element, n__event_name, n__observer, n__capturing )
{
	if ( element.removeEventListener )  // the DOM2, W3C way
		{  element.removeEventListener( n__event_name, n__observer, n__capturing );  }
	else if ( element.detachEvent )  // the IE way
		{  element.detachEvent( "on" + n__event_name, n__observer );  }
}

function n__changeOpacity(n__objectToChange,n__opacityLevel,n__opacityScale)
{
	if(browserDetect.browser == "Explorer")
	{
		n__opacityScale == 1 ? n__opacityLevel *= 100 : false;
		n__objectToChange.style.filter = 'alpha(opacity=' + n__opacityLevel + ');';
	}
	else
	{
		n__opacityScale == 100 ? n__opacityLevel /= 100 : false;
		n__objectToChange.style.opacity = n__opacityLevel;
		n__objectToChange.style.MozOpacity = n__opacityLevel; //for older mozilla browser
	}
}

function n__setTransparentPNG(n__objectToChange, n__imageLocation, n__elementType)
{
	//only if the image location is a PNG, and we are in IE, then we need to do this crazy shiz
	if(n__imageLocation.search(/\.png/i) >= 0 && browserDetect.browser == "Explorer")
	{
		//if this is an image element, then handle it accordingly
		if(n__elementType = "image")
		{
			n__objectToChange.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + n__imageLocation + "', sizingMethod='scale');";
			n__objectToChange.src = 'noogimages/blank.gif';
		}
		else  //if it is a background image
		{
			n__objectToChange.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + n__imageLocation + "', sizingMethod='scale');";
			n__objectToChange.style.backgroundImage = 'url(noogimages/blank.gif)';
		}
	}
	else
	{
		if(n__elementType != "image")
		{
			n__objectToChange.style.backgroundImage = "url('" + n__imageLocation + "')";
		}
		else
		{
			n__objectToChange.src = n__imageLocation;
		}
	}
}

//fixes an event object for cross browser usage
//(pass a window reference if we are working from a different window
function n__fixEvent(n__eventObject, n__windowReference)
{
	var n__windowRef = window;

	//if a window reference was passed, then use it
	if(typeof n__windowReference != "undefined")
	{
		n__windowRef = n__windowReference;
	}

	if (typeof n__eventObject == 'undefined'){ n__eventObject = n__windowRef.event; }
	if (typeof n__eventObject.layerX == 'undefined') {n__eventObject.layerX = n__eventObject.offsetX; }
	if (typeof n__eventObject.layerY == 'undefined') {n__eventObject.layerY = n__eventObject.offsetY; }
	return n__eventObject;
}

//this section is quite important, it creates the text ruler that sits in the background
//of the noog system.  Use this function whenever you want to get the width/height of text.
var n__textRulerObject = document.createElement('span');
				n__textRulerObject.style.display = 'block';
				n__textRulerObject.style.position = 'absolute';
				n__textRulerObject.style.top = '0px';
				n__textRulerObject.style.left = '0px';
				n__textRulerObject.style.clear = 'none';
				n__textRulerObject.style.visibility = 'hidden';
				document.getElementsByTagName("body")[0].appendChild(n__textRulerObject);

function n__textRuler(n__newTitle, n__fontSize, n__fontWeight, n__fontFamily)
{

	typeof n__fontSize != 'undefined' ? n__textRulerObject.style.fontSize = n__fontSize : false;
	typeof n__fontWeight != 'undefined' ? n__textRulerObject.style.fontWeight = n__fontWeight : false;
	typeof n__fontFamily != 'undefined' ? n__textRulerObject.style.fontFamily = n__fontFamily : false;

	n__textRulerObject.innerHTML = n__newTitle;

	n__textDimenions = {
		width : n__textRulerObject.clientWidth,
		height : n__textRulerObject.clientHeight
	};

	return n__textDimenions;
}

//pass this function a text string, width contraint, the fontSize, fontWeight, and FontFamily
//and it will return a properly truncated version of the string (using ...)
function n__truncateText(n__text, n__widthConstraint, n__fontSize, n__fontWeight, n__fontFamily)
{	
	//set the truncated string to the original text to start
	var n__truncatedString = n__text;
	var n__truncationStarted = false;
	
	var n__textDimensions = n__textRuler(n__text, n__fontSize, n__fontWeight, n__fontFamily);
	while(n__textDimensions.width > n__widthConstraint && n__truncatedString.length > 3)
	{
		if(n__truncationStarted == true)
		{
		   n__truncatedString = n__truncatedString.substring(0, n__truncatedString.length-4);
		   n__truncatedString = n__truncatedString + "...";
		}
		else
		{
		   n__truncatedString = n__truncatedString.substring(0,n__truncatedString.length-2);
		   n__truncatedString = n__truncatedString + "...";
		   n__truncationStarted = true;
		}
		n__textDimensions = n__textRuler(n__truncatedString, n__fontSize, n__fontWeight,n__fontFamily);
	}
	return n__truncatedString;
}

//trims a string
function n__trim(n__stringToTrim)
{
	var n__trimmed = n__stringToTrim.replace(/^\s+|\s+$/g, '') ;
	return n__trimmed;
}

//checks to see if the child element is actually a child of the parent
function n__isParent(n__childElement, n__parentObject)
{
	while(n__childElement)
	{
		if(n__childElement == n__parentObject)
		{
			return true;
		}
		n__childElement = n__childElement.parentNode;
	}
	return false;
}

//this function will remove all the children of an html element
function n__removeAllChildren(n__node)
{
	if(n__node == undefined || n__node == null)
	{
		return;
	}

	var n__len = n__node.childNodes.length;
	
	while (n__node.hasChildNodes())
	{
		n__node.removeChild(n__node.firstChild);
	}
}

//this function gets the length of an associative array
function n__associativeArrayLength(n__arrayObject)
{
	var n__qty = 0;
	for(var n__property in n__arrayObject)
	{
	   n__qty++;
	}
	return n__qty;
}

function n__urlEncodeString(n__stringToDo)
{	
	//parse what was sent as a string
	n__stringToDo = String(n__stringToDo);

	//first convert common MS characters...blah
	n__stringToDo = n__stringToDo.replace(/\u2018|\u2019|\u201e/gi, "'"). //single quote
								  replace(/\u201c|\u201d|\u201a/gi, '"'). //double quote
								  replace(/\u2026/gi, '...'). //triple dots
								  replace(/\u2022/gi, '*'). //bullet
								  replace(/\u2013/gi, '-'). //endash
								  replace(/\u2014/gi, '--'). //emdash
								  replace(/\u02dc/gi, '~'). //tilde
								  replace(/\u2122/gi, '(TM)'); //trademark
	
	if(window.encodeURIComponent)
	{
		n__stringToDo = encodeURIComponent(n__stringToDo); //does not encode ~!*()'
		n__stringToDo = n__stringToDo.replace(/\~/gi, "%7E").//encodeURIComponent does not handle @*/+
									  replace(/\!/gi, "%21").
									  replace(/\*/gi, "%2A").
									  replace(/\(/gi, "%28").
									  replace(/\)/gi, "%29").
									  replace(/\'/gi, "%27");
	}
	else
	{
		n__stringToDo = escape(n__stringToDo); //first url encode it
		n__stringToDo = n__stringToDo.replace(/\+/gi, "%2b").//escape does not handle @*/+
									  replace(/\//gi, "%2F").
									  replace(/\*/gi, "%2A").
									  replace(/\@/gi, "%40");
	}
	return n__stringToDo;
}


//this function converts html characters to their special characters
//pass an integer number length in the second value if you want to break up long words with &shy;
function n__encodeHTMLSpecialChars(n__stringToDo, n__maxWordLength)
{
	
	try{//insert (&shy;) between every character so that it wraps (not using &#8203;)
		if(n__maxWordLength > 0)
		{
			var n__breakupCharacter = "&#8203;"
			
			//IE6 user &shy; because it doesnt support &#8203;
			if(browserDetect.browser == "Explorer" && browserDetect.version <= 6)
			{
				n__breakupCharacter = "&shy;";
			}
			var n__maxRegexpString = '/(\\S{'+n__maxWordLength+',}?)/g';
			var n__maxRegexp = eval(n__maxRegexpString);
			n__stringToDo = n__stringToDo.replace(n__maxRegexp, "$1" + n__breakupCharacter)
		}
	}catch (err){}
	
	n__stringToDo = n__stringToDo.replace(/\&((?!(shy\;|\#8203\;)))/gi, "&amp;"). //replace all &'s except for &shy;
								  replace(/\"/gi, '&quot;').
								  replace(/\'/gi, "&#039;").
								  replace(/</gi, "&lt;").
								  replace(/>/gi, "&gt;").
								  replace(/\r\n/gi, "<br/>"). //first replace \r\n
								  replace(/\n/gi, "<br/>"); //then replace the \n's with <br>

	return n__stringToDo;
}

//this function reverts what the php htmlspecialchars() function does
function n__unEncodeHTMLSpecialChars(n__stringToDo)
{
	n__stringToDo = n__stringToDo.replace(/&amp;/gi, "&").
								  replace(/&quot;/gi, '"').
								  replace(/&#039;/gi, "'").
								  replace(/&lt;/gi, "<").
								  replace(/&gt;/gi, ">");

	return n__stringToDo;
}

function n__escapeQuotes(n__stringToDo)
{
	n__stringToDo = n__stringToDo.replace(/\"/gi, '\\"').
								  replace(/\'/gi, "\\'");
	return n__stringToDo;
}

//validates an IP address
function n__isValidIPAddress(n__ipaddr) 
{
	var n__regExp = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
	if (n__regExp.test(n__ipaddr)) 
	{
		var n__parts = n__ipaddr.split(".");
		if (parseInt(parseFloat(n__parts[0])) == 0) { return false; }
		for (var i=0; i<n__parts.length; i++)
		{
			if (parseInt(parseFloat(n__parts[i])) > 255) { return false; }
		}
	return true;
	}
	else
	{
		return false;
	}
}

//returns the current unix timestamp (- seconds behind)
function n__getCurrentTimestamp(n__secondsBehind)
{
	return (parseInt((new Date()).getTime()/1000) - n__secondsBehind);
}

//this function uses the function below it to provide a properly formatted date
//if you want to subtract a certain number of seconds, then pass the argument
function n__getCurrentDateTime(n__secondsBehind)
{
	typeof n__secondsBehind == 'undefined' ? n__secondsBehind = 0 : false;
	return n__getDateTimeFromTimestamp(n__getCurrentTimestamp(n__secondsBehind));
}

//this function will take a unix timestamp and return everything you need!
function n__getDateTimeFromTimestamp(n__dateTimestamp)
{
	var n__returnObject = {
		n__year : "",
		n__month : "",
		n__day : "",
		n__date : 0,
		n__hours : 0,
		n__minutes : 0,
		n__seconds : 0,
		n__time : 0
	};

	//if you have provided an offset, you must subtract it
	var n__theDate = new Date(n__dateTimestamp * 1000);
															
	n__returnObject.n__year = n__theDate.getFullYear();
	n__returnObject.n__month = n__getStringMonth(n__theDate.getMonth(), true);
	n__returnObject.n__date = n__theDate.getDate();
	n__returnObject.n__day = n__getStringDay(n__theDate.getDay(), true);
	n__returnObject.n__hours = n__theDate.getHours();
	n__returnObject.n__minutes = n__theDate.getMinutes();
	n__returnObject.n__seconds = n__theDate.getSeconds();
	
	n__returnObject.n__hours >= 12 ? n__returnObject.n__time = "pm" : n__returnObject.n__time = "am";
	n__returnObject.n__hours > 12 ? n__returnObject.n__hours -= 12 : false;
	n__returnObject.n__hours == 0 ? n__returnObject.n__hours = 12 : false;
	n__returnObject.n__seconds < 10 ? n__returnObject.n__seconds = "0" + n__returnObject.n__seconds : false;
	n__returnObject.n__minutes < 10 ? n__returnObject.n__minutes = "0" + n__returnObject.n__minutes : false;
	
	return n__returnObject;
}

//this function returns the string representation of the day
//bool fullVersion = true for full day, false for abbreviated
function n__getStringDay(n__dayNumber, n__fullVersion)
{	
	var n__returnString = "";
	switch(n__dayNumber)
	{
		case 0:
		  n__fullVersion ? n__returnString = "Sunday" : n__returnString = "Sun";
		  break;
		case 1:
		  n__fullVersion ? n__returnString = "Monday" : n__returnString = "Mon";
		  break;  
		case 2:
		  n__fullVersion ? n__returnString = "Tuesday" : n__returnString = "Tue";
		  break;
		case 3:
		  n__fullVersion ? n__returnString = "Wednesday" : n__returnString = "Wed";
		  break;
		case 4:
		  n__fullVersion ? n__returnString = "Thursday" : n__returnString = "Thur";
		  break;
		case 5:
		  n__fullVersion ? n__returnString = "Friday" : n__returnString = "Fri";
		  break;
		case 6:
		  n__fullVersion ? n__returnString = "Saturday" : n__returnString = "Sat";
		  break;
	}
	return n__returnString;
}

//same as function above
function n__getStringMonth(n__monthNumber, n__fullVersion)
{	
	var n__returnString = "";
	switch(n__monthNumber)
	{
		case 0:
			n__fullVersion ? n__returnString = "January" : n__returnString = "Jan";
			break;
		case 1:
			n__fullVersion ? n__returnString = "February" : n__returnString = "Feb";
			break;
		case 2:
			n__fullVersion ? n__returnString = "March" : n__returnString = "Mar";
			break;
		case 3:
			n__fullVersion ? n__returnString = "April" : n__returnString = "Apr";
			break;
		case 4:
			n__fullVersion ? n__returnString = "May" : n__returnString = "May";
			break;
		case 5:
			n__fullVersion ? n__returnString = "June" : n__returnString = "Jun";
			break;
		case 6:
			n__fullVersion ? n__returnString = "July" : n__returnString = "Jul";
			break;
		case 7:
			n__fullVersion ? n__returnString = "August" : n__returnString = "Aug";
			break;
		case 8:
			n__fullVersion ? n__returnString = "September" : n__returnString = "Sep";
			break;
		case 9:
			n__fullVersion ? n__returnString = "October" : n__returnString = "Oct";
			break;
		case 10:
			n__fullVersion ? n__returnString = "November" : n__returnString = "Nov";
			break;
		case 11:
			n__fullVersion ? n__returnString = "December" : n__returnString = "Dec";
			break;
		 
	}
	return n__returnString;
}

//pass this function the original time (in date object form), this function returns an array with 2 values
// [0] - the timeObject
// [1] - the standard duration string
function n__timePassed(n__originalTime)
{
	var n__returnString = "";

	var n__timeObject = {
		n__hours : 0,
		n__minutes : 0,
		n__seconds : 0
	};

	var n__returnArray = new Array();
	n__returnArray[0] = n__timeObject;
	n__returnArray[1] = "";
	
	if(n__originalTime > 0)
	{
		var n__currentTime = new Date();
		var n__startTime = new Date(n__originalTime * 1000);
		
		try
		{	
			var n__numSecs = (n__currentTime.getTime() - n__startTime.getTime())/1000;

			n__timeObject.n__hours = Math.floor(n__numSecs/3600);
			n__timeObject.n__minutes = Math.floor((n__numSecs - (n__timeObject.n__hours*3600))/60);
			n__timeObject.n__seconds = Math.floor(n__numSecs - (n__timeObject.n__hours*3600) - (n__timeObject.n__minutes*60));
		}
		catch (err){}

		//if no hours and no minutes, just display seconds
		if(n__timeObject.n__minutes == 0 && n__timeObject.n__hours == 0)
		{
			//only print off seconds if they are greater than 0
			if(n__timeObject.n__seconds > 0)
			{
				n__timeObject.n__seconds <= 1 ? n__returnString += n__timeObject.n__seconds + " second" : n__returnString += n__timeObject.n__seconds + " seconds";
			}
		}
		else
		{
			if(n__timeObject.n__hours > 0)
			{
				 n__timeObject.n__hours <= 1 ? n__returnString += n__timeObject.n__hours + " hour, " : n__returnString += n__timeObject.n__hours + " hours, ";
			}

			if(n__timeObject.n__minutes > 0)
			{
				 n__timeObject.n__minutes <= 1 ? n__returnString += n__timeObject.n__minutes + " minute" : n__returnString += n__timeObject.n__minutes + " minutes";
			}
		}
		n__returnArray[0] = n__timeObject;
		n__returnArray[1] = n__returnString;
	}
	
	return n__returnArray;
	
}

//COOKIE FUNCTIONS
function n__createCookie(name, value, n__days)
{
	if (n__days)
	{
		var n__date = new Date();
		n__date.setTime(n__date.getTime()+(n__days*24*60*60*1000));
		var expires = "; expires="+n__date.toGMTString();
	}
	else
	{
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/;domain=noog.com";
}

function n__readCookie(name)
{
	var n__nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		
		while (c.charAt(0)==' ') 
		{  c = c.substring(1,c.length);  }

		if (c.indexOf(n__nameEQ) == 0) 
		{  return c.substring(n__nameEQ.length,c.length);  }
	}
	return null;
}

function n__eraseCookie(n__name)
{
	n__createCookie(n__name,"",-1);
}

//this parse json is used only for massive ammounts of data
function n__parseJSON(n__json)
{
	return eval('(' + n__json + ')');
}

//parses a json text file  NEED TO FIGURE OUT HOW TO HANDLE ERRORS!
function n__parseJSON2(text)
{
    var p = /^\s*(([,:{}\[\]])|"(\\.|[^\x00-\x1f"\\])*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null)\s*/,
        token,
        operator;

    function error(m, t) {
        throw {
            name: 'JSONError',
            message: m,
            text: t || operator || token
        };
    }

    function next(b) {
        if (b && b != operator) {
            error("Expected '" + b + "'");
        }
        if (text) {
            var t = p.exec(text);
            if (t) {
                if (t[2]) {
                    token = null;
                    operator = t[2];
                } else {
                    operator = null;
                    try {
                        token = eval(t[1]);
                    } catch (e) {
                        error("Bad token", t[1]);
                    }
                }
                text = text.substring(t[0].length);
            } else {
                error("Unrecognized token", text);
            }
        } else {
            token = operator = undefined;
        }
    }


    function val() {
        var k, o;
        switch (operator) {
        case '{':
            next('{');
            o = {};
            if (operator != '}') {
                for (;;) {
                    if (operator || typeof token != 'string') {
                        error("Missing key");
                    }
                    k = token;
                    next();
                    next(':');
                    o[k] = val();
                    if (operator != ',') {
                        break;
                    }
                    next(',');
                }
            }
            next('}');
            return o;
        case '[':
            next('[');
            o = [];
            if (operator != ']') {
                for (;;) {
                    o.push(val());
                    if (operator != ',') {
                        break;
                    }
                    next(',');
                }
            }
            next(']');
            return o;
        default:
            if (operator !== null) {
                error("Missing value");
            }
            k = token;
            next();
            return k;
        }
    }
    next();
    return val();
}


/*this function allow test for normal keys (returns true if pass, false if otherwise)
	- letters & numbers
	- spaces
	- , _ - . ~ ` ! @ # $ % ^ & * () + = {} [] \/ | ' " <> ?
*/
function n__normalKeyCheck(n__testString)
{
	//Regular Expression Rules
	// replace the * by a +
	// * = if any or more
	// + = 1 or more
	// \w = a letter (= [a-zA-Z])
	// \d = a number (= [0-9])
	// \s = white space (= [ \n\r\t])
	// \n = new line
	// \r = carriage return
	// \t = tabs
	// ^ = the beginning of the string
	// $ = the end of the string
	//   \xdd Matches the ASCII character expressed by the hex number dd.
	//			"\x28" matches left parentheses character "(" 
	//   \uxxxx Matches the ASCII character expressed by the UNICODE xxxx.
	//		"\u00A3" matches "£". 

	/*this function allow all normal keys
		- letters & numbers
		- spaces
		- , _ - . ~ ` ! @ # $ % ^ & * () + = {} [] \/ | ' " <> ?
	*/
	var n__regExp = /^[\w\d\s\.\-\_\,\~\`\!\@\#\$\%\^\&\*\(\)\+\=\{\}\[\]\\\|\x27\x22\<\>\?\/\;\:]*$/;
	return n__regExp.test(n__testString);
}

////checks if a string is only numbers and letters
function n__alphaNumericCheck(n__testString)
{
	var n__regExp = /^[\w\d\s]*$/;
	return n__regExp.test(n__testString);
}

//converts urls in a string to a link
function n__linktify(n__testString)
{
	var n__test1 = /(^|[^\'\"])(\bhttps?:\/\/[^\s\"\<\>]+)/ig;
	var n__test2 = "$1<a href=\"$2\" target=\"_blank\">$2</a>";
	n__testString = n__testString.replace(n__test1, n__test2);
	
	var n__test3 = /(^|[^\'\"])(^|\s+)(www\.[^\s\"\<\>]+)/ig;
	var n__test4 = "$1$2<a href=\"http://$3\" target=\"_blank\">$3</a>";
	n__testString = n__testString.replace(n__test3,n__test4);

	return n__testString;
}

//converts a youtube video link to an embedded video, specify a width of the video
function n__youTubeify(n__testString)
{
	var n__test1 = /((http\:\/\/www)|(www))\.youtube\.com\/watch\?v\=[a-zA-Z0-9\-\_\&\=\;]*/ig;

	//if we have a youtube video
	if(n__test1.test(n__testString))
	{
		//lets obtain the video id
		var n__splitString = n__testString.split(/\=/gi);
		var n__test2 = /[a-zA-Z0-9\-\_]*/i;
		var n__videoId = n__splitString[1].match(n__test2);

		var n__videoEmbed = '<div class="youTubeThumb" onmouseover="this.style.border=\'solid blue 1px\'" '+
													  'onmouseout="this.style.border=\'solid white 1px\'" '+
													  'title="Play YouTube Video" '+
													  'onclick="try{n__noogUser.n__launchYouTubeVideo(\''+n__videoId+'\');}catch(err){};" '+
													  'style="background-image: url(\'http://img.youtube.com/vi/'+n__videoId+'/default.jpg\');">'+
								'<div class="playIcon"/>&nbsp;</div></div>';

		n__testString = n__testString.replace(n__test1, n__videoEmbed);
	}
	return n__testString;
}

//whenever you want to focus an input element, use this function so that
//the n__windowIsFocused value is correct...uses setTimeout because of 
//weird browser issues
function n__focusInput(n__inputToFocus)
{
	setTimeout(function()
		      {
		           try
		           {
					   n__inputToFocus.focus();
						
					   //after you focus the input, set the windowFocus to 1
					   //friggin major haxor...wait 50 millisecnods to do it
					   setTimeout(function()
								  {
									n__noogUser.n__windowIsFocused = 1;
								  },50);

				   }catch(err){};
			   },100);
}

//same for bluring an input
function n__blurInput(n__inputToBlur)
{
	try
	{
		 n__inputToBlur.blur();
	}
	catch (err){};
}

function n__selectInput(n__inputToSelect)
{
	setTimeout(function()
		      {
		           try
		           {
					   n__inputToSelect.select();
				   }catch(err){};
			   },100);
}

//checks value to see if it is an integer (pass any value, string or number)
function n__isInteger(n__s)
{
	return (n__s.toString().search(/^-?[0-9]+$/) == 0);
}

//This function will use the indexOf string function, but it will return an array of
//hits (not just the first one).  If the array length returned is zero, then no hits were found
function n__multiIndexOf(n__subject, n__search)
{
	var n__returnArray = new Array();
	
	var n__indexResult = -1;
	var n__currentSubstring = n__subject;
	var n__currentOffset = 0;

	while(true)
	{
		n__currentSubstring = n__currentSubstring.substring(n__indexResult + 1, n__currentSubstring.length);
		n__indexResult = n__currentSubstring.indexOf(n__search);

		//we found a result
		if(n__indexResult != -1)
		{
			n__returnArray[n__returnArray.length] = n__indexResult + n__currentOffset;
			n__currentOffset += n__indexResult + 1;
		}
		//we didnt find a result, break from the loop
		else
		{
			break;
		}
	}

	return n__returnArray;
}

//use this function to set the background image of an element
//NOTE:  Prevents blank url background image that will do a request to the parent document!!!
function n__setBackgroundImage(n__elementToSet, n__backgroundImage)
{
	if(n__backgroundImage == null || n__backgroundImage == "")
	{
		n__elementToSet.style.backgroundImage = "";
	}
	else
	{
		n__elementToSet.style.backgroundImage = "url('" + n__backgroundImage + "')";
	}
}

//takes a string and strips all html tags
function n__stripHTML(n__string)
{
	// What a tag looks like
	var n__matchTag = /<(?:.|\s)*?>/g;
	
	// Replace the tag and return the new string
	return n__string.replace(n__matchTag, "");
}

//this will try to do a search a value for a particular word..if found it returns where found, otherwise -1
function n__doWordSearch(n__word, n__search)
{
	var n__returnValue = -1;
	try
	{
		n__returnValue = n__word.search(n__search);
	}
	catch (err){};

	return n__returnValue;
}

//call this function to disable text selection on an element
function n__disableTextSelect(n__element)
{
	//special firefox css method
	try {  n__element.style.MozUserSelect = 'none';  }catch (err){};

	n__element.onselectstart = function (){return false};
}

function n__enableTextSelect(n__element)
{
	//special firefox css method
	try {  n__element.style.MozUserSelect = 'text';  }catch (err){};

	n__element.onselectstart = null;
}