﻿function toggleMenuVisibility(sender,hidingid)
{
	var el = document.getElementById(hidingid);
	if(existsDefined(el))
	{
		var isHidden = el.style.display == "none" ? true : false;
		hideAllSubMenus();
		if(isHidden)
		{
			el.style.display = "";
		}
		else
		{
			el.style.display = "none";
		}		
	}
}
function existsDefined(i)
{
	if(i != null && i != undefined)
		return true;
	else
		return false;
}
var submenuID = "SubMenu";
function hideAllSubMenus()
{
	var x = document.getElementsByTagName("div");
	for(var i = 0; i < x.length; i++)
	{
		if(x[i].id.indexOf(submenuID) != -1)
			if(x[i].id.indexOf(submenuID) == x[i].id.length - submenuID.length)
			{
				x[i].style.display = "none";
			}
	}
}
function getFlashMovieObject(movieName)
{
	if (window.document[movieName]) 
	{
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName]; 
	}
	else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	{
		return document.getElementById(movieName);
	}
}
function SendDataToFlashMovie(movieID,varname, strData)
{
	var flashMovie=getFlashMovieObject(movieID);
	flashMovie.SetVariable("/:" + varname, strData);
}
function RewindFlashMovie(movieID)
{
	var flashMovie=getFlashMovieObject(movieID);
	flashMovie.Rewind();
}
function PlayFlashMovie(movieID)
{
	var flashMovie=getFlashMovieObject(movieID);
	flashMovie.Play();
	
}
function HideElement(elid)
{
	var el = document.getElementById(elid);
	if(existsDefined(el))
	{
		el.style.display = "none";
	}
}
function ShowElement(elid)
{
	var el = document.getElementById(elid);
	if(existsDefined(el))
	{
		el.style.display = "";
	}
}
var selectedSubMenuItem = null;
function ChangeFlash(movieID, varname, path, sender,pdir,p)
{
	if(existsDefined(selectedSubMenuItem))
	{
		selectedSubMenuItem.style.fontWeight = "normal";
		selectedSubMenuItem.style.color = "";
	}	
	selectedSubMenuItem = sender;
	sender.style.color = "black";
	sender.style.fontWeight = "bold";
	HideElement('divNonFlashContent');
	ShowElement('divFlashContent');
	if(existsDefined(p))
		setTimeout("SendDataToFlashMovie('" + movieID + "','p','" + p + "');",500); 
	else
		setTimeout("SendDataToFlashMovie('" + movieID + "','p','false');",500); 
		
	setTimeout("SendDataToFlashMovie('" + movieID + "','pdir','" + pdir + "');",510); 
	setTimeout("SendDataToFlashMovie('" + movieID + "','" + varname + "','" + path + "');",500); 
	setTimeout("RewindFlashMovie('" + movieID + "');", 520); 
	setTimeout("PlayFlashMovie('" + movieID + "');", 550);
	return false;
}
function ChangeImage(path,imageid,lnkid,pdir,sender)
{
	HideElement('divFlashContent');
	ShowElement('divNonFlashContent');
	if(existsDefined(selectedSubMenuItem))
	{
		selectedSubMenuItem.style.fontWeight = "normal";
		selectedSubMenuItem.style.color = "";
	}	
	selectedSubMenuItem = sender;
	sender.style.color = "black";
	sender.style.fontWeight = "bold";
	
	var imagePath = "images/flash/" + pdir + "/" + path + "/1.jpg";

	makePreWindow("image.htm?imagePath=" + imagePath,400,400,0);
	
	
}
function imageInit()
{
	var img = document.getElementById("imgImage");
	if(existsDefined(img))
	{
		var imgPath = get_query_string("imagePath");
		if(imgPath != "")
			img.src = imgPath;
	}
	resizeWindow();
}
function get_query_string(qstr) 
{
	var i, pos, argname, argvalue, queryString, pairs;
	queryString = location.href.substring(location.href.indexOf("?")+1);
	pairs = queryString.split("&");
	for (i = 0; i < pairs.length; i++) 
	{
		pos = pairs[i].indexOf('=');
		if (pos == -1) 
		{
			continue;
		}
		argname = pairs[i].substring(0,pos);
		argvalue = pairs[i].substring(pos+1);
		if (argname == qstr) 
		{
			return unescape(argvalue.replace(/\+/g, " "));
		}
	}
	return "";
}
function makePreWindow( url, window_width, window_height, scrollbars )
{
    var screenPosX,screenPosY;
	var newWindow = null;
	if(!scrollbars)
	{
		scrollbars = 0;
	}
	if(window_width > screen.availWidth || window_height > screen.availHeight)
	{
		scrollbars = 1;
		window_height = window_height + 14;
		window_width = window_width + 14;
	}
	screenPosX = 0;
	screenPosY = 0;
	newWindow = window.open(url, 'Preview','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scrollbars+',resizable=0,copyhistory=0,width='+window_width+',height='+window_height+',screenX='+screenPosX+',screenY='+screenPosY);
	newWindow.focus();
}
function resizeWindow()
{	
	var width = 1083;
	var height = 834;
	window.resizeTo(width,height);
}