// JavaScript Document

function adjHeight (bodyid) {

	var bheight, wheight, dif;

        bheight=document.getElementById('wrap').offsetHeight;



if (!window.innerWidth)

	{

document.execCommand("BackgroundImageCache",false,true);

		//strict mode

		if (!(document.documentElement.clientWidth == 0))

		{ wheight = document.documentElement.clientHeight; }

		//quirks mode

		else

		{ wheight = document.body.clientHeight; }

	}

	//w3c

	else

	{ wheight = window.innerHeight; }



    if (wheight > bheight) {

		dif = wheight - bheight + 5;

        document.getElementById('content').style.paddingBottom=dif+"px";

	}



document.getElementById(bodyid).style.backgroundColor = "#C4CFD9";

document.getElementById("wrap").style.backgroundColor = "#C4CFD9";



}



function adjHeightHome (bodyid) {



var col1height, col2height, col3height, diffcol;

diffcol=0;

col1height=document.getElementById('column1').offsetHeight;

col2height=document.getElementById('column2').offsetHeight;

col3height=document.getElementById('column3').offsetHeight;



document.getElementById('column2').style.paddingBottom=diffcol+"px";



if ( (col2height < col3height) && (col2height >= col1height)) {

	diffcol=col3height - col2height; 

}



if ( (col2height >= col3height) && (col2height < col1height)) {

	diffcol=col1height - col2height; 

}



if ( (col2height < col3height) && (col2height < col1height) && (col3height < col1height)) {

	diffcol=col1height - col2height; 

}



if ( (col2height < col3height) && (col2height < col1height) && (col3height > col1height)) {

	diffcol=col3height - col2height; 

}



		var bheight, wheight, dif;

		dif=0;

        bheight=document.getElementById('wrap').offsetHeight;



if (!window.innerWidth)

	{

document.execCommand("BackgroundImageCache",false,true);

		//strict mode

		if (!(document.documentElement.clientWidth == 0))

		{ wheight = document.documentElement.clientHeight; }

		//quirks mode

		else

		{ wheight = document.body.clientHeight; }

	}

	//w3c

	else

	{ wheight = window.innerHeight; }



    if (wheight > bheight) {

		dif = wheight - bheight + 5;

        document.getElementById('content').style.paddingBottom=dif+"px";

	}



document.getElementById(bodyid).style.backgroundColor = "#C4CFD9";

document.getElementById("wrap").style.backgroundColor = "#C4CFD9";



var dif4col = diffcol + dif;

//document.getElementById('column2').style.paddingBottom=dif4col+"px";



}



function adjHeightAll () {

document.getElementById("wrap").style.backgroundColor = "#C7D2DC";

}



function resHeight () {



		var bheight, wheight, dif;

        bheight=document.getElementById('wrap').offsetHeight;



if (!window.innerWidth)

	{

		//strict mode

		if (!(document.documentElement.clientWidth == 0))

		{ wheight = document.documentElement.clientHeight; }

		//quirks mode

		else

		{ wheight = document.body.clientHeight; }

	}

	//w3c

	else

	{ wheight = window.innerHeight; }



    if (wheight > bheight) {

		dif = wheight - bheight + 5;

        document.getElementById('content').style.paddingBottom=dif+"px";

	}



}



startList = function() {

if (document.all&&document.getElementById) {

navRoot = document.getElementById("nav");

for (i=0; i<navRoot.childNodes.length; i++) {

node = navRoot.childNodes[i];

if (node.nodeName=="LI") {

node.onmouseover=function() {

this.className+=" over";

  }

  node.onmouseout=function() {

  this.className=this.className.replace(" over", "");

   }

   }

  }

 }

}



startList2 = function() {

if (document.all&&document.getElementById) {

navRoot = document.getElementById("navddsm");

for (i=0; i<navRoot.childNodes.length; i++) {

node = navRoot.childNodes[i];

if (node.nodeName=="LI") {

node.onmouseover=function() {

this.className+=" over";

  }

  node.onmouseout=function() {

  this.className=this.className.replace(" over", "");

   }

   }

  }

 }

}



function OpenIt(newin) { 

flyout=window.open(newin,"popup","status=no,toolbar=no,location=no,menu=no,resizable=yes,scrollbars=yes,width=950,height=780")

}



/*

function pausecomp(millis) 

{

var date = new Date();

var curDate = null;



do { curDate = new Date(); } 

while(curDate-date < millis);



//pausecomp(1500);

} 

*/



/*

if (window.innerHeight) {

theHeight=window.innerHeight;

}

else if (document.documentElement && document.documentElement.clientHeight) {

theHeight=document.documentElement.clientHeight;

}

else if (document.body) {

theHeight=document.body.clientHeight;

}

*/



/*

	var h = 0;



	//IE

	if(!window.innerWidth)

	{

		//strict mode

		if(!(document.documentElement.clientWidth == 0))

		{

			h = document.documentElement.clientHeight;

		}

		//quirks mode

		else

		{

			h = document.body.clientHeight;

		}

	}

	//w3c

	else

	{

		h = window.innerHeight;

	}

*/

function ClickTab(tub_num){
	var tab = document.getElementById("tabList");
	tab.className = "tabList tab_"+tub_num;
	$("#tabCell div").removeClass("active");
	$("#tabContent"+tub_num).addClass("active");
	return false;	
}

var slideShowTimer = null;
var currentSlide = null;

function NextSlide(){
	if (slideShowTimer) window.clearTimeout(slideShowTimer);
	if (currentSlide) {
		if ($(currentSlide).next().length > 0) var newSlide = $(currentSlide).next();
		else var newSlide = $("#verticalsSlideShow").children("div")[0];
		$(currentSlide).css({"z-index": 2});
		$(newSlide).css({"z-index": 1, "opacity": 1});
		$(newSlide).addClass("slideActive");
		$(currentSlide).animate({"opacity": 0},2000,function(){ 
			$(currentSlide).removeClass("slideActive"); 
			currentSlide = newSlide;
			slideShowTimer = window.setTimeout("NextSlide()",3000);
		});
	}
	else {
		currentSlide = $("div.slideActive");
		slideShowTimer = window.setTimeout("NextSlide()",3000);
	}
}

var slideShowTimer1 = null;
var currentSlide1 = null;

function NextSlide1(){
	if (slideShowTimer1) window.clearTimeout(slideShowTimer1);
	if (currentSlide1) {
		if ($(currentSlide1).next().length > 0) var newSlide = $(currentSlide1).next();
		else var newSlide = $("#partnersSlideShow").children("a")[0];
		$(currentSlide1).css({"z-index": 2});
		$(newSlide).css({"z-index": 1, "opacity": 1});
		$(newSlide).addClass("slideActive");
		$(currentSlide1).animate({"opacity": 0},2000,function(){ 
			$(currentSlide1).removeClass("slideActive"); 
			currentSlide1 = newSlide;
			slideShowTimer1 = window.setTimeout("NextSlide1()",4000);
		});
	}
	else {
		currentSlide1 = $("#partnersSlideShow a.slideActive");
		slideShowTimer1 = window.setTimeout("NextSlide1()",4000);
	}
}

var slideShowTimer2 = null;
var currentSlide2 = null;
var animationInProcess = false;

function NextSlide2(){
	if (slideShowTimer2) window.clearTimeout(slideShowTimer2);
	if (currentSlide2) {
		if ($(currentSlide2).next().length > 0) var newSlide = $(currentSlide2).next();
		else var newSlide = $("#swfSlideShow").children("a").eq(0);
		ReplaceSlide(newSlide,true);
	}
	else {
		currentSlide2 = $("#swfSlideShow a.slideActive");
		slideShowTimer2 = window.setTimeout("NextSlide2()",4000);
	}
}

function ReplaceSlide(newSlide,start_timer){
	if (animationInProcess == true) return false;
	else {
		animationInProcess = true;
		$(currentSlide2).css({"z-index": 2});
		$(newSlide).css({"z-index": 1, "opacity": 1});
		$(newSlide).addClass("slideActive");
		var interv = (start_timer == true)? 1500 : 500;
		$(currentSlide2).animate({"opacity": 0},interv,function(){ 
			$(currentSlide2).removeClass("slideActive"); 
			currentSlide2 = newSlide;
			interv = (start_timer == true)? 4000 : 8000;
			slideShowTimer2 = window.setTimeout("NextSlide2()",interv);
			animationInProcess = false;
		});
		$("#swfButtons").children("a").removeClass("active");
		var i = GetIndexOfElement($("#swfSlideShow").children("a"),$(newSlide)[0]);
		if (i > -1) {
			$("#swfButtons").children("a").eq(i).addClass("active");
		}
		
		return true;
	}
}

function ClickSwfButton(elem, slide_numb){
	
	if (animationInProcess == false) {
		if (slideShowTimer2) window.clearTimeout(slideShowTimer2);
		ReplaceSlide($("#swfSlideShow").children("a").eq(slide_numb-1),false);		
	}
	
	return false;
}

function GetIndexOfElement(source_array,elem) {
	//alert(source_array.length);
	for(var i=0;i<source_array.length;i++)
		if (source_array[i] == elem) return i;
	return -1;
}