var index;
var tabcontainer;
var tabArr;
var tabLength;

function detailViewTab(){
	if (index == undefined) index = 0;
	tabContainer = document.getElementById('productDetail');
	tabArr = tabContainer.getElementsByTagName('img');
	tabLength = tabArr.length;
	
	for (i=0; i<tabLength; i++) {
		tabArr[i].idx = i;
		tabArr[i].onclick = function() {
			if (this.idx == index) return false;
			setDetailTab(this.idx)				
		}
	}
}

function setDetailTab(idx) {
	//var page = document.getElementById()
	for (k=0; k<tabLength; k++){			
		if (k == idx){
			tabArr[k].src = tabArr[k].src.replace('.gif', '_on.gif');
		}else if (k == index){
			tabArr[k].src = tabArr[k].src.replace('_on.gif', '.gif');
		}
		
		if (k>0){
			var tgtSpecID = "pag0"+k;
			var tgtSpec = document.getElementById(tgtSpecID);
			if (idx != "0"){
				tgtSpec.style.display = "none";
				if (k == idx){
					tgtSpec.style.display = "block";
				}
			}else{
				tgtSpec.style.display = "block";
			}
		}
	}
	index = idx;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(detailViewTab);

