

function setCookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) {
	expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );
  document.cookie = name+'='+escape( value ) +
	( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
	( ( path ) ? ';path=' + path : '' ) +
	( ( domain ) ? ';domain=' + domain : '' ) +
	( ( secure ) ? ';secure' : '' );
}

function getStyle(el,styleProp)
{
	if (el.currentStyle)
		var y = el.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
	return y;
}


function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
	return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ';', len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

function deleteCookie( name, path, domain ) {
  if ( getCookie( name ) ) document.cookie = name + '=' +
		( ( path ) ? ';path=' + path : '') +
		( ( domain ) ? ';domain=' + domain : '' ) +
		';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

function cookiesEnabled(){
	setCookie('test', 'none', '', '/', '', '');
	if (getCookie('test')){
	  deleteCookie('test', '/', '');
	  return true;
	} else {
	  return false;
	}
}

function getElementsByClassName(node, classname){
      var a = [];
      var re = new RegExp('\\b' + classname + '\\b');
      var els = node.getElementsByTagName("*");
      for(var i=0,j=els.length; i<j; i++)
          if(re.test(els[i].className))a.push(els[i]);

      return a;
}

// Standard AJAX create request function
function createRequest(){
	var ajaxRequest; 
	try {
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try {
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)	{
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e)	{
				alert("Your browser does not support Ajax.  Please update your browser");
			}
		}
	}
	return ajaxRequest;
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
} 


function userAgentSwitch(agent_list, return_vals, default_val)
{
	// This function will take in an array of user agent types and an array of return values
	// The function will loop through the list of user agents and if it finds a match, it will
	// use the index of the matching value and return the value in the return_vals array at the same location.
	// if no value match is made, it will return the default_val
	if(agent_list != null && agent_list.length > 0)
	{
		var ua = navigator.userAgent ;
		for(var i=0; i < agent_list.length; i++)
		{
			if(ua.indexOf(agent_list[i]) > 0)
			{
				return return_vals[i];
			}
		}
		return default_val
	}
	
}

