// JavaScript Document

function MM_GetObject(id) {
    if(document.all) {
        return document.all(id);
    }
    else{
        return document.getElementById(id);
    }
}

function history_back() {
	history.back()
	return false;
}

function swapImage(obj) {
	if(obj.src.indexOf("_on.") == -1) {
		obj.src = obj.src.replace(".jpg", "_on.jpg");
	}
}

function restoreImage(obj) {
	obj.src = obj.src.replace("_on.jpg", ".jpg");
}

function swapPng(obj) {
	if(obj.src.indexOf("_on.") == -1) {
		obj.src = obj.src.replace(".png", "_on.png");
	}
}

function restorePng(obj) {
	obj.src = obj.src.replace("_on.png", ".png");
}

function ShadowOpen(obj) {
	var url = obj.href;
	Shadowbox.open({
		content: url,
		player: "iframe",
		height: 395,
		width: 1000
	});
	return false;
}

function StaffOpen(obj) {
	var url = obj.href;
	Shadowbox.open({
		content: url,
		player: "iframe",
		height: 420,
		width: 720
	});
	return false;
}

function LeaderOpen(obj) {
	var url = obj.href;
	Shadowbox.open({
		content: url,
		player: "iframe",
		height: 410,
		width: 830
	});
	return false;
}

function FadeIn() {
    var obj = MM_GetObject("mainimage");
    obj.style.filter = "alpha(opacity=" + percent + ")";
    obj.style.opacity = percent/100;
    percent += 5;
    if(percent < 100) {
        setTimeout("FadeIn()", 50);
    }
    else {
        setTimeout("FadeOut()", sec);
    }
}
function FadeOut() { 
    var obj = MM_GetObject("mainimage");
    obj.style.filter = "alpha(opacity=" + percent + ")"; 
    obj.style.opacity = percent/100;
    percent -= 5;
    if(percent >= 0) {
        setTimeout("FadeOut()", 50);
    }
    else {
        idx++;
        //obj.src = "images/index"+("0"+(idx%count)).slice(-2)+".jpg";
        obj.src = images[idx%count];
        FadeIn();
    }
}

function IFadeIn() {
    var obj = MM_GetObject("mainimage");
    var obj2 = MM_GetObject("skip");
    obj.style.filter = "alpha(opacity=" + percent + ")";
    obj2.style.filter = "alpha(opacity=" + percent + ")";
    obj.style.opacity = percent/100;
    obj2.style.opacity = percent/100;
    percent += 5;
    if(percent < 100) {
        setTimeout("IFadeIn()", 50);
    }
    else {
		if(images[idx][0]) {
	        MM_GetObject("mainimage2").src = "images/i"+("0"+idx).slice(-2)+".png";
	        setTimeout("IFadeIn2()", sec);
		}
		else {
	        setTimeout("IFadeOut()", sec);
		}
    }
}
function IFadeIn2() {
    var obj = MM_GetObject("mainimage2");
    obj.style.filter = "alpha(opacity=" + percent2 + ")";
    obj.style.opacity = percent2/100;
    percent2 += 5;
    if(percent2 < 100) {
        setTimeout("IFadeIn2()", 50);
    }
    else {
        setTimeout("IFadeOut()", sec);
    }
}
function IFadeOut() { 
    var obj = MM_GetObject("mainimage");
    var obj2 = MM_GetObject("skip");
    var obj3 = MM_GetObject("mainimage2");
    obj.style.filter = "alpha(opacity=" + percent + ")";
    obj2.style.filter = "alpha(opacity=" + percent + ")";
    obj3.style.filter = "alpha(opacity=" + percent2 + ")";
    obj.style.opacity = percent/100;
    obj2.style.opacity = percent/100;
    obj3.style.opacity = percent2/100;
    percent -= 5;
	if(percent2 > 0) {
		percent2 -= 5;
	}
    if(percent >= 0) {
        setTimeout("IFadeOut()", 50);
    }
    else {
        idx++;
		if(idx>count) {
	        obj.className = "hidden";
	        obj2.className = "hidden";
	        obj3.className = "hidden";
	        MM_GetObject("mainblc").className = "visible";
		}
		else {
	        obj.src = "images/i"+("0"+idx).slice(-2)+".jpg";
			if(images[idx][1]) {
				obj2.src = "images/skip_b.png";
			}
			else {
				obj2.src = "images/skip_w.png";
			}
	        IFadeIn();
		}
    }
}
function ISkip() {
	MM_GetObject("mainimage").className = "hidden";
	MM_GetObject("skip").className = "hidden";
	MM_GetObject("mainimage2").className = "hidden";
	MM_GetObject("mainblc").className = "visible";
	return false;
}

function DispFadeIn() {
    var obj = MM_GetObject("mainimage");
    obj.style.filter = "alpha(opacity=" + percent + ")";
    obj.style.opacity = percent/100;
    percent += 10;
    if(percent < 100) {
        setTimeout("DispFadeIn()", 50);
    }
    else {
        setTimeout("DispFadeOut()", sec);
    }
}
function DispFadeOut() { 
    var obj = MM_GetObject("mainimage");
    obj.style.filter = "alpha(opacity=" + percent + ")"; 
    obj.style.opacity = percent/100;
    percent -= 10;
    if(percent >= 0) {
        setTimeout("DispFadeOut()", 50);
    }
    else {
        idx++;
        obj.src = "images/display"+num+("0"+(idx%count+1)).slice(-2)+".jpg";
        DispFadeIn();
    }
}

function ViewMenu(obj) {
    menu = obj;
    if(w==25) {
        setTimeout("MenuWidth()", 1);
    }
}
function MenuWidth() {
    menu.style.width = w+"px";
	w++;
    if(w<152) {
        setTimeout("MenuWidth()", 1);
    }
}

function UnderMenu(num) {
	for(i=1; i<=4; i++) {
		if(i==num) {
			var obj = MM_GetObject("menu"+i);
			if(obj.className == "visible") {
				MM_GetObject("li"+i).className = "";
				obj.className = "hidden";
			}
			else {
				MM_GetObject("li"+i).className = "y2";
				obj.className = "visible";
			}
		}
		else {
			MM_GetObject("li"+i).className = "";
			MM_GetObject("menu"+i).className = "hidden";
		}
	}
	return false;
}

