﻿//function $(the_id) {
//	var obj = document.getElementById(the_id);
//	if ( obj == null)
//	  obj = document.getElementById(ID(the_id));
//	
//	return obj;
//}

function ID( idtag ){
    return 'ctl00_MC1_' + idtag;
}
function isArray(obj) {
   return (obj.constructor.toString().indexOf("Array") == -1 ? false : true);
}


 // Function takes an button sets to either disabled or enabled, with given text
 function buttonSetBusy( button, isBusy, buttonText ){
        button.value = buttonText;
        button.disabled = isBusy;
 }

function DLog( message )
{
  var y;
  var x;
  var logT = $('logTable');

  if ( logT ){
      x= logT.insertRow(0);
      y= x.insertCell(0);
      y.innerHTML = message;
  }
}

function toggle(obj, On) {
  if ( On == true ){
    obj.style.display = '';
  }else if ( On == false ){
    obj.style.display = 'none';
  }else{
	    if ( obj.style.display != 'none' ) {
		    obj.style.display = 'none';
	    }
	    else {
		    obj.style.display = '';
	    }
	}
}

function toggleByID(aID, On) {
    if ( $(aID) != null )
        toggle($(aID), On);
    else if ( $(ID(aID)) != null )
        toggle($(ID(aID)), On);
}
function getWindowSize()
{
	var height = 0;
	if(self.innerHeight) {
			height = self.innerHeight;
	}else if(document.documentElement && document.documentElement.clientHeight) {
			height = document.documentElement.clientHeight;
	}else {
			height = document.body.clientHeight;
	}
	return height;
}

function fillArray( theArray, val, startIndex, endIndex ){
    if ( startIndex == null)  startIndex = 0;
    if ( endIndex   == null)  endIndex   = theArray.length-1;

    for( var i = startIndex; i <= endIndex; i++){
        theArray[i] = val;
    } 
}

function getWindowSize()
{
	var height = 0;
	if(self.innerHeight) {
			height = self.innerHeight;
	}else if(document.documentElement && document.documentElement.clientHeight) {
			height = document.documentElement.clientHeight;
	}else {
			height = document.body.clientHeight;
	}
	return height;
}


//
// Mozilla/Firefox compatibility fix, allows Mozilla to read IE targetted DOM 
//
var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);

if (! isIE) {
  HTMLElement.prototype.__defineGetter__("innerText", 
              function () { return(this.textContent); });
  HTMLElement.prototype.__defineSetter__("innerText", 
              function (txt) { this.textContent = txt; });
}



function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

// 06/14/2011 cookie management
function setCookie(name, value, days) {
    var date, expires;
    if (days) {
        date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        expires = "; expires=" + date.toUTCString();
    }
    else {
        expires = "";
    } 
    document.cookie = name + "=" + value + expires + "; path=/";
}
function getCookie(name) {
    var cname, cvalue, index;
    var cookies = document.cookie.split(";");
    
    if (cookies.length > 0) {
        for (var i = 0; i < cookies.length; i++) {
            index = cookies[i].indexOf("=");
            cname = jQuery.trim(cookies[i].substring(0, index));
            cvalue = jQuery.trim(cookies[i].substring(index+1, cookies[i].length));
            if (name == cname) {
                return cvalue;
            }
        }
    }
    return null;
}
function deleteCookie(name) {
    setCookie(name, '', -1);
}
