images=new Array()

centerImage=1 // 0 = no, 1 = yes
imageSize=100 // % size the large image is shown at
displayBorderWidth=8
displayBorderColor="#FFFFFF"
offsetX=0;
offsetY=100;
preload=new Array()

var pics_count = 0;

function addGalleryImage(url, alt, descr) {
	images[pics_count] = new Array();
	images[pics_count][0] = url;
	images[pics_count][1] = alt, 
	images[pics_count][2] = descr;
	pics_count++;
}

function preloadGallery() {
	for(var i=0;i<images.length;i++){
		preload[i]=new Image()
		preload[i].src=images[i][0]
	}
}

function placeGalleryBox() {
	document.write("<div id=\"gallery_imgholder\" style=\"position:absolute;left:0px;top:0px;display:none; \" title=\"Нажмите, чтобы закрыть\" >");
	document.write("<img name=\"gallery_pic\" id=\"gallery_pic\" src=\"blank.gif\" alt=\"\" style=\"position:relative\" >");
	document.write("</div>");
}

function getBodyScrollTop() {
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function showImage(num){
	displayEl=document.getElementById("gallery_imgholder")
	displayPic=document.images["gallery_pic"]
	displayPic.onclick=function(){
		displayEl.style.display="none"
	}
	imageWidth=preload[num].width/100*imageSize
	imageHeight=preload[num].height/100*imageSize
	if(document.getElementById("gallery_displaytext")){
		displayEl.removeChild(displayText)
	}
	displayEl.style.backgroundColor=displayBorderColor
	displayEl.style.width=(displayBorderWidth==0?imageWidth:imageWidth+(displayBorderWidth*2))+"px"
	displayEl.style.height=(displayBorderWidth==0?imageHeight:imageHeight+(displayBorderWidth*2))+"px"
	//displayEl.style.backgroundImage="url("+preload[num].src+")"
	displayEl.style.display="block"
	displayPic.src=preload[num].src
	displayPic.style.width=imageWidth+"px"
	displayPic.style.height=imageHeight+"px"
	displayPic.style.margin=displayBorderWidth+"px"
	displayPic.alt=images[num][1]
	if(images[num][2]){ // create text box if required
		displayEl.style.height=""
		displayText=document.createElement("DIV")
		displayText.setAttribute("id","gallery_displaytext")
		with(displayText.style){
			marginLeft=displayBorderWidth+"px"
			marginRight=displayBorderWidth+"px"
			marginBottom=displayBorderWidth+"px"
			color="black"
			textAlign="center"
		}
		displayText.innerHTML=images[num][2]
		displayEl.appendChild(displayText)
		if(images[num][3]){
			document.getElementById("gallery_displaytext").className=images[num][3] // apply style
		} else {
			document.getElementById("gallery_displaytext").className="gallery_defaultstyle"
		}
	}
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		centerLeft=(document.body.clientWidth/2) - (displayEl.offsetWidth/2) + offsetX
		centerTop = getBodyScrollTop() - (displayEl.offsetHeight/2) + offsetY
	} else {
		//IE
		centerLeft=(document.body.clientWidth/2) - (displayEl.offsetWidth/2) + offsetX
		centerTop=getBodyScrollTop() - (displayEl.offsetHeight/2) + offsetY
	}
	if(centerImage==1){
		displayEl.style.left=centerLeft+"px"
		displayEl.style.top=centerTop+"px"
	}
}
// -->
/*
<style>
.gallery_defaultstyle{
	color:#008000;
	background-color:#ddeedd;
	border:2px solid #bbccbb;
}
.gallery_textstyle2{
	color:#808000;
	background-color:#eeeedd;
	border:2px solid #ccccbb;
}
.gallery_textstyle3{
	color:#800000;
	background-color:#eedddd;
	border:2px solid #ccbbbb;
}
.gallery_textstyle4{
	color:#000000;
	background:#ddddee;
	border:1px solid #bbbbcc;
}
</style>
<img src="http://www.03www.su/00001.jpg" onclick="showImage(0)"  width=100>
<img src="http://www.03www.su/00002.jpg" onclick="showImage(1)" width=100>
<img src="http://www.03www.su/00003.jpg" onclick="showImage(2)" width=100>
<img src="http://www.03www.su/00004.jpg" onclick="showImage(3)" width=100>
<img src="http://www.03www.su/00005.jpg" onclick="showImage(4)" width=100>
<img src="http://www.03www.su/00006.jpg" onclick="showImage(5)" width=100>
*/





