
function switchLanguage(code)
{
	var uri = window.location.toString();
	
	if(uri.indexOf('/en/') > -1 || uri.indexOf('/gd/') > -1)
	{
		// change path	
	
		var str;
		
	
		if(code=='en'){
			str = '/gd/';
		} else {
			str = '/en/';
		}
			
		var pos = uri.indexOf(str)+1;	
		var el1 = uri.substr(0, pos);
		var el2 = uri.substr(pos+2, uri.length);	
		var path = el1 + code + el2;
		
		window.location = path;
		

	} else {
		// index page
		
		var path = uri.substr(0, uri.lastIndexOf('/', uri.length)+1);
		
		
		if(code=='en'){
			path += 'index-en.html';	
		} else {
			path += 'index.html';
		}
		
		window.location = path;
		
	}
	
}