/*------------------------------------------------------------------------
# JA Utahia II for Joomla 1.5 - Version 1.4 - Licence Owner JA592
# ------------------------------------------------------------------------
# Copyright (C) 2004-2008 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software
# Author: J.O.O.M Solutions Co., Ltd
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
# This file may not be redistributed in whole or significant part.
-------------------------------------------------------------------------*/
var arr_w;
var arr_img;
var arr_img_small;
var arr_img_big;
var arr_img_temp;
anim_change=1.2;
anim_int = 20;
curr_img=0;
var title;
notDone=0;

baseOpacity = 30;
var activeimg=null;
var isIE;
var ia=0;
var icon_small=32;
var icon_big=71;
var small_size=0.5;
var icon_padding=0;
var timeoutID = 0;
function iconmenu_over(imgid){
	curr_img=imgid;
	//setOpacity (arr_img[imgid], 100);
	timeoutID = setTimeout("animation()",20);
	//animation ();
}

function iconmenu_out(imgid){
	curr_img=0;
	//setOpacity (arr_img[imgid], 50);
	timeoutID = setTimeout("animation()",30)
	//animation ();
}

function iconmenu_init(){
	var menuicon = document.getElementById ('ja-iconmenu');
	var imgs = menuicon.getElementsByTagName ('IMG');
	arr_w=new Array(imgs.length);
	arr_img=new Array(imgs.length);
	arr_img_big=new Array(imgs.length);
	arr_img_small=new Array(imgs.length);
	arr_img_temp=new Array(imgs.length);
	isIE = imgs[0].filters ? true:false;
	if (isIE)
		isIE = (document.all && !window.opera && window.XMLHttpRequest) ? false : true;
	//icon_small = Math.round(icon_big * small_size);
	//if (isIE) anim_change = Math.round(anim_change/1.5);

	for(var j=1;j<arr_w.length;j++){
		arr_w[j]=icon_small;
		arr_img[j]=imgs[j];
		if (imgs[j].className == "active")
		{
			activeimg = imgs[j];
			ia = j;
		}
		var imgsrc = imgs[j].src;
		if (isIE)
		{
			imgsrc = imgs[j].style.filter;
			if (imgsrc) imgsrc = imgsrc.match (new RegExp("src='([^']*)'"))[1];
		}
		arr_img_small[j] = imgsrc;
		arr_img_big[j] = imgsrc.substr (0, imgsrc.length - 4) + '-big' + imgsrc.substr(imgsrc.length - 4, 4);
		arr_img_temp[j] = new Image();
		arr_img_temp[j].src = arr_img_big[j];
	}
	title=document.getElementById('ja-imageTitle');

	timeoutID = setTimeout("animation()",anim_int);

}
function animation(){
	if (timeoutID) clearTimeout(timeoutID);

	var l=0;
	var la = 0;
	for(var i=1;i<arr_w.length;i++){
		if(curr_img!=i){
			if(arr_w[i]>icon_small){
				arr_w[i]-=anim_change;
				if(arr_w[i]<=icon_small){
					arr_w[i]=icon_small;
					if (isIE)
					{
						arr_img[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+arr_img_small[i]+"', sizingMethod=scale)";
					}else
					arr_img[i].src = arr_img_small[i];
				}
				arr_img[i].style.height=arr_w[i] + "px";
				arr_img[i].style.width=arr_w[i] + "px";
				notDone=1;
			}
			//setOpacity (arr_img[i], Math.round(arr_w[i]*100/icon_big));
			if (i<curr_img)
				l+=arr_w[i]
			if (i<ia)
				la+=arr_w[i]
		}
	}
	if(curr_img!=0&&arr_w[curr_img]<icon_big){
		imageElem=arr_img[curr_img];
		if (isIE)
		{
			imageElem.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+arr_img_big[curr_img]+"', sizingMethod=scale)";
		}else
		imageElem.src = arr_img_big[curr_img];

		arr_w[curr_img]+=anim_change;
		notDone=1;
		if(arr_w[curr_img]>icon_big){
			arr_w[curr_img]=icon_big
		}
		l+=Math.floor(arr_w[curr_img]/2);

		imageElem.style.height=arr_w[curr_img] + "px";
		imageElem.style.width=arr_w[curr_img] + "px";
		//setOpacity (imageElem, Math.round(arr_w[curr_img]*100/icon_big));
		var left = 0;
		title.innerHTML = imageElem.alt;
		if (title.style.display == "none")
		{
			left = l - icon_big/2 + icon_padding * 2 * (curr_img-1);
			title.style.left = left + "px";
			title.style.display = "block";
		}
		left = Math.floor(l-title.offsetWidth/2) + icon_padding * 2 * (curr_img-1);
		title.style.left = left + "px";
		//title.style.top = (icon_big - imageElem.height) + "px";
	}

	if (!curr_img)
	{
		/*
		if (activeimg)
		{
			//title.style.display = "none";
			la+=Math.floor(arr_w[ia]/2);
			title.innerHTML = activeimg.alt;
			var left = Math.floor(la-title.offsetWidth/2);
			title.style.left = left + "px";
			title.style.top = (menu_height - title.offsetHeight - icon_small) + "px";
			if (ia == (arr_img.length-1))
			{
				if (activeimg.offsetWidth > icon_small)
				{
					title.right = document.getElementById('ja-menuicon').offsetWidth;
				}
			}
			title.style.display = "block";
		} else */
		title.style.display = "none";
	}

	if(notDone){
		timeoutID = setTimeout("animation()",anim_int);
		notDone=0
	}
}

jaAddEvent (window, 'load', iconmenu_init);


function setOpacity (img, opac){
	if (!img || img.className == "active") return;
	if (!isIE)
		img.style.MozOpacity=opac/100
}