

function getClientSize(wh){
  var rv;
  switch (wh){
    case "width":
      if (navigator.userAgent.toLowerCase().indexOf("msie") != -1)
        rv = document.body.clientWidth;
      else
        rv = window.innerWidth;
      break;

    case "height":
      if (navigator.userAgent.toLowerCase().indexOf("msie") != -1)
        rv = document.body.clientHeight;
      else
        rv = window.innerHeight;
      break;
  }
  return rv;
}

function getQueryStringVal(arg) {
    var myUrl = document.location.href;

    // just get the Query String portion
    var myQS = myUrl.substring( myUrl.indexOf("?"), myUrl.length );

    var theArg = new String ("?" + arg + "=" );
    var retVal = "";

    //Check for "?arg=" or "&arg=" in the QS.
    // if we find it, the value is everything up to "&" or
    // the rest of the QS if there's no "&"

    if (myQS.indexOf(theArg) >= 0 ) {
        var equalIndex = myQS.indexOf("=");

        if (myQS.indexOf("&") >= 0 ) {
          retVal = myQS.substring( equalIndex+1 , myQS.indexOf("&"));
        } else {
          retVal = myQS.substring( equalIndex+1, myQS.length );
        }
    } else {
        theArg = new String("&" + arg + "=" );
        var argIndex = myQS.indexOf(theArg);
        if ( argIndex  >= 0 ) {
            retVal = myQS.substring( argIndex + theArg.length, myQS.length);
            var ampIndex = retVal.indexOf("&");
            if ( ampIndex >= 0 ) {
                retVal = retVal.substring( 0, ampIndex );
            }
        }
    }
    return retVal;
}

// Writing cookies.
function _DL_SetCookie (name, value, hours, path, domain, secure) {

  var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
  document.cookie = name + '=' + escape(value) +
    ((numHours)?(';expires=' + numHours):'') +
    ((path)?';path=' + path:'') +
    ((domain)?';domain=' + domain:'') +
    ((secure && (secure == true))?'; secure':'');
}



// Reading cookies.
function _DL_ReadCookie(name) {
    if(document.cookie == '') {
      return false;
    }
    else { // there is a cookie
      var firstChar, lastChar;
      var theBigCookie = document.cookie;
      firstChar = theBigCookie.indexOf(name);
      var NN2Hack = firstChar + name.length;
      if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) {
        firstChar += name.length + 1;
        lastChar = theBigCookie.indexOf(';', firstChar);
        if(lastChar == -1) {
          lastChar = theBigCookie.length;
        }
        return unescape(theBigCookie.substring(firstChar, lastChar));
      } else {
        // If there was no cookie of that name, return false.
        return false;
      }
    }
}

function drawMain(){
	// Center and resize for main.
	alert(getClientSize("height"));
	//getElement("mainBody").style.height = getClientSize("height") + "px";
}

function getElement(id){
	return document.getElementById(id);	
}

function writeDiv(id, arg){
	document.getElementById(id).innerHTML = arg;	
}


function getNews (data) {
	var a = data;
	var html = "<ul>";
	
	try{
		for (i in a) {
			html += "<li class=\"newsItem\"><a href=\"" + a[i].url + "\"";
			if (a[i].target) html += " target=\"" + a[i].target + "\"";
			html += ">" + a[i].name + "</a>";
			if (a[i].isnew) html += " <span class=\"new\">new!</span>";
			html += "</li>\n";
		}
	}catch(e){
		alert(e.message);	
	}
	html += "</ul>";
	document.write(html);
}


function getSupporters (level) {
	var a = null;

	if (level == "funders") a = aFunders;
	if (level == "partners") a = aPartners;
	if (level == "diamond") a = aBSDiamond;
	if (level == "platinum") a = aBSPlatinum;
	if (level == "gold") a = aBSGold;
	if (level == "silver") a = aBSSilver;
	if (level == "benefactor") a = aBSBenefactor;
	if (level == "advocate") a = aBSAdvocate;
	if (level == "friends") a = aBSFriends;

	var html = "";
	for (i in a) {
		if (a[i].img){
			if (a[i].url){
				html += "<a href=\"" + a[i].url + "\" target=\"_blank\">";
				html += "<img src=\"" + a[i].img + "\" border=0/>";
				if (a[i].showName) html += "&nbsp;&nbsp;" + a[i].name;
				html += "</a><br>\n";
			}else{
				html += "<img src=\"" + a[i].img + "\"/>";
				if (a[i].showName) html += "&nbsp;&nbsp;" + a[i].name;
				html += "<br>\n";
			}
			
		}else{
			if (a[i].url)
				html += "<a href=\"" + a[i].url + "\" target=\"_blank\">" + a[i].name + "</a>\n";
			else
				html += a[i].name + "\n";
		}
		html += "<br>";
	}

	document.write(html);
}


function drawPlayer(){
	var html = "";
	html += "<OBJECT id='mediaPlayer' width='320' height='45'";
	html += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'";
	html += "codebase='http://activex.microsoft.com/activex/controls/ mplayer/en/nsmp2inf.cab#Version=5,1,52,701'";
	html += "standby='Loading Microsoft Windows Media Player components…' type='application/x-oleobject'>";
	html += "<param name='fileName' value='" + file + "'>";
	html += "<param name='animationatStart' value='1'>";
	html += "<param name='transparentatStart' value='1'>";
	html += "<param name='autoStart' value='1'>";
	html += "<param name='ShowControls' value='1'>";
	html += "<param name='showdisplay' value='false'>";
	html += "<param name='ShowStatusBar' value='0'>";
	html += "<param name='loop' value='0'>";
	html += "<EMBED type='application/x-mplayer2'";
	html += "pluginspage='http://microsoft.com/windows/mediaplayer/ en/download/'";
	html += "id='mediaPlayer' name='mediaPlayer' displaysize='1' autosize='0'";
	html += "bgcolor='darkblue' showcontrols='1' showtracker='1'";
	html += "showdisplay='0' showstatusbar='0' videoborder3d='0' width='320' height='45'";
	html += "src='" + file + "' autostart='1' designtimesp='5311' loop='0'>";
	html += "</EMBED>";
	html += "</OBJECT>";
	document.write(html);
}

function play(file, title){
	try {
		
	}catch(e){}
}
