docid = "";
docpass = "";

function resetMenu(){
    var menuList = $("menu").getElementsByTagName("li");
	for(i = 0; i < menuList.length; i++){
        menuList[i].className = "";
	}
}

function stylePage(){
    var menuUl = $("menu");
    var menuList = menuUl.getElementsByTagName("a");
	for(i = 0; i < menuList.length; i++){
		menuList[i].onclick = function(){
			for(j = 0; j < menuList.length; j++){
				menuList[j].parentNode.className = "";
			}
			this.parentNode.className = "selected";
		}
	}
};

function buildPopup(divid,divclass,divinnerHTML,_x,_y){
    var newDiv = new Element("div");
    if(divid != null || divid != ""){
    	newDiv.setAttribute("id",divid);
    }
    if(divclass != null || divclass != ""){
    	newDiv.setAttribute("class",divclass);
    	newDiv.setAttribute("className",divclass);
    }
    newDiv.update( divinnerHTML );
    newDiv.setStyle({
         position: 'absolute',
         top: _y+"px",
         left: _x+"px"
    });
    $("main").appendChild(newDiv);
/*    newDiv.style.position = "absolute";
    newDiv.style.top = _y;
    newDiv.style.left = _x;*/
}

function encode(txt){
	var returnString = txt;
	returnString = returnString.replace(/&/g,"_and_;");
	returnString = returnString.replace(/\+/g,"_plus_;");
	returnString = returnString.replace(/#/g,"%23");
	returnString = returnString.replace(/</g,"_lb_;");
	returnString = returnString.replace(/>/g,"_rb_;");
	returnString = returnString.replace(/\n/g,"_nlc_;");
	return returnString;
};

function decode(txt){
	var returnString = txt;
	returnString = returnString.replace(/%5C/g,"\\");
	returnString = returnString.replace(/%27/g,"'");
	returnString = returnString.replace(/_plus_;/g,"+");
	returnString = returnString.replace(/_and_;/g,"&");
	returnString = returnString.replace(/%23/g,"#");
	returnString = returnString.replace(/_lb_;/g,"&#60;");
    returnString = returnString.replace(/_rb_;/g,"&#62;");
	returnString = returnString.replace(/_nlc_;/g,"<br>");
	return returnString;
};

function countdown( y, m, d ){
    var montharray = new Array( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" );

    var today = new Date();
    var todayyear = today.getYear()
    if( todayyear < 1000 ){
        todayyear += 1900;
    }
    var todaystring = montharray[ today.getMonth() ] + " " + today.getDate() + ", " + todayyear;
    var futurestring = montharray[ m - 1 ] + " " + d + ", " + y;
    var dd = Date.parse( futurestring ) - Date.parse( todaystring );
    dd = Math.floor( dd / ( 60*60*1000*24 ) );
    $( "counter" ).innerHTML = dd;
    setTimeout( "countdown( 2010, 5, 1 )", 60000 );
};

function getGoogleGroup(feed,quant){
    var grss = zXmlHttp.createRequest();
	grss.open("get", "script/getRss.php?url="+feed+"&quant="+quant, true);
	grss.onreadystatechange = function(){
		if(grss.readyState == 4 && grss.status == 200){
            document.getElementById("main").innerHTML = "<div id=\"feedContent\">" + grss.responseText + "</div>";
		}
	}
	grss.send(null);
};
