function ChangeParamValueOrAppend(link, param_name, new_value)
{
    var src, res, pos, pos_end, pos_qm;

    src = link;
    res = "";

    if (src.indexOf("#more")>-1) src = src.substring(0, src.length-5);

    if (src.indexOf("#")>-1) src = src.substring(0, src.length-1);

    pos = src.indexOf(param_name + "=");
    
    if(pos > -1) //there is a occurence of (param_name + "=") in src (only first is cosidered)
    {   
	//copy part before the occurence str_from in src to the result
	if(pos > 0) res += src.substring(0, pos);
	
	//add str_to the result
	res += (param_name + "=" + new_value);
	
	//remove everything to the first occurence of str_to and the first occurence of str_to from src
	if(pos + param_name.length + 1 < src.length)
	    src = src.substring(pos + param_name.length + 1, src.length);
	else
	    src = ""
	;
	
	//copy the rest of link after this parameter (if anything exists)
	pos_end = src.indexOf("&");
	if(pos_end > -1) res += src.substring(pos_end, src.length);
    }
    else
    {   
	pos_qm = src.indexOf("?");
	
	if(pos_qm > -1)
	{
	    if(pos_qm < src.length - 1)
		res = src + "&" + param_name + "=" + new_value;
	    else
		res = src + param_name + "=" + new_value
	    ;
	}
	else
	    res = src + "?" + param_name + "=" + new_value
	;
    }
    
    return(res);
}

function RedirectLanguage(new_lang)
{
    location.replace
    (
	ChangeParamValueOrAppend
	(
	    document.location.href,
	    "language",
	    new_lang
	)
    );
}

function doExpand(paraNum, imageNum) {
	if (paraNum.style.display=="none")
		{paraNum.style.display=""; imageNum.src="img/close.jpg"}
	else 
		{paraNum.style.display="none"; imageNum.src="img/open.jpg"}
}

function doExpand(paraNum) {
	if (paraNum.style.display=="none")
		{paraNum.style.display=""}
	else 
		{paraNum.style.display="none"}
}
