
/************* JavaScript By Brankov ******************/

var menu = new Array();
	
		menu[1] = new Array();
		menu[1][0] = "home";
		menu[1][1] = 0;
		menu[1][2] = "Home";
		menu[2] = new Array();
		menu[2][0] = "services";
		menu[2][1] = 0;
		menu[2][2] = "Services";
		menu[3] = new Array();
		menu[3][0] = "portfolio";
		menu[3][1] = 0;
		menu[3][2] = "Portfolio";
		menu[4] = new Array();
		menu[4][0] = "faq";
		menu[4][1] = 0;
		menu[4][2] = "FAQ";
		menu[5] = new Array();
		menu[5][0] = "aboutus";
		menu[5][1] = 0;
		menu[5][2] = "About Us";
		menu[6] = new Array();
		menu[6][0] = "contact";
		menu[6][1] = 0;
		menu[6][2] = "Contact";
	var numberMenus = 6;

		var speed = 2;
		var moveIncrement = 50;
		var growShrinkIncrement = 60;
		var homePosition = 50;
		var readPosition = 250;
		var deckItem = 20;
		var deckItemCorection = 7;
		var distance = deckItem + deckItemCorection;
		var deck = distance * numberMenus;
		var delay = 800;

function calculatePosition()
{
	for ( position = 1; position < (numberMenus + 1); position ++)
	{
		menu[position][3] = wiw - (distance + ((numberMenus + 1)-position) * distance);
		menu[position][4] = 0.1*wiw;
		//menu[position][4] = 0.15*wiw - (distance + ((numberMenus + 1)6-position) * distance);
	}
}


function setPosition()
{
	setTimeout('setPositionLate()', delay);
	closePages();
}

function setPositionLate()
{
var ws = screen.availWidth;
var hs = screen.availHeight;
var wd = document.body.width;
var hd = document.body.height;
var ww = window.availWidth;
var hw = window.availHeight;


	if (window.navigator.appName != "Microsoft Internet Explorer")
	{
		wiw = window.innerWidth;
		hiw = window.innerHeight;
		for (c1 = 0; c1 < numberMenus; c1++)
		{
			document.getElementById(menu[c1+1][0]).style.width = deckItem - deckItemCorection;
		}
	}
	else
	{
		wiw = document.getElementById('bodyMesure').offsetWidth;
		hiw = document.getElementById('bodyMesure').offsetHeight;
	}
 
calculatePosition();

	for (c0 = 0; c0 < numberMenus; c0++)
	{
		movePageRight(menu[c0+1][0]);
	}

}


function grow(divGrow, place)
{
movePageLeft(divGrow);
//gr(divGrow);
closePages(divGrow);
}

function gr(divGr)
{
w = document.getElementById(divGr).offsetWidth;
w += growShrinkIncrement;
if (w < (wiw - (menu[findMenu(divGr)][4] + deck + 2*distance)))
	{
		document.getElementById(divGr).style.width = w;
		setTimeout('gr(\''+divGr+'\')', speed);
	}
else
	{	
		divCont = divGr + '_content';
		h1_div = 'h1_' + divGr + '_content';
		document.getElementById(h1_div).innerHTML = menu[findMenu(divGr)][2];
		document.getElementById(divGr).innerHTML = document.getElementById(divCont).innerHTML;
		menu[findMenu(divGr)][1] = 1;
	}
}

function shrink(divShrink)
{
movePageRight(divShrink);
sh(divShrink);
		dCont = 'div_' + divShrink + '_content';
		h1_div = 'h1_' + divShrink + '_content';
		icon_div = 'icon_' + divShrink;
		document.getElementById(h1_div).innerHTML = findMenu(divShrink);
		document.getElementById(icon_div).src = "styles/prev.gif";
		document.getElementById(dCont).innerHTML = "";
}

function sh(divSh)
{
w = document.getElementById(divSh).offsetWidth;
w -= growShrinkIncrement;
if (w > 30)
	{
		document.getElementById(divSh).style.width = w;
		setTimeout('sh(\''+divSh+'\')', speed);
	} 
else
	{
		if (window.navigator.appName == "Microsoft Internet Explorer")
			{
				document.getElementById(divSh).style.width = deckItem;
			}
		else
			{
				document.getElementById(divSh).style.width = deckItem - deckItemCorection;
			}
		menu[findMenu(divSh)][1] = 0;
	}
}

function findMenu(divFindMenu)
{
	for(c = 0; c < numberMenus; c++)
	{
		if (menu[c+1][0] == divFindMenu)
			{
				menuItem = c+1;
			}	
	}
	return menuItem;
}


function movePageLeft(divMovePageLeft)
{
l = document.getElementById(divMovePageLeft).offsetLeft;
l -= moveIncrement;
if (l > menu[findMenu(divMovePageLeft)][4])
	{
		document.getElementById(divMovePageLeft).style.left = l;
		setTimeout('movePageLeft(\''+divMovePageLeft+'\')', speed);
	} 
else {
		document.getElementById(divMovePageLeft).style.left = menu[findMenu(divMovePageLeft)][4];
		gr(divMovePageLeft);
	}
}


function movePageRight(divMovePageRight)
{
l = document.getElementById(divMovePageRight).offsetLeft;
l += moveIncrement;

if (l < menu[findMenu(divMovePageRight)][3])
	{
		document.getElementById(divMovePageRight).style.left = l;
		setTimeout('movePageRight(\''+divMovePageRight+'\')', speed);
	} 
else
	{
		document.getElementById(divMovePageRight).style.left = menu[findMenu(divMovePageRight)][3];
	}
}

function findOpenPage()
{
	for(c = 0; c < numberMenus; c++)
	{
		if (menu[c+1][0] == div)
			{
				menuItem = c+1;
			}	
	}
	return menuItem;	
}


function closePages(noCloseDiv)
{
	for(c = 0; c < numberMenus; c++)
	{
//alert(noCloseDiv);
		if (menu[c+1][1] == 1 && menu[c+1][0] != noCloseDiv)
			{
				shrink(menu[c+1][0]);
			}	
	}

}



/*********************** popUp ***************************/

function show_popup(picName, topImg)
{
	var p=window.createPopup();
	var pbody=p.document.body;
	pbody.style.backgroundColor="white";
	pbody.style.border="solid #aaaaaa 1px";
	pbody.innerHTML ='<center><h2>'+picName+'</h2></center>';
	pbody.innerHTML+='<br>';
	pbody.innerHTML+='<center><img src="../images/contstructionlogo.gif" alt="www.ekip.brankov.net" name="'+picName+'" width="300" border="0" id="'+picName+'"></center>';
	pbody.innerHTML+='<br>';
	// pbody.innerHTML+='<a href="javascript: close();">close</a>';
	pbody.innerHTML+='<br>' + topImg + 'px';
	p.show(0.1*wiw + 30,300 + topImg,320,370,document.body);
}

function open_win(picName)
{
param = 'phpscripts/pic_viewer.php?picName='+picName;
window.open(param,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=578, height=400")
}

function resizeWindow()
{
top.resizeTo(500,300);
}
