function FrameCode(currentFrame,key)
{
	if(key.indexOf('menu') == 0)
	{
		if(currentFrame == "10")
		{
			GetMenuAnimInstance(key).anim.currentFrame = 10;
		}
		var height = (currentFrame) * (GetMenuAnimInstance(key).maxHeight / GetMenuAnimInstance(key).anim.frameCount); 
		if(height > GetMenuAnimInstance(key).minHeight)
		{
			document.getElementById(key).style.height = height;
		}
		else
		{
			document.getElementById(key).style.height = GetMenuAnimInstance(key).minHeight;
		}
		if(currentFrame == "1")
		{
			document.getElementById(key).style.height = GetMenuAnimInstance(key).minHeight;
			FixFFHeight(document.getElementById(key));
		}
	}
	else if(key == "display")
	{
		if(currentFrame == "1")
		{
			//opacity
			document.all.displayBack.style.opacity = "0.0";
			document.all.displayBack.style.filter = 'alpha(opacity=0)';
			document.all.displayTable.style.opacity = "0.0";
			document.all.displayTable.style.filter = 'alpha(opacity=0)';
		}
		else if(currentFrame == "10")
		{
			//opacity
			if(displayOpacity != "100")
			{
				document.all.displayBack.style.opacity = "0." + displayOpacity;
			}
			else
			{
				document.all.displayBack.style.opacity = "1.0";
			}
			document.all.displayBack.style.filter = 'alpha(opacity=' + displayOpacity + ')';
			document.all.displayTable.style.opacity = "";
			document.all.displayTable.style.filter = "";
		}
		else
		{	
			var opacity = (currentFrame) * (displayOpacity / 10);
			//opacity
			document.all.displayBack.style.opacity = "0." + opacity;
			document.all.displayBack.style.filter = 'alpha(opacity=' + opacity + ')';
			document.all.displayTable.style.opacity = "0" + opacity;
			document.all.displayTable.style.filter = 'alpha(opacity=' + opacity + ')';
		}
	}
}
			
function GetRandomLetter()
{
	return String.fromCharCode(Number(Number(Math.random() * 25).toFixed(0)) + 97);
}

function GetRandomId()
{
	return GetRandomLetter() + GetRandomLetter() + 
		GetRandomLetter() + GetRandomLetter() + 
		GetRandomLetter() + GetRandomLetter() +
		GetRandomLetter() + GetRandomLetter() +
		GetRandomLetter() + GetRandomLetter();
}

var menuAnimations = new Array();
function MenuAnim(minHeight,maxHeight,anim)
{
	this.minHeight = minHeight;
	this.maxHeight = maxHeight;
	this.anim = anim;
}
function CreateMenuAnimInstances()
{
	for(var i = 0; i < document.all.length; i++)
	{
		var currentID = document.all[i].id;
		try
		{
			if(currentID.indexOf('menu') == 0)
			{
				currentID += GetRandomId();
				menuAnimations.push(
					new MenuAnim(
						currentID.substring(4,currentID.indexOf('height')),
						document.all[i].style.height.replace("px","").replace("pt",""),
						new Animation(60,10,currentID)
						));
						
				document.all[i].style.height = currentID.substring(4,currentID.indexOf('height'));
				document.all[i].style.visibility = 'visible';
				document.all[i].id = currentID;
			}
		}
		catch(e){}
	}
}
function GetMenuAnimInstance(id)
{
	for(var i = 0; i < menuAnimations.length; i++)
	{
		if(menuAnimations[i].anim.animationKey == id)
		{
			return menuAnimations[i];
		}
	}
	return null;
}

function RefreshMyself()
{
	location.assign(location.href);
}

function CloseDisplay()
{
	document.all.displayBack.style.display = 'none';
	document.all.displayTable.style.display = 'none';
	document.body.scroll = 'yes';
}

var displayAnim = new Animation(60,10,"display");
var displayOpacity = "90";
function DisplayHTML(html,backColor,opacity,align,valign)
{
	CloseDisplay();
	if(html == null)
	{
		html = "usage: DisplayHTML(html,backColor,opacity,align,valign)";
	}
	if(backColor == null)
	{
		backColor = "#ffffff";
	}
	if(opacity == null)
	{
		opacity = "90";
	}
	if(align == null)
	{
		align = "center";
	}
	if(valign == null)
	{
		valign = "center";
	}
	
	//fix opacity & show
	document.all.displayBack.style.opacity = "0.0";
	document.all.displayBack.style.filter = 'alpha(opacity=0)';
	document.all.displayTable.style.opacity = "0.0";
	document.all.displayTable.style.filter = 'alpha(opacity=0)';

	//show and position back & table
	var heightFix = document.body.offsetHeight;
	if(navigator.appName != "Microsoft Internet Explorer")heightFix = window.outerHeight;
	document.all.displayBack.style.display = '';
	document.all.displayBack.style.position = 'absolute';
	document.all.displayBack.style.left = '0';
	document.all.displayBack.style.top = document.body.scrollTop;
	document.all.displayBack.style.zIndex = '10001';
	document.all.displayBack.style.width = document.body.offsetWidth;
	document.all.displayBack.style.height = heightFix;
	document.all.displayTable.style.display = '';
	document.all.displayTable.style.position = 'absolute';
	document.all.displayTable.style.left = '0';
	document.all.displayTable.style.top = document.body.scrollTop;
	document.all.displayTable.style.zIndex = '10002';
	document.all.displayTable.style.width = document.body.offsetWidth;
	document.all.displayTable.style.height = heightFix;
	
	//valign
	document.all.displayContent.align = align;
	document.all.displayContent.vAlign = valign;
	
	//do not scroll while displaying html
	document.body.scroll = 'no';
	
	//put content
	document.all.displayContent.innerHTML = html;
	
	//background color
	document.all.displayBack.style.backgroundColor = backColor;
	
	//opacity
	displayOpacity = opacity;
	displayAnim.play();
}
function PrintHTML(HTML)
{
	var WinPrint = window.open('','print','left=0,top=0,width=350,height=100,toolbar=0,scrollbars=0,status=0');
	var dontPrint = "<style>@media print{.dontPrint{display:none;}}</style>";
	var message = "<div class='dontPrint' style='width:500;height:500;position:absolute;top:0;left:0;z-index:9999;background-color:#ffffff;font-family:arial;font-size:25pt;padding-left:80;padding-top:20;'>Please wait...</div>";
	WinPrint.document.write(dontPrint + message + HTML);
	WinPrint.document.close();
	WinPrint.focus();
	WinPrint.print();
	WinPrint.close();
}
function PrintParent(obj,nodeName)
{
	if(nodeName == null)
	{
		nodeName = 'div';
	}
	if(obj.parentElement.nodeName.toLowerCase() == nodeName.toLowerCase())
	{
		PrintHTML(obj.parentElement.innerHTML);
	}
	else
	{
		try{PrintParent(obj.parentElement,nodeName);}catch(e){alert("Printing area/s not found!");}
	}
}
function PrintAll(nodeName,separate)
{
	if(nodeName == null)
	{
		nodeName = 'div';
	}
	if(separate == null)
	{
		separate = false;
	}
	if(separate)
	{
		separate = "<hr>";
	}
	else
	{
		separate = "";
	}
	var allElements = new Array();
	for(var i = 0; i < document.all.mainPageDiv.childNodes.length; i++)
	{
		try
		{
			if(document.all.mainPageDiv.childNodes[i].nodeName.toLowerCase() == nodeName.toLowerCase())
			{
				allElements.push(document.all.mainPageDiv.childNodes[i]);
			}
		}
		catch(e){}
	}
	var toPrint = "";
	var toRemove = new Array();
	for(var i2 = 0; i2 < allElements.length; i2++)
	{
		var toAdd = allElements[i2].innerHTML;
		
		toAdd = toAdd.replace(/position: absolute;/gi,"");
		toAdd = toAdd.replace(/position:absolute;/gi,"");
		toAdd = toAdd.replace(/100%/gi,"");
		toAdd = toAdd.replace(/width:/gi,"");
		toAdd = toAdd.replace(/height:/gi,"");
		toAdd = toAdd.replace(/ width=/gi," ");
		toAdd = toAdd.replace(/ height=/gi," ");
		toAdd = toAdd.replace(/ width =/gi," ");
		toAdd = toAdd.replace(/ height =/gi," ");
		
		toPrint += toAdd + "<br><br>" + separate + "<br>";
	}
	PrintHTML(toPrint);
}
function onEnterClickButton(evt,btn)
{
	if(evt.which || evt.keyCode)
	{
		try
		{
			if ((evt.which == 13) || (evt.keyCode == 13)) 
			{
				document.getElementById(btn).click();
				evt.returnValue = false;
				try{evt.preventDefault();}catch(e){}
			}
		}
		catch(e)
		{
		}
	} 
}
function CanLink()
{
	return true;
}
