/*
//	© 2009 InWise Internet Company do Brasil S.A. - Todos os direitos reservados
//	www.inwise.com.br
*/

var aGallery = [

	{ 
		Title: "Modo completo e modo compacto",
		Description: ""
	},
	{
		Title: "Visor e canais",
		Description: ""
	},
	{
		Title: "Flip deslizante",
		Description: "Recebimento de chamada quando o softphone não está em foco."
	},
	{
		Title: "Gravação de chamadas",
		Description: ""
	},
	{
		Title: "Secretária eletrônica",
		Description: ""
	},
	{
		Title: "Conferência",
		Description: ""
	},
	{
		Title: "Configurações",
		Description: "Janela principal de configurações."
	},
	{
		Title: "Dispositivos USB",
		Description: "Janela de seleção de dispositivos USB."
	},
	{
		Title: "Segurança",
		Description: "Janela de configuração de segurança ilustrando as diversas opções de segurança disponíveis na versão 2.0."
	},
	{
		Title: "Log Visual",
		Description: "Log Visual ilustrando as transações de uma chamada SIP com áudio (RTP) Codec g729."
	},
	{
		Title: "Cópia de segurança",
		Description: "Janela do assistente de cópia de segurança."
	},
	{
		Title: "Siga-me",
		Description: "Janela de configurações do Siga-me."
	}
]

var GALLERYCOLOR_MOUSEOVERTB = "#BFD4E0";
var GALLERYCOLOR_SELECTEDTB = "#2171AD";
var GALLERYCOLOR_DEFAULTTB = "transparent";

var hLastSelectedItem;
var hLoadingImg;

function GalleryBuildItems() {

	for ( var i = 0, iLen = aGallery.length, sI; i < iLen; i++ ) {

		sI = ForceStrLen(( i + 1 ).toString(), 2, "0" );
		document.write( '<td width="60" height="60" ><a href="javascript:void(0);" onMouseOver="HandleGalleryItemMouseOver( this );" onMouseOut="HandleGalleryItemMouseOut( this );" onClick="SelectImage( this.childNodes[0], ' + i + ' );" class="ImageLink" ><img id="GalleryIMG_' + sI + '" name="GalleryIMG_' + sI + '" src="/sources/images/products/gallery/' + sI +'_tb.gif" width="60" height="60" border="0" alt="' + aGallery[i].Title + '" ></a></td><td width="8" height="60"></td>' );

	}

	return true;

}

function SelectImage( hImage, iIndex ) {

	if ( hLastSelectedItem != null ) {

		SetBGColor( hLastSelectedItem, GALLERYCOLOR_DEFAULTTB );
		hLastSelectedItem.childNodes[0].onmouseover = HandleGalleryItemMouseOver;
		hLastSelectedItem.childNodes[0].onmouseout = HandleGalleryItemMouseOut;

	} else
		GalleryDisplayTable.style.display = "block";

	GalleryMotion.style.display = "block";
	hLastSelectedItem = hImage.parentNode.parentNode;

	hLoadingImg = document.createElement( "IMG" ); 
	hLoadingImg.id = "GalleryImageDisplay";
	hLoadingImg.vspace = "16";
	hLoadingImg.onload = HandleDisplayImageOnload;
	
	if ( aGallery[ iIndex ].Image == null )
		hLoadingImg.src = "/sources/images/products/gallery/" + hImage.id.substr(( 'GalleryIMG_' ).length ) + ".gif";
	else
		hLoadingImg.src = aGallery[ iIndex ].Image;

	GalleryImageDisplayContainer.innerHTML = "";
	GalleryDisplayTableTitle.innerHTML = aGallery[ iIndex ].Title;
	GalleryDisplayTableDescription.innerHTML = aGallery[ iIndex ].Description;

	SetBGColor( hLastSelectedItem, GALLERYCOLOR_SELECTEDTB );

	hImage.parentNode.onmouseover = null;
	hImage.parentNode.onmouseout = null;

	return true;

}

function HandleGalleryItemMouseOver( hElement ) {

	// *** Ajustar para firefox
	if ( hElement == null )
		hElement = this;

	return SetBGColor( hElement.parentNode, GALLERYCOLOR_MOUSEOVERTB );

}

function HandleGalleryItemMouseOut( hElement ) {

	// *** Ajustar para firefox
	if ( hElement == null )
		hElement = this;

	return SetBGColor( hElement.parentNode, GALLERYCOLOR_DEFAULTTB );

}

function HandleDisplayImageOnload() {

	if ( hLoadingImg != null ) {
	
		GalleryImageDisplayContainer.appendChild( hLoadingImg );
		hLoadingImg = null;

		if ( hLastSelectedItem != null ) {

			GalleryMotion.style.display = "none";
			GalleryImageDisplayContainer.style.display = "block";

		}		
	}

	return true;

}

function HandleDisplayImageOnError() {

	if ( hLoadingImg != null ) {

		GalleryMotion.style.display = "none";
		GalleryImageDisplayContainer.style.display = "none";
		hLoadingImg = null;

	}

	return true;

}