table_currentlocation=document.location + '';

function table_urlreplace(variable,value,jumptolocation){
	// ha meg nincs ilyen get parameter az urlben	
	if(table_currentlocation.indexOf(variable+'=')==-1){
		if(value!=""){
			if(table_currentlocation.indexOf('?')==-1)
				separator='?';
			else
				separator='&';
			table_currentlocation = table_currentlocation + separator + variable + '=' + value;
		}
	}
	// ha mar van ilyen get parameter, meg kell valtoztatni
	else{
		splittedlocation = table_currentlocation.split(variable + '=');
		valuesplit=splittedlocation[1];
		// ha a hatralevo reszben nincs tobb ertek
		if(valuesplit.indexOf('&')==-1){
			if(value!=""){
				table_currentlocation=splittedlocation[0] + variable + '=' + value;
			}
			else
				table_currentlocation=splittedlocation[0];	
		}
		// ha tobb ertek is van utana akkor
		else{
			splittedvalues=splittedlocation[1].split('&');
			if(value!=""){
				sep='&';
				table_currentlocation=splittedlocation[0] + variable + '=' + value;			
			}
			else{
				sep='';
				table_currentlocation=splittedlocation[0];
			}
			for(i=1;i<splittedvalues.length;i++)
				table_currentlocation=table_currentlocation + sep + splittedvalues[i];	
		}
		table_currentlocation=table_strip(table_currentlocation,"&");
		table_currentlocation=table_strip(table_currentlocation,"?");
	}
	if(jumptolocation==true)
		document.location=table_currentlocation;
}

function table_strip(s,stripchar)
{
    if((s)||(s=='')){
    while((s.indexOf(stripchar,0) == 0) && (s.length > 1))
    {
        s = s.substring(1,s.length);
    }
    while((s.lastIndexOf(stripchar) == (s.length - 1) && (s.length > 1)))
    {
        s = s.substring(0,(s.length - 1));
    }
    if((s.indexOf(stripchar,0) == 0) && (s.length == 1)) s = '';
    return s;
}
}
