/*
** Developed by London Trust Media, Inc. <http://www.londontrustmedia.com>
**
** Copyright (c) 2009 London Trust Media, Inc.
** All Rights Reserved.
*/

var ANIM_SPEED = 10;	/* highlihght speed */
var ANIM_SPEEDM = 15; /* movement speed */
var ANIM_Q = 1.2; /* movement power */




function menu_on(which) {
	var wm1="menu0"+which;
	var wm2="im0"+which;
	var wm3="mtitle0"+which;
	
	var target1=document.getElementById(wm1);
	var target2=document.getElementById(wm2);
	var target3=document.getElementById(wm3);

	setOpacity(target1,10);
	
	target2.style.cursor='pointer';

	setOpacity(target3,7);
}

function pLoad(num)
{
	// 58 is the top end.
	var pbarWidth=(num/57)*100;
	pbarWidth=parseInt(pbarWidth);
	if(pbarWidth>=100)
		pbarWidth=100;
	document.getElementById("cctemp").innerHTML='<b><big><big><big><big>korman</b>construction</big></big></big></big></big></b><br><br>';
	document.getElementById("cctemp").innerHTML+='<div style="width:'+pbarWidth+'%;background-color:#ffffff;float:left;color:#000000;text-align:right;">'+pbarWidth+'%</div>';
	
}
function menu_off(which) {
	var wm1="menu0"+which;
	var wm2="im0"+which;
	var wm3="mtitle0"+which;

	var target1=document.getElementById(wm1);
	var target2=document.getElementById(wm2);
	var target3=document.getElementById(wm3);
	
	setOpacity(target1,7);
	target2.style.background='none';
	target2.style.cursor='default';
	
	setOpacity(target3,6);
}
function menu_click(which) {
	var wm1="mbh0"+which;
	var wm5="bh0"+which;
	
	if(which!=0) {
		var target1=document.getElementById(wm1);
	}
	var target5=document.getElementById(wm5);

	// z-index issue to make sure new page is "Always On Top"
	target5.style.zIndex="46";

	// if focus, we close and return the item
	if(myFocus==which && which!=0) {
		moveObject(target1,250,-17);
		var mtar1=document.getElementById("bh00");
		moveObjectc(target5,250,-555,0,null,mtar1);

		target5.style.zIndex="45";
		myFocus=0;
	}
	else if(myFocus==which && which==0)
	{
		return;
	}
	else
	{
		// if focus is not 0
		// we have to move whatever is focused first back home		
		if(myFocus != 0)
		{
			var mtar1=document.getElementById("mbh0"+myFocus);
			var mtar5=document.getElementById("bh0"+myFocus);

			moveObject(mtar1,250,-17);
			moveObjectc(mtar5,250,-555,which,target1,target5);
			mtar5.style.zIndex="45";
			myFocus=0;
		}
		else if(myFocus == 0)
		{
			var mtar1=document.getElementById("bh00");
			moveObjectc(mtar1,250,-555,which,target1,target5);
			mtar1.style.zIndex="45";
			myFocus=0;
		}

		// now let's move the new place in place
	}
}
function menu_click2(which,target1,target5)
{
		if(which!=0)
		{
			moveObject(target1,5,268);
		}
		
		moveObject(target5,-510,305);
		
		myFocus=which;

}

function pbookscroll(which)
{
	var mySlide=document.getElementById("photobook");
	var newImage=document.getElementById("pb"+which);
	var oldImage=document.getElementById("pb"+photoFocus);

	if(photoFocus==which)
		return;
	else
	{
		if(which > photoFocus)
		{
			// add
			moveObject(mySlide,photoPosition,photoPosition-photoMove);
			photoPosition-=photoMove;

		}
		else
		{
			// subtract
			moveObject(mySlide,photoPosition,photoPosition+photoMove);
			photoPosition+=photoMove;
		}
		
		//resize newimage changeopacity
		changeHeight(newImage,220,300);
		setOpacity(newImage,10);
		
		//resize oldimage changeopacity
		changeHeight(oldImage,300,220);
		setOpacity(oldImage,5);

		photoFocus=which;
	}
	
}
function pblight(which)
{
	if(photoFocus==which)
		return;
	else
		setOpacity(document.getElementById("pb"+which),9);
}
function pboff(which)
{
	if(photoFocus==which)
		return;
	else
		setOpacity(document.getElementById("pb"+which),5);
}
function hideobj(obj)
{
	if(obj.highLight)
		window.clearInterval(obj.highLight);
	var c=0;
	obj.highLight = window.setInterval(
		function() {
			setOpacity(obj,10-(c/1));
			c++;
			if (c > 10)
			{
				window.clearInterval(obj.highLight);
				obj.style.display='none';
			}
		}
		,1);		
}
function moveObject(obj,start,end)
{

	if(obj.moveMent)
		window.clearInterval(obj.moveMent);
	var c=0;
	var distance = end - start;
	obj.moveMent = window.setInterval(
		function() {
			obj.style.left = start+((1/ANIM_SPEEDM)*c)*(distance) + "px";
			c++;
			if (c >= ANIM_SPEEDM)
			{
				window.clearInterval(obj.moveMent);
			}
		}
		,1);
}
function moveObjectc(obj,start,end,which,target1,target5)
{

	if(obj.moveMent)
		window.clearInterval(obj.moveMent);
	var c=0;
	var distance = end - start;
	obj.moveMent = window.setInterval(
		function() {
			obj.style.left = start+((1/ANIM_SPEEDM)*c)*(distance) + "px";
			c++;
			if (c >= ANIM_SPEEDM)
			{
				window.clearInterval(obj.moveMent);
				menu_click2(which,target1,target5);
			}
		}
		,1);
}
function changeHeight(obj,start,end)
{

	if(obj.moveMent)
		window.clearInterval(obj.moveMent);
	var c=0;
	var distance = end - start;
	obj.moveMent = window.setInterval(
		function() {
			obj.style.height = start+((1/ANIM_SPEEDM)*c)*(distance) + "px";
			c++;
			if (c >= ANIM_SPEEDM)
			{
				window.clearInterval(obj.moveMent);
			}
		}
		,1);
}
function setOpacity(obj,value) {
	obj.style.opacity = value/10;
	obj.style.filter = 'alpha(opacity=' + value*10 + ')';
}
