﻿// JScript File

Sne={
	timeInterval: 25,
	animationTime: 250,
	timer: null,
	slideWidthIncrement:  0,
	slideMarginIncrement: 0,
	slideElement: null,
	slideFrame: null,
	finalWidth: 0,
	
	slideOut:function()
	{
		if (Sne.slideElement)
		{
			if (Sne.slideElement.clientWidth >= Sne.finalWidth)
			{
				clearInterval(Sne.timer);
			}
			else
			{			
				if ((Sne.slideElement.clientWidth + Sne.slideWidthIncrement) > Sne.finalWidth)
				{
					Sne.slideElement.style.width = Sne.finalWidth + "px";
				}
				else
				{
					Sne.slideElement.style.width = (Sne.slideElement.clientWidth + Sne.slideWidthIncrement) + "px";
				}
				
				if ((parseInt(Sne.slideFrame.style.marginLeft) + Sne.slideMarginIncrement) > 0)
				{
					Sne.slideFrame.style.marginLeft = 0;
				}
				else
				{
					Sne.slideFrame.style.marginLeft = (parseInt(Sne.slideFrame.style.marginLeft) + Sne.slideMarginIncrement) + "px";
				}
			}
		}		
	},
	
    hoverFrame:function(element, width, height)
    {
		clearInterval(Sne.timer);
		Sne.slideElement = element;
		Sne.finalWidth = width;
		if (element)
		{
			Sne.slideFrame = element.getElementsByTagName('iframe')[0];
			element.style.zIndex = 100001;
			element.style.height = height;
			element.style.width = element.clientWidth + "px";
			Sne.slideWidthIncrement=(Sne.finalWidth - element.clientWidth)/(Sne.animationTime/Sne.timeInterval);
			Sne.slideMarginIncrement = Math.abs(parseInt(Sne.slideFrame.style.marginLeft))/(Sne.animationTime/Sne.timeInterval);
			Sne.timer = setInterval (Sne.slideOut, Sne.timeInterval);
		}
    },
    
    unHoverFrame:function(element, width, height)
    {
		var frame;
   		clearInterval(Sne.timer); 
		 
		if (element)
		{
			element.style.zIndex = 100001;
			element.style.width = width + "px";
			element.style.height = height + "px";			

			frame = element.getElementsByTagName("iframe")[0]
			if (frame)
			{
				frame.style.marginLeft = -188 + "px";
			}
		}
    },
    
	hideElementById:function(elementName)
	{
		var element = document.getElementById(elementName);
		
		if (element)
		{
			element.style.visibility = "hidden";
		}
	} ,
	
	showElementById:function(elementName)
	{
		var element = document.getElementById(elementName);
		
		if (element)
		{
			element.style.visibility = "visible";
		}
	},
	
	select360ViewHonda:function(selectedTabName, selectedPanelName, unselectedTabName, unselectedPanelName, iframeID)
	{
		/* Get the elements to modify */
		var selectedTab = document.getElementById(selectedTabName);
		var selectedPanel = document.getElementById(selectedPanelName);
		var unselectedTab = document.getElementById(unselectedTabName);
		var unselectedPanel = document.getElementById(unselectedPanelName);
		
		/* Set the tab headers to indicate the selected view */
		if (selectedTab) 
			selectedTab.style.fontWeight = "bold";
		if (unselectedTab)
			unselectedTab.style.fontWeight = "normal";
		
		/* Set the selected panel to the visible one */
		if (selectedPanel) 
		{
			selectedPanel.style.display = "block";

            // get iframe and set its source to its current source.
            // this will prevent the issue of the flash animation 
            // disappearing in firefox.
           	
           	if (! window.ActiveXObject) 
           	{
           	    var f = document.getElementById(iframeID);
                f.src = f.src;
            }
		}				

		if (unselectedPanel)
			unselectedPanel.style.display = "none";

	}
} 
