function ps_go(u) {document.location.href=u;}

function ps_link(url)
{
    var url = string_decode64(url);
    ps_go(url);
}

var price_keyStr = "ABCDEFGHIJKLMNOP" +
                "QRSTUVWXYZabcdef" +
                "ghijklmnopqrstuv" +
                "wxyz0123456789+/" +
                "=";

function string_decode64(input) {
   var output = "";
   var chr1, chr2, chr3 = "";
   var enc1, enc2, enc3, enc4 = "";
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   var base64test = /[^A-Za-z0-9\+\/\=]/g;
   if (base64test.exec(input)) {
      return '';
   }
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = price_keyStr.indexOf(input.charAt(i++));
      enc2 = price_keyStr.indexOf(input.charAt(i++));
      enc3 = price_keyStr.indexOf(input.charAt(i++));
      enc4 = price_keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }

      chr1 = chr2 = chr3 = "";
      enc1 = enc2 = enc3 = enc4 = "";

   } while (i < input.length);

   return output;
}

// Displays the page given by an URL encoded using Base64
function pop_encoded(encoded)
{
    w = (document.all ? screen.width : screen.width) * 0.9;
    h = (document.all ? screen.height : screen.height-150) * 0.9;
    opzioni = 'scrollbars=yes,toolbar=yes,location=yes,directories=yes,menubar=yes,resizable=yes,status=yes,width=' + w + ',height=' + h + ',screenX=0,screenY=0,top=0,left=0';
    var url = string_decode64(encoded);
    window.open(url,'',opzioni);
}


function pop_up_img(encoded_url, win_name,option)
{ 
  var url = string_decode64(encoded_url);
  
  features = "width=550,height=450,left=0,top=0";
  features += ",screenX=0,screenY=0";
  features += option +",resizable=0,location=0,directories=0";
  features += ",menubar=0,toolbar=0,status=0";
  
  w=window.open(url,win_name,features);
  w.focus();
}
