/* debug */
function trace() {
	var debug = document.getElementById('debug');
	if (!debug) {
		var debug = document.createElement('div');
		debug.setAttribute('id', 'debug');
		document.body.appendChild(debug);
		/*
		debug.onclick = function() {
			if (this.closed) {
				this.style.height = '200px';
				this.closed = false;
			} else {
				this.style.height = '2px';
				this.closed = true;
			}
		}
		*/
	}
	if (debug) {
		var o = '';
		o = 'arguments.length = ' + arguments.length + '<br />';
//		o += arguments;
		for (var i=0; i<arguments.length; i++) {
			o += '<div style="margin-left: 16px;">';
			o += arguments[i];
			for (j in arguments[i]) {
				o += '<div style="margin-left: 16px;">';
				o += '<b>' + j +'</b>&nbsp;=&nbsp;' + String(arguments[i][j]).split('<').join('&lt;').split('>').join('&gt;').split('\"').join('&raquo;');
				o += '</div>';
			}				
			o += '</div>';
		}
		debug.innerHTML = o;
	}
}
/* /debug */



/* preset */
var oID = document.getElementById;
var IE = /*@cc_on!@*/false;
var IE6 = (IE && (navigator['appVersion'].indexOf('MSIE 6') > 0)) ? true : false;
/* /preset */



/* event handlers */
function addEvent(o, sEvent, fFunc) {
	if (window.attachEvent) {
		o.attachEvent('on' + sEvent, fFunc);
	} else if (window.addEventListener) {
		o.addEventListener(sEvent, fFunc, false);
	}
}

function addLoadEvent(fFunc) {
	addEvent(window, 'load', fFunc);
}

function addDOMLoadEvent(func) {
	if (!window.__load_events) {

		var init = function () {
			if (arguments.callee.done) return; // quit if this function has already been called
			arguments.callee.done = true; // flag this function so we don't do the same thing twice
			if (window.__load_timer) { // kill the timer
				clearInterval(window.__load_timer);
				window.__load_timer = null;
			}
			for (var i=0; i<window.__load_events.length; i++) { // execute each function in the stack in the order they were added
				window.__load_events[i]();
			}
			window.__load_events = null;
		};

		// for Mozilla/Opera9
		if (document.addEventListener) {
			document.addEventListener('DOMContentLoaded', init, false);
		}

		// for Internet Explorer
		/*@cc_on @*/
		/*@if (@_win32)
			document.write('<scr'+'ipt id=__ie_onload defer src=//0><\/scr'+'ipt>');
			var script = document.getElementById('__ie_onload');
			script.onreadystatechange = function() {
				if (this.readyState == 'complete') {
					init(); // call the onload handler
				}
			};
		/*@end @*/

		// for Safari
		if (/WebKit/i.test(navigator.userAgent)) { // sniff
			window.__load_timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					init(); // call the onload handler
				}
			}, 10);
		}

		// for other browsers
		window.onload = init;

		// create event function stack
		window.__load_events = [];
	}

	// add function to event stack
	window.__load_events.push(func);
}
/* /event handlers */



/* trim */
String.prototype.trim = function () {
	return this.replace(/^\s+|\s+$/g, "");
}
/* /trim */



/* QWEswfobj for IE*/
// disable the blinking when set outerHTML, may need to load external css file, where only flash objects have display: none property
if (IE) document.writeln('<style type="text/css">object {display: none;}</style>');
// rewrite satay swf objects
function QWEswfobj() {
	var swf = '';
	var obj = document.getElementsByTagName('object');
	for (var i=0; i<obj.length; i++) {
		if ((obj[i].getAttribute('type') == 'application/x-shockwave-flash') || (obj[i].getAttribute('classid') == 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000')) {
			swf = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			swf += (obj[i].getAttribute('id')) ? ' id="' + obj[i].getAttribute('id') + '"' : '';
			swf += (obj[i].getAttribute('width')) ? ' width="' + obj[i].getAttribute('width') + '"' : '';
			swf += (obj[i].getAttribute('height')) ? ' height="' + obj[i].getAttribute('height') + '"' : '';
			swf += '>' + "\n";
			for (var j=0; j<obj[i].childNodes.length; j++) {
				if ((obj[i].childNodes[j].nodeName) && (obj[i].childNodes[j].nodeName.toLowerCase() == 'param')) {
					swf += '<param name="'+obj[i].childNodes[j].getAttribute('name')+'" value="'+obj[i].childNodes[j].getAttribute('value')+'" />'+"\n";
				} else if ((obj[i].childNodes[j].nodeName) && (obj[i].childNodes[j].nodeName.toLowerCase() == 'div')) {
					swf += '<div>' + obj[i].childNodes[j].innerHTML + '</div>' + "\n";				
				}
			}
			swf += '</object>'+"\n";
			obj[i].outerHTML = swf;
		}
		obj[i].style.display = 'block';
	}
}
/* /QWEswfobj */



/* :hover for IE6 */
function hover(obj) {
	obj.onmouseover = function() {
		this.className += ' hover';
	}
	obj.onmouseout = function() {
		this.className = this.className.split('hover').join('');
	}
}
/* /:hover for IE6 */



/* trim */
String.prototype.trim = function () {
	return this.replace(/^\s+|\s+$/g, "");
}
/* /trim */


/* get elements by className */
function getElementsByClassName(parentNode, className) {
	var result = [];
	if (!className) {
		if (typeof(parentNode) == 'string') {
			var className = parentNode;
			parentNode = document;
		} else {
			return result;
		}
	}
	var obj = parentNode.getElementsByTagName('*');
	for (var i=0; i<obj.length; i++) {
		if (obj[i].className.match(new RegExp('\\b' + className + '\\b'))) {
			result.push(obj[i]);
		}
	}
	return result;
}
/* /get elements by className */



/* get style */
function getStyle(obj, styleProp) {
	var result = (window.getComputedStyle) ? document.defaultView.getComputedStyle(obj, null).getPropertyValue(styleProp) : ((obj.currentStyle) ? obj.currentStyle[styleProp] : '');
	if (String(result).indexOf('rgb') >= 0) {
		var h = '0123456789abcdef';
		var d = result.split('rgb(')[1].split(')')[0].split(' ').join('').split(',');
		result = '#' + h[d[0] >> 4] + h[d[0] % 16] + h[d[1] >> 4] + h[d[1] % 16] + h[d[2] >> 4] + h[d[2] % 16];
	}
	return result;
}
/* /get style */



/* get dimension */
function getDimension(obj) {
	var pobj = obj;
	obj.x = 0;
	obj.y = 0;
	obj._x = obj.offsetLeft;
	obj._y = obj.offsetTop;
	obj._width = obj.offsetWidth;
	obj._height = obj.offsetHeight;
	while (pobj.nodeName != 'BODY') {
		obj.x += pobj.offsetLeft;
		obj.y += pobj.offsetTop;
		pobj = pobj.parentNode;
	}
	return {x: obj.x, y: obj.y, _x: obj._x, _y: obj._y, _width: obj._width, _height: obj._height};
}
/* /get dimension */



/* get mouse */
function getMouse(e) {
	e = e || window.event;
	return {x: (e.pageX || e.clientX + document.documentElement.scrollLeft), y: (e.pageY || e.clientY + document.documentElement.scrollTop)};
}
/* /get mouse */



/* scroll object */
function scrollobjDirect(obj, x, y) {
	obj.style.left = String(Math.round(x)) + 'px';
	obj.style.top = String(Math.round(y)) + 'px';
}

function scrollobj(obj, hspace, vspace) {
	var outer = obj.parentNode;
	outer.inner = obj;
	outer.hspace = hspace;
	outer.vspace = vspace;
	outer.onmousemove = function(e) {
		getDimension(this.inner);
		getDimension(this);
		scrollobjDirect(this.inner, Math.min(0, Math.max(this._width-this.inner._width, (this._width-this.inner._width)*(getMouse(e).x-this.x-this.hspace)/(this._width-2*this.hspace))), Math.min(0, Math.max(this._height-this.inner._height, (this._height-this.inner._height)*(getMouse(e).y-this.y-this.vspace)/(this._height-2*this.vspace))));
	}
}
/* /scroll object */



/**/
function labelinCorrection() {
	var field = getElementsByClassName('labelin');
	for (var i=0; i<field.length; i++) {
		if (field[i].labelin && (window.focused != field[i])) {
			field[i].labelin.style.display = (field[i].value.length == 0) ? 'block' : 'none';
		}
	}
}

function labelin() {
	var field = getElementsByClassName('labelin');
	window.focused = null;
	window.blurred = null;
	for (var i=0; i<field.length; i++) {
		if ((String(' input textarea ').indexOf(field[i].nodeName.toLowerCase()) >= 0) && (String(' text password textarea ').indexOf(field[i].type || 'textarea') >= 0)) {
			getDimension(field[i]);
			field[i].labelin = document.createElement('label');
			field[i].labelin.className = 'labelin';
			field[i].labelin.style.left = String(field[i]._x) + 'px';
			field[i].labelin.style.top = String(field[i]._y) + 'px';
			field[i].labelin.style.whiteSpace = 'nowrap';
			field[i].labelin.innerHTML = field[i].title || 'untitled';
			field[i].labelin.field = field[i];
			field[i].labelin.onclick = field[i].labelin.onfocus = function() {
				this.style.display = 'none';
				this.field.focus();
			}
			field[i].onfocus = function() {
				this.labelin.style.display = 'none';
				window.focused = this;
				if (window.blurred == field[i]) {window.blurred = null;}
			}
			field[i].onblur = function() {
				this.labelin.style.display = (this.value.length == 0) ? 'block' : 'none';
				window.blurred = this;
				if (window.focused == field[i]) {window.focused = null;}
			}
			field[i].labelin.style.display = (field[i].value.length == 0) ? 'block' : 'none';
			field[i].parentNode.appendChild(field[i].labelin);
		}
	}
	if (field.length > 0) {
		setInterval('labelinCorrection()', 333);
	}
}
/**/



/**/
function flashdisk() {
	var o = '';
	var attrib = Array();
	var disk = getElementsByClassName('disk');
	for (var i=0; i<disk.length; i++) {
		if (disk[i].className.indexOf('disk') > -1) {
			o = '';
			attrib = Array();
			attrib['datasrc'] = (disk[i].getElementsByTagName('h6').length > 0) ? '/swf/bubble.swf' : '/swf/upperbubble.swf';
			attrib['width'] = parseInt(getStyle(disk[i], 'width'));
			attrib['height'] = parseInt(getStyle(disk[i], 'height'));
			attrib['flashvars'] = 'maskeeWidth=' + attrib['width'] + '&maskeeHeight=' + attrib['height'];
			attrib['flashvars'] += '&bubbleColor=' + ((disk[i].getElementsByTagName('h6').length > 0) ? getStyle(disk[i].getElementsByTagName('h6')[0], 'color').split('#').join('0x') : '0x820053');
			attrib['flashvars'] += '&titleColor=' + ((disk[i].getElementsByTagName('h6').length > 0) ? getStyle(disk[i].getElementsByTagName('h6')[0], 'color').split('#').join('0x') : '0x820053');
			attrib['flashvars'] += '&leadColor=' + ((disk[i].getElementsByTagName('p').length > 0) ? getStyle(disk[i].getElementsByTagName('p')[0], 'color').split('#').join('0x') : '0xffffff');
			attrib['flashvars'] += '&titleTextContent=' + ((disk[i].getElementsByTagName('h6').length > 0) ? disk[i].getElementsByTagName('h6')[0].innerHTML : '');
			attrib['flashvars'] += '&leadTextContent=' + ((disk[i].getElementsByTagName('p').length > 0) ? disk[i].getElementsByTagName('p')[0].innerHTML : '');
			attrib['flashvars'] += '&imageURL=' + ((disk[i].getElementsByTagName('img').length > 0) ? disk[i].getElementsByTagName('img')[0].src : '/i/image.jpg');
			attrib['flashvars'] += '&bubbleURL=' + ((disk[i].getElementsByTagName('a').length > 0) ? disk[i].getElementsByTagName('a')[0].href : '');
			if (IE) {
				o += '<embed flashvars="' + attrib['flashvars'] + '" width="' + attrib['width'] + '" height="' + attrib['height'] + '" wmode="transparent" scale="noscale" quality="best" bgcolor="#FFFFFF" src="' + attrib['datasrc'] + '" type="application/x-shockwave-flash"/>';
			} else {
				o += '<object type="application/x-shockwave-flash" data="' + attrib['datasrc'] + '" width="' + attrib['width'] + '" height="' + attrib['height'] + '">';
				o += '<param name="wmode" value="transparent" />';
				o += '<param name="flashvars" value="' + attrib['flashvars'] + '" />';
				o += '</object>';
			}
			disk[i].innerHTML = o;
		}
	}
}
/**/



/**/
function showmedia() {
	var media = document.getElementById('media');
	var obj = (media && (media.getElementsByTagName('a').length > 0)) ? media.getElementsByTagName('a')[0] : 'null';
	if (media && obj) {
		var objtype = obj.href.substr(obj.href.length-4, 4);
		var o = '';
		switch (objtype) {
			case '.jpg' :
			case 'jpeg' :
			case '.gif' :
				o += '<img src="' + obj.href + '" alt="" />';
				break;
			case '.swf' :
				o += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">' + "\n";
				o += '<param name="movie" value="' + obj.href + '">' + "\n";
				o += '<param name="menu" value="false">' + "\n";
				o += '<param name="bgcolor" value="#ffffff">' + "\n";
				o += '<embed src="' + obj.href + '" menu="false" bgcolor="#ffffff" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>' + "\n";
				o += '</object>' + "\n";
				break;
			case '.wmv' :
			case '.mpg' :
			case 'mpeg' :
			case '.avi' :
				o += '<object type="application/x-oleobject" standby="loading..." codebase="http://www.microsoft.com/ntserver/netshow/download/en/nsmp2inf.cab#version=5,1,51,415" classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6">' + "\n";
				o += '<param name="url" value="' + obj.href + '" />' + "\n";
				o += '<param name="autostart" value="1" />' + "\n";
				o += '<param name="uimode" value="none" />' + "\n";
				o += '<param name="playcount" value="1" />' + "\n";
				o += '<param name="showcontrols" value="0" />' + "\n";
				o += '<param name="showstatusbar" value="0" />' + "\n";
				o += '<param name="enablecontextmenu" value="0" />' + "\n";
				o += '<param name="stretchtofit" value="1" />' + "\n";
				o += '<param name="volume" value="100" />' + "\n";
				o += '<embed src="' + obj.href + '" autostart="1" uimode="none" playcount="1" showcontrols="0" showstatusbar="0" enablecontextmenu="0" stretchtofit="1" volume="100" loop="false" pluginspage="http://www.microsoft.com/windows/mediaplayer/download/default.asp" type="video/x-ms-asf-plugin" />' + "\n";
				o += '</object>' + "\n";
				break;
			default :
				o = null;
				break;
		}
		if (o) {
			media.innerHTML = o;
		}
	}
}
/**/



/* initialization */
function DOMLoadInit() {

	var tmp = null;

	/* execute QWEswfobj in IE */
	if (IE) QWEswfobj();
	/* /execute QWEswfobj in IE */

	/* IE6 bugfix */
	if (IE6) {
		var cite = document.getElementsByTagName('cite');
		for (var i=0; i<cite.length; i++) {
			hover(cite[i]);
		}
	}
	/* /IE6 bugfix */

	/* input init */
	var input = document.getElementsByTagName('input');
	for (var i=0; i<input.length; i++) {
		if (IE6 && (input[i].parentNode.className.indexOf('submit') >= 0)) {hover(input[i]);}
		if (input[i].type.indexOf('hidden') >= 0) {input[i].className += ' hidden';}
	}
	/* /input init */

	/* modify links */
	var a = document.getElementsByTagName('a');
	for (var i=0; i<a.length; i++) {
		if (a[i].className.indexOf('_blank') >= 0) {
			a[i].onclick = function() {
				this.blur();
				window.open(this.href);
				return false;
			}
		}
	}
	/* /modify links */

	/* label in input */
	labelin();
	/* /label in input */
	
	/* flash disk inserts */
	flashdisk();
	/* /flash disk inserts */

	/* show media: image, video, ... */
	showmedia();
	/* /show media: image, video, ... */
}

function onLoadInit() {
}

addDOMLoadEvent(DOMLoadInit);

addLoadEvent(onLoadInit);
/* /initialization */



