//
//	Utility functions and core extensions for general use.
//

var global_IE7_Compat_mode = false;

String.prototype.leftPad = function (l, c) { return new Array(l - this.length + 1).join(c || '0') + this; }

function fixBrowserIncompatibility()
{	
	if(typeof(window.external) != 'undefined')
	{
		global_IE7_Compat_mode = true;
		document.getElementsByName = function(name, tag)
		{
			if(!tag)			
				tag = '*';			
				
			var elems = document.getElementsByTagName(tag);
			var res = []
			for(var i=0;i<elems.length;i++)
			{
				att = elems[i].getAttribute('name');
				if(att == name) 				
					res.push(elems[i]);				
			}
			return res;
		}

	}
}

// walk through all elements in the dom and execute a script on each
function fixTheDomInCertainBrowsers() 
{
	  $("darkBoxDIV").style.display="none";

      var items = document.getElementsByTagName("*");
      var i=items.length;

      var item;

      do
      {		
        item = items[i-1];
        		
		//if(item.style.filter)
//			item.style.filter = "alpha(opacity=100)";
		
      }
      while (--i);
}


//find special characters
function stringContains(str, chars)
{
	for (var i = 0; i < str.length; i++) 
	{
		if (chars.indexOf(str.charAt(i)) != -1)        
			return true;        
	}
}
  
//dollar function (get element)
function $(e)
{
	return document.getElementById(e);
}

function stripQuerystring()
{
	str = window.location.href;
	parts = str.split("?");
	window.location.href = parts[0];
}

//redirect to new url
function redirect(url)
{
	window.location.href=url;
}

//trim
String.prototype.trim = function () {  return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");};

//days in month
function daysInMonth(iMonth, iYear)
{
	return 32 - new Date(iYear, (iMonth-1), 32).getDate();
}

//absolute position of top left corner of element.
function getPos(el) { 
    // yay readability 
    for (var lx=0, ly=0; 
         el != null; 
         lx += el.offsetLeft, ly += el.offsetTop, el = el.offsetParent); 
    return {x: lx,y: ly}; 
} 

function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}


