// JavaScript Document, Ronald Garcia 26/02/2007

function redirectMe(locationParam, domainParam){
	var indexEs = "";
	var indexpart = "";
	var indexExist = "";
	var entireLocation = domainParam+locationParam;
	
	if (entireLocation.indexOf("/es/") != -1){
		indexEs = entireLocation.indexOf("/es/");
	} else if (entireLocation.indexOf("/en/") != -1) {
		indexEs = entireLocation.indexOf("/en/");
	} else if (entireLocation.indexOf("index_en.php") !=-1){
		indexEs = 1;
	} else {indexes=0
	}
	
	
	var firstpart = entireLocation.substring(0, indexEs);
	var secondpart = entireLocation.substring(indexEs+1, indexEs+3);
	var lastpart = entireLocation.substring(indexEs+3);
	//change the filename
	var indexLanguage = indexpart.indexOf("_");
	var indexExtension = indexpart.indexOf(".");
	var page = indexpart.substring(0, indexLanguage+1);
	var extension = indexpart.substring(indexExtension);
	var pageparam = "";
	if(indexEs == 0){
		pageparam = "index_en.php";
	} else {
		pageparam = "index.php";	
	}
	//end
	//declare updated parts
	var nsecondpart = "";
	var nlastpart = "";
	
	if (secondpart == "es"){
		nsecondpart = "en";
		location = "http://"+domainParam+"/"+nsecondpart+lastpart;
	} else if (secondpart == "en"){
		nsecondpart = "es";	
		location = "http://"+domainParam+"/"+nsecondpart+lastpart;
	} else {
		location = "http://"+domainParam+"/"+pageparam;
	}
	
}