//Gradual Elements Fader- By Dynamic Drive at http://www.dynamicdrive.com
//Last updated: Nov 8th, 07'

var gradualFader={}

gradualFader.baseopacity=0.4 //set base opacity when mouse isn't over element (decimal below 1)
gradualFader.outopacity=0;
gradualFader.increment=0.08 //amount of opacity to increase after each iteration (suggestion: 0.1 or 0.2)
gradualFader.timeStep=60; //krok czasowy

document.write('<style type="text/css">\n') //write out CSS to enable opacity on "gradualfader" class
document.write('#main_page_image{filter:progid:DXImageTransform.Microsoft.alpha(opacity='+gradualFader.baseopacity*100+'); -moz-opacity:'+gradualFader.baseopacity+'; opacity:'+gradualFader.baseopacity+';}\n')
document.write('</style>')

gradualFader.setopacity=function(obj, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
	var targetobject=obj
	if (targetobject && targetobject.filters && targetobject.filters[0]){ //IE syntax
		if (typeof targetobject.filters[0].opacity=="number") //IE6
			targetobject.filters[0].opacity=value*100
		else //IE 5.5
			targetobject.style.filter="alpha(opacity="+value*100+")"
		}
	else if (targetobject && typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
		targetobject.style.MozOpacity=value
	else if (targetobject && typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
		targetobject.style.opacity=value
	targetobject.currentopacity=value
}

gradualFader.fadeupdown=function(obj, direction){
	var targetobject=obj;
	var fadeamount=(direction=="fadeup")? this.increment : -this.increment;

	if (targetobject && (direction=="fadeup" && targetobject.currentopacity<1 || direction=="fadedown" && targetobject.currentopacity>this.outopacity)){
		this.setopacity(obj, targetobject.currentopacity+fadeamount)
		window["opacityfader"+obj._fadeorder]=setTimeout(function(){gradualFader.fadeupdown(obj, direction)}, this.timeStep)
	}
	else if (direction=="fadedown" && targetobject.currentopacity<=this.outopacity)
	{
		obj.src = 'theme/default/img/spacer.gif';
	}
}

gradualFader.clearTimer=function(obj){
if (typeof window["opacityfader"+obj._fadeorder]!="undefined")
	clearTimeout(window["opacityfader"+obj._fadeorder])
}

function veganPreloadImages ()
{
  var d=document;
	if(!d.MM_p) d.MM_p=new Array();

	var i,j=d.MM_p.length,a=veganPreloadImages.arguments;
	for(i=0; i<a.length; i++)
	{
		if (a[i].length > 0 && a[i].indexOf("#")!=0)
		{
			d.MM_p[j]=new Image;
			d.MM_p[j++].src=a[i];
		}
	}
}

function veganShowImage (img_file)
{
	obj = document.getElementById ('main_page_image');

	if (obj)
	{
		if (obj.src != img_file)
		{
			obj.src = img_file;
			gradualFader.setopacity(obj, gradualFader.baseopacity);
		}
		if (!obj.currentopacity)
		{
			obj._fadeorder = 0;
			gradualFader.setopacity(obj, gradualFader.baseopacity);
		}
		
		gradualFader.clearTimer(obj);
		gradualFader.fadeupdown(obj, 'fadeup');
	}
	playSound ();
}

function veganHideImage ()
{
	obj = document.getElementById ('main_page_image');

	if (obj)
	{
		gradualFader.clearTimer(obj);
		gradualFader.fadeupdown(obj, 'fadedown');
	}
}



