function test(site,msg) {
  if (msg != 2) {
    x=confirm("Have you already downloaded and evaluated the software and it works satisfactorily on your machine? If so, click OK.  Otherwise click CANCEL and you will be taken to download page.  No refund guarantee if you skip this step!");
    if (!x) {
      open("http://"+site,"_blank");
      return false;
    }
  }
  if (msg) {alert("I M P O R T A N T !!!         I M P O R T A N T !!!         I M P O R T A N T !!!\n\nYou will now be taken to our payment services provider, PayPal, to complete this purchase.\n\nYou MUST click CONTINUE on the LAST PAYPAL PAGE to return to this site and receive your REGISTRATION CODE.  Otherwise your purchase is NOT registered.  If you experience problems and do not immediately receive the required information, use our contact form to advise us.");}
  return true;
}

function test2(file_loc) {
  x=confirm("Do you need to download the software?  If so, click OK to download while you continue.\nIf you already downloaded, click Cancel.");
  if (x) {
    //alert("After the download completes, you can close the small empty window which will appear.");
    open(file_loc,"_blank","toolbar=no,directories=no,status=no,resizable=1,width=100,height=50");
    return false;
  }
  return true;
}

function kuka(str,word){   //get ? parms from url
 str=str+'&'
 var i=0; while ((str.substr(i,word.length) != word) && (i <= 
 str.length)){i++}
 var j=0; while ((str.substr(i+j,1) != '&') && ((i+j)<= str.length)){j++}
 return UNhtmlblanks(str.substr(i+word.length+1,j-1-word.length));
}

function UNhtmlblanks(s) {   //HTML %20 -> ' '
 var i,o,x;
 var c="%20 %2B+%3D=%2F/%5C\\%7C|%60`%7E~%21!%40@%23#%24$%25%^%5E^";
 c=c+"%26&%28(%29)%5B[%5D]%7B{%7D}%3B;%3A:%27'%22\"%2C,%3C<%3E>%3F?";
 o=s;
 while ((i=o.indexOf("+"))>=0) {o=o.substr(0,i)+" "+o.substr(i+1,o.length);}
 i=0;
 while (i<o.length) {
  if (o.substr(i,1) == '%') {
   x=o.substr(i,3);
   x=c.indexOf(x);
   if (x>=0) {o=o.substr(0,i)+c.substr(x+3,1)+o.substr(i+3,o.length);}
  }
  i++;
 }
 return o;
}

function wri(s) {document.write(s);}

function getCookie(name0) {
  var cookieFound = false;
  var start = 0;
  var end = 0;
  var cookieString = document.cookie;
  var i = 0;
  var name=name0 + "=";
  while (i <= cookieString.length) {
    start = i;
    end = start + name.length;
    if (cookieString.substring(start,end) == name) {
      if (start==0 || cookieString.substring(start-1,start)==" ") {
        cookieFound = true;
        break;
      }
    }
    i++;
  }
  if (cookieFound) {
    start = end;
    end = document.cookie.indexOf("; ",start);
    if (end < start) {end = document.cookie.length;}
    var value = document.cookie.substring(start,end);
    i = 0;
    while (i <= value.length) {
      if (value.substring(i,i+1) == "`") {
        value = value.substring(0,i) + " " + value.substring(i+1,value.length+1);
      }
      if (value.substring(i,i+1) == "¨") {
        value = value.substring(0,i) + ";" + value.substring(i+1,value.length+1);
      }
      i++;
    }
    return value;
  }
  return "";
}

function setCookie(name,value0,days,minutes,path) {
  var value = value0;
  var i = 0;
  while (i <= value.length) {
    if (value.substring(i,i+1) == " ") {
      value = value.substring(0,i) + "`" + value.substring(i+1,value.length+1);
    }
    if (value.substring(i,i+1) == ";") {
      value = value.substring(0,i) + "¨" + value.substring(i+1,value.length+1);
    }
    i++;
  }
  var expires = new Date();
  expires.setTime (expires.getTime() + (1000 * 60 * minutes) + (days * 24 * 60 * 60 * 1000));
  var cookString = name + "=" + value + "; expires=" + expires.toGMTString();
  if (path != "") {cookString = cookString + "; path=" + path;}
  document.cookie = cookString;
}

// referring URL
var newref=document.referrer;
var cref=getCookie("mcreferrer");
var uref=kuka(location.search,"uref");
//alert("Please pardon this temporary test!\nnewref="+newref+"; cref="+cref+"; uref="+uref);
if (uref!="") {
 setCookie("mcreferrer",uref,720,0,"/");
}else{
 if (cref=="") {
  setCookie("mcreferrer",newref,720,0,"/");
  uref=newref;
 }
}
// referring AD service
var aref=kuka(location.search,"aref");
if (aref!="") setCookie("mcaref",aref,720,0,"/");
else aref=getCookie("mcaref");

