// Keeps all the global Functions Used everywhere within the page
// Developed by Vahe Tshitoyan


function winWidth() {
	if (window.innerWidth) return window.innerWidth;
	else if (document.documentElement) return document.documentElement.offsetWidth;
    else if (document.body.clientWidth) return document.body.clientWidth;
}

function winHeight() {
	if (window.innerHeight) return window.innerHeight;
	else if (document.documentElement) return document.documentElement.offsetHeight;
    else if (document.body.clientHeight) return document.body.clientHeight;
}
function placeIt(id, x, y) {
   object=document.getElementById(id);
   object.style.left=x+"px";
   object.style.top=y+"px";
}
function hideIt(object) {
   object.style.visibility="hidden";
}

function showIt(object) {
   object.style.visibility="visible";
}


var activeMenu=null;
var activeTitle=null;
var mainMenu_interval = null;
var activeDiv = document.getElementById('content');
  
function hideActive() {
	if ( activeMenu !== null ) {
	  hideIt(activeMenu);
	  activeMenu = null;
	}
	
}

function popMenu(M, T) {
	hideActive();
	fillTitleD(T);
	activeMenu = document.getElementById(M);
	showIt(activeMenu);
}

function fillTitle(id) {
if (mainMenu_interval !== null) {
clearInterval(mainMenu_interval);
}
var object = document.getElementById(id);
name = id;
returnTitle();
activeTitle = document.getElementById(id);
object.style.backgroundImage = "url('menu_blank_hover.png')";
object.style.backgroundPosition = "0px"
object.style.color = "white";
object.style.textDecoration = 'none';
}

function returnTitle() {
if (activeTitle !== null) {
activeTitle.style.backgroundImage = "url('menu_blank.png')";
activeTitle.style.color = "#6587E0";
activeTitle.style.backgroundPosition = "0";
}
}

function fillBackground(id) {
var object = document.getElementById(id);
position = parseInt(object.style.backgroundPosition);
if ( position < 0 ) {
position += 5;
object.style.backgroundPosition = position + "px";
} else clearInterval(mainMenu_interval);
}

function fillTitleD(id) {
if (mainMenu_interval !== null) {
clearInterval(mainMenu_interval);
}
var object = document.getElementById(id);
name = id;
returnTitle();
activeTitle = document.getElementById(id);
object.style.backgroundRepeat = "no-repeat";
object.style.backgroundPosition = "-140px";
object.style.backgroundImage = "url('menu_blank_hover_D.png')";
object.style.color = "white";
object.style.textDecoration = 'none';
mainMenu_interval = setInterval("fillBackground(name)", 15);
}

function fillBackgroundD(id) {
var object = document.getElementById(id);
position = parseInt(object.style.backgroundPosition);
if ( position < 0 ) {
position += 5;
object.style.backgroundPosition = position + "px";
} else clearInterval(mainMenu_interval);
}


//variable that will increment through the images
var image_counter=0;

function switchImage(index) {
	imageToChange = document.getElementById("slideshow_image");
	if (window.innerHeight) {
		imageToChange.src = image[image_counter];
	} else {
		imageToChange.filters[0].apply();
		imageToChange.src = image[image_counter];
		imageToChange.filters[0].play(3);
			
	}
}

function slideShow() {
		setTimeout('slideShow("slideshow_image", image)', 6000);
		switchImage(image_counter);
		if (image_counter < image.length - 1) {
			image_counter++;
		} else {
			image_counter = 0;
		}
}