function update_param_in_url(argname,argvalue,oldurl){
//look for the argument 'argname' in the url 'oldurl' and
//either update it to the value 'argvalue' or add it if
//it doesn't exist

    address = oldurl.substring(0,(oldurl.indexOf('?'))+1);
		if(address == "")
		address = oldurl;

    query = oldurl.substring((oldurl.indexOf('?')+1));
	
		pairs = query.split("&");
    found = false;
		for(i=0; i<pairs.length; i++){
        key   = pairs[i].split("=")[0];
        value = pairs[i].split("=")[1];
        if(key == argname){
            found = true;
						value = argvalue;
						pairs[i] = key+"="+value;
				}
				if(i>0)
				address = address+"&"+pairs[i];
				else
				address = address+pairs[i];
				
        
    }
    if(!found)
		{
		if(pairs.length>0)
		address = address+"&"+argname+"="+argvalue;
		else
		address = address+argname+"="+argvalue;
		
		}
		return address;
}

function update_id_in_url(argname,argvalue,oldurl){
//look for the argument 'argname' in the url 'oldurl' and
//either update it to the value 'argvalue' or add it if
//it doesn't exist

//		address = oldurl;
	if(argvalue != ""){
		var loc = oldurl.indexOf("/dynoplot/");
		address = oldurl.substring(0, loc+10);
//alert(oldurl);
//alert(address);

		loc = oldurl.indexOf("/", loc+10);
		if(loc<0)
		loc = 0;
		address = address+argvalue+oldurl.substring(loc);
		return address;
	}
	else
	return "/dyno/dynoplot/index.htm";
}

