InitializeRedirects = function(internal, branch_name)
{
	/**************************** INTERNAL REDIRECTS ***************************************/
	// This list causes redirections in links depending on whether you are internal to the library or on a home computer
	var URLs = new Array();
	// netlibrary		
	URLs[0] = {urli: "http://netlibrary.com", urlo: "http://starship.snap.lib.ca.us/netlibrary_form.html"};
	// live homework help by tutor.com
	URLs[1] = {urli: "http://www.tutor.com/solano/", urlo: 
	"http://starship.snap.lib.ca.us/tutor_form.html"};
	// heritage quest 
	URLs[2] = {urli: "http://www.heritagequestonline.com/", urlo: "http://starship.snap.lib.ca.us/wc-bin/heritagequest"};
	// rand california
	URLs[3] = {urli: "http://ca.rand.org/", urlo: "http://www.solanolibrary.com/research/template.cfm?id=6362"};
	// proquest
	URLs[4] = {urli: "http://www.il.proquest.com/pqdauto", urlo: "http://starship.snap.lib.ca.us/proquest_form.html"};
	// learning express library
	URLs[5] = {urli: "http://learningexpresslibrary.com/", urlo: "http://starship.snap.lib.ca.us/wc-bin/learningexpresslibrary"};
	// encyclopedia brittannica
	URLs[6] = {urli: "http://search.eb.com/", urlo: "http://starship.snap.lib.ca.us/wc-bin/britannica"};
	// career center by tutor.com
	URLs[7] = {urli: "http://lhh.tutor.com/default.aspx?ProgramGUID=3492ddc8-fcfb-407d-ac90-b91f62a02940&InterfaceId=3&InterfaceType=Adult", urlo: "http://starship.snap.lib.ca.us/tutor2_form.html"};
	// BookFlix
	URLs[8] = {urli: "http://bkflix.grolier.com", urlo: "http://auth.grolier.com/cgi-libscript/entrypoint.pl?154617ntt&link=bkflix.grolier.com"};



	




	/******************************** BRANCH REDIRECTS **************************************/
	// This list causes redirections of links depending on which library you are at, or leaves links alone if you're external.
	// The branch names are keyed from the CMS item names for the intranet branches! If those get changed, change these as well!
	var branchURLs = new Array();
	branchURLs[0] = {
		url: "http://starship.snap.lib.ca.us/solano/servlet/kcHome",
		"Cordelia": "http://starship.snap.lib.ca.us/cordelia/servlet/kcHome",
		"Fairfield Civic Center": "http://starship.snap.lib.ca.us/fairfield/servlet/kcHome",
		"John F. Kennedy": "http://starship.snap.lib.ca.us/jfk/servlet/kcHome",
		"Rio Vista": "http://starship.snap.lib.ca.us/rio/servlet/kcHome",
		"Springstowne": "http://starship.snap.lib.ca.us/springstowne/servlet/kcHome",
		"Suisun City": "http://starship.snap.lib.ca.us/suisun/servlet/kcHome",
		"Vacaville Town Square": "http://starship.snap.lib.ca.us/townsquare/servlet/kcHome",
		"Vacaville Cultural Center": "http://starship.snap.lib.ca.us/vacaville/servlet/kcHome" };
		
	var libcardURLs = new Array();
	libcardURLs[0] = {
		url: "https://ecard.snap.lib.ca.us/index.php?do=english",
		"Cordelia": "https://ecard.snap.lib.ca.us/index.php?do=english&ecode=CORDEL",
		"Fairfield Civic Center": "https://ecard.snap.lib.ca.us/index.php?do=english&ecode=FAIRFD",
		"John F. Kennedy": "https://ecard.snap.lib.ca.us/index.php?do=english&ecode=JFK",
		"Rio Vista": "https://ecard.snap.lib.ca.us/index.php?do=english&ecode=RIOVST",
		"Springstowne": "https://ecard.snap.lib.ca.us/index.php?do=english&ecode=SPRNGS",
		"Suisun City": "https://ecard.snap.lib.ca.us/index.php?do=english&ecode=SUISUN",
		"Vacaville Town Square": "https://ecard.snap.lib.ca.us/index.php?do=english&ecode=TSVACA",
		"Vacaville Cultural Center": "https://ecard.snap.lib.ca.us/index.php?do=english&ecode=VACA" };
		
	var splibcardURLs = new Array();
	splibcardURLs[0] = {
		url: "https://ecard.snap.lib.ca.us/index.php?do=spanish",
		"Cordelia": "https://ecard.snap.lib.ca.us/index.php?do=spanish&ecode=CORDEL",
		"Fairfield Civic Center": "https://ecard.snap.lib.ca.us/index.php?do=spanish&ecode=FAIRFD",
		"John F. Kennedy": "https://ecard.snap.lib.ca.us/index.php?do=spanish&ecode=JFK",
		"Rio Vista": "https://ecard.snap.lib.ca.us/index.php?do=spanish&ecode=RIOVST",
		"Springstowne": " https://ecard.snap.lib.ca.us/index.php?do=spanish&ecode=SPRNGS",
		"Suisun City": "https://ecard.snap.lib.ca.us/index.php?do=spanish&ecode=SUISUN",
		"Vacaville Town Square": "https://ecard.snap.lib.ca.us/index.php?do=spanish&ecode=TSVACA",
		"Vacaville Cultural Center": "https://ecard.snap.lib.ca.us/index.php?do=spanish&ecode=VACA" };

	var links = $$("a");

	for(var link = 0; link < links.length; link++)
	{
		// process internal-external link rewriting
		for(var i = 0; i < URLs.length; i++)
		{
			if(links[link].href == URLs[i]["urli"])
			{
				//alert("found internal:" + links[link].href)
				if( !internal )
					links[link].href = URLs[i]["urlo"];	
			}
			
			if(links[link].href == URLs[i]["urlo"])
			{
				//alert("found external:" + links[link].href)
				if( internal )
					links[link].href = URLs[i]["urli"];			
			}
		}
		
		// process branch-specific link rewriting
		for(var j = 0; j < branchURLs.length; j++)
		{
			if(links[link].href == branchURLs[j]["url"])
			{
				if(branchURLs[j][branch_name])
					links[link].href = branchURLs[j][branch_name];
			}
		}
		
		
		// process library card branch-specific link rewriting
		for(var j = 0; j < libcardURLs.length; j++)
		{
			if(links[link].href == libcardURLs[j]["url"])
			{
				if(libcardURLs[j][branch_name])
					links[link].href = libcardURLs[j][branch_name];
			}
		}
		
		
		// process SPANISH library card branch-specific link rewriting
		for(var j = 0; j < splibcardURLs.length; j++)
		{
			if(links[link].href == splibcardURLs[j]["url"])
			{
				if(splibcardURLs[j][branch_name])
					links[link].href = splibcardURLs[j][branch_name];
			}
		}
		
		
	}
	
	
	
	
	
	
	
	// causes outgoing links to get logged in Google Analytics
	for(var ac=0; ac<links.length; ac++) {
		if (links[ac].href.indexOf(location.hostname) == -1 && links[ac].href.indexOf("javascript:") == -1) {
			links[ac].onclick = function () {
				var url = this.href.replace(/[\/]/g,"_");
				var url = url.replace("http:__","");
				pageTracker._trackPageview("/outgoing/" + url);
				return true;				
			}
		}
	}	
}
