// JavaScript Document

function changeURLtoEs ()
{
    /*
    This script gets the URL of the current page, then breaks the url into 3 parts:
	
		www.chavezcenter.org/en/about-us/index.html
		|------------------||--||-----------------|
		1					2	3
		this allows for each English page to be directly linked to each Spanish page
    */
    var URL = unescape(location.href)    // get current URL in plain ASCII
	newLang = "/es/";

    var xend = URL.length

	var endOfPathway = URL.indexOf("/en/");
	
	if (endOfPathway > 0) {
		var beginOfFilename = endOfPathway + 4;
		var newURL = URL.substring(0,endOfPathway) + newLang + URL.substring(beginOfFilename,xend);
		window.location.href = newURL;
		//alert("The page you are viewing is: " + newURL);
	}	
}


function changeURLtoEn ()
{
    /*
    This script gets the URL of the current page, then breaks the url into 3 parts:
	
		www.chavezcenter.org/es/about-us/index.html
		|------------------||--||-----------------|
		1					2	3
		this allows for each English page to be directly linked to each Spanish page
    */
    var URL = unescape(location.href)    // get current URL in plain ASCII
	newLang = "/en/";

    var xend = URL.length

	var endOfPathway = URL.indexOf("/es/");
	var beginOfFilename = endOfPathway + 4;
	var newURL = URL.substring(0,endOfPathway) + newLang + URL.substring(beginOfFilename,xend);
	
	window.location.href = newURL;
    //alert("The page you are viewing is: " + newURL);
}


