﻿function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) { 
//Generic Animation Step Value Generator By www.hesido.com 
    var delta = maxValue - minValue; 
    var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
    return stepp;
    } 
function doFade(elem,startOpacity,endOpacity,steps,intervals,powr) { 
    if (elem.fadeInt)
	window.clearInterval(elem.fadeInt);
    var actStep = 0;
    elem.fadeInt = window.setInterval(
	function() { 
	  elem.currentOpacity = easeInOut(startOpacity,endOpacity,steps,actStep,powr);
	  elem.style.opacity = elem.currentOpacity; 
	  actStep++;
	  if (actStep > steps) window.clearInterval(elem.fadeInt);
	} 
	,intervals)
}
function doFadeIE(elem,startOpacity,endOpacity,steps,intervals,powr) { 
    if (elem.fadeInt)
	window.clearInterval(elem.fadeInt);
    var actStep = 0;
    elem.fadeInt = window.setInterval(
	function() { 
	  elem.currentOpacity = easeInOut(startOpacity,endOpacity,steps,actStep,powr);
	  elem.style.filter = "alpha(opacity=" + elem.currentOpacity + ")";
	  actStep++;
	  if (actStep > steps) window.clearInterval(elem.fadeInt);
	} 
	,intervals)
}

function focusColors(){
var cont_formHolder = document.getElementById('formHolder');
var forms = cont_formHolder.getElementsByTagName('form');
for (var i = 0, j = forms.length; i < j; i++) {
	if(document.all){
	forms[0].style.filter="alpha(opacity=100)";
	forms[1].style.filter="alpha(opacity=100)";
	} else {
	forms[0].style.opacity="1";
	forms[1].style.opacity="1";
	}
	if(forms[0].getElementsByTagName('ul').length>0 || forms[0].getElementsByTagName('input').length==0){ 
			forms[0].style.backgroundColor="#f1f8ff";
			forms[1].style.backgroundColor="#ffffff";
			if(document.all){
				forms[1].style.height="1%";
				if(forms[1].style.filter=="alpha(opacity=100)"){
				doFadeIE(forms[1], 100, 40, 10, 10, 1);
				}
				forms[0].style.filter="alpha(opacity=100)";
			} else {
				if(forms[1].style.opacity==1){
				doFade(forms[1], 1, .4, 10, 10, 1);
				}
				forms[0].style.opacity="1";
			}
	}
	forms[0].onclick=function(){
			this.style.backgroundColor="#f1f8ff";
			forms[1].style.backgroundColor="#ffffff";
			if(document.all){
				forms[1].style.height="1%";
				if(forms[1].style.filter=="alpha(opacity=100)"){
				doFadeIE(forms[1], 100, 40, 10, 10, 1);
				}
				forms[0].style.filter="alpha(opacity=100)";
			} else {
				if(forms[1].style.opacity==1){
				doFade(forms[1], 1, .4, 10, 10, 1);
				}
				forms[0].style.opacity="1";
			}
		
		}
	if(forms[1].getElementsByTagName('ul').length>0 || forms[1].getElementsByTagName('input').length==0){ 
			forms[1].style.backgroundColor="#f1f8ff";
			forms[0].style.backgroundColor="#ffffff";
			if(document.all){
				forms[0].style.height="1%";
				if(forms[0].style.filter=="alpha(opacity=100)"){
				doFadeIE(forms[0], 100, 40, 10, 10, 1);
				}
				forms[1].style.filter="alpha(opacity=100)";
			} else {
				if(forms[0].style.opacity==1){
				doFade(forms[0], 1, .4, 10, 10, 1);
				}
				forms[1].style.opacity="1";
			}
	}
	forms[1].onclick=function(){
			this.style.backgroundColor="#f1f8ff";
			forms[0].style.backgroundColor="#ffffff";
			if(document.all){
				forms[0].style.height="1%";
				if(forms[0].style.filter=="alpha(opacity=100)"){
				doFadeIE(forms[0], 100, 40, 10, 10, 1);
				}
				forms[1].style.filter="alpha(opacity=100)";
				//forms[0].style.filter="alpha(opacity = 50)";
				//forms[1].style.filter="alpha(opacity = 100)";
			} else {
				if(forms[0].style.opacity==1){
				doFade(forms[0], 1, .4, 10, 10, 1);
				}
				forms[1].style.opacity="1";
			}
			
		}
	/*
	document.onmousedown=function(){
		forms[0].style.backgroundColor="#ffffff";
		forms[1].style.backgroundColor="#ffffff";
	}
	*/
	/*
	formBGColor(forms[i]);
	*/
	/*
	****** fix IE's lack of :focus pseudo class ******
	*/
	if(document.all){
		var inputs = forms[i].getElementsByTagName('input');
		var textareas = forms[i].getElementsByTagName('textarea');
		for (var k = 0, l = inputs.length; k < l; k++) {
			if(inputs[k].type!='radio' && inputs[k].type!='checkbox' && inputs[k].type!='submit'){
				inputs[k].onfocus=function(){
					this.style.backgroundColor='#fff';
				}
				inputs[k].onblur=function(){
					this.style.backgroundColor='#e4f1ff';
				}
			}
		}
		for (var m = 0, n = textareas.length; m < n; m++) {
			textareas[m].onfocus=function(){
				this.style.backgroundColor='#fff';
			}
			textareas[m].onblur=function(){
				this.style.backgroundColor='#e4f1ff';
			}
		}
	}
	}

}


	


addLoadEvent(focusColors);

