<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// ===============================================================================================

window.addEvent('domready', function()
{
	// ======================================================================================
	// INPUT REQUIRED FUNCTIONS =============================================================
	// ======================================================================================
	
	var required_fields = $$('input.required', 'textarea.required');
	required_fields.each(function(item, index)
	{		
		if (item.type != 'radio')
		{
			var message_field = item.get('id') + "_message";
			item.addEvent('keyup', function()
			{
				if (item.value.length != 0)
				{
					$(message_field).set('text', '');
				}
			});
		}
		else
		{
			var message_field = item.get('name') + "_message";
			item.addEvent('click', function()
			{
				$(message_field).set('text', '');
			});
		}
	});	
	
	// ======================================================================================
	// CHARACTER COUNTER FUNCTION ===========================================================
	// ======================================================================================
	
	var characterCounters = $$('textarea.characterCounter');
	characterCounters.each(function(item, index)
	{
		var counter = $('count_' + item.get('id'));
		var maxCharacters = counter.get('html').toInt();
		var numCharacters = item.get('value').length;
		var charactersLeft = maxCharacters - numCharacters;
		
		if (charactersLeft <= 0)
		{
			item.set('value', item.get('value').substr(0, maxCharacters));
			charactersLeft = 0;
		}
			
		counter.set('html', charactersLeft);
		
		item.addEvent('keyup', function()
		{
			var numCharacters = this.get('value').length;
			var charactersLeft = maxCharacters - numCharacters;
			if (charactersLeft <= 0)
			{
				this.set('value', this.get('value').substr(0, maxCharacters));
				charactersLeft = 0;
			}
			
			counter.set('html', charactersLeft);
		});
	});	
	
	// ======================================================================================
	// KBOX =================================================================================
	// ======================================================================================
	
	var returnToNormal = function()
	{
		$('closer').destroy();
		$('iFrame').destroy();
		
		var myFx = new Fx.Tween($('bgDiv'),
		{
			onComplete: function()
			{
				$('bgDiv').destroy();
			}
		});
		
		myFx.start('opacity', 0);
	};
		
	$$('a.kbox').each(function(item, index)
	{				
		item.addEvent('click', function(e)
		{			
			var e = new Event(e).stop();

			var url = this.get('href');
			var scrollSize = window.getScrollSize();
			var windowSize = window.getSize();
			var scrollPos = window.getScroll();
			
			var bgDiv = new Element('div',
			{
				id: 'bgDiv',
				styles:{
					position: 'absolute',
					top: '0px',
					left: '0px',
					width: '100%',
					height: scrollSize.y,
					'background-color': 'white',
					opacity: 0
				}
			});
			
			var closer = new Element('div',
			{
				id: 'closer',
				html: '<img src="/images/close.png" style="margin-top:5px;">',
				styles: {
					position: 'absolute',
					width: 53,
					cursor: 'pointer',
					'z-index': 9
				}
			});
			
			closer.addEvent('click', returnToNormal);
			var iFrame = new Element('iframe',
			{
				id: "iFrame",
				src: url,
				styles: {
					position: 'absolute',
					top: '0px',
					left: '0px',
					width: 311,
					height: 372,
					border: 'none',
					'z-index': 10
				},
				scrolling: 'no',
				noresize: 'noresize',
				border: 0,
				frameborder: 0,
				cellspacing: 0
			});
						
			var bodyElement = $(document.body);
			bgDiv.inject(bodyElement, 'bottom');
			
			var myFx = new Fx.Tween(bgDiv, 
			{
				onComplete: function()
				{	
					var topPos = (windowSize.y / 2) - (iFrame.getStyle('height').toInt() / 2) + scrollPos.y;
					var leftPos = (windowSize.x / 2) - (iFrame.getStyle('width').toInt() / 2);
					
					iFrame.setStyles(
					{
						top: topPos,
						left: leftPos
					});
															
					iFrame.inject(bodyElement, 'top');
					
					var iFrameCoords = iFrame.getCoordinates();
					closer.setStyles(
					{
						top: iFrameCoords.bottom,
						left: iFrameCoords.right - closer.getStyle('width').toInt()
					});
					closer.inject(iFrame, "after");
				}
			});
			
			myFx.start('opacity', 0.6);
		});
	});
	
	// ======================================================================================
	// HELP TIPS ============================================================================
	// ======================================================================================
	
	var helpTips = new Tips('.helptip', 
	{
		'fixed': true,
		'hideDelay': 1000,
		'link': 'cancel',
		'className': 'helptip-container',
		'offsets':
		{
			'x': 20,
			'y': -80
		},
		'show': function(tip, el)
		{
			tip.show();
		},
		'hide': function(tip, el)
		{
			tip.hide();	
		}
	});
	
	$$('div.helptip-container').each(function(item, index)
	{
		item.addEvent('mouseover', function()
		{
			this.fade('show');
		});
	});
});


//-->