

query_vars = new Object(); 



function readQuery() 
{ 
        // get the URLs query string 
        var query_string = unescape(document.location.search.toString().substring(1)); 

        // if no query string 
        if(query_string.length == 0) 
        { 
                query_vars = null; 
                return; 
        } 

        // if no '=', then just the one variable 
        if( query_string.indexOf('=',0) == -1 ) 
        { 
                query_vars = query_string; 
                return; 
        } 
        
        // split the query string into 'name=value' pairs 
        var var_list = query_string.split('&'); 

        // loop through the list of values 
        for(i=0; i<var_list.length; i++) 
        { 
                // split them into separate names / values 
                var_list[i] = var_list[i].split('='); 

                // if no value set for the variable, set to null 
                if( var_list[i][1] == '' ) var_list[i][1] = null; 

                // create variable within the query vals object 
                eval( "query_vars." + var_list[i][0] + "='" + var_list[i][1] + "'" ); 

        } 
        
} 

readQuery(); 

