/* <![CDATA[ */
			
	var ajaxPath = '/lib/ajax.php';
	
	function NewsSlider()
	{
		this.imgdistance = 982;
		
		this.slides;
		this.obj;
		this.obj_text;
		this.obj_image;
		this.current;
		this.newtext;
		this.newimage;
		this.navi;
		this.imgposition;
		this.ismoving;
		this.isfading;
		this.timer;
		this.fadetimer;
		this.autofade;
		
		this.initialize = function()
		{
			var t=this;
			if(jQuery('#home-news').length>=1){
				
				t.ismoving = false;
				t.isfading = false;
				t.current=1;
				
				t.obj = jQuery('#home-news');
				t.obj_text = jQuery('#home-news-text');
				t.obj_image = jQuery('#home-news-image');
				
				jQuery.ajax({
					url: ajaxPath+'?f=5',
					success: function(xml){
						t.slides=new Array();
						jQuery(xml).find('banner').each(function(){
							ho = new Object();
							ho.file = jQuery(this).find('file').text();
							ho.header = jQuery(this).find('header').text();
							ho.content = jQuery(this).find('content').text();
							ho.alt = jQuery(this).find('alt').text();
							ho.alink = jQuery(this).find('link').text();
							t.slides[t.slides.length]=ho;
						});
						if(t.slides.length>1){t.buildSlide();}
					}
				});
			}
		}
		
		this.buildSlide = function()
		{
			var t=this;
			t.obj_text.empty();
			t.obj_image.empty().css('width',String(t.imgdistance*(t.slides.length+2))+'px');
			jQuery('#home-news-othertext').remove();

			t.navi = jQuery(document.createElement('div')).attr({'id':'home-news-navi'});
			t.addImage(0, t.slides[t.slides.length-1]);
			
			jQuery.each(t.slides, function(key, value){
				t.addImage(key+1, value);
				t.obj_text.append(
					jQuery(document.createElement('div')).attr({'id':'home-news-text-'+String(key+1),'class':'home-news-wrap'}).append(
						jQuery(document.createElement('div')).append(
							jQuery(document.createElement('h2')).attr({'class':'home-news-header'}).html(value.header),
							jQuery(document.createElement('p')).attr({'class':'home-news-content'}).html(value.content)
						),
						jQuery(document.createElement('p')).attr({'class':'home-news-link'}).append(
							jQuery(document.createElement('a')).attr({'href':value.alink,'title':value.header}).text('Click here to find out more')
						)
					).hide()
				);
				t.navi.append(jQuery(document.createElement('a')).attr({'title':value.alt,'id':'home-news-navi-'+String(key+1),'rel':String(key+1)}).html('&bull;').click(function(){
					t.moveSlider(Number(jQuery(this).attr('rel')));
				}));
			});
			
			t.addImage(t.slides.length+1, t.slides[0]);
			jQuery('#home-news').after(t.navi);

			t.obj.append(
				jQuery(document.createElement('a')).attr({'id':'home-news-leftbtn'}).html('&lt;').click(function(){t.moveSliderLeft()}),
				jQuery(document.createElement('a')).attr({'id':'home-news-rightbtn'}).html('&gt;').click(function(){t.moveSliderRight()})
			);
			
			t.obj_image.css('left','-'+String(t.imgdistance*t.current)+'px');
			jQuery('#home-news-text-'+String(t.current)).show();
			jQuery('#home-news-navi-'+String(t.current)).addClass('active');
			
			t.autofade = setTimeout(function(){t.moveSliderRight()}, 6000);
		}
		
		this.addImage = function(key, value)
		{
			var t=this;
			t.obj_image.append(
				jQuery(document.createElement('div')).attr({'id':'home-news-image-'+key}).append(
					jQuery(document.createElement('img')).attr({'width':'982','height':'240','src':'/images/home/'+value.file,'alt':value.alt})
				)
			);
		}
		
		this.moveSlider = function(pos)
		{
			var t=this;
			if(t.ismoving === false && t.isfading === false){
				var pos2 = pos;
				if(pos2>=t.slides.length+1){pos2=1;}
				else if(pos2<=0){pos2=t.slides.length;}	
				if(pos2!=t.current){
					t.newtext = pos2;
					t.newimage = pos;
					if(t.newtext>=t.slides.length+1){t.newtext=1;}
					else if(t.newtext<=0){t.newtext=t.slides.length;}
					t.isfading = true;
					t.ismoving = true;
					t.navi.find('a').removeClass('active');
					clearTimeout(t.autofade);
					t.obj_image.animate({'left':'-'+String(t.imgdistance*t.newimage)+'px'},1000,function(){
						t.obj_image.css('left','-'+String(t.imgdistance*t.newtext)+'px');
						t.ismoving = false;
					});
					jQuery('#home-news-text-'+t.current).fadeOut(500,function(){
						jQuery('#home-news-text-'+t.newtext).fadeIn(500,function(){
							t.current=t.newtext;
							jQuery('#home-news-navi-'+String(t.current)).addClass('active');
							t.autofade = setTimeout(function(){t.moveSliderRight()}, 6000);
							t.isfading = false;
						});
					});
				}
			}
		}
		
		this.moveSliderLeft = function()
		{
			var t=this;
			t.moveSlider(t.current-1);
		}
		
		this.moveSliderRight = function()
		{
			var t=this;
			t.moveSlider(t.current+1);
		}
	}
	
	function HomeSlide(section, aug)
	{
		this.distance = 324;
		
		this.section = section;
		this.aug = aug;
		
		this.list;
		this.leftBtn;
		this.rightBtn;
		this.position;
		this.maxposition;
		this.newposition
		this.width;
		this.ismoving;
		
		this.buildSlide = function()
		{
			var t=this;
			
			t.position = 0;
			t.maxposition = 0;
			t.newposition = 0;
			t.width = 0;
			t.ismoving = false;
			
			t.leftBtn = jQuery(document.createElement('div')).addClass('homeoffersleftbtn').append(
				jQuery(document.createElement('a')).attr({'id':'homeslideleftbtn'+t.section}).html('&lt;').click(function(){t.moveSlider('L')})
			);
			
			t.rightBtn = jQuery(document.createElement('div')).addClass('homeoffersrightbtn').append(
				jQuery(document.createElement('a')).attr({'id':'homesliderightbtn'+t.section}).html('&gt;').click(function(){t.moveSlider('R')})
			);
			
			jQuery('#'+t.aug).append(t.leftBtn, t.rightBtn);
			
			t.list = jQuery('#'+t.aug).find('ul');
			t.position = parseInt(t.list.css('left'));
			t.width = parseInt(t.list.css('width'));
			
			while(t.maxposition < t.width){t.maxposition+=t.distance;}
			t.maxposition=0-t.maxposition+t.distance;
			
			t.leftBtn.find('a').addClass('off');
			if(this.maxposition >= 0){ t.rightBtn.find('a').addClass('off'); }
		}
		
		this.moveSlider = function(dir)
		{
			var t=this;
			
			if(t.ismoving === false){
				var newpos = (dir=='L')? t.newposition+t.distance : t.newposition-t.distance;
				if(newpos > 0){ newpos = 0; }else if(newpos < t.maxposition){ newpos = t.maxposition; }
				t.newposition = newpos;
				if(newpos == 0){ t.leftBtn.find('a').addClass('off'); }else{ t.leftBtn.find('a').removeClass('off'); }
				if(newpos == t.maxposition){ t.rightBtn.find('a').addClass('off'); }else{ t.rightBtn.find('a').removeClass('off'); }
				t.ismoving = true;
				t.list.animate({'left':String(newpos)+'px'},500,function(){
					t.ismoving = false;
				});
			}
		}
	}
	
	if (typeof jQuery != 'undefined'){ 
		jQuery(document).ready(function(){
			var newsSlider = new NewsSlider();
			newsSlider.initialize();
			var leftSlider = new HomeSlide('C','homeoffersslide-left');
			leftSlider.buildSlide();
			var rightSlider = new HomeSlide('P','homeoffersslide-right');
			rightSlider.buildSlide();
		});
	}
