function GetUrlParam( paramName )
{
	var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
	var oMatch = oRegex.exec( window.top.location.search ) ;
	
	if ( oMatch && oMatch.length > 1 )
		return unescape( oMatch[1] ) ;
	else
		return '' ;
}
function HTMLEscape( string )
{
	var reg;
	reg = new RegExp('&', 'g');
	string = string.replace(reg, '&amp;');
	reg = new RegExp("'", 'g');
	string = string.replace(reg, '&quote;');
	reg = new RegExp('"', 'g');
	string = string.replace(reg, '&#039;');
	reg = new RegExp('<', 'g');
	string = string.replace(reg, '&lt;');
	reg = new RegExp('>', 'g');
	string = string.replace(reg, '&gt;');
	return string;
}

function dataset()
{
	// Get Caption
	var caption = HTMLEscape(unescape(GetUrlParam('caption')));
	var id = 'caption';
	var obj=document.all && document.all(id) 
			|| document.getElementById && document.getElementById(id);
	obj.innerHTML = caption;

	// Get Title
	document.title = caption;
	
	// Get Filename
	var file   = HTMLEscape(unescape(GetUrlParam('file')));
	// Get Size
	var width  = HTMLEscape(unescape(GetUrlParam('width')));
	var height = HTMLEscape(unescape(GetUrlParam('height')));
	id = 'image';

	// Fix Path
	if (file.indexOf('://') >= 0 ||
		file.indexOf('..') >= 0) {
		file = '';
	}
	// Support FileType
	if (file != '' &&
		!(file.match(/\.gif$/i)) &&
		!(file.match(/\.jpe?g$/i)) &&
		!(file.match(/\.png$/i))
		) {
		alert('Unsupport FileType');
		file = '';
	}

	// IMG Tag Size Put
	if (width != '') {
		width = ' width:'+width+'px;';
	}
	if (height != '') {
		height = ' height:'+height+'px;';
	}
	
	if (file != '') {
		// Fix Absolute Path
		path = window.location.pathname;
		path = path.substr(0, path.lastIndexOf('/')+1);
		reg = new RegExp(path, 'g');
		file = file.replace(reg, '');
		
		obj=document.all && document.all(id) 
			|| document.getElementById && document.getElementById(id);
		obj.innerHTML = '<div class="imgbox"><img src="./'+file+'" style="'+width+height+'" /></div>';
	}
}

function image_popup(url, width, height, caption)
{
	// Get Size & Fix Size
	if (width > 0 && height > 0) {
		window_width  = parseInt(width);
		window_height = parseInt(height) + 100;
		if (window_width <= 660) {
			window_width = 660;
		}
		if (window_height >= 600) {
			window_height = 600;
		}
		// Open Window
/**
 * ThinkIT customize
 *
 * @date 2006/11/09
 * @author Nobutaka Naito <naito@thinkit.co.jp>
 * @summary SEOÂÐºö
 **/
		window.open('/attach/popup_image.html?file='+escape(url)+'&width='+width+'&height='+height+'&caption='+escape(caption), '_blank', 'width='+window_width+',height='+window_height+',scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,directories=no,resizable=yes');
	} else {
		// Open Window
		window.open('/attach/popup_image.html?file='+escape(url)+'&caption='+escape(caption), '_blank', 'scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,directories=no,resizable=yes');
	}
/* customize end */
}
