//#1 SPECIFY number of Images in Original Document
 var number_of_images=50

//#2 Initialize CounterClick for each Images
var i=0
var ImgCounterClick = new  Array(number_of_images)
	for (i=0; i<number_of_images; i++)
	ImgCounterClick[i]=0

// requires an image in the same directory as the one triggering the rollover with an _X suffix.
// the function is called as follow toggleImgOn(this) in the <img tag

function toggleImg(e) {
	var imgID = e.id;
	var thisimg = document.getElementById(imgID);
	// check the extension of the image object we are referring to
	if (thisimg.src.indexOf("_X") > -1)
	// and replace "_X" with "" to its src
  		{thisimg.src = thisimg.src.replace(/_X(\.[a-z0-9]+)$/i,'$1');
  		ImgCounterClick[imgID]=0 }
  	else // and replace "_S" with "_X" to its src
 		{thisimg.src = thisimg.src.replace(/(\.[a-z0-9]+)$/i,'_X$1');
 		ImgCounterClick[imgID]=1;
 		}
 		
 	for (i=0; i < number_of_images; i++) {  // reset to small the other images
 		if (ImgCounterClick[i]==1 & i==imgID) { continue;
 		} else if (ImgCounterClick[i]==1) { var imgclicked = document.getElementById(i);
 		imgclicked.src = imgclicked.src.replace(/_X(\.[a-z0-9]+)$/i,'$1');
 		}
 		}
	 
}


// requires an image in the same directory as the one triggering the rollover with an _on suffix.
// the function is called as follow toggleImgOn(this) in the <img tag

function toggleImgOn(e) {
	var imgID = e.id;
	var thisimg = document.getElementById(imgID);
	// check the extension of the image object we are referring to
	if (thisimg.src.indexOf("_on") > -1)
	// and replace "_X" with "" to its src
  		{thisimg.src = thisimg.src.replace(/_on(\.[a-z0-9]+)$/i,'$1');
  		ImgCounterClick[imgID]=0 }
  	else // and replace "_S" with "_X" to its src
 		{thisimg.src = thisimg.src.replace(/(\.[a-z0-9]+)$/i,'_on$1');
 		ImgCounterClick[imgID]=1;
 		}
 		
 	for (i=0; i < number_of_images; i++) {  // reset to small the other images
 		if (ImgCounterClick[i]==1 & i==imgID) { continue;
 		} else if (ImgCounterClick[i]==1) { var imgclicked = document.getElementById(i);
 		imgclicked.src = imgclicked.src.replace(/_on(\.[a-z0-9]+)$/i,'$1');
 		}
 		}
	
}





function resizeImage (imageOrImageName, width, height) {
  var image = typeof imageOrImageName == 'string' ?
                document[imageOrImageName] : imageOrImageName;
  if (document.layers) {
    image.currentWidth = width;
    image.currentHeight = height;
    var layerWidth = image.width > width ? image.width : width;
    var layerHeight = image.height > height ? image.height : height;
    if (!image.overLayer) {
      var l = image.overLayer = new Layer(layerWidth);
    }
    var l = image.overLayer;
    l.bgColor = document.bgColor;
    l.clip.width = layerWidth; 
    l.clip.height = layerHeight;
    l.left = image.x;
    l.top = image.y;
    var html = '';
    html += '<IMG SRC="' + image.src + '"';
    html += image.name ? ' NAME="overLayer' + image.name + '"' : '';
    html += ' WIDTH="' + width + '" HEIGHT="' + height + '">';
    l.document.open();
    l.document.write(html);
    l.document.close();
    l.visibility = 'show';
  }
  else {
    image.width = width;
    image.height = height;
  }
}
function zoomImage (imageOrImageName, factor) {
  var image = typeof imageOrImageName == 'string' ?
                document[imageOrImageName] : imageOrImageName;
  if (document.layers) {
    var currentWidth = image.currentWidth ? image.currentWidth : 
image.width;
    var currentHeight = image.currentHeight ? image.currentHeight : 
image.height;
  }
  else {
    var currentWidth = image.width;
    var currentHeight = image.height;
  }
  var width = parseInt(currentWidth * factor);
  var height = parseInt(currentHeight * factor);
  resizeImage(image, width, height);
}



// function toggleImgSizexx(e) {
// 	var imgID = e.id;
// 	var thisimg = document.getElementById(imgID);
// 	// check the extension of the image object we are referring to
// 	if (thisimg.src.indexOf("_X") > -1)
// 	// and replace "_X" with "" to its src
//   		{thisimg.src = thisimg.src.replace(/_X(\.[a-z0-9]+)$/i,'$1');
//   		ImgCounterClick[imgID]=0 }
//   	else // and replace "_S" with "_X" to its src
//  		{thisimg.src = thisimg.src.replace(/(\.[a-z0-9]+)$/i,'_X$1');
//  		ImgCounterClick[imgID]=1;
//  		}
//  		
//  	for (i=0; i < number_of_images; i++) {  // reset to small the other images
//  		if (ImgCounterClick[i]==1 & i==imgID) { continue;
//  		} else if (ImgCounterClick[i]==1) { var imgclicked = document.getElementById(i);
//  		imgclicked.src = imgclicked.src.replace(/_X(\.[a-z0-9]+)$/i,'$1');
//  		}
//  		}
// 	 
// }

// function toggleImgSize(e) {
// 	var imgID = e.id;
// 	var thisimg = document.getElementById(imgID);
// 	// check the extension of the image object we are referring to
// 	if (thisimg.src.width > -1)
// 	var m=getImageWidth(thisimg)
// 	alert(m);
	
	// and replace "_X" with "" to its src
  	// 	{thisimg.src = thisimg.src.replace(/_X(\.[a-z0-9]+)$/i,'$1');
//   		ImgCounterClick[imgID]=0 }
//   	else // and replace "_S" with "_X" to its src
//  		{thisimg.src = thisimg.src.replace(/(\.[a-z0-9]+)$/i,'_X$1');
//  		ImgCounterClick[imgID]=1;
//  		}
//  		
//  	for (i=0; i < number_of_images; i++) {  // reset to small the other images
//  		if (ImgCounterClick[i]==1 & i==imgID) { continue;
//  		} else if (ImgCounterClick[i]==1) { var imgclicked = document.getElementById(i);
//  		imgclicked.src = imgclicked.src.replace(/_X(\.[a-z0-9]+)$/i,'$1');
//  		}
//  		}
	 
//}


// function getImageWidthxx(e)
// 
// {
// var height = 0;
// var imgID = e.id;
// var thisimg = document.getElementById(imgID);
// var height = thisimg.height;
// alert (height);
// }
// 
// function getImageWidth(myImage) {
// 	var x, obj;
// 	if (document.layers) {
// 		var img = getImage(myImage);
// 		return img.width;
// 		var w = img.width
// 		alert(w);
// 	} else {
// 		return getElementWidth(myImage);
// 		var w = getElementWidth(myImage);
// 		alert(w);
// 	}
// 	return -1;
// 	alert('hello');
// }
// 
// function getImageHeight(myImage) {
// 	var y, obj;
// 	if (document.layers) {
// 		var img = getImage(myImage);
// 		return img.height;
// 	} else {
// 		return getElementHeight(myImage);
// 		return img.height;
// 	}
// 	return -1;
// }