//Adds a method to arrays to find where a specific item is in the array
Array.prototype.indexOf = function (query) {
	var val = -1;
	for (var i=0; i<this.length; i++)
	{
		if (this[i] == query)
		{
			return i;
			break;
		}
	}
}



function disableTextSelect(element)
{
	if (typeof element.onselectstart != "undefined") {
		//Internet Explorer
		element.onselectstart = function(){ return false;};		
	} else if (typeof element.style.MozUserSelect!="undefined"){
		//Mozila ... FF ... and the like.
		element.style.MozUserSelect="none"	
	} else {
		element.onmousedown=function(){return false}
	};
	
	element.style.cursor = "default"
}


function addClass (el, className)
{
	if (el.className.indexOf(className) == -1)
	{
		el.className = el.className + " " + className;
	}
}

function removeClass (el, className)
{
	var result = el.className;
	var loc = el.className.indexOf(className);
	if (loc != -1)
	{
		result = el.className.substring(0, loc) + el.className.substring(loc + className.length);
	}
	el.className = result;
}

function getElementsByClassExclude (tagname, classname, ar, exclude)
{
	var alltags = document.all? document.all : document.getElementsByTagName(tagname);
	_allTagsIterate(classname, alltags, exclude, ar);
}

function getElementsByClass (tagname, classname, ar)
{
		getElementsByClassExclude (tagname, classname, ar, "");
}

function elementGetElementsByClass (element, tagname, classname, ar)
{
	var alltags = new Array();
	alltags = element.getElementsByTagName(tagname);
	_allTagsIterate(classname, alltags, "", ar);
}

function _allTagsIterate (classname, alltags, exclude, ar)
{
	var Classes;
	for (i=0; i<alltags.length; i++){
		Classes = new Array();
		Classes = alltags[i].className.split(" ");	
		if (Classes.indexOf(classname) > -1)
		{
			ar.push(alltags[i]);
		}
	}
}

function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

String.prototype.trim = trimString;

function windowWidthGet () {
	var windowWidth;
	
	if (window.innerWidth)
	{
		windowWidth = window.innerWidth;
	}
	else
	{
		windowWidth = document.documentElement.offsetWidth;
	}
	
	return windowWidth;
}

function windowHeightGet () {
	var windowHeight;
	
	if (window.innerWidth)
	{
		windowHeight = window.innerHeight;
	}
	else
	{
		windowHeight = document.documentElement.offsetHeight;
	}
	
	return windowHeight;
}

function getElementLeft (element) {
	xPos = eval(element).offsetLeft;
	tempEl = eval(element).offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	return xPos;
}

function getElementTop (element) {
	yPos = eval(element).offsetTop;
	tempEl = eval(element).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}

function killBubble(event)
{
	if (event)
	{
		event.stopPropagation();
	} else if (window.event) {
		window.event.cancelBubble = true;	
	}	
}

