function GetCookieValue( cookieName )
	{
	var cookieArray = new Array();
	var cRE = new RegExp("(\;|^)[^;]*("+cookieName+")\=([^;]*)(;|$)");
	//alert(document.cookie);
	cookieArray = cRE.exec(document.cookie);

	if( cookieArray != null )
		{
		return cookieArray[3];
		}
	return "";
	}

function SaveCookieValue(CookieName,CookieValue)
	{
	document.cookie=CookieName+"="+CookieValue+";path=/";
	}

function inspect(elm)
    {
    var str = "";
    for (var i in elm)
        {
        str += i + ": " + elm.getAttribute(i) + "  -  ";
        }
    alert(str);
    }

function GetTag(TagID)
    {
    //return document.all[TagID];
    var Ret=document.getElementById(TagID);
    if (!Ret) alert("GetTag: tag '"+TagID+"' does not exist.");
    return Ret;
    }

function RewriteInnerHTML(TagID,NewInnerHTML)
    {
    var Tag;

    Tag=document.getElementById(TagID);
/*    alert(
        "innerHTML: "+GetTag(TagID).innerHTML+"\n\n"+
        "outerHTML: "+GetTag(TagID).outerHTML+"\n\n"+
        "innerText: "+GetTag(TagID).innerText+"\n\n"+
        "outerText: "+GetTag(TagID).outerText+"\n\n"
        );*/
    GetTag(TagID).innerHTML=NewInnerHTML;
    }

function GetFileSizeStringInGigs(Size)
    {
    Size/=1024*1024*1024;
    Size=Math.floor(Size*10+.5)/10; //round to the nearest 10th
    return Size;
    }

function GetFileSizeStringShort(Size)
    {
    var TypeStr="b"
    if (Size>1024*1024*1024)
        {
        TypeStr="g";
        Size/=1024*1024*1024;
        }
    if (Size>1024*1024)
        {
        TypeStr="m";
        Size/=1024*1024;
        }
    else
    if (Size>1024)
        {
        TypeStr="k";
        Size/=1024;
        }
    Size=Math.floor(Size*10+.5)/10; //round to the nearest 10th
    return Size+TypeStr;
    }

function GetFileSizeStringWithFormat(Size,RoundTo)
    {
    var TypeStr=" bytes"
    if (Size>1024*1024*1024)
        {
        TypeStr=" gigs";
        Size/=1024*1024*1024;
        }
    if (Size>1024*1024)
        {
        TypeStr=" megs";
        Size/=1024*1024;
        }
    else
    if (Size>1024)
        {
        TypeStr=" k";
        Size/=1024;
        }
    Size=Math.floor(Size*RoundTo+.5)/RoundTo; //round to the nearest 10th
    return Size+TypeStr;
    }

function GetFileSizeString(Size)
    {
    return GetFileSizeStringWithFormat(Size,100);
    }

function GetCurrentTimeString()
    {
    var DateTemp = new Date();
    var H=DateTemp.getHours();
    var AMPM;
    if (H>11)
        {
        AMPM="p";
        H-=12;
        }
    else
        AMPM="a";
    if (H==0) H+=12;
    return PrependZeros(H,2)+":"+PrependZeros(DateTemp.getMinutes(),2)+AMPM;
    }

function GetCurrentDateString()
    {
    var DateTemp = new Date();
    return PrependZeros(DateTemp.getMonth(),2)+"/"+PrependZeros(DateTemp.getDate(),2)+"/"+(DateTemp.getYear()+1900);
    }

function GetDateSortStr(DateStr,TimeStr)
    {
    var Year=DateStr.substring(6,10);
    var Month=DateStr.substring(0,2);
    var Date=DateStr.substring(3,5);
    var Hour=TimeStr.substring(0,2);
    var Min=TimeStr.substring(3,5);
    var PM=(TimeStr.substring(5.6))=="p";
    if (PM) Hour=Hour*1+12;
    var Ret=Year+Month+Date+
        PrependZeros(Hour,2)+
        PrependZeros(Min,2);

//    alert(Ret);
    return Ret;
    }

function GetTimeStr(TimeInSec)
    {
    var Ret="";
    if (TimeInSec>3600)
        Ret=Math.floor(TimeInSec/3600)+"h ";

    Ret+=Math.floor(TimeInSec/60)%60+"m ";
    Ret+=Math.floor(TimeInSec)%60+"s";
    return Ret;
    }
