  function confirmAction(url) {
    var yesno;
    yesno = (confirm("Through this website you are able to link to other websites which are not under the control of Grain SA.  We have no control over the nature, content and availability of those sites.  The inclusion of any links does not imply a recommendation or endorse the views expressed within them.  Grain SA has no responsibility or liability in respect of the use of these links whether directly or indirectly." + '\r\n\r\n' + "Op hierdie webtuiste sal u ook skakels na ander webtuistes vind wat nie deur Graan SA beheer word nie.  Ons het geen beheer oor die aard, inhoud en beskikbaarheid van sodanige webtuistes nie.  Die plasing van enige skakels op hierdie webtuiste impliseer nie ’n aanbeveling of onderskrywing van die sienings van die betrokke webtuistes nie.  Graan SA aanvaar geen verantwoordelikheid of aanspreeklikheid vir die gebruik van hierdie web-koppelings betref, hetsy deur direkte of indirekte gebruik nie."));

    if (yesno) location.href= url;
  }

  function cleanURL(str, bDeleteDomain)
  {
    if (str == null || str.length == 0)
      return "";
	


    var i;
    i = str.indexOf("javascript:wopen");
    if (i == 0) {
      str = str.substr(18);
      str = str.replace("',%20'Classified',%20600,%20480);", '');
    }

  

    //  str = str.replace('javascript:wopen', '');

    i = str.indexOf("http://");
    if (i == 0)
    {
      str = str.substr(7);
    }
    else if (str.indexOf("https://") == 0)
    {
      str = str.substr(8);
    }


    i = str.indexOf("?");
    if ( i > -1 )
      str = str.substring(0,i);
      
    i = str.indexOf("&");
    if ( i > -1 )
      str = str.substring(0,i);

    for (;;)
    {
      i = str.lastIndexOf("/");
      
      if ( i == -1 || i < (str.length -1) )
        break;
         
      str = str.substring(0,i);         
    }
   
    while (str.indexOf("/") == 0)
      str = str.substring(1);
                              
    if (bDeleteDomain)
    {
      i = str.indexOf("/");
      if ( i > -1 )
      {
        str = str.substring(i+1);   
      }
    }
      
    for (;;)
    {   
      i = str.indexOf("//");
      if (i == -1)
        break;
      str = str.replace(/\/\//g, "/");
    }
   
    return str;
  } 

  function getDomain(str)
  {
    if (str.indexOf("mailto:") == 0)
      return location.hostname;

    if (str == null || str.length == 0)
      return "len0";
   
    str = cleanURL(str, 0).toLowerCase();
   
    var i = str.indexOf("/");
    if (i > -1)
      str = str.substring(0, i);

    var parts = str.split('.');
   

    var len;
    len = parts.length;
   
    if (len < 3) 
      return "len3" + str;

    var lastPart;
    lastPart = parts[len-1];
    var secondPart;       
    secondPart = parts[len-2];
   
    var two = 2;
   
    if (secondPart == "co")
      ++two;
   
    var returnString;
    returnString = parts.splice(len-two, two).join('.');

    if (returnString == "milonic.com")
	return location.hostname;

    if (returnString == "grainsa.co.za")
	return location.hostname;

    if (returnString == "graansa.co.za")
	return location.hostname;

    if (len >= 0)
      return returnString;

   
    if (len == 0)
      return "";
  }


  function replaceHyperlinks() {
    var thisdomain = location.hostname;
    var links = document.getElementsByTagName("a");
    var pattern = '';
    for (var i=0; i< links.length; i++)
    {
      pattern  = new RegExp(links[i].href);
      if (getDomain(links[i].href) != getDomain(thisdomain)) {
	// links[i].href = links[i].href.replace(pattern, 'javascript:confirmAction("' + links[i].href + '");');
       links[i].href = 'javascript:confirmAction("' + links[i].href + '");';
      }
        // links[i].href = links[i].onClick.replace(pattern, 'return confirmAction()');
    }
  }