function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null)
     {
       document.MM_sr[j++]=x; 
       if(!x.oSrc) x.oSrc=x.src; 
           x.src=a[i+2];

     }
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
  if (document.images) {
  i_maps2 = new Image(68 ,77); i_maps2.src = (imageURL + "i_maps2.gif");
  i_maps1 = new Image(68 ,77); i_maps1.src = (imageURL + "i_maps1.gif");
  i_dd2 = new Image(68 ,77); i_dd2.src = (imageURL + "i_dd2.gif");
  i_dd1 = new Image(68 ,77); i_dd1.src = (imageURL + "i_dd1.gif");
  i_rtp2 = new Image(68 ,77); i_rtp2.src = (imageURL + "i_rtp2.gif");
  i_rtp1 = new Image(68 ,77); i_rtp1.src = (imageURL + "i_rtp1.gif");
  }

function MM_generateRandom()
{
  return Math.round(( Math.random())*1000000000);
}

function MM_getUID(thedocument)
{
  var temp = thedocument.URL;
  var a = temp.split('?');
  var t = null;
  var undefined;
  t = a[1];
  if (t !== undefined)
  {
    var x = t.split('&');
    for (var i=0;i<x.length;i++)
    {
    var z = x[i].split('=');
    if((z[0]=="uid")||(z[0]=="UID"))
    //thedocument.write(z[1]);
    return(z[1]);	
    }
  }
}

function MM_readcookie(thedocument)
{
  var allcookies = thedocument.cookie;
  var pos = allcookies.indexOf("uid=");
  var uid = "";
  if (pos != -1) 
  {
	var start = pos + 4;
 	var end = allcookies.indexOf(";", start);
	if (end == -1) end = allcookies.length;
	uid = allcookies.substring(start,end);
  }
  return (uid);
}

function MM_userregistered(thedocument)
{
   var check = MM_readcookie(thedocument);
   if (check == "")
	return false;
   else
	{
	   var firstchar = check.substring(0,1);
	   if (firstchar == "r")
		return true;
	   else
		return false;
        }
}

function MM_imageoutput(thisdocument,image,width,height,border,usemap,vspace,name,hspace)
{
if (image != "")
  {
    thisdocument.write ("<img src=");  
    thisdocument.write (imageURL);
    thisdocument.write (image);
    thisdocument.write (" width=");
    thisdocument.write (width);
    thisdocument.write (" height=");
    thisdocument.write (height);
    thisdocument.write (" border=");
    thisdocument.write (border);
	if (usemap != "")
	{
		thisdocument.write (" usemap=");
		thisdocument.write (usemap);
	}

	if (vspace != "")
	{
		thisdocument.write (" vspace=");
		thisdocument.write(vspace);
	}

	if (hspace != "")
	{
		thisdocument.write (" hspace=");
		thisdocument.write(hspace);
	}

	if (name != "")
	{
		thisdocument.write (" name=");
		thisdocument.write(name);
	}


    thisdocument.write ("><br>");
  }
  return (imageURL);
}



function MM_imagebutton(thisdocument,image,value,name,border,vspace)
{
	thisdocument.write("<input type=\"image\" src=\"");
	thisdocument.write(imageURL);
	thisdocument.write(image);
	thisdocument.write("\" value=\"");
	thisdocument.write(value);
	thisdocument.write("\" name=\"");
	thisdocument.write(name);
	thisdocument.write("\" border=\"");
	thisdocument.write (border);
	thisdocument.write("\" vspace=\"");
	thisdocument.write(vspace);
	thisdocument.write("\">");

	return (imageURL);
}

function MM_addUidToUrl (the_url)
{
  // get the user's UID from the cookie
  var the_uid = MM_readcookie(document);

  // if the UID exists append it to the URL
  if (the_uid.length > 0)
     the_url = the_url + "&uid=" + the_uid;

  // return the new URL
  return (the_url);
}


function MM_removeinvalidchars(thestring)
{
    var instring = "";
    for (var i=0 ; i<(thestring.length); i++)
    {
      if (thestring.charAt(i) == '+')
      {
        instring += ' ';
      }
      else
        instring += thestring.charAt(i);
    }
    return instring;
}

function readURL(thewindow,index)
{
  var urlstr = thewindow.location.href;
  var retval = "";
  var pos = urlstr.indexOf(index);

  if (pos != -1) 
  {
        var start = pos + index.length + 1;
        var end = urlstr.indexOf("&", start);
        if (end == -1) end = urlstr.length;
        retval = urlstr.substring(start,end);
  }

  return (retval);
}
