function langSwitch(myWin,myURL){
	var pat = new Object();
	pat.spa = new Object();
	pat.spa.pat = "/spanish/";
	pat.spa.found = 0;
	
	pat.eng = new Object();
	pat.eng.pat = "/english/";
	pat.eng.found = 0;

	pat.spa.found = myURL.indexOf(pat.spa.pat);
	pat.eng.found = myURL.indexOf(pat.eng.pat);

	var out = new String();
	if (pat.spa.found != -1) out = replaceStr(myURL,pat.spa.pat,pat.eng.pat,false);
	else if (pat.eng.found != -1) out = replaceStr(myURL,pat.eng.pat,pat.spa.pat,false);
	myWin.location.href = out;
	}

function replaceStr(string,text,by,global) {
// Replaces text with by in string
    var strLength = string.length
	var txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

	if (global){
	    if (i+txtLength < strLength) newstr += replaceStr(string.substring(i+txtLength,strLength),text,by.global);
		}
	else {
		newstr += string.substring(i+txtLength,strLength);
		}


    return newstr;
	}

