
function changeOver( e, id, idmm, hid )
{
	$element(idmm).style.left = getLeft(id) + "px";
	$element(idmm).style.width = getWidth(id) + "px";
	$element(idmm).style.top = ( getTop(id) + getHeight(id) + 3 ) + "px";
	var toHeight = getHeight(hid) + 20;
	var menuShow = new Animation("anm1");
	var time = 20;
	menuShow.RegisterAnimation( id, "opacity", "", 0.5, "", time, 0.8 );
	menuShow.RegisterAnimation( id, "filter", "alpha(opacity=", 50, ")", time, 80 );
	menuShow.RegisterAnimation( idmm, "height", "", 0, "px", time, toHeight );
	menuShow.CopyStateInAnimation();
	menuShow.RemoveAllOfTypeOnElement(Animation, id);
	menuShow.RemoveAllOfTypeOnElement(Animation, idmm);
	menuShow.Start();
}

function changeOut( e, id, idmm, _this )
{
	if (!e) e = window.event;
	
	var current, related;
	if (isIE())
	{
		current = _this;
		related = window.event.toElement;
	}
	else
	{
		current = e.currentTarget;
		related = e.relatedTarget;
	}
	
	if ( current != related && !isParent(current, related)
		&& related != $element(idmm) && !isParent($element(idmm), related) )
	{
		var menuHide = new Animation("anm2");
		var time = 20;
		menuHide.RegisterAnimation( id, "opacity", "", 0.8, "", time, 0.5 );
		menuHide.RegisterAnimation( id, "filter", "alpha(opacity=", 80, ")", time, 50 );
		menuHide.RegisterAnimation( idmm, "height", "", 120, "px", time, 0 );
		menuHide.CopyStateInAnimation();
		menuHide.RemoveAllOfTypeOnElement(Animation, id);
		menuHide.RemoveAllOfTypeOnElement(Animation, idmm);
		menuHide.Start();
	}
}

function productImagesOver( e, id )
{
	var menuShow = new Animation("anm1");
	var time = 10;
	
	menuShow.RegisterAnimation( id, "top", "", 0, "px", time, 5 );
	menuShow.RegisterAnimation( id, "left", "", 0, "px", time, 5 );
	
	menuShow.RegisterAnimation( "shadow_" + id, "opacity", "", 0.99, "", time, 0.2 );
	menuShow.RegisterAnimation( "shadow_" + id, "filter", "alpha(opacity=", 99, ")", time, 20 );
	
	menuShow.CopyStateInAnimation();
	menuShow.RemoveAllOfTypeOnElement(Animation, id);
	menuShow.RemoveAllOfTypeOnElement(Animation, "shadow_" + id);
	menuShow.Start();
}

function productImagesOut( e, id )
{
	var menuShow = new Animation("anm1");
	var time = 10;
	
	menuShow.RegisterAnimation( id, "top", "", 5, "px", time, 0 );
	menuShow.RegisterAnimation( id, "left", "", 5, "px", time, 0 );
	
	menuShow.RegisterAnimation( "shadow_" + id, "opacity", "", 0.2, "", time, 0.99 );
	menuShow.RegisterAnimation( "shadow_" + id, "filter", "alpha(opacity=", 20, ")", time, 99 );
	
	menuShow.CopyStateInAnimation();
	menuShow.RemoveAllOfTypeOnElement(Animation, id);
	menuShow.RemoveAllOfTypeOnElement(Animation, "shadow_" + id);
	menuShow.Start();
}

var Calendar = new Class()
Calendar.Declare(
	{
		CurrentMonth: null,
		CurrentYear: null,
		LinkArray: new Array(),
		LinkArrayTitles: new Array(),
		refs: new Array(),
		
		RenderMonth: function( el, m, y )
		{
			if (m == null)
				m = new Date().getMonth();
			
			if (y == null)
				y = new Date().getFullYear();
			
			el = $element(el);
			
			this.CurrentMonth = m;
			this.CurrentYear = m;
			
			while(el.firstChild)
				el.removeChild( el.firstChild );
			
			var today = new Date();
			today.setMonth( m );
			today.setFullYear( y );
			var numOfDays = getDays( m, y );
			
			var firstDay = new Date();
			firstDay.setMonth( m );
			firstDay.setFullYear( y );
			firstDay.setDate( 1 );
			var firstDayNumber = firstDay.getDay();
			
			var endDay = new Date();
			endDay.setMonth( m );
			endDay.setFullYear( y );
			endDay.setDate( numOfDays );
			var endDayNumber = 7 - endDay.getDay();
			
			var pMonth = new Date();
			pMonth.setFullYear( y );
			pMonth.setMonth( m - 1 );
			var pMonthDays = getDays( pMonth.getMonth(), pMonth.getFullYear() );
			
			for( var i = 0; i < (numOfDays + firstDayNumber + endDayNumber - 1); ++i )
			{
				var li = document.createElement("li");
				
				if (i < firstDayNumber)
					li.className = "previousMonthDay";
				else if ( i >= (firstDayNumber + numOfDays) )
					li.className = "nextMonthDay";
				else li.className = "monthDay";
				
				var realToday = new Date();
				if ( realToday.getDate() == ( i - firstDayNumber + 1 ) &&
					realToday.getMonth() == m &&
					realToday.getFullYear() == y )
				{
					li.className += " today";
				}
				
				var allLinks = new Array();
				var allLinksArrays = new Array();
				for(var j = 0; j < this.LinkArray.length; ++j)
				{
					for(prop in this.LinkArray[j])
					{
						if ( this.LinkArray[j][prop].Date.d == ( i - firstDayNumber + 1 ) && 
							this.LinkArray[j][prop].Date.m == m &&
							this.LinkArray[j][prop].Date.y == y )
						{
							allLinks[ allLinks.length ] = this.LinkArray[j][prop];
							if (allLinksArrays.length == 0 || allLinksArrays[ allLinksArrays.length - 1 ] != j)
								allLinksArrays[ allLinksArrays.length ] = j;
						}
					}
				}
				
				if (allLinks.length > 0)
				{
					for(var j = 0; j < allLinksArrays.length; ++j)
						li.className += " linkArray_" + allLinksArrays[j];
					
					li.lnks = allLinks;
					
					function onMouseOver()
					{
						var _this = (isIE() ? window.event.srcElement : this);
						
						var clr = new ColorAnimation("clrAnim");
						// clr.PreRegisterAnimation( "backgroundColor", "", [ 0xFF, 0xFF, 0xDB ], "", [ 0xFF, 0xFF, 0 ] );
						clr.PreRegisterAnimation( "backgroundColor", "", [ 0xFF, 0xFF, 0xFF ], "", [ 0xC5, 0x00, 0x29 ] );
						clr.PreRegisterAnimation( "color", "", [ 0x37, 0x4F, 0x5A ], "", [ 0xFF, 0xFF, 0xFF ] );
						clr.RemoveAllOfTypeOnElement( ColorAnimation, _this );
						clr.RunOn(_this, 40);
						
						var balloonContent = $element("balloonContent");
						
						while(balloonContent.firstChild)
							balloonContent.removeChild( balloonContent.firstChild );
						
						// _this.appendChild( $element("balloonEl") );
						$element("balloonEl").style.display = "";
						$element("balloonEl").style.top = ( getTop( _this ) + Math.round(2*getHeight( _this )/3.) ) + "px";
						$element("balloonEl").style.left = getLeft( _this ) + "px";
						
						$element("balloonEl").onmouseout = onMouseOut;
						
						for(var j = 0; j < _this.lnks.length; ++j)
						{
							var a = document.createElement("a");
							a.href = _this.lnks[j].Link;
							$createText( _this.lnks[j].Title, a );
							balloonContent.appendChild(a);
						}
					}
					
					function onMouseOut(e)
					{
						var _this = (isIE() ? window.event.srcElement : this);
						
						if (!e) e = window.event;

						var current, related;
						if (isIE())
						{
							current = _this;
							related = window.event.toElement;
						}
						else
						{
							current = e.currentTarget;
							related = e.relatedTarget;
						}
						
						if ( current != related && !$element(current).isParentOf(related)
							&& related != $element("balloonEl") && !$element("balloonEl").isParentOf(related) )
						{
							// $element("body").appendChild( $element("balloonEl") );
							
							if (_this.id != "balloonEl")
							{
								var clr = new ColorAnimation("clrAnim");
								// clr.PreRegisterAnimation( "backgroundColor", "", [ 0xFF, 0xFF, 0 ], "", [ 0xFF, 0xFF, 0xDB ] );
								clr.PreRegisterAnimation( "backgroundColor", "", [ 0xC5, 0x00, 0x29 ], "", [ 0xFF, 0xFF, 0xFF ] );
								clr.PreRegisterAnimation( "color", "", [ 0xFF, 0xFF, 0xFF ], "", [ 0x37, 0x4F, 0x5A ] );
								clr.RemoveAllOfTypeOnElement( ColorAnimation, _this );
								clr.RunOn(_this, 40);
							}
							
							var balloonContent = $element("balloonContent");
							$element("balloonEl").style.display = "none";
							
							while(balloonContent.firstChild)
								balloonContent.removeChild( balloonContent.firstChild );
						}
					}
					
					chainEventListener( "mouseover", onMouseOver, li );
					chainEventListener( "mouseout", onMouseOut, li );
				}
				
				el.appendChild( li );
				
				if (i < firstDayNumber)
					$createText( pMonthDays - firstDayNumber + i + 1, li );
				else if ( i >= (firstDayNumber + numOfDays) )
					$createText( ( i - (firstDayNumber + numOfDays) ) + 1, li );
				else $createText( i - firstDayNumber + 1, li );
			}
		},
		
		NextMonth: function( el )
		{
			var month = new Date();
			month.setFullYear( this.CurrentYear );
			month.setMonth( this.CurrentMonth - 1 );
			
			this.RenderMonth( el, month.getMonth(), month.getFullYear() );
		},
		
		PreviousMonth: function( el )
		{
			var month = new Date();
			month.setFullYear( this.CurrentYear );
			month.setMonth( this.CurrentMonth + 1 );
			
			this.RenderMonth( el, month.getMonth(), month.getFullYear() );
		}
	}
);

function resellersChangeOver(e, top, left, widthHeight)
{
	if (!e) e = window.event;
	
	var el = $element( isIE() ? e.srcElement : e.target );
	el.style.zIndex = 10000;
	
	var menuShow = new Animation("anm1");
	var time = 10;
	var bounds = el.getRelativeBounds();
	var proportion = 1.5;
	var toLeft = Math.round( left - (proportion - 1) * widthHeight / 2. );
	var toTop = Math.round( top - (proportion - 1) * widthHeight / 2. );
	var toWidth = proportion * widthHeight;
	var toHeight = proportion * widthHeight;
	menuShow.RegisterAnimation( el, "left", "", bounds.left.get(), "px", time, toLeft );
	menuShow.RegisterAnimation( el, "top", "", bounds.top.get(), "px", time, toTop );
	menuShow.RegisterAnimation( el, "height", "", bounds.height.get(), "px", time, toHeight );
	menuShow.RegisterAnimation( el, "width", "", bounds.width.get(), "px", time, toWidth );
	menuShow.CopyStateInAnimation();
	menuShow.RemoveAllOfTypeOnElement(Animation, el);
	menuShow.Start();
}

function resellersChangeOut(e, top, left, widthHeight)
{
	if (!e) e = window.event;
	
	var el = $element( isIE() ? e.srcElement : e.target );
	el.style.zIndex = "";
	
	var menuShow = new Animation("anm1");
	var time = 10;
	var bounds = el.getRelativeBounds();
	var proportion = 1.5;
	var toLeft = left;
	var toTop = top;
	var toWidth = widthHeight;
	var toHeight = widthHeight;
	menuShow.PreRegisterAnimation( "left", "", bounds.left.get(), "px", toLeft );
	menuShow.PreRegisterAnimation( "top", "", bounds.top.get(), "px", toTop );
	menuShow.PreRegisterAnimation( "height", "", bounds.height.get(), "px", toHeight );
	menuShow.PreRegisterAnimation( "width", "", bounds.width.get(), "px", toWidth );
	menuShow.RemoveAllOfTypeOnElement(Animation, el);
	menuShow.RunOn(el, time);
}

function fileListAnimationHover( id )
{
	var el = $element( id );
	
	var clr = new ColorAnimation("clrAnim");
	clr.PreRegisterAnimation( "backgroundColor", "", [ 0xE0, 0xE0, 0xE0 ], "", [ 0xFF, 0xEF, 0x8F ] );
	clr.PreRegisterAnimation( "border", "1px solid ", [ 0xD4, 0xD0, 0xC8 ], "", [ 0xFF, 0xCD, 0x07 ] );
	clr.RemoveAllOfTypeOnElement( ColorAnimation, el );
	clr.RunOn(el, 30);
}

function fileListAnimationOut( id )
{
	var el = $element( id );
	
	var clr = new ColorAnimation("clrAnim");
	clr.PreRegisterAnimation( "backgroundColor", "", [ 0xFF, 0xEF, 0x8F ], "", [ 0xE0, 0xE0, 0xE0 ] );
	clr.PreRegisterAnimation( "border", "1px solid ", [ 0xFF, 0xCD, 0x07 ], "", [ 0xD4, 0xD0, 0xC8 ] );
	clr.RemoveAllOfTypeOnElement( ColorAnimation, el );
	clr.RunOn(el, 30);
}

function changeSelfServiceOver( id, elanim )
{
	$element(id).style.display = "block";
	
	/*
	var clr = new ColorAnimation("clrAnim");
	clr.PreRegisterAnimation( "backgroundColor", "", [ 0xF5, 0xF5, 0xF5 ], "", [ 0xFF, 0xFF, 0xFF ] );
	clr.RemoveAllOfTypeOnElement( ColorAnimation, elanim );
	clr.RunOn(elanim, 20);
	*/
	
	// window.scrollTo( getWidth("body") , getScrollY() );
}

function changeSelfServiceOut( e, id, _this, elanim )
{
	if (!e) e = window.event;
	
	var current, related;
	if (isIE())
	{
		current = _this;
		related = window.event.toElement;
	}
	else
	{
		current = e.currentTarget;
		related = e.relatedTarget;
	}
	
	if ( current != related && !$element(current).isParentOf(related) )
	{
		/*
		var clr = new ColorAnimation("clrAnim");
		clr.PreRegisterAnimation( "backgroundColor", "", [ 0xFF, 0xFF, 0xFF ], "", [ 0xF5, 0xF5, 0xF5 ] );
		clr.RemoveAllOfTypeOnElement( ColorAnimation, elanim );
		clr.onEnd = function()
		{
			$element(id).style.display = "none";
		}
		clr.RunOn(elanim, 20);
		*/
		
		$element(id).style.display = "none";
	}
}

/******************************* Templates *************************************/
try
{
	
UITemplates.Register(
	{
		Tag: "embed",
		type: "application/x-mplayer2",
		pluginspage: "http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/",
		showcontrols: "1",
		showdisplay: "0" ,
		showstatusbar: "1" ,
		enablecontextmenu: "1",
		NoContents: true
		/*
		filename: '...',
		src: '...',
		width: ...,
		height: ...,
		*/
	},
	"Video"
);

UITemplates.Register(
	{
		Tag: "div",
		Contents: [ [
			{
				Tag: "div",
				className: "image",
				Contents: [ [
					{
						Tag: "img"
					}
				] ]
			},
			{
				Tag: "div",
				className: "title",
				Contents: [ [
					{
						Tag: "a"
					}
				] ]
			},
			{
				Tag: "div",
				className: "submenu_wrapper"
			}
		] ]
	},
	"IconButton"
);

UITemplates.Register(
	{
		Tag: "div",
		Contents: [ [
			{
				Tag: "div",
				className: "image",
				Contents: [ [
					{
						Tag: "img",
						src: "/systemimages/Enorasis/Images/prev.gif",
						className: "rightArrow",
						NoContents: true
					},
					{
						Tag: "img"
					}
				] ]
			},
			{
				Tag: "div",
				className: "title"
			},
			{
				Tag: "div",
				className: "submenu_wrapper"
			}
		] ]
	},
	"SelfServiceParent"
);

UITemplates.Register(
	{
		Tag: "div",
		className: "submenu",
		Contents: [ [
			{
				Tag: "div",
				Contents: [ [
					{
						Tag: "ul"
					}
				] ]
			}
		] ]
	},
	"SelfServiceSubMenu"
);

UITemplates.Register(
	{
		Tag: "div",
		display: "block",
		Contents: [ [
			{
				Tag: "div",
				display: 'none',
				overflow: "hidden",
				Contents: [ [
					{
						Tag: "img"
					}
				] ]
			},
			{
				Tag: "canvas",
				display: 'none'
			}
		] ],
		
		putImage: function( imgCopy )
		{
			imgCopy = $element( imgCopy ); 
			if (isIE())
			{
				var i_w = getWidth(imgCopy);
				var i_h = getHeight(imgCopy);
				
				this.style.height = i_h * this.c_height + "px";
				this.style.width = i_w + "px";
				
				this.BoundObject.Contents[0].parentNode.style.height = i_h * this.c_height + "px";
				this.BoundObject.Contents[0].parentNode.style.display = "block";
				this.BoundObject.Contents[0].parentNode.style.verticalAlign = 'bottom';
				
				this.BoundObject.Contents[0].style.width = i_w + "px";
				this.BoundObject.Contents[0].style.filter = "alpha(opacity=" + 100 * this.c_alpha +
					") alpha(opacity=0, finishopacity=100, style=1, startX=0, startY="
					+ ( ( 1 - this.c_height ) * 100) + ", finishX=0, finishY=1000) flipv";
				
				this.BoundObject.Contents[0].src = imgCopy.src;
				this.BoundObject.Contents[0].style.marginBottom = "-" + ( (1 - this.c_height) * i_h ) + 'px';
			}
			else
			{
				var i_w = getWidth(imgCopy);
				var i_h = getHeight(imgCopy);
				
				var cv = this.BoundObject.Contents[1];
				cv.height = i_h * this.c_height;
				cv.width = i_w;
				cv.style.display = "block";
				cv.style.height = i_h * this.c_height + "px";
				cv.style.width = i_w + "px";
				
				this.BoundObject.Contents[0].style.display = "none";
				if (cv.getContext)
				{
					var ct = cv.getContext("2d");
					ct.clearRect( 0, 0, i_w, i_h * this.c_height );
					
					ct.globalCompositeOperation = "source-over";
					ct.globalAlpha = this.c_alpha;
					ct.save();
					ct.translate( 0, i_h - 1 );
					ct.scale(1,-1);
					ct.drawImage( imgCopy, 0, 0, i_w, i_h );
					ct.restore();
					
					ct.globalCompositeOperation = "destination-out";
					var gradient = ct.createLinearGradient(0, 0, 0, i_h * this.c_height);
					
					gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
					gradient.addColorStop(0.8, "rgba(255, 255, 255, 0.5)");
					gradient.addColorStop(0, "rgba(255, 255, 255, 0.0)");
					
					ct.fillStyle = gradient;
					if (navigator.appVersion.indexOf('WebKit') != -1)
					{
						ct.fill();
					}
					else
					{
						ct.fillRect(0, 0, i_w, i_h * this.c_height);
					}
				}
			}
		}
		
		/*
		c_alpha,
		c_height
		*/
	},
	"ReflectImage"
);

}
catch(e) {}
