/*****************************   anDeRan   ************************************/

var is_ie  = !!document.uniqueID;
var is_ie6 = is_ie && navigator.appVersion.match(/MSIE (5.5|6)/);

var preloadImgs = function () {
	var i = arguments.length;
	while (i-- > 0) {
		(new Image()).src = '/images/' + arguments[i];
	}
};

var lightInfo = function (num, over) {
	var column = document.getElementById('info-' + num);
	if (column) {
		column.className = over ? 'overed' : '';
	}
};

var lightPoint = function (num, over) {
	var column = document.getElementById('point-' + num);
	if (column) {
		column.className = over ? 'overed' : '';
	}
};

var makeActive = function (col, num) {
	var img = document.getElementById('image').getElementsByTagName('IMG')[0];
	img.src = 'images/Image/home_' + num + '.jpg';
	document.getElementById('home-link').href = '#' + num;
	var cols = col.parentNode.getElementsByTagName('LI');
	var i = cols.length;
	while (i-- > 0) {
		if (cols[i].className && cols[i].className.indexOf('active') != -1) {
			if (cols[i] != col) {
				cols[i].className = cols[i].className.replace('active', '');
				var img =  cols[i].getElementsByTagName('IMG')[0];
				var txt = cols[i].firstChild.textContent ? cols[i].firstChild.textContent : cols[i].firstChild.innerText;
				cols[i].innerHTML = '<a href="#">' + txt + ' <span><img src="' + img.src + '" width="103" height="34" alt="" /></span></a>';
			}
		}
		if (cols[i] == col) {
			if (cols[i].className && cols[i].className.indexOf('active') != -1) {
				continue;
			} else {
				cols[i].className = cols[i].className + ' active';
				var img =  cols[i].getElementsByTagName('IMG')[0];
				var txt = cols[i].firstChild.textContent ? cols[i].firstChild.textContent : cols[i].firstChild.innerText;
				cols[i].innerHTML = '<strong>' + txt + ' <span><img src="' + img.src + '" width="103" height="34" alt="" /></span></strong>';
			}
		}
	}
};

window.onload = function () {
	var map = document.getElementById('map');
	if (map) {
		var point = map.getElementsByTagName('A');
		var i = point.length;
		while (i-- > 0) {
			point[i].onmouseover = function () {
				lightInfo(this.id.replace('point-', ''), 1);
			};
			point[i].onmouseout = function () {
				lightInfo(this.id.replace('point-', ''), 0);
			};
		}

		var info = document.getElementById('map-info').getElementsByTagName('TD');
		var i = info.length;
		while (i-- > 0) {
			info[i].onmouseover = function () {
				this.className = 'overed';
				lightPoint(this.id.replace('info-', ''), 1);
			};
			info[i].onmouseout = function () {
				this.className = '';
				lightPoint(this.id.replace('info-', ''), 0);
			};
		}
	}

	if (is_ie6) {
		var colors = document.getElementById('colors');
		if (colors) {
			var color = colors.getElementsByTagName('P');
			var i = color.length;
			while (i-- > 0) {
				color[i].onmouseover = function () {
					this.className = 'overed';
				};
				color[i].onmouseout = function () {
					this.className = '';
				};
			}
		}
	}
};
