  /*******************************************************************/  /*  Script Written By Tamir Mordo http://www.tetitu.co.il          */  /*  this code Written Exclusivly for http://www.margolin-bros.com/ */  /*  you may not reUse it for another site beside                   */  /*  http://www.margolin-bros.com/ Without Written Permisions       */
  /*******************************************************************/
var maxwidth = 0
var maxheight=0
function setmaxwidth(mywidth)
{
	if (maxwidth < mywidth)
	{
		maxwidth = mywidth
		document.getElementById("outer-appear").style.width = maxwidth.toString() + "px"
		document.getElementById("appear-div").style.width = maxwidth.toString() + "px"
	}
}
function setmaxheight(myheight)
{
}
function myimage()
{
	var m_i = -1
	var m_loaded = false
	var m_href = ""
	var m_rel = ""
	var m_title = ""
	var img= new Image()
	this.seti = seti
	this.geti = geti
	this.getwidth = getwidth
	this.getheight = getheight
	this.setimg=setimg
	this.loaded = getloaded
	this.getimage = getimage
/*	this.href = href
	this.rel = rel
	this.title = title
	this.gethref = gethref
	this.getrel = getrel
	this.gettitle = gettitle
*/	
	
	img.onload=function ()
	{
		m_loaded = true
		
		setmaxwidth(img.width)
		if (m_i==0)
		{
			// first image loaded i need to display it
			imagerotate.showNext()
		}
	}
	function seti(myval){m_i=myval}
	function geti(myval){return m_i}
	function setimg(myval){img.src=myval}
	function getloaded(){return m_loaded}
	function getimage(){return img}
	function getwidth(){return img.width}
	function getheight(){return img.height}

/*	function href(myhref){m_href = myhref}
	function rel(myrel){m_rel = myrel}
	function title(mytitle){m_title = mytitle}
	
	function gethref(){return m_href}
	function getrel(){return m_rel}
	function gettitle(){return m_title}
	
*/	
}

function mymorph()
{
	var imgs = new Array()
	var arrayLength = -1;
	var m_ondisplay = -1;
	var outer=document.getElementById("outer-appear")
	var apear=document.getElementById("appear-div")
	this.addImage = addImage
	this.showNext = showNext
	this.showNext2 = showNext2
	this.href = href
	this.rel = rel
	this.title = title
	
	
	function href(myhref){imgs[arrayLength].href = myhref
	
	}
	function rel(myrel){imgs[arrayLength].rel = myrel}
	function title(mytitle){imgs[arrayLength].title = mytitle}
	
	function addImage(mysrc)
	{
		arrayLength++;
		imgs[arrayLength] = new myimage();
		imgs[arrayLength].seti(arrayLength)
		imgs[arrayLength].setimg(mysrc);
		
	}
	function showNext()
	{
		var olddisplay =m_ondisplay
		m_ondisplay++
		if (m_ondisplay > arrayLength) m_ondisplay = 0
		//outer.style.width=imgs[m_ondisplay].getwidth().toString() + "px"
		//outer.style.width="700px"
		outer.style.height=imgs[m_ondisplay].getheight().toString() + "px"
		if (olddisplay!= -1)
		{
			outer.style.background = 'url(' + imgs[olddisplay].getimage().src + ')';
			outer.style.backgroundRepeat="no-repeat"
			outer.style.backgroundPosition="center top"
			new Effect.Opacity("outer-appear", {duration:3.0, from:1.0, to:0.0})
		}
		
		setTimeout("imagerotate.showNext2()",1000)
	}
	function showNext2()
	{
		var undefin
		//apear.style.width="700px"//imgs[m_ondisplay].getwidth().toString() + "px"
		apear.style.height=imgs[m_ondisplay].getheight().toString() + "px"
		Element.hide(apear);
		if  (imgs[m_ondisplay].href != undefin)
		{
			//if(this.target != "") {url = this.target} 
			apear.onclick = function()
			{
				var t = imgs[m_ondisplay].rel
				var params = parseQuery(t.substr(5,999));
				var url = imgs[m_ondisplay].href;
				var title = imgs[m_ondisplay].title;
				if(showIbox(url,title,params)) {
				showBG();
				window.onscroll = maintPos;
				window.onresize = maintPos;
			}
			return false;			
			}
			if (Prototype.Browser.IE)
				apear.style.cursor='hand'
			else
				apear.style.cursor='pointer'
			
		}
		else
		{
		apear.style.cursor=''
			apear.onclick = function()
			{
				return false;			
			}
			
		}
		new Effect.Opacity("appear-div", {duration:0.0, from:1.0, to:0.0})
		apear.style.background = 'url('+ imgs[m_ondisplay].getimage().src +')';
		apear.style.backgroundRepeat="no-repeat"
		apear.style.backgroundPosition="center top"
		new Effect.Appear('appear-div');
		setTimeout("imagerotate.showNext()",4000)
	}
	
	function attachlink()
	{
	
		e.onclick = function() { // rather assign an onclick event
			var t = this.getAttribute(ibAttr);
			var params = parseQuery(t.substr(5,999));
			var url = this.href;
			if(this.target != "") {url = this.target} 
	
			var title = this.title;

			if(showIbox(url,title,params)) {
				showBG();
				window.onscroll = maintPos;
				window.onresize = maintPos;
			}
			return false;
		}
	}
}
