﻿// functions
function showTab(tabName,tabs,tab_num){ 
	for(var i = 0;i <= tabs;i++){
		if(GetObj("aTab_" + tabName + "_" + tabs + i)){GetObj("aTab_" + tabName + "_" + tabs + i).className = '';}
		if(GetObj("aTCont_" + tabName + "_" +  tabs + i)){GetObj("aTCont_" + tabName + "_" +  tabs + i).style.display = 'none';}
	}
	if(GetObj("aTab_" + tabName + "_" + tabs + tab_num)){GetObj("aTab_" + tabName + "_" + tabs + tab_num).className = 'selected';}
	if(GetObj("aTCont_" + tabName + "_" + tabs + tab_num)){GetObj("aTCont_" + tabName + "_" + tabs + tab_num).style.display = 'block';}
	return false;
}
function GetObj(objName){
	if(document.getElementById){
		return eval('document.getElementById("' + objName + '")');
	}else{
		return eval('document.all.' + objName);
	}
}


//
function imgscroll(){
	var speed=90;
	var td = document.getElementById("imgMarquee");
	var td2 = document.getElementById("imgMarquee02");
	var td1 = document.getElementById("imgMarquee01");
	td2.innerHTML = td1.innerHTML ;
	function Marquee(){
		if(td2.offsetWidth-td.scrollLeft<=0)
			td.scrollLeft-=td1.offsetWidth;
		else{
			td.scrollLeft++
		}
	}
	var MyMar=setInterval(Marquee,speed)
	td.onmouseover=function() {clearInterval(MyMar)}
	td.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}




  // table tr odd class
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {
    var even = false;
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eee";
    var table = document.getElementById(id);
    if (! table) { return; }
    var tbodies = table.getElementsByTagName("table");
    for (var h = 0; h < tbodies.length; h++) {
      var trs = tbodies[h].getElementsByTagName("tr");
      for (var i = 0; i < trs.length; i++) {
	    if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
          var tds = trs[i].getElementsByTagName("td");
          for (var j = 0; j < tds.length; j++) {
            var mytd = tds[j];
	        if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
		      mytd.style.backgroundColor = even ? evenColor : oddColor;
            }
          }
        }
        even =  ! even;
      }
    }
  }

//open new window
function popOpen(url,w,h,name) {
	var isIE = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));
	if (isIE) {
		w =w+17;
	}else {
		w = w+9;
	}
	sw=screen.availWidth/2-w/2;
	sh=screen.availHeight/2-h/2;
	newWin=window.open(url,name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=auto,resizable=1,width='+w+',height='+h+',top='+sh+',screenY='+sh+',left='+sw+',screenX'+sw);
	if (window.focus) {newWin.focus()};
}

function resetimgs() {
	var maxWidth = 620;
	var isImg = document.getElementById("mainBody");
	if (isImg) {
	var imgs = document.getElementById("mainBody").getElementsByTagName("IMG");
	for ( i = 0; i<imgs.length; i++ ) {
		if (imgs[i].width > maxWidth) {
			var iw = parseInt(imgs[i].width) ; 
			var ih = parseInt(imgs[i].height) ;
			imgs[i].style.width = maxWidth +"px";
			var iih = ih * maxWidth;
			imgs[i].style.height =  parseInt( iih / iw ) + "px";
			imgs[i].onclick = function() {window.open(this.src)};
			imgs[i].style.cursor = "pointer";
			imgs[i].title = "Click to view original image";
		}
	}
	}
}


