
/*
INSTRUCTIONS:
	- Paste this code in teh head of you page, or in an external .JS file (it's easier to manage JS this way and you should allways use it)

	- In your page, simply add  onclick="clng()" to the language selection button.
	- This script is made to work with 2 sets of files (eg: myfile.php and sp_myfile.php) whenever the function is called it will alternate between them.

Enjoy

*/

function clng(){
var prefix = 'fr_' // prefix you would liek to add to URL.. can be whatever you want
var lada = window.location.href;
var pageName = lada.substring(lada.lastIndexOf('/') + 1 );
var pathWithoutPage = lada.substring(0, lada.length -pageName. length);

	if (pageName == "") { // this section fixes the index problem
		pageName = "index.php"; // set index extension to whatever yu prefer PHP, HTM, HTML, ASP etc..
	}

if (pageName.substring(0,prefix.length) == prefix) {
 location.href = pathWithoutPage+pageName.substring(prefix.length, pageName.length);
} else {
 location.href = pathWithoutPage+prefix+pageName;
}
}

// end Change Language Script