/*****************************************

initRollovers

*****************************************/

function getUrlVars()
{
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++)
	{
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
	return vars['count'];
}

function initRollovers() {
	var url = getUrlVars();
//	alert(url);
	if (!document.getElementById) return

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	var nav_top = document.getElementById('nav_top');
	var nav_vietnam = document.getElementById('nav_vietnam');
	var nav_cambodia = document.getElementById('nav_cambodia');
	var nav_laos = document.getElementById('nav_laos');
	var nav_other = document.getElementById('nav_other');

	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'imgover_top') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				nav_top.setAttribute('src', '/images/html/nav_top.gif');
				nav_vietnam.setAttribute('src', '/images/html/nav_vietnam.gif');
				nav_cambodia.setAttribute('src', '/images/html/nav_cambodia.gif');
				nav_laos.setAttribute('src', '/images/html/nav_laos.gif');
				nav_other.setAttribute('src', '/images/html/nav_other.gif');

				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}
			nav_top.setAttribute('src', '/images/html/nav_top_on.gif');
			/*aImages[i].onmouseout = function() {
			if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
			this.setAttribute('src', sTempSrc);
			}*/
		}

		if (aImages[i].className == 'imgover_left') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {

				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));

				nav_top.setAttribute('src', '/images/html/nav_top.gif');
				nav_vietnam.setAttribute('src', '/images/html/nav_vietnam.gif');
				nav_cambodia.setAttribute('src', '/images/html/nav_cambodia.gif');
				nav_laos.setAttribute('src', '/images/html/nav_laos.gif');
				nav_other.setAttribute('src', '/images/html/nav_other.gif');

				if(sTempSrc == '/images/html/top/area_select01.gif')
				nav_vietnam.setAttribute('src', '/images/html/nav_vietnam_on.gif');
				if(sTempSrc == '/images/html/top/area_select02.gif')
				nav_laos.setAttribute('src', '/images/html/nav_laos_on.gif');
				if(sTempSrc == '/images/html/top/area_select03.gif')
				nav_cambodia.setAttribute('src', '/images/html/nav_cambodia_on.gif');
				if(sTempSrc == '/images/html/top/area_select04.gif')
				nav_other.setAttribute('src', '/images/html/nav_other_on.gif');
			}
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}
			aImages[i].onmouseout = function() {
			if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
			this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;
