
//----------------------------------------------------------
//    DOM HTML
//    Ver 0.9.4
//----------------------------------------------------------
//  Get elements by class name
document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className.split(" ");
		for (var j = 0; j < classes.length; j++) {
			var className = classes[j];
			if (className == cl) {
				retnode.push(elem[i]);
			}
		}
	}
	return retnode;
}

var DomHTML = {

	//-------------------------------------------------------
	//    Document width
	//-------------------------------------------------------
	getDocumentWidth: function (_document) {
		if (!_document) { _document = document;}
		if(_document.body) {
			if(_document.body.scrollWidth || _document.body.scrollWidth == 0) {
				return _document.body.scrollWidth;
			}
			if(_document.documentElement) {
				return _document.documentElement.offsetWidth;
			}
			return _document.body.offsetWidth;
		}
	
		if(_document.width || _document.width == 0) {
			return _document.width;
		}
		return 0;
	},


	//-------------------------------------------------------
	//    Get scroll top
	//-------------------------------------------------------
	getScrollTop: function() {
		if(window.scrollY) { return window.scrollY;}
		if(window.pageYOffset) { return window.pageYOffset;}
		if(document.documentElement && document.documentElement.scrollTop){
			return document.documentElement.scrollTop;
		} else if(document.body && document.body.scrollTop) {
			return document.body.scrollTop;
		}
		return 0;
	},


	//-------------------------------------------------------
	//    Document height
	//-------------------------------------------------------
	getDocumentHeight: function () {
		if(document.body) {
			if(document.body.scrollHeight || document.body.scrollHeight == 0) {
				return document.body.scrollHeight;
			}
			if(document.documentElement) {
				return document.documentElement.offsetHeight;
			}
			return document.body.offsetHeight;
		}	
		if(document.height || document.height == 0) {
			return document.height;
		}
		return 0;
	},


	//-------------------------------------------------------
	//    Effects
	//-------------------------------------------------------
	effects: {

		//-----------------------
		//  Set width
		//-----------------------
		width: function(_target, _width, _fade) {
			var current = _target.offsetWidth;
			if (!_fade) {
				var width = _width;
			} else {
				var width = current + ((_width - current) / _fade);
				if (width != current) {
					setTimeout(function() { DomHTML.effects.width(_target, _width, _fade / 1.25)}, 50);
				}
			}
			_target.style.width = width + "px";
		},

		//-----------------------
		//  Set opacity
		//-----------------------
		opacity: function(_target, _opacity, _fade, _fadetype) {
			var current = _target.style.opacity * 100;
			if (!_fade) {
				var opacity = _opacity;
			} else {
				var opacity = Math.round(current + ((_opacity - current) / _fade));
				if (opacity != current) {
					setTimeout(function() { DomHTML.effects.opacity(_target, _opacity, _fade / 1.25)}, 50);
				}
			}
			_target.style.zoom = 1;
			_target.style.filter = 'alpha(opacity=' + (opacity) + ')';
			_target.style.MozOpacity = opacity / 100;
			_target.style.opacity = opacity / 100;
		}
	},


	//-------------------------------------------------------
	//    Add event
	//-------------------------------------------------------
	addEvent: function(elemObj, eventType, funcName, useCapture) {
		if (!elemObj) { return false;}
		if (elemObj.addEventListener){
			elemObj.addEventListener(eventType, funcName, useCapture);
		} else if (elemObj.attachEvent){
			elemObj.attachEvent("on"+eventType, funcName);
		} else {
			return false;
		}
		return true;
	}

};
//  Embed Flash ver 0.91
//----------------------------------------------------------
var embedFlash = {

	//  Properties
	//-------------------------------------------------------
	pass: "",
	width: "",
	height: "",
	quality: "",
	wmode: "",
	bgcolor: "",
	scale: "",

	//  Constructor
	//-------------------------------------------------------
	setProperties: function(_pass, _width, _height, _quality, _wmode, _bgcolor, _scale) {
		embedFlash.pass = _pass;
		embedFlash.width = _width;
		embedFlash.height = _height;
		embedFlash.quality = _quality;
		embedFlash.wmode = _wmode;
		embedFlash.bgcolor = _bgcolor;
		embedFlash.scase = _scale;
	},

	//  Embed
	//-------------------------------------------------------
	embed: function() {
		if (document.body.id != "toppage") { return false;}
		var html = "";
		html += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='" + embedFlash.width + "' height='" + embedFlash.height + "' align='middle'>";
		html += "<param name='allowScriptAccess' value='sameDomain'>\n";
		html += "<param name='movie' value='" + embedFlash.pass + "'>\n";
		html += "<param name='quality' value='" + embedFlash.quality + "'>\n";
		html += "<param name='wmode' value='" + embedFlash.wmode + "'>\n";
		html += "<param name='bgcolor' value='" + embedFlash.bgcolor + "'>\n";
		html += "<param name='scale' value='" + embedFlash.scale + "'>\n";
		html += "<embed";
		html += " src='" + embedFlash.pass + "' ";
		html += " quality='" + embedFlash.quality + "' ";
		html += " wmode='" + embedFlash.wmode + "' ";
		html += " bgcolor='" + embedFlash.bgcolor + "' ";
		html += " width='" + embedFlash.width + "' height='" + embedFlash.height + "' ";
		html += " scale='" + embedFlash.scale + "' ";
		html += " align='middle' ";
		html += " allowScriptAccess='sameDomain' ";
		html += " type='application/x-shockwave-flash' ";
		html += " pluginspage='http://www.macromedia.com/go/getflashplayer'>\n";
		html += "</embed>\n";
		html += "</object>\n";
		var flash = document.createElement("div");
		flash.style.position = "absolute";
		flash.style.left = "50%";
		flash.style.top = "75px";
		flash.style.width = embedFlash.width + "px";
		flash.style.height = embedFlash.height + "px";
		flash.style.marginLeft = "-" + (embedFlash.width / 2) + "px";
		flash.style.zIndex = "4";
		flash.innerHTML = html;
		document.body.appendChild(flash);
	},

	//  Add event
	//-------------------------------------------------------
	addEvent: function(elemObj, eventType, funcName, useCapture) {
		if (elemObj.addEventListener){
			elemObj.addEventListener(eventType, funcName, useCapture);
			return true;
		} else if (elemObj.attachEvent){
			var r = elemObj.attachEvent("on"+eventType, funcName);
			return r;
		}
	} 
}
var fileURI = "/scripts/../docs/toppage.swf";
embedFlash.setProperties(fileURI, "800", "285", "high", "transparent", "#FFFFFF", "showall");
embedFlash.addEvent(window, "load", embedFlash.embed);
//----------------------------------------------------------
//    New window
//     Ver 1.0.0 [ 2008.3.18 ]
//     <a rel="newWindow[args...]" title="[Name]">
//     Charset=UTF-8
//----------------------------------------------------------
var NewWindow = {

	//-------------------------------------------------------
	//    Set
	//-------------------------------------------------------
	set: function() {
		var links = document.getElementsByTagName("a");
		var imax = links.length;
		for (var i=0;i<imax;i++) {
			if (!links[i].rel) { continue;}
			if (!links[i].rel.match(/newWindow/)) { continue;}
			var args = links[i].rel.replace("newWindow", "").split(" ");
			args.unshift(links[i].title);
			args.unshift(links[i].href);
			links[i].onclick = NewWindow.setOpen (args);
		}
	},


	//-------------------------------------------------------
	//    Window open
	//-------------------------------------------------------
	setOpen: function(URL) {
		var func = function() {
			NewWindow.open(URL);
			return false;
		}
		return func;
	},
	open: function(_args) {
	    var win;
		URL = _args[0];
		NAME = _args[1] || "NewWindow";
		WIDTH = _args[2] || 300;
		HEIGHT = _args[3] || 450;
		SCROLL = _args[4] || "yes";
		RESIZE = _args[5] || "yes";
		TOOLBAR = _args[6] || "no";
		LOCATION = _args[7] || "no";
		DIRECTORIES = _args[8] || "no";
		STATUS = _args[9] || "no";
		MENUBAR = _args[10] || "no";
	    win = window.open(
			URL,
			NAME,
			"toolbar=" + TOOLBAR +
			",location=" + LOCATION +
			",directories=" + DIRECTORIES +
			",status=" + STATUS +
			",menubar=" + MENUBAR +
			",scrollbars=" + SCROLL +
			",resizable=" + RESIZE +
			", width="+ WIDTH +
			", height=" + HEIGHT
		);
	    win.focus();
	}
};
DomHTML.addEvent(window, "load", NewWindow.set);
