//ipiCommon.js
//This script should contain the common functions for all IPI pages

//Handle Product Bar.. Mouse over
var hideProductsSoon = false;
function mouseShowProduct() {
	var AboutBar = document.getElementById('navbar3');
	if (AboutBar.style.display != "none"){
		Effect.BlindUp(AboutBar, {duration:0.4} );
		hideAboutSoon = false;
	}
	var productBar = document.getElementById('navbar2');
	if (productBar.style.display == "none"){
		Effect.BlindDown(productBar, {duration:0.4, queue: 'end'});
	} else {
		clearTimeout(hideProductsSoon);
		hideProductsSoon = false;
	}
}
function mouseOutProduct() {
	var productBar = document.getElementById('navbar2');
	if (productBar.style.display == "none"){
		//Effect.BlindDown(productBar);
	} else {
		hideProductsSoon = setTimeout("hideProduct()", 500);
	}
}

function hideProduct(){
	var productBar = document.getElementById('navbar2');
	Effect.BlindUp(productBar, {duration:0.4});
	clearTimeout(hideProductsSoon);
	hideProductsSoon = false;	
}


//Handle About Bar.. Mouse over
var hideAboutsSoon = false;
function mouseShowAbout() {
	var AboutBar = document.getElementById('navbar3');
	var productBar = document.getElementById('navbar2');
	if (productBar.style.display != "none"){
		Effect.BlindUp(productBar, {duration:0.4});
		hideProductsSoon = false;
	} 
	if (AboutBar.style.display == "none"){
		Effect.BlindDown(AboutBar, {duration:0.4, queue: 'end'});
	} else {
		clearTimeout(hideAboutsSoon);
		hideAboutsSoon = false;
	}
}
function mouseOutAbout() {
	var AboutBar = document.getElementById('navbar3');
	if (AboutBar.style.display == "none"){
		//Effect.BlindDown(AboutBar);
	} else {
		hideAboutsSoon = setTimeout("hideAbout()", 500);
	}
}

function hideAbout(){
	var AboutBar = document.getElementById('navbar3');
	Effect.BlindUp(AboutBar, {duration:0.4});
	clearTimeout(hideAboutsSoon);
	hideAboutsSoon = false;	
}

function loadSection(section){
	if (section == 'all'){
		var count = 1;
		for(count = 1 ; count <= sectionCount ; count++){
			if (document.getElementById('section-'+count)){	
				Effect.Appear('section-'+count);
			} 
			if (count != 1 && document.getElementById('sectionImage-'+count)){
				var image = document.getElementById('sectionImage-'+count);
				image.style.display = "none";
			}
		}
		Effect.Appear('sectionImage-1');
	}
	else {
		var count = 1;
		for(count = 1 ; count <= sectionCount; count++){			
			if (document.getElementById('section-'+count)){
				var item = document.getElementById('section-'+count);
				item.style.display = "none";
			}
			if (document.getElementById('sectionImage-'+count)){
				var image = document.getElementById('sectionImage-'+count);
				image.style.display = "none";
			}
		}
		if (document.getElementById('section-'+section)){
			Effect.Appear('section-'+section);
		} else {
			loadSection('all');
		}
		if (document.getElementById('sectionImage-'+section)){
			Effect.Appear('sectionImage-'+section);
		} else {
			Effect.Appear('sectionImage-1');
		}
	}
}
var currentSection = 1;
function loadSectionImage(section){
		var count = currentSection;
		var backDiv = document.getElementById('homepageImage');
		var image = document.getElementById('sectionImage-'+count);
		backDiv.style.backgroundImage = "url("+image.src+")";
		image.style.display = "none";

		if (document.getElementById('sectionImage-'+section)){
			Effect.Appear('sectionImage-'+section, { queue: 'end'});
		} else {
			alert(section);
			Effect.Appear('sectionImage-1');
		}
}