/***********************************************
* Fade-in image slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//alert(document.firstChild.filters);
var faderObjList = new Array();

function Fader(name, width, height, pause)
{
	this.name = name
	this.width = width + "px"; //SET IMAGE WIDTH
	this.height = height + "px"; //SET IMAGE WIDTH
	this.pause = pause; //SET PAUSE BETWEEN SLIDE
	this.fadeimages=new Array()
	this.dom=document.getElementById

	faderObjList[name] = this;

	this.curpos=10
	this.canvas0 = this.name+'canvas0'
	this.canvas1 = this.name+'canvas1'
	this.curcanvas=this.canvas0
	this.curimageindex=0
	this.nextimageindex=1

	function addImage(imgUrl, linkUrl, target, alt)
	{
		nextIndex = this.fadeimages.length
		this.fadeimages[nextIndex]=[imgUrl, linkUrl, target, alt]
	}
	this.addImage = addImage;

	function insert()
	{
		if (this.dom)
		{
			document.write('<div style="position:relative;width:'+this.width+';height:'+this.height+';overflow:hidden">');
			if (undefined !== document.firstChild.filters)
			{
				document.write('<div  id="'+this.canvas0+'" style="position:absolute;width:'+this.width+';height:'+this.height+';top:0;left:0;filter:alpha(opacity=10)"></div><div id="'+this.canvas1+'" style="position:absolute;width:'+this.width+';height:'+this.height+';top:0;left:0;filter:alpha(opacity=10);visibility: hidden"></div></div>')
			}
			else
			{
				document.write('<div  id="'+this.canvas0+'" style="position:absolute;width:'+this.width+';height:'+this.height+';top:0;left:0;-moz-opacity:10"></div><div id="'+this.canvas1+'" style="position:absolute;width:'+this.width+';height:'+this.height+';top:0;left:0;-moz-opacity:10;visibility: hidden"></div></div>')
			}
		}
		else
			document.write('<img name="'+this.name+'" src="'+this.fadeimages[0][0]+'" alt="'+this.fadeimages[0][3]+'" title="'+this.fadeimages[0][3]+'" />')
	}
	this.insert = insert;

	function fadepic()
	{
		if (this.curpos<100)
		{
			this.curpos+=10
			if (undefined !== tempobj.filters)
				tempobj.filters.alpha.opacity=this.curpos
			else if (undefined !== tempobj.style.MozOpacity)
				tempobj.style.MozOpacity=this.curpos/101
		}
		else
		{
			clearInterval(this.dropslide)
			nextcanvas=(this.curcanvas==this.canvas0)? this.canvas0 : this.canvas1
			document.getElementById(nextcanvas).innerHTML=this.insertimage(this.nextimageindex)
			this.nextimageindex=(this.nextimageindex<this.fadeimages.length-1)? this.nextimageindex+1 : 0
			document.getElementById(nextcanvas).style.visibility="hidden"

			//setTimeout("rotateimage()",pause)
			//setTimeout(function (t) { t.rotateimage(); }, this.pause, this)

			setTimeout("staticRotateImage('"+this.name+"')",this.pause)

		}
	}
	this.fadepic = fadepic;

	function insertimage(i)
	{
		var tempcontainer=this.fadeimages[i][1]!=""? '<a href="'+this.fadeimages[i][1]+'" target="'+this.fadeimages[i][2]+'">' : ""
		tempcontainer+='<img src="'+this.fadeimages[i][0]+'" border="0" alt="'+this.fadeimages[i][3]+'" title="'+this.fadeimages[i][3]+'" />'
		tempcontainer=this.fadeimages[i][1]!=""? tempcontainer+'</a>' : tempcontainer
		return tempcontainer
	}
	this.insertimage = insertimage;

	function rotateimage()
	{
		if (this.dom)
		{
			this.resetit(this.curcanvas)
			var crossobj=tempobj=document.getElementById(this.curcanvas)
			crossobj.style.zIndex++
			tempobj.style.visibility="visible"

			var temp='setInterval("staticFadePic(\''+this.name+'\')",50)'
			this.dropslide=eval(temp)

			this.curcanvas=(this.curcanvas==this.canvas0)? this.canvas1 : this.canvas0
		}
		else
			document.images.defaultslide.src=this.fadeimages[this.curimageindex][0]

		this.curimageindex=(this.curimageindex<this.fadeimages.length-1)? this.curimageindex+1 : 0
	}
	this.rotateimage = rotateimage;

	function resetit(what)
	{
		this.curpos=10
		var crossobj=document.getElementById(what)
		if (undefined !== crossobj.filters)
			crossobj.filters.alpha.opacity=this.curpos
		else if (undefined !== crossobj.style.MozOpacity)
			crossobj.style.MozOpacity=this.curpos/101
	}
	this.resetit = resetit;

	function startFader()
	{
		document.getElementById(this.curcanvas).innerHTML=this.insertimage(this.curimageindex)
		this.rotateimage()
	}
	this.startFader = startFader;

	function start()
	{
		var preloadedimages=new Array()
		for (p=0;p<this.fadeimages.length;p++)
		{
			preloadedimages[p]=new Image()
			preloadedimages[p].src=this.fadeimages[p][0]
		}

		if (this.dom)
		{
			//window.onload=this.startFader
			//this.startFader();

			var prev=window.onload;
			var obj=this;
			window.onload=function(){ if(prev) prev(); obj.startFader(); }
			//alert(window.onload);
		}
		else
		{
			setInterval("rotateimage()",pause)
		}
	}
	this.start = start;
}

function staticFadePic(name)
{
	faderObjList[name].fadepic();
}

function staticRotateImage(name)
{
	faderObjList[name].rotateimage();
}


var pFinderWipe = 0;
var pFinderMouseOverArea = new Array();

function pfinderMouseOver(area, mouseIn)
{
	pFinderMouseOverArea[area] = mouseIn;

	var finderObj = document.getElementById('pfinderBox');
	var iframeObj = document.getElementById('finderframe');

	if (pFinderMouseOverArea[0] || pFinderMouseOverArea[1])
	{
		if (finderObj.style.display != 'block')
		{
			iframeObj.height = 0;
			finderObj.style.display = 'block';
		}
		pFinderWipe = 3;
		wipeFinder();
	}
	else
	{
		//finderObj.style.display = 'none';
		pFinderWipe = -3;
		wipeFinder();
	}
	return true;
}

function toggleFinder()
{
	var finderObj = document.getElementById('pfinderBox');
	var iframeObj = document.getElementById('finderframe');
	if (finderObj.style.display != 'block' || iframeObj.height == 0)
	{
		finderObj.style.display = 'block';
		iframeObj.height = 0;
		pFinderWipe = 3;
		wipeFinder();
	}
	else
	{
		//finderObj.style.display = 'none';
		pFinderWipe = -3;
		wipeFinder();
	}

	return true;
}

function wipeFinder()
{
	var finderObj = document.getElementById('pfinderBox');
	var iframeObj = document.getElementById('finderframe');

	if (pFinderWipe > 0)
	{
		if (iframeObj.height < 140 - pFinderWipe)
		{
			iframeObj.height = (iframeObj.height*1 + pFinderWipe);
			finderObj.style.height = iframeObj.height + 'px';

			setTimeout("wipeFinder()", 10);
			pFinderWipe += 3;
		}
		else
		{
			iframeObj.height = 140;
			finderObj.style.height = iframeObj.height + 'px';
		}
	}
	else if (pFinderWipe < 0)
	{
		if (iframeObj.height > -pFinderWipe)
		{
			iframeObj.height = (iframeObj.height*1 + pFinderWipe);
			finderObj.style.height = iframeObj.height + 'px';

			setTimeout("wipeFinder()", 10);
			pFinderWipe -= 3;
		}
		else
		{
			iframeObj.height = 0;
			finderObj.style.height = iframeObj.height + 'px';
		}
	}
}

function screenshotBrowser(url)
{
  popupWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=740,height=715');
  popupWin.focus();
  self.name = "mainWin";
}
