/*
The code in this file or document and its designs, methods, data, know-how and all other related elements are the property of LUXSON ltd © Copyright 2009-2010 and/or may contain code operated under third party licence(s); unauthorised use is therefore prohibited, including (without limitation) copying, editing, adapting, reverse engineering or any other similar or related action, in part or in full. Separate rights may also exist for LUXSON and/or client and/or third party content and/or services. For licensing information please contact LUXSON ltd.
*/

function LSNews(h, n){

	var n_nA = new Array();
	var n_tInt;
	var n_cItem = 0;
	var n_pItem = 0;
	var n_nHolid = h;
	var n_nItems = n;
	var n_timeoutInt;
	var n_active = false;
	
	function n_buildNewsItems()
	{	
		
		var n_arrTemp = document.getElementById(n_nHolid).getElementsByTagName('div');
		for(var i = 0; i < n_arrTemp.length; i++){
			if(n_arrTemp[i].className == n_nItems){
				n_nA.push(n_arrTemp[i]);
			}
		}
	
		for(var j = 1; j < n_nA.length; j++){
			n_nA[j].style.display = 'none';
		}
	
		n_timeoutInt = setTimeout(function(){n_changeNews(1)}, 17000);
	
	}
	
	function n_changeNews(n_dir)
	{
		n_active = true;
		var n_segs = 40;
		var n_upd = 0;
		var n_nw = 620;
		var n_pivP = 310;
		var n_pivD = ((-310)*n_dir);
		n_pItem = n_cItem;
		n_cItem += n_dir;
		
		clearTimeout(n_timeoutInt);
		
		if(n_cItem >= n_nA.length) n_cItem = 0;
		if(n_cItem < 0) n_cItem = n_nA.length-1;
		
		n_nA[n_pItem].style.left = '0px';
		n_nA[n_cItem].style.left = (620*n_dir)+'px';
		
		n_nA[n_pItem].style.display = 'block';
		n_nA[n_cItem].style.display = 'block';
		
		this.n_updateMove = function(){
			if(n_upd >= n_segs){
				n_nA[n_pItem].style.left = '-'+n_nw+'px';
				n_nA[n_cItem].style.left = '0px';
				n_nA[n_pItem].style.display = 'none';
				clearInterval(n_tInt);
				n_timeoutInt = setTimeout(function(){n_changeNews(1)}, 17000);
				n_active = false;
			}else{
				/*nA[pItem].style.left = ((-pivP)+(Math.cos(Math.PI+((Math.PI/segs)*upd)))*pivD)+'px';
				nA[cItem].style.left = (pivP+(Math.cos(Math.PI+((Math.PI/segs)*upd)))*pivD)+'px';*/
				n_nA[n_pItem].style.left = (((-n_pivP)*n_dir)+(Math.cos(Math.PI+((Math.PI/n_segs)*n_upd)))*n_pivD)+'px';
				n_nA[n_cItem].style.left = ((n_pivP*n_dir)+(Math.cos(Math.PI+((Math.PI/n_segs)*n_upd)))*n_pivD)+'px';
				
			}
			n_upd++;
		}
		
		n_tInt = setInterval("this.n_updateMove()", 30);
	
	}
	
	this.nextNewsItem = function(){
		if(n_active == false) n_changeNews(1);
	}
	
	this.prevNewsItem = function(){
		if(n_active == false) n_changeNews(-1);
	}
	
	function addLoadEvent(func) { 
	  var oldonload = window.onload; 
	  if (typeof window.onload != 'function') { 
		window.onload = func; 
	  } else { 
		window.onload = function() { 
		  if (oldonload) { 
			oldonload(); 
	  	} 
	  	func(); 
		} 
	  } 
	} 
	addLoadEvent(n_buildNewsItems);
	
}

var lsNews = new LSNews('newsHolder', 'news');
