//alert("loaded");

var setContent = function(){return this;}
setContent.prototype = {
	init: function(){
		/* Environment Variable
		----------------------------------------------------------- */
		agent = navigator.userAgent.toLowerCase();
		dname = new String(document.domain);
		path = new String(location.pathname);
		win = (agent.indexOf("windows") != -1);
		mac = (agent.indexOf("mac") != -1);
		gecko = agent.indexOf("gecko") != -1;
		opera = agent.indexOf("opera",0) != -1;
		safari = agent.indexOf("safari") != -1;
		ie = agent.indexOf("msie") != -1 && !opera;
		ie5win = (agent.indexOf("msie 5.0") != -1) && win;
		ie55win = (agent.indexOf("msie 5.5") != -1) && win;
		ie5mac = (agent.indexOf("msie") != -1) && mac;
		ns = agent.indexOf("netscape") != -1 && !opera;
		ns6 = (agent.indexOf("netscape6/6.0") != -1) && ns;
		firstpath = path.split("/"); 	firstp = firstpath[1];
		dir = (	firstp =="english")? firstpath[2] : firstpath[1];

		/* Common function
		----------------------------------------------------------- */
		getClsName = function(d){
			return d.className.toLowerCase();
			//return new String(d.getAttribute(getClsAttr())).toLowerCase();
		};
		getClsAttr = function(){
			return (ie)? "className" : "class";
		};
		getElmByClsName = function(clsName){
			var elms = new Array();
			var re = new RegExp('(^| )' + clsName + '( |$)');
			var ael = document.getElementsByTagName('*');
			var op = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
			if (document.all && !op) ael = document.all;
			for(var i=0,j=0,f=ael.length ; i<f ; i++) {
				if(re.test(ael[i].className)) {
					elms[j]=ael[i];
					j++;
				}
			}
			return elms;
		};
		
		toppage = false;
		
		/* set function
		----------------------------------------------------------- */
		new rollOver();
		if(!toppage){
			new setCssProperty();
		}
	}
}

// Set css property function
var setCssProperty = function(){this.init();}
setCssProperty.prototype = {
	init: function(){
		var content = document.getElementById("contentcol");
		var divs = content.getElementsByTagName("div");
		var textcol = document.getElementById("text");if(!textcol) return false;
		var damdiv = document.createElement("div");
		damdiv.id = "text-dam"; 
		divs[0].appendChild(damdiv);
		damycol = document.getElementById("text-dam");
		damycol.innerHTML = " &nbsp; ";
		if(path.indexOf("04.html") < 0 && path.indexOf("08.html") < 0 ){
			damycol.style.backgroundColor = "#000000";
			damycol.style.filter = "alpha(opacity=70)";
			damycol.style.MozOpacity = 0.7;
			damycol.style.opacity = 0.7;
			damycol.style.zIndex = 100;
		}
		textcol.style.backgroundColor = "transparent";
		textcol.style.zIndex = 200;
	}
}

// Swap image function
var rollOver = function(){this.init();}
rollOver.prototype = {
	init: function(){
		var imgs = new Image();
		var hovers = getElmByClsName("hover");
		toppage = (hovers.length > 0)? true : false;
		for(var i=0,f=hovers.length; i < f; i++) {
			(function(i) {
				var img = hovers[i].getElementsByTagName('img')[0];
				var filetype = img.src.substring(img.src.lastIndexOf('.'), img.src.length);
				hovers[i].off = img.src;
				hovers[i].on = img.src.replace('-off' + filetype, '-on' + filetype);
				hovers[i].onmouseover = function(){img.src = hovers[i].on;}
				hovers[i].onmouseout = function(){img.src = hovers[i].off;}
			})(i);
		}
	}
}

var contents = new setContent();
window.addOnload(contents.init);