var currHLFolder="Welcome";

var iconImages={'Welcome':'welcome-','UsefulInfo':'usefulinfo-','WeeklyBulletin':'weeklybulletin-','OrgAct':'orgact-','WhatsHappen':'whatshappen-','RelLinks':'rellinks-','Directions':'directions-'};
var iconDisplay=function(id1,id2,id3){}

function clicked(foldName, url, containerid){

// Contents of changing image when clicked

 highlightFolder(false,currHLFolder);
 
// Contents of ajaxpage function for Ajax functionality.

var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
document.getElementById(containerid).innerHTML=loadstatustext
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
 
// Contents of ajaxpage function for Ajax functionality, continued.

 highlightFolder(true,foldName);

}

function highlightFolder(option,foldName){

 var myFolder=(foldName);

 if($(myFolder+str_to_num(myFolder))){
 var childTds=$(myFolder+str_to_num(myFolder)).getElementsByTagName("td");
 var childLen=childTds.length;
 var childImg=$(myFolder+str_to_num(myFolder)).getElementsByTagName("img");
 childImg.item(0).src='http://'+_churchServer+'/img/'+iconImages[myFolder]+((option)?'select':'unselect')+'.gif';
}

 currHLFolder=myFolder;
 
}

/* ----------------------------- Contents of global-js-j.js ----------------------------- */

function changeFolderNames(tableId){

 var childTds=$(tableId).getElementsByTagName("tr");
 var childLen=childTds.length;
 for(var j=0;j<childLen;j++){
 if(childTds.item(j).getAttribute("id")){
 childTds.item(j).setAttribute("id",childTds.item(j).getAttribute("id")+str_to_num(childTds.item(j).getAttribute("id")));
}
}
}

function str_to_num(encStr){
var num_out="";
for(i=0;i<encStr.length;i++){
num_out+=encStr.charCodeAt(i)-23;
}
return num_out;
}

/* ----------------------------- Contents of class_prototype.htm ----------------------- */

function $(){
 var elements=new Array();

 for(var i=0;i<arguments.length;i++){
 var element=arguments[i];
 if(typeof element=='string')
 element=document.getElementById(element);

 if(arguments.length==1)
 return element;

 elements.push(element);
}

 return elements;
}



// Contents of Ajax.js used for Ajax functionality.

var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var loadstatustext="<img src='img/loading.gif' /> Loading..."

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

// Used for the popup information box for the What's Happening page (calendar of events)

    uniqueUrl = 1;
// This needs to be fixed if the current page plans to use the "bUseSame" option
// for more than one window. ViewWin is obviously not sufficient for tracking multiple windows
    var ViewWin = null;
    function popout(url, targetWin, h, w, bTouchUrl, bUseSame )
    {
        if( bUseSame && ViewWin != null && !ViewWin.closed && ViewWin.name == targetWin )
        {
            ViewWin.focus();
        }
        else
        {
        
            if (bTouchUrl)
            {
                if (bTouchUrl == 1)
                {
                    url += "&z=" + uniqueUrl;
                    uniqueUrl++;
                }
            }
            
            if (h && h > 0)
                height=h;
            else
                height=470;

            if (w && w > 0)
                width=w;
            else
                width=630;

		if( bUseSame  )            
ViewWin=window.open(url, targetWin,
                            'width='+width+',height='+height+',resizable=yes,menubar=yes,scrollbars=yes,status=yes' );
		else
window.open(url, targetWin,
                            'width='+width+',height='+height+',resizable=yes,menubar=yes,scrollbars=yes,status=yes' );



        }
         
    }