// JavaScript Document

// Tab Content
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_over.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace("on", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_over.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

/* inputbox value */
function inputtext_init(ele, str){
	if(!ele.inputCheckValue && ele.value == str){
		ele.value = "";
		ele.inputCheckValue = true;
	}
}

/* quick */
function quicks(ele){
	this.target_id = ele;
	this.target = document.getElementById(ele);
}
quicks.prototype.getStyle = function(ElementID, what){
	var target = document.getElementById(ElementID);
	var value = "";
	if(target.currentStyle){
		value = target.currentStyle[what];
	}else if(window.getComputedStyle){
		value = window.getComputedStyle(target,null)[what];
	}
	return value;
}
quicks.prototype.int = function(){
	var temp = this.getStyle(this.target_id, "top");
	this.target.style.top = temp;
	this.int_top = temp;
}
quicks.prototype.move = function(){
	var yMenuFrom, yMenuTo, timeoutNextCheck, speed;
	var target = this.target;
	var int_top = this.int_top;

	yMenuFrom = parseInt(target.style.top, 10);
	yMenuTo = parseInt(int_top) + parseInt(document.documentElement.scrollTop, 10);
	
	timeoutNextCheck = 250;

	var _func = this;
	if(yMenuFrom == yMenuTo){
		return setTimeout(function(){_func.move();}, timeoutNextCheck);
	}else{
		speed = Math.ceil((yMenuTo - yMenuFrom) *0.2);
		target.style.top = (parseInt(target.style.top, 10) + speed) + "px";
		timeoutNextCheck = 20;
		return setTimeout(function(){_func.move();}, timeoutNextCheck);
	}
}

/* discography */
function disco_tab(obj){
	if(!document.getElementById(obj)) return false;
	
	var temp = document.getElementById(obj);
	var source = temp.getElementsByTagName("img");
	var btn_img;
	
	function over(text){
		text.src = text.over;
		if(btn_img){
			btn_img.src = btn_img.src.replace("_over.gif", ".gif");
		}
		btn_img = text;
	}
	
	var show = new Image();
	for(i=0; i<source.length; i++){
		if(source[i].src.indexOf(".gif") != -1){
			show[i] = source[i].src.replace(".gif", "_over.gif");
			source[i].over = show[i];
			source[i].onmouseover = function(){
				if(this.src.indexOf("_over.gif") != -1){
					
				} else {
					over(this);
				}
			}
		}
	}	
}

