function openWindow(url, w, h) {
	var windowprops = "width=" + w + ",height=" + h;
	popup = window.open(url,'remote',windowprops);
}

function OpenSmallPopup(path){
window.open('./' + path, 'WindowNAME', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=520,height=350');      
}

function OpenPopup(path){
window.open('./' + path, 'WindowNAME', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=520,height=550');      
}

function OpenTextPopup(text, w, h){
	var windowprops = "width=" + w + ",height=" + h;
	popup = window.open('','',windowprops);
	var tmp = popup.document;
	tmp.write('<html><head></head><body><style>body{font-family:Arial;font-size:11px;}</style>');
	tmp.write('<p>' + text + '</p>');
	tmp.write('</body></html>');
	tmp.close();
}

function popitup2() {
	newwindow2=window.open('','name','height=200,width=150');
	var tmp = newwindow2.document;
	tmp.write('<html><head><title>popup</title>');
	tmp.write('<link rel="stylesheet" href="js.css">');
	tmp.write('</head><body><p>this is once again a popup.</p>');
	tmp.write('<p><a href="javascript:alert(self.location.href)">view location</a>.</p>');
	tmp.write('<p><a href="javascript:self.close()">close</a> the popup.</p>');
	tmp.write('</body></html>');
	tmp.close();
}



var registeredImages = new Object();
var numberToPreload = 6;
var preloadCount = 0;

function registerImage( id, image, html, caption ) {
    registeredImages[id] = new Object();
    registeredImages[id].image = image;
    registeredImages[id].html = html;
    registeredImages[id].caption = caption;

    if ( preloadCount < numberToPreload ) {
      var imagePreloader = new Image();
      imagePreloader.src = image;
      preloadCount++;
    }
  }

var allPreloaded = 0;
var selectedImageID = "original_image";

function displayImage( id ) {
    if ( id == selectedImageID ) return;

/*
    if (registeredImages[selectedImageID].ciuAnnoContainer) {
      registeredImages[selectedImageID].ciuAnnoContainer.hide();
    }
*/	
    selectedImageID = id;

    document.getElementById('prodImageCell').innerHTML = registeredImages[id].html;
    document.getElementById('prodImageCaption').innerHTML = registeredImages[id].caption;

    for ( elementID in registeredImages ) {
      var imageThumbnail = document.getElementById(elementID);
      if (imageThumbnail != null) {
	imageThumbnail.style.border = '1px solid #999999';
      }
      if ( !allPreloaded ) {
        var imagePreloader = new Image();
        imagePreloader.src = registeredImages[elementID].image;
      }
    }

    document.getElementById(id).style.border = '1px solid #990000';

    allPreloaded = 1;
/*
    if (registeredImages[id].ciuAnnoContainer) {
      registeredImages[id].ciuAnnoContainer.show();
    }
*/	

  }


