// slideformer version 1.0 alpha1
// CopyRight(C) MDS.Co.,Ltd.
// http://www.md-systems.net/
// info@md-systems.net
// see example!
SlideFormer = function (slideId,zIndex) {
	var self = document.createElement('div');
	self.id = 'slideformer';
	if( slideId ){ self.id = slideId;}
	self.zIndex	= '999';
	if( zIndex ){ self.zIndex = zIndex;}
	self.grayOutRate			= 15;
	self.path					= '';
	self.imagePos				= 0;
	self.imageTagArray			= new Array();
	self.imageObjectArray		= new Array();
	self.alphaNumber			= 0;
	self.panel					= new SlideFormer.SlidePanel(self.slideId+'_panel', self.zIndex+1);
	self.style.display			= 'block';
	self.style.position			= 'absolute';
	self.style.top				= '0px';
	self.style.left				= '0px';
	self.style.backgroundColor	= '#000000';
	self.style.filter			= 'alpha(opacity=60)';
	self.style.opacity			= '0.6';
	self.style.zIndex			= '-' + self.zIndex;
	self.style.visibility		= 'hidden';
	self.style.textAlign		= 'center';
	var scriptTags 				= document.getElementsByTagName('script');
	for(var i=0,n=scriptTags.length;i<n;i++) {
		if(scriptTags[i].src.match('slideformer.js')) {
			self.path = scriptTags[i].src.replace('slideformer.js','');
		}
	}
	self.show = function( imagePos ) {
		this.imagePos			= imagePos;
		this.style.visibility	= 'visible';
		this.style.zIndex		= this.zIndex;
		this.style.width		= String(Math.max( document.body.clientWidth , document.body.scrollWidth )) + 'px';
		this.style.height		= String(Math.max( document.body.clientHeight , document.body.scrollHeight )) + 'px';
		this.panel.style.visibility	= 'visible';
		this.panel.style.zIndex		= String( parseInt(this.zIndex) + 1 );
		this.panel.style.width		= '10px';
		this.panel.style.height		= '10px';
		this.panel.style.overflow	= 'hidden';
		SlideFormer.whiteIn();
	};
	self.startShowPanel = function() {
		this.panel.setImage(this.getCurrentImage());
		document.getElementsByTagName('body')[0].appendChild(this.panel);
		setTimeout(SlideFormer.expandPanel, 30);
	};
	self.next = function() {
		if( this.imagePos < this.imageTagArray.length ) {
			this.imagePos++;
			this.panel.setImage(this.getCurrentImage());
			setTimeout(SlideFormer.expandPanel, 30);
		}
	};
	self.prev = function() {
		if( this.imagePos > 0 ) {
			this.imagePos--;
			this.panel.setImage(this.getCurrentImage());
			setTimeout(SlideFormer.expandPanel, 30);
		}
	};
	self.hide = function() {
		SlideFormer.erasePanel();
	};
	self.removeShowPanel = function() {
		document.getElementsByTagName('body')[0].removeChild(this.panel);
	};
	self.getCurrentImage = function() {
		if( this.imageObjectArray[this.imagePos] ) {
			this.imageObjectArray[this.imagePos].imageNumber	= this.imagePos;
			this.imageObjectArray[this.imagePos].totalCount		= this.imageTagArray.length;
			return this.imageObjectArray[this.imagePos];
		} else {
			this.imageObjectArray[this.imagePos]	= new Image();
			var imageTag	= this.imageTagArray[this.imagePos];
			if( imageTag ) {
				var parentTag	= this.imageTagArray[this.imagePos].parentNode;
				var fileName	= imageTag.className.replace('slideformer','').replace(' ', '');
				if( parentTag.tagName.toLowerCase() == 'a' ) {
					this.imageObjectArray[this.imagePos].src	= parentTag.src;
					this.imageObjectArray[this.imagePos].title	= parentTag.title;
					this.imageObjectArray[this.imagePos].alt	= imageTag.alt;
				} else if( fileName.length > 0 ) {
					var uriArray	= imageTag.src.split('/');
					uriArray.pop();
					uriArray.push(fileName);
					this.imageObjectArray[this.imagePos].src	= uriArray.join('/');
					this.imageObjectArray[this.imagePos].title	= imageTag.title;
					this.imageObjectArray[this.imagePos].alt	= imageTag.alt;
				} else {
					this.imageObjectArray[this.imagePos].src	= imageTag.src;
					this.imageObjectArray[this.imagePos].title	= imageTag.title;
					this.imageObjectArray[this.imagePos].alt	= imageTag.alt;
				}
				this.imageObjectArray[this.imagePos].imageNumber	= this.imagePos;
				this.imageObjectArray[this.imagePos].totalCount		= this.imageTagArray.length;
				for( var i=0; i < this.imagePos-3; i++ ) {
					this.imageObjectArray[i]	= null;
				}
				for( var i=this.imagePos+3; i < this.imageTagArray.length; i++ ) {
					this.imageObjectArray[i]	= null;
				}
				return this.imageObjectArray[this.imagePos];
			}
		}
	};
	self.toWhiteIn = function () {
		this.initAlphaNumber();
		if( this.alphaNumber < 80 ) {
			this.alphaNumber += this.grayOutRate;
			if( this.alphaNumber > 80 ) { this.alphaNumber	= 80; }
			this.style.opacity	= String( this.alphaNumber/100);
			this.style.filter	= 'alpha(opacity='+String(this.alphaNumber)+')';
		}
		if( this.alphaNumber < 80 ) {
			return false;
		} else {
			this.alphaNumber	= 80;
			return true;
		}
	};
	self.toWhiteOut = function () {
		this.initAlphaNumber();
		if( this.alphaNumber > 0 ) {
			this.alphaNumber -= this.grayOutRate;
			if( this.alphaNumber < 0 ) { this.alphaNumber	= 0; }
			this.style.opacity	= String(this.alphaNumber/100);
			this.style.filter	= 'alpha(opacity='+String(this.alphaNumber)+')';
		}
		if( this.alphaNumber > 0 ) {
			return false;
		} else {
			this.alphaNumber	= 0;
			return true;
		}
	};
	self.initAlphaNumber = function () {
		if( !this.alphaNumber ) {
			if( this.style.opacity ) {
				this.alphaNumber	= Math.round(parseFloat(this.style.opacity)*100);
			} else if( this.style.filter ) {
				var str = this.style.filter;
				str	= str.replace('alpha','');
				str	= str.replace('opacity','');
				str	= str.replace('(','');
				str	= str.replace(')','');
				str	= str.replace('=','');
				this.alphaNumber	= Math.round(parseFloat(str));
			}
		}
	};
	document.getElementsByTagName('body')[0].appendChild(self);
	return self;
}
SlideFormer.SlidePanel = function(panelId,zIndex) {
	var self = document.createElement('div');
	self.id = 'slideformer_panel';
	if( panelId ){
		self.id = panelId;
	}
	self.zIndex	= '1000';
	if( zIndex ){
		self.zIndex = zIndex;
	}
	self.grayOutRate			= 70;
	self.expandRate				= 20;
	self.defaultWidth			= 80;
	self.defaultHeight			= 80;
	self.width					= 0;
	self.height					= 0;
	self.currentWidth			= self.defaultWidth;
	self.currentHeight			= self.defaultHeight;
	self.padding				= 8;
	self.alphaNumber			= 0;
	self.style.display			= 'block';
	self.style.position			= 'absolute';
	self.style.overflow			= 'hidden';
	self.style.top				= '0px';
	self.style.left				= '0px';
	self.style.backgroundColor	= '#FFFFFF';
	self.style.borderStyle		= 'solid';
	self.style.borderWidth		= '1px';
	self.style.zIndex			= '-' + String( parseInt(self.zIndex) );
	self.style.textAlign		= 'center';
	self.style.padding			= String(self.padding) + 'px';
	self.imageObject			= null;
	var scriptTags 				= document.getElementsByTagName('script');
	for(var i=0,n=scriptTags.length;i<n;i++) {
		if(scriptTags[i].src.match('slideformer.js')) {
			self.path = scriptTags[i].src.replace('slideformer.js','');
		}
	}
	// テーブルの初期化
	self.table					= document.createElement('table');
	self.appendChild(self.table);
	self.table.style.margin			= '0 auto';
	self.table.style.borderCollapse	= 'collapse';
	self.tbody					= document.createElement('tbody');
	self.table.appendChild(self.tbody);
	self.imageTr				= document.createElement('tr');
	self.imageTr.borderStyle	= 'none';
	self.imageTd				= document.createElement('td');
	self.imageTd.borderStyle	= 'none';
	self.imageTd.colSpan		= 2;
	self.imageTd.style.textAlign		= 'center';
	self.imageTd.style.verticalAlign	= 'middle';
	self.imageTd.style.padding			= '0px';
	self.imageTr.appendChild(self.imageTd);
	self.tbody.appendChild(self.imageTr);
	// タイトルライン
	self.titleTr				= document.createElement('tr');
	self.titleTd				= document.createElement('td');
	self.titleTd.style.textAlign	= 'left';
	self.titleTd.style.color		= '#808080';
	self.titleTd.style.fontSize		= '14px';
	self.titleTd.style.fontFamily	= 'monospace';
	self.titleTd.style.fontWeight	= 'bold';
	self.titleTd.style.lineHeight	= '14px';
	self.titleTd.style.padding		= '3px';
	self.titleTd.colSpan			= 2;
	self.titleTr.appendChild(self.titleTd);
	// ディスクリプションライン
	self.descriptionTr			= document.createElement('tr');
	self.descriptionTd			= document.createElement('td');
	self.descriptionTd.style.textAlign	= 'left';
	self.descriptionTd.style.color		= '#808080';
	self.descriptionTd.style.fontSize	= '12px';
	self.descriptionTd.style.lineHeight	= '12px';
	self.descriptionTd.style.fontFamily	= 'monospace';
	self.descriptionTd.style.padding	= '0px';
	self.descriptionTd.colSpan	= 2;
	self.descriptionTr.appendChild(self.descriptionTd);
	// 閉じるボタンの初期化
	self.closeButton				= new Image();
	self.closeButton.src			= self.path + 'images/closelabel.gif';
	self.closeButton.onclick		= function() { SlideFormer.slideformerObject.hide() };
	self.closeButton.onmouseover	= function() { this.style.cursor = 'pointer'; }
	// 最終ライン（画像数表示と閉じるボタン
	self.bottomTr			= document.createElement('tr');
	self.bottomTd			= document.createElement('td');
	self.closeTd			= document.createElement('td');
	self.bottomTr.appendChild(self.bottomTd);
	self.bottomTr.appendChild(self.closeTd);
	self.closeTd.appendChild(self.closeButton);
	self.closeTd.style.textAlign	= 'right';
	self.closeTd.style.padding		= '0px';
	self.bottomTd.style.textAlign	= 'left';
	self.bottomTd.style.color		= '#808080';
	self.bottomTd.style.fontSize	= '12px';
	self.bottomTd.style.fontFamily	= 'monospace';
	self.bottomTd.style.padding		= '0px';
	// ローディング画像
	self.loadingImage				= new Image();
	self.loadingImage.src			= self.path + 'images/loading.gif';
	
	// prevボタンブロック
	self.prevDiv					= document.createElement('div');
	var prevButton					= new Image();
	prevButton.src					= self.path + 'images/prevlabel.gif';
	prevButton.id					= 'slideformer-prev-button';
	prevButton.style.visibility		= 'hidden';
	self.prevDiv.style.width		= '49%';
	self.prevDiv.style.margin		= '0px';
	self.prevDiv.style.paddingTop	= '30px';
	self.prevDiv.style.styleFloat	= 'left';
	self.prevDiv.style.cssFloat		= 'left';
	self.prevDiv.style.borderWidth	= '0px';
	self.prevDiv.style.textAlign	= 'left';
	self.prevDiv.appendChild(prevButton);
	self.prevDiv.onmouseover	= function() {
		this.style.cursor = 'pointer';
		document.getElementById('slideformer-prev-button').style.visibility = 'visible';
	};
	self.prevDiv.onmouseout	= function() {
		document.getElementById('slideformer-prev-button').style.visibility = 'hidden';
	};
	self.prevDiv.onclick	= function() {
		SlideFormer.slideformerObject.prev();
	};
	// nextボタンブロック
	self.nextDiv					= document.createElement('div');
	var nextButton					= new Image();
	nextButton.src					= self.path + 'images/nextlabel.gif';
	nextButton.id					= 'slideformer-next-button';
	nextButton.style.visibility		= 'hidden';
	self.nextDiv.style.width		= '49%';
	self.nextDiv.style.margin		= '0px';
	self.nextDiv.style.paddingTop	= '30px';
	self.nextDiv.style.styleFloat	= 'right';
	self.nextDiv.style.cssFloat		= 'right';
	self.nextDiv.style.borderWidth	= '0px';
	self.nextDiv.style.textAlign	= 'right';
	self.nextDiv.appendChild(nextButton);
	self.nextDiv.onmouseover	= function() {
		this.style.cursor = 'pointer';
		document.getElementById('slideformer-next-button').style.visibility = 'visible';
	};
	self.nextDiv.onmouseout	= function() {
		document.getElementById('slideformer-next-button').style.visibility = 'hidden';
	};
	self.nextDiv.onclick	= function() {
		SlideFormer.slideformerObject.next();
	};
	// 画像設定
	self.setImage = function( imageObject ) {
		this.imageObject	= imageObject;
		this.width			= null;
		this.height			= null;
		if ( document.documentElement.clientWidth && document.documentElement.scrollWidth ) {
			this.style.left	= String( (Math.max(document.documentElement.clientWidth,document.documentElement.scrollWidth)-this.currentWidth)/2 ) + 'px';
		} else {
			this.style.left	= String( (Math.max(document.body.clientWidth,document.body.scrollWidth)-this.currentWidth)/2 ) + 'px';
		}
		this.initialize(false);
	};
	self.isLoading				= false;
	self.isLoadedImage			= false;
	self.isLoadedPrev			= false;
	self.isLoadedNext			= false;
	self.isLoadedTitle			= false;
	self.isLoadedDescription	= false;
	self.isLoadedBottom			= false;
	self.toProperSize = function() {
		if( this.isLoading == false ) {
			this.imageTd.innerHTML				= '';
			this.isLoading						= true;
			this.imageTd.appendChild(this.loadingImage);
			this.style.opacity	= '1';
			this.style.filter	= 'alpha(opacity=100)';
		}
		if( !this.width || !this.height ) {
			if( !this.imageObject.width || !this.imageObject.height ) {
				return false;
			} else {
				this.width			= parseInt(this.imageObject.width) + ( this.padding * 2 );
				this.height			= parseInt(this.imageObject.height) + ( this.padding * 2 );
			}
		}
		if( this.currentWidth != this.width ) {
			if( this.currentWidth < this.width ) {
				this.currentWidth += this.expandRate;
				if( this.currentWidth > this.width ) { this.currentWidth = this.width; }
			} else if( this.currentWidth > this.width ) {
				this.currentWidth -= this.expandRate;
				if( this.currentWidth < this.width ) { this.currentWidth = this.width; }
			}
			this.style.width	= String(this.currentWidth)+'px';
			if ( document.documentElement.clientWidth && document.documentElement.scrollWidth ) {
				this.style.left	= String( (Math.max(document.documentElement.clientWidth,document.documentElement.scrollWidth)-this.currentWidth)/2 ) + 'px';
			} else {
				this.style.left	= String( (Math.max(document.body.clientWidth,document.body.scrollWidth)-this.currentWidth)/2 ) + 'px';
			}
			return false;
		} else if(this.currentHeight != this.height) {
			if( this.currentHeight < this.height ) {
				this.currentHeight += this.expandRate;
				if( this.currentHeight > this.height ) { this.currentHeight = this.height; }
			} else if( this.currentHeight > this.height ) {
				this.currentHeight -= this.expandRate;
				if( this.currentHeight < this.height ) { this.currentHeight = this.height; }
			}
			this.style.height	= String(this.currentHeight)+'px';
			return false;
		} else {
			if( this.viewImage() == false ) {
				return false;
			} else {
				return true;
			}
		}
	};
	self.viewImage = function() {
		if( this.isLoadedImage == false ) {
			this.imageTd.removeChild(this.loadingImage);
			this.imageTd.innerHTML				= '';
			this.table.style.width				= this.imageObject.width + 'px';
			this.table.style.height				= this.imageObject.height + 'px';
			this.imageTd.style.width			= this.imageObject.width + 'px';
			this.imageTd.style.height			= this.imageObject.height + 'px';
			this.imageTd.style.backgroundImage	= 'url(' + this.imageObject.src + ')';
			if( this.imageObject.imageNumber > 0 ) {
				this.prevDiv.style.height		= String(this.imageObject.height-30) + 'px';
				this.isLoadedPrev				= true;
				this.imageTd.appendChild(this.prevDiv);
			}
			if( this.imageObject.imageNumber < this.imageObject.totalCount - 1 ) {
				this.nextDiv.style.height		= String(this.imageObject.height-30) + 'px';
				this.isLoadedNext				= true;
				this.imageTd.appendChild(this.nextDiv);
			}
			this.isLoadedImage	= true;
			return false;
		} else if( !this.isLoadedTitle && this.imageObject.title ) {
			this.titleTd.innerHTML	= this.imageObject.title;
			this.tbody.appendChild(this.titleTr);
			this.isLoadedTitle = true;
			this.height += 17;
			return false;
		} else if( !this.isLoadedDescription && this.imageObject.alt ) {
			this.descriptionTd.innerHTML	= this.imageObject.alt;
			this.isLoadedDescription	= true;
			this.tbody.appendChild(this.descriptionTr);
			this.height += 15;
			return false;
		} else if( !this.isLoadedBottom ) {
			this.isLoadedBottom	= true;
			this.height += this.closeButton.height + 6;
			this.bottomTd.innerHTML	= 'image '
				+ String( this.imageObject.imageNumber + 1 ) + ' of ' + String(this.imageObject.totalCount);
			this.tbody.appendChild(this.bottomTr);
			return false;
		} else {
			return true;
		}
	};
	self.toWhiteIn = function () {
		this.initAlphaNumber();
		if( this.alphaNumber < 100 ) {
			this.alphaNumber += this.grayOutRate;
			if( this.alphaNumber > 100 ) { this.alphaNumber	= 100; }
			this.style.opacity	= String(this.alphaNumber/100);
			this.style.filter	= 'alpha(opacity='+String(this.alphaNumber)+')';
		}
		if( this.alphaNumber < 100 ) {
			return false;
		} else {
			this.initialize(true);
			return true;
		}
	};
	self.toWhiteOut = function () {
		this.initAlphaNumber();
		if( this.alphaNumber > 0 ) {
			this.alphaNumber -= this.grayOutRate;
			if( this.alphaNumber < 0 ) { this.alphaNumber	= 0; }
			this.style.opacity	= String(this.alphaNumber/100);
			this.style.filter	= 'alpha(opacity='+String(this.alphaNumber)+')';
		}
		if( this.alphaNumber > 0 ) {
			return false;
		} else {
			this.initialize(true);
			return true;
		}
	};
	self.initialize = function(initSize) {
		this.alphaNumber	= 0;
		if( initSize ) {
			this.currentWidth	= self.defaultWidth;
			this.currentHeight	= self.defaultHeight;
		}
		self.style.width					= String(self.currentWidth) + 'px';
		self.style.height					= String(self.currentHeight) + 'px';
		this.table.style.width				= '100%';
		this.table.style.height				= '100%';
		this.imageTd.style.width			= '100%';
		this.imageTd.style.height			= '100%';
		this.imageTd.style.backgroundImage	= 'url()';
		if( this.isLoadedBottom ) {
			this.tbody.removeChild(this.bottomTr);
		}
		if( this.isLoadedDescription ) {
			this.tbody.removeChild(this.descriptionTr);
		}
		if( this.isLoadedTitle ) {
			this.tbody.removeChild(this.titleTr);
		}
		var prevButton;
		if( prevButton = document.getElementById('slideformer-prev-button') ) {
			prevButton.style.visibility = 'hidden';
		}
		var nextButton;
		if( nextButton = document.getElementById('slideformer-next-button') ) {
			nextButton.style.visibility = 'hidden';
		}
		if( this.isLoadedPrev ) {
			this.imageTd.removeChild(this.prevDiv);
		}
		if( this.isLoadedNext ) {
			this.imageTd.removeChild(this.nextDiv);
		}
		this.isLoadedImage					= false;
		this.isLoadedPrev					= false;
		this.isLoadedNext					= false;
		this.isLoadedTitle					= false;
		this.isLoadedDescription			= false;
		this.isLoadedBottom					= false;
		this.isLoading						= false;
	};
	self.initAlphaNumber = function () {
		if( !this.alphaNumber ) {
			if( this.style.opacity ) {
				this.alphaNumber	= Math.round(parseFloat(this.style.opacity)*100);
			} else if( this.style.filter ) {
				var str = this.style.filter;
				str	= str.replace('alpha','');
				str	= str.replace('opacity','');
				str	= str.replace('(','');
				str	= str.replace(')','');
				str	= str.replace('=','');
				this.alphaNumber	= Math.round(parseFloat(str));
			}
		}
	};
	return self;
}
SlideFormer.whiteIn = function() {
	if( SlideFormer.slideformerObject ) {
		if( SlideFormer.slideformerObject.toWhiteIn() == false ) {
			setTimeout(SlideFormer.whiteIn, 10);
		} else {
			if ( document.documentElement && document.documentElement.scrollTop ) {
				SlideFormer.slideformerObject.panel.style.top	= String( document.documentElement.scrollTop + 30 ) + 'px';
			} else {
				SlideFormer.slideformerObject.panel.style.top	= String( document.body.scrollTop + 30 ) + 'px';
			}
			SlideFormer.slideformerObject.startShowPanel();
		}
	}
}
SlideFormer.whiteOut = function() {
	if( SlideFormer.slideformerObject ) {
		if( SlideFormer.slideformerObject.toWhiteOut() == false ) {
			setTimeout(SlideFormer.whiteOut, 10);
		} else {
			SlideFormer.slideformerObject.style.visibility		= 'hidden';
			SlideFormer.slideformerObject.style.zIndex			= '-' + String(SlideFormer.slideformerObject.zIndex);
			document.getElementsByTagName('body')[0].removeChild(SlideFormer.slideformerObject.panel);
			SlideFormer.slideformerObject.panel.style.zIndex	= '-' + String( parseInt(SlideFormer.slideformerObject.zIndex) - 1 );
			SlideFormer.slideformerObject.panel.visibility		= 'hidden';
		}
	}
}
SlideFormer.expandPanel = function() {
	if( SlideFormer.slideformerObject.panel.toProperSize() == false ) {
		setTimeout(SlideFormer.expandPanel, 10);
	}
}
SlideFormer.erasePanel = function() {
	if( SlideFormer.slideformerObject ) {
		if( SlideFormer.slideformerObject.panel.toWhiteOut() == false ) {
			setTimeout(SlideFormer.erasePanel, 10);
		} else {
			SlideFormer.whiteOut();
		}
	}
}
//
// utility functions
//
SlideFormer.int2hexString = function( number ) {
	var charArray	= new Array(
		'0','1','2','3','4','5','6','7','8','9',
		'a','b','c','d','e','f'
	);
	var n16=0;              
	var result ="";
	while (number > 0) {
		n16		= number % 16;
		number	= ( number - n16 ) / 16;
		result = charArray[n16] + result;
	}
	if( result.length == 0 ) {
		result	= '00';
	}else if( result.length == 1 ) {
		result	= '0' + result;
	}
	return result;
}
SlideFormer.hexString2Int = function( hexString ) {
	hexString		= hexString.toLowerCase();
	var k 			= 1;
	var returnVal	= 0;
	for( var i=hexString.length - 1; i>=0; i-- ) {
		var str = hexString.substr(i,1);
		if('a'==str){ str='10'; }
		else if('b'==str){ str='11'; }
		else if('c'==str){ str='12'; }
		else if('d'==str){ str='13'; }
		else if('e'==str){ str='14'; }
		else if('f'==str){ str='15'; }
		returnVal += parseInt(str) * k;
		k*=16;
	}
	return returnVal;
}
SlideFormer.resiseWindow = function() {
	if( SlideFormer.slideformerObject ) {
		if ( document.documentElement.clientWidth && document.documentElement.scrollWidth ) {
			SlideFormer.slideformerObject.panel.style.left
				= String((document.documentElement.clientWidth-parseInt(SlideFormer.slideformerObject.panel.style.width))/2 ) + 'px';
			SlideFormer.slideformerObject.style.width	= String(document.documentElement.clientWidth-10) + 'px';
			SlideFormer.slideformerObject.style.width
				= String(Math.max( document.documentElement.clientWidth , document.documentElement.scrollWidth )) + 'px';
			SlideFormer.slideformerObject.style.height
				= String(Math.max( document.documentElement.clientHeight , document.documentElement.scrollHeight )) + 'px';
		} else {
			SlideFormer.slideformerObject.panel.style.left
				= String((document.body.clientWidth-parseInt(SlideFormer.slideformerObject.panel.style.width))/2) + 'px';
			SlideFormer.slideformerObject.style.width	= String(document.body.clientWidth-10) + 'px';
			SlideFormer.slideformerObject.style.width
				= String(Math.max( document.body.clientWidth , document.body.scrollWidth )) + 'px';
			SlideFormer.slideformerObject.style.height
				= String(Math.max( document.body.clientHeight , document.body.scrollHeight )) + 'px';
		}
	}
}
SlideFormer.start = function() {
	var slideformerObject	=  new SlideFormer('slideformer','999');
	var images = document.getElementsByTagName('img');
	var imageNumber	= 0;
	for(var i=0,n=images.length;i<n;i++) {
		if(images[i].className.match('slideformer')) {
			slideformerObject.imageTagArray.push(images[i]);
			images[i].slideformer	= slideformerObject;
			images[i].onmouseover	= function(){
				this.style.cursor = 'pointer';
			};
			images[i].imageNumber	= imageNumber;
			images[i].onclick	= function(){
				this.slideformer.show(this.imageNumber);
			};
			var parentTag	= images[i].parentNode;
			if( parentTag ){
				if( parentTag.tagName.toLowerCase() == 'a' ) {
					parentTag.slideformer	= slideformerObject;
					parentTag.imageNumber	= imageNumber;
					parentTag.src	= parentTag.href;
					parentTag.href	= "javascript:";
					parentTag.onclick	= function(){
						this.slideformer.show(this.imageNumber);
					};
				}
			}
			imageNumber++;
		} 
	}
	SlideFormer.slideformerObject	= slideformerObject;
}
if(window.attachEvent){
	window.attachEvent('onload',SlideFormer.start);
	window.attachEvent('onresize',SlideFormer.resiseWindow);
}else{
	window.addEventListener('DOMContentLoaded',SlideFormer.start,false);
	window.addEventListener('resize',SlideFormer.resiseWindow,false);
}


