
var tabImgName = '';

function setTabFirstImg(){
	tabImgName = 'button1';
	JSFX.fadeIn(tabImgName,tabImgName);
	document.getElementsByName(tabImgName)[0].title = 1;
}

function tabclicked(name)
{
	return true;
	/*if(tabImgName == ''){
		document.getElementsByName(name)[0].title = 1;
		tabImgName = name;
	}else{
		document.getElementsByName(name)[0].title = 1;
		document.getElementsByName(tabImgName)[0].title = 0;
		JSFX.fadeOut(tabImgName);
		tabImgName = name;
		}*/
}

function onFocusBlur(){
	var inps = document.getElementsByTagName("INPUT");
	for(i=0; i < inps.length; i++){
		if(inps[i].className == "onFocusBlurWhite"){
			inps[i].value = inps[i].title;
			inps[i].style.color = '#666';
			inps[i].style.fontSize = '11px';
			inps[i].onfocus = function () {
					if(this.value == '' || this.value == this.title){
						this.value = '';
						this.style.color = '#333';
						this.style.fontSize = '12px';
					}
				}
			inps[i].onblur = function () {
				if(this.value == ''){
					this.value = this.title;
					this.style.color = '#666';
					this.style.fontSize = '11px';
				}
			}
		}
		
		if(inps[i].className == "onFocusBlurBlack"){
			inps[i].value = inps[i].title;
			inps[i].style.color = '#777777';
			inps[i].style.fontSize = '12px';
			inps[i].onfocus = function () {
					if(this.value == '' || this.value == this.title){
						this.value = '';
						this.style.color = '#F3F3F3';
						this.style.fontSize = '12px';
					}
				}
			inps[i].onblur = function () {
				if(this.value == ''){
					this.value = this.title;
					this.style.color = '#777777';
					this.style.fontSize = '12px';
				}
			}
		}
	}	
}

/////////////////////////////////////////////////////

var clickedImg = '';
var minFade = 0.4;
var otime = '';
var itime = '';
function fadeImage() {
	var imgs = document.getElementsByTagName("IMG");
	for(i=0; i<imgs.length; i++) {
		if(imgs[i].className == "fadeImage"){
			imgs[i].style.opacity=minFade;
			imgs[i].style.filter="alpha(opacity="+minFade*100+")";
			imgs[i].onclick = function () {
								var tId = clickedImg;
								clickedImg = this.id;
								fadeIn(tId);
							}
		}
	}
}

function time() {
// http://kevin.vanzonneveld.net
// +   original by: GeekFG (http://geekfg.blogspot.com)
// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// +   improved by: metjay
// *     example 1: timeStamp = time();
// *     results 1: timeStamp > 1000000000 && timeStamp < 2000000000

return Math.round(new Date().getTime()/1000);
}


var picDelay = 5000;
var picSpeed = 100;
var firstPicI = 0;
function setImageSlide(divId){
	var pics = document.getElementById(divId).childNodes;
	i=0;
	for(i=0; i < pics.length; i++){
		if(pics[i].tagName == "A"){
			pics[i].style.opacity = 0;
			pics[i].style.filter="alpha(opacity=0)";
		}
	}
	i-=2;
	firstPicI = i-8;
	pics[i].style.opacity = 1;
	pics[i].style.filter="alpha(opacity=100)";
	setTimeout("runSlideShow('"+divId+"', '"+i+"')",picDelay);
}

function runSlideShow(divId,picI){
	var pics = document.getElementById(divId).childNodes;
	picIBack = picI - 2;
	if(picIBack < 0){
		picIBack = 	pics.length - 2;
	}
	if(pics[picI].tagName == "A"){
		var opa = document.getElementById(divId).childNodes[picI].style.opacity;
		opa = Number(opa) - 0.1;
		document.getElementById(divId).childNodes[picI].style.opacity = opa;
		document.getElementById(divId).childNodes[picI].style.filter="alpha(opacity="+opa*100+")";
		//picIBack is the new image
		document.getElementById(divId).childNodes[picIBack].style.opacity = 1 - opa;
		document.getElementById(divId).childNodes[picIBack].style.filter="alpha(opacity="+100 - (opa*100)+")";
		//document.getElementById(divId).childNodes[firstPicI].setAttribute('href',document.getElementById(divId).childNodes[picIBack].href);
		//alert(document.getElementById("firstImage").href);
		document.getElementById("firstImage").href = document.getElementById(divId).childNodes[picIBack].href;
		//alert(document.getElementById("firstImage").href);
		//document.title = document.getElementById(divId).childNodes[firstPicI].href;
		if(opa > 0)
			{
				setTimeout("runSlideShow('"+divId+"', '"+picI+"')",picSpeed);
			}else{
				picI = picI - 2;
				if(picIBack == pics.length-2){
					picI = picIBack;	
				}
				setTimeout("runSlideShow('"+divId+"', '"+picI+"')",picDelay);
			}
	}
}


var speed = 10;
var delay = 1000;
var pause = false;
var ms = 0;
var slideSide = 'up';

function slideDown(){
	slideSide = 'down';
}

function slideUp(){
	slideSide = 'up';

}


function slideResume(){
	pause = false;
	ms = speed;
	setTimeout("slideDivs()",ms);
}

function slidePause(){
	pause = true;
	
}

function getDivCount(){
	var a = document.getElementById("mainslide").childNodes;
	var divCount = 0;
	for(i=0; i<a.length; i++){
		if(a[i].className){
			divCount++;
		}
	}
	return divCount;
}

function slideDivs(){
	var mt = document.getElementById("mikhak").style.marginTop;
	//document.title = mt;
	mt = mt.substr(0,mt.length-2);
	if(slideSide == 'up'){
		mt = mt - 1;
	}else{
		mt = parseInt(mt) + 1;
	}
	if(mt % 17 == 0){
		ms = delay;
		if(pause == true){
			return false;
		}
	}else{
		ms = speed;
	}
	document.getElementById("mikhak").style.marginTop = mt + "px";
	
	if(slideSide == 'up'){
		var pt = document.getElementById("pinned").offsetTop;
		//document.title = pt;
		if(pt == 8){
			document.getElementById("mikhak").style.marginTop = "0px";
		}
	}else{
		var pt = document.getElementById("mikhak").offsetTop;
		if(pt > 8){
			var divCount = getDivCount();
			var downSize = (((divCount - 1) * 17) * -1) + 34;
			document.getElementById("mikhak").style.marginTop = downSize + "px";
		}
	}
	
	setTimeout("slideDivs()",ms);
}

