/*
Script Author: Phillip Dodson of Visional Echoes, LLC
Script Address: http://blog.visionalechoes.com/2007/07/07/javascript-stuff/query-string-value-getter/

Refer to the above URL for usage information.

Feel free to use this function however you wish.
If you see where it can be improved, please let me know.

Version: 1.0
*/

function GetQueryValue(k,q) // Key, Query String
{
   q=q||location.href;  // uses current uri if no query is supplied
   var tmpNdx=q.indexOf('?');
   if (tmpNdx!=-1) // If string has query information
   {
      q=q.slice(tmpNdx+1); // Remove all information except for query
      q=q.split('&');      // Create array of key/value pairs
      for (var i=0;i<q.length;i++)
      {
         var p=q[i].indexOf('=');
         if (p>0)
         {
            var thisk=q[i].substring(0,p);
            if (thisk==k) return q[i].substring(p+1); // return value
         }
      }
      return null; // If key doesn't exist, return null	
   } else {
      return null; // If no query information, return null
   }
}