﻿function initIndexPage() {
	var mainDiv = $('mainDiv');
	gmap = new googlemap();//for google maps

	//make pagerList
	var pagerListStart = $('pageNavDiv'); //after the prev page button
	if(pageCount > 1){
	    (pageCount).times(function(i){
	        if( currentPage != i ){
	           var url = "default.aspx?pageIndex=" + i;
	           var content = "<a href='" + url + "'>"+ (i+1) +"</a>";
	           }
	        else
	            content = "<b class='currentPage'>" + (i+1) + "</b>";
	        pagerListStart.insert(' ' + content );
	    });
	}
	
	/*Replaced by listview
	//Obtain all editorials from editorialList and add them to alphaEditorials
    var toList = $('alphaEditorials');
    $$('#editorialList img').each(function(imgElem){
        var name = imgElem.readAttribute('alt');
        var href = imgElem.up('a').readAttribute('href');
        toList.insert("<li><a href='" + href + "'>" + name + "</a></li>");
    });
    */
    
    //add to top to footer
    $('footerList').insert('<li> | <a href="javascript:scroll()">Top</a></li>');
    
    
    //scroll to top
    $$('.upButton').each(function(elm){
        Event.observe(elm, 'click', function(event) {
            scroll();
        });
    });
    

     /* move to appropriate location on page*/
    var queryString = location.search;
    if (queryString.length > 1) {
      var anchor = ( queryString.include('ePg') ? "editorials" : "articles" );
      scroll(anchor);  
    }
    
    /*fix for disabled property*/
    $$('.pageNavLink').each(function(elm){
        if(elm.readAttribute('disabled') == "disabled"){
            elm.remove();
        }
    });
}

function scroll(anchor){
    if(anchor)
        new Effect.ScrollTo(anchor);
    else
        new Effect.ScrollTo("mainTop");
}

    
/*google analytics*/
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
    var pageTracker = _gat._getTracker("UA-8645809-1");
    pageTracker._trackPageview();
} catch(err) {}