function tippbox(tid){
	var tippArr = new Array();
	var tippId = tid;
	var tippPointer;
	
	this.add = function(tid, id){
		tippArr[tippArr.length] = id;
		
//		if (tippArr[0] != id){
//			$('#tippBox_' + tid + ' #tippBoxItem_' + id + ' #tippBoxNav_' + id).css('display', 'none');
//			$('#tippBox_' + tid + ' #tippBoxItem_' + id ).css('display', 'none');
//		}else{
//			$('#tippBox_' + tid + ' #tippBoxItem_' + id + ' #tippBoxNav_' + id).css('display', 'block');
//			$('#tippBox_' + tid + ' #tippBoxItem_' + id ).css('display', 'block');
//		}	
		
		
		// Zufallsanzeige
		$('#tippBox_' + tid + ' #tippBoxItem_' + id + ' #tippBoxNav_' + id).css('display', 'none');
		$('#tippBox_' + tid + ' #tippBoxItem_' + id ).css('display', 'none');
		
		tippPointer = tippArr.length;
		
//		this.browserTippItem(tid, tippArr[0]);
//		this.showRandom();
	}
	
	this.showTippItem = function(tid, id){
		for (var i = 0; i < tippPointer; i++){
			if (parseInt(tippArr[i]) != parseInt(id)){
				$('#tippBox_' + tid + ' #tippBoxItem_' + tippArr[i] + ' #tippBoxNav_' + tippArr[i]).css('display', 'none');
				$('#tippBox_' + tid + ' #tippBoxItem_' + tippArr[i] ).css('display', 'none');
			}else{
				$('#tippBox_' + tid + ' #tippBoxItem_' + tippArr[i] + ' #tippBoxNav_' + tippArr[i]).css('display', 'block');
				$('#tippBox_' + tid + ' #tippBoxItem_' + tippArr[i] ).css('display', 'block');
			}
		}
		
		this.browserTippItem(tid, id);
	}
	
	this.browserTippItem = function(tid, id){
		var tippPointerMinus = tippPointer - 1;
		for (var i = 0; i < tippPointer; i++){			
			if (tippArr[i] == id){				
				if (i == 0){
					$('#tippBox_' + tid + ' #tippBoxItem_' + id + ' #tippBoxNav_' + id + ' .tippNavLeft a').attr('href', 'javascript:tippbox_' + tippId + '.showTippItem("' + tippId + '", "' + tippArr[tippPointer-1] + '");');
				}
				if (i > 0){
					$('#tippBox_' + tid + ' #tippBoxItem_' + id + ' #tippBoxNav_' + id + ' .tippNavLeft a').attr('href', 'javascript:tippbox_' + tippId + '.showTippItem("' + tippId + '", "' + tippArr[i-1] + '");');
				}
				if (i < parseInt(tippPointerMinus)){
					$('#tippBox_' + tid + ' #tippBoxItem_' + id + ' #tippBoxNav_' + id + ' .tippNavRight a').attr('href', 'javascript:tippbox_' + tippId + '.showTippItem("' + tippId + '", "' + tippArr[i+1] + '");');
				}
				if ((i == parseInt(tippPointerMinus)) && (parseInt(tippPointerMinus) > 0)){
					$('#tippBox_' + tid + ' #tippBoxItem_' + id + ' #tippBoxNav_' + id + ' .tippNavRight a').attr('href', 'javascript:tippbox_' + tippId + '.showTippItem("' + tippId + '", "' + tippArr[0] + '");');
				}
			}
		}
	}
	
	this.showRandom = function(){
		var minVal = 0;
		var maxVal = tippPointer - 1;
		var randVal = minVal + (Math.random() * (maxVal-minVal));
  		var nr = (typeof floatVal == 'undefined') ? Math.round(randVal) : randVal.toFixed(floatVal);
		
		var randomId = tippArr[nr];
		this.showTippItem(tippId, randomId);
		
	}
	
	$().ready(function(){
		if (tippPointer == 1) {
			$('#tippBox_' + tippId + ' #tippBoxItem_' + tippArr[0] + ' #tippBoxNav_' + tippArr[0]).css('display', 'none');
		}
	});
	
	
	 // Debug
	$('#tippBox_' + tippId).live('click', function(event){
		var tmpArrEntryStr = '';
		for (i = 0; i < tippArr.length; i++){
			tmpArrEntryStr += tippArr[i];
			tmpArrEntryStr += ' - ';
		};
	});
	
}

