/*
 *
 */
function Toggle(parent, evt, imagePath)
{
	// get the event - cross browser
	var e = (window.event) ? window.event : evt;
	// prevent onclick event firing on parent menu holders
	e.cancelBubble = true;

	// get the parent element
	var objParent = GetElement(parent);
	
	//if the div exists
	if (objParent != null)
	{
		var isOpened;

		// toggle the div (menu)
		isOpened = ToggleMenu(objParent.id, false, imagePath);
		
		// if the div diesnt exist - return here
		if (isOpened == null)
			return;

		var newImagePath;

		// set indicator for div - plus or minus
		if (isOpened)
			newImagePath = imagePath + "minus.gif";
		else
			newImagePath = imagePath + "plus.gif";
			
		GetElement("img" + parent).src = newImagePath;
	}
}

/******************************************* Deal with image transitions **/

var oldImage = '';

function MouseOver(img)
{
	oldImage = img.src;
	img.src = '/images/qs.gif';
}

function MouseOut(img)
{
	img.src = oldImage;
	oldImage = '';
}

var myimages = new Array()
function PreloadImages()
{
	for (i=0; i<PreloadImages.arguments.length; i++)
	{
		myimages[i] = new Image()
		myimages[i].src = PreloadImages.arguments[i]
	}
}

/******************************************* Deal with image transitions **/

var oldClass = '';

function ClassMouseOver(e)
{
	oldClass = e.className;
	e.className = 'item-hover';
}

function ClassMouseOut(e)
{
	e.className = oldClass;
	oldClass = '';
}

/************************************************** Handle help requests **/

function OpenHelp(id, evt)
{
	// get the event - cross browser
	var e = (window.event) ? window.event : evt;
	e.cancelBubble = true;

	var win, options, height = 530, width = 730;

	var options = 'toolbar=no,menubar=no,status=no,resizable=yes,scrollbars=yes'
	options = options + ',height=' + height;
	options = options + ',width=' + width;
	options = options + ',top=' + ((screen.height - height) / 2);
	options = options + ',left=' + ((screen.width - width) / 2);

	win = window.open('help.aspx?id=' + id, 'HelpWindow', options);
	win.focus();
}

/******************************************* Handle menu item selections **/
function SetFrame(url, target, evt)
{
	// get the event - cross browser
	var e = (window.event) ? window.event : evt;
	e.cancelBubble = true;

	if (target == "_top")
	{
		window.top.location.href = url;
		return;
	}

	if (target == "MainFrame")
	{
		if (parent.pageLoading)
			alert("Form loading. Please wait ...");
		else if (parent.workShop)
		{
			if (confirm("The work shop is active. Time spent on repair may be lost if you continue. \nAlternatively save your repair time and click ok to continue."))
			{
				LoadFrame(url);
				parent.workShop = false;
			}
		}
		else
		{
			LoadFrame(url);
		}
		return;
	}
	
	var frames = window.top.frames;
	for (var i = 0; i < frames.length; i++)
	{
		if (frames[i].name == target)
		{
			frames[i].location.href = url;
			return;
		}
	}
}
function LoadFrame(url)
{
	if (	
			url.substring(0, 27) == "/ServiceCentre/rev_list.asp" || 
			url.substring(0, 63) == "/ServiceCentre/transaction/inventory/Transaction_Edit_List.aspx" || 
			url.substring(0, 43) == "/Warrantor/transactions/insert_txn_201.aspx" ||
			url.substring(0, 43) == "/Warrantor/transactions/insert_txn_202.aspx"
		)
		parent.pageLoading = true;
	//if (url.substring(0, 41) == "/ServiceCentre/transaction/RMA_Search.asp")
	//	parent.workShop = true;
	window.top.frames['MainFrame'].location.href = url;
}

