//function fade_f (id, morph)
//function request_f ( requestUrl, kind, id, updatebasket )
//function changeClass_f ( removeClass, addClass, id )v
//function innerHtml_f ( kind, ele, response )
//function display_f (kind, ele, how)
//function tween_f (id, height)
//function move_f ( id, direction, position )
//function slider_f (direction)
//function rate_f (kind, pos, rateCalc, exist)
//function addToFavorite_f ( idLabuyla, idAuction, exist )
//function reloadCaptchaCodeFunc()
//function change (color)
//function reloadBasket_f( paymentKind )
//function search_defaulting()
//function searchsubmitting( searchstring )
//function lightboxFunc( images, smallPreview )
//function switchImage( idImage, srcImage, isSmall )
//function reloadAuctionPrice_f( paymentKind, subtotal )
//function showDeliverAddress(id, kind)
//function formValue_f (id, to1, to2)
//function reloadAuctionTotalPrice_f( paymentKind, subtotal )
//function sendPayment( formName )
//checkPass(strPass, strId, strClassname, strTextId, aTexts)

var tld = window.location.hostname;
tld = 'http://' + tld;

var mediaServer = "http://media2.labuyla.ch/";





function fade_f (id, morph)
{	
	var id = id;
	var idExist = document.getElementById(id);

	if ( idExist != null)
	{
		$(id).fade(morph);
	}
	
}
//  rate aktualisieren
function rate_cur_f() 
{
	//if ( res.match(/[^0-9][0-9][^0-9]/gi) || res.match(/Danke/gi) )  {   
	if (document.getElementById('id_labuyla_rate'))  { 
		var id_labuyla_rate = document.getElementById('id_labuyla_rate').value; 
		id_labuyla_rate = parseInt(id_labuyla_rate);  
		if ( id_labuyla_rate > 0 )  { 
			if (document.getElementById('customer_rate_cur'))  { 
				var cur_rate = document.getElementById('customer_rate_cur').value; 
				cur_rate = parseInt(cur_rate);
				if ( cur_rate > 0 )  {
						var customer_rates = document.getElementById('customer_rates_old').value; 
						var customer_rates_total = document.getElementById('customer_rates_total_old').value; 
						
						customer_rates = parseInt(customer_rates) + 1; 
						customer_rates_total = parseInt(customer_rates_total) + parseInt(cur_rate); 
						rate_new = customer_rates_total / customer_rates; 
						rate_new = Math.round(rate_new); 
						document.getElementById('rate_calc_cur').value = rate_new; 
						
						innerHtml_f ( 1, 'id_rating_total', customer_rates );  
						
						//alert (rate_new+' '+id_labuyla_rate); 
						rate_f (1, rate_new, id_labuyla_rate, 1); 
				}
			} 
		}
	} 
}


function request_f ( requestUrl, kind, id, updatebasket )
{
	
	var requestUrl 		= requestUrl;
	var kind 			= kind;
	var id 				= id;
	var updatebasket	= updatebasket;
	
	var request_han 	= new Request
	({

		url: requestUrl,
		method: 'get',
		update: null,
		onComplete: function(response) 
		{	
			//alert(response);
			if ( kind == 3 )
			{ 
				innerHtml_f ( kind, id, response );
			}
			
			if ( kind == 4 )
			{ 			
				arr_split 	= response.split('###');				
				innerHtml_f ( 1, 'basketPreviewQuantity', arr_split[1] );					
				innerHtml_f ( 1, 'basketPreviewAmount', arr_split[2] );
				
				// wenn user im basket ist und diesen leert, wird basket neu aufgerufen
				if(arr_split[1] == 0 && window.location == tld + "/shop/basket.html")
				{
					window.location= tld + "/shop/basket.html";
				}
				
				if (document.getElementById('info_'+id)) 
				{	
					display_f (1, 'info_'+id, 'block')
					fade_f('info_'+id, 1);
					innerHtml_f ( 1, 'info_'+id, arr_split[0] );
					window.setTimeout("fade_f('info_"+id+"','0')", 2000);
				}
			}
			
			// shop favoriten
			if ( kind == 5 )
			{
				
				changeClass_f ( 'productDetailWishlist', 'productDetailWishlistActive', 'bidFavorite_'+id );
				
				if (document.getElementById('info_'+id)) 
				{
					fade_f('info_'+id, 1);
					innerHtml_f ( 1, 'info_'+id, response );
					window.setTimeout("fade_f('info_"+id+"','0')", 2000);
				}
			}
			
			
			if ( kind == 6 )
			{
				//  rate aktualisieren
				rate_cur_f();  
				
				if (document.getElementById('info_'+id)) 
				{
					
					fade_f('info_'+id, 1);
					innerHtml_f ( 1, 'info_'+id, response ); 
					window.setTimeout("fade_f('info_"+id+"','0')", 2000); 

				}
				else if (document.getElementById('info_act_'+id)) 
				{
					display_f(1, 'info_act_'+id, 'block');
					fade_f('info_act_'+id, 1);
					innerHtml_f ( 1, 'info_act_'+id, response ); 
					window.setTimeout("fade_f('info_act_"+id+"','0')", 2000); 

				}

			}

			if ( kind == 61 )
			{
				if (document.getElementById('info_'+id)) 
				{
					fade_f('info_'+id, 1);
					innerHtml_f ( 1, 'info_'+id, response ); 
					window.setTimeout("fade_f('info_"+id+"','0')", 2000); 
				}

			}

			if ( updatebasket == "true" )
			{
				reloadBasket_f();	
			}	
			
			if ( kind == 7 ) 		
			{			
				auctionObject ( response );
			}
			
			if ( kind == 8 ) 		
			{
				auctionOpenHandle ( response );
			}
			
			if ( kind == 9 ) 		
			{				
				//#### uebernahme von suchergebnissen fuer vorschlagsliste in suchmodul
				if ( response == "keine" || response == "undefined" )
				{
					display_f ( 1, 'searchlist', 'none' );
				}
				else
				{
					display_f ( 1, 'searchlist', 'block' );
					innerHtml_f ( 3, 'searchlist', response );
					
				}
				
			}	
			
			// auction favoriten
			if ( kind == 100 )	
			{
				message = response;
				value = response.substr(0, 4);
				
				if ( value == 'DONE' )
				{
					changeClass_f ( 'wishListSmall', 'wishListSmallActive', 'a_wishList_'+id );
					
					var arr_response 	= response.split("|");
					message 			= arr_response[1];
				}
				
				innerHtml_f ( 3, 'a_message_' + id, message );
				display_f (1, 'a_message_' + id, 'block');
				
			}	
			
			if ( kind == 101 )	
			{
				message = response;
				value = response.substr(0, 4);
				
				if ( value == 'DONE' )
				{
					changeClass_f ( 'productDetailWishlist', 'productDetailWishlistActive', 'a_wishList_'+id );
					
					var arr_response 	= response.split("|");
					message 			= arr_response[1];
				}
				
				innerHtml_f ( 3, 'a_message_' + id, message );
				display_f (1, 'a_message_' + id, 'block');
				
			}
					
		}
		
								
	}).send();
		
}


function changeClass_f ( removeClass, addClass, id )
{
	$(id).removeClass(removeClass);
	$(id).addClass(addClass);
}

function innerHtml_f ( kind, ele, response )
{

	var kind 		= kind;
	var response 	= response;
	var ele 		= ele;

	if ( kind == 1 )
	{
		$(ele).innerHTML = response;
	}
	
	else if ( kind == 2 )
	{
		return  $(ele).innerHTML ;
	}
	
	else if ( kind == 3 )
	{
		$(ele).innerHTML = response;
	}

}



function display_f (kind, ele, how)
{
	if ( kind == 1 )
	{
		$(ele).setStyle('display', how);
	}	
	
	if ( kind == 2 )
	{
		return document.getElementById( ele ).style.display;
	}
	
	if ( kind == 3 )
	{
		// wexelt den display-status, parameter how ist egal
		if( document.getElementById( ele ).style.display == "none")
		{
			$(ele).setStyle('display', 'block');
		}
		else
		{
			$(ele).setStyle('display', 'none');
		}
	}
}


/*
	tween func
*/
function tween_f (id, height)
{
	var id = id;
	var height = height;
	
	$(id).set('tween', {
			duration: 600
	}).tween('height', height+'px');
			
}



function move_f ( id, direction, position )
{
	//alert (id+'_'+direction+'_'+position);

	$(id).tween(direction, position + 'px');
}


/*
	noch harte werte drin die raus sind
*/
sliderPosition = 0;

function slider_f (direction)
{
	imagesCount = innerHtml_f ( 2, 'imagesCount', '' );
	run 		= true;
	
	if ( direction == "l" )
	{
		sliderPosition--;
	}
	
	if ( direction == "r" )
	{
		sliderPosition++;
		
	}
	
	position = sliderPosition*62;
	
	if ( sliderPosition < 0 )
	{
		run 			= true;
		sliderPosition 	= 6;
		position		= 372;
	}
	
	if ( sliderPosition == 7 )
	{
		run 			= true;
		sliderPosition 	= 0;
		position		= 0;
	}
		
	
	if ( run === true )
	{
		move_f ( "images", "right", position );	
	}
	
	innerHtml_f (1, 'position', sliderPosition + ' ' + position);
	
	
	
	
	
	
	
}


/*
	rate func
*/
function rate_f (kind, pos, rateCalc, exist)
{


	if ( kind == 1 )
	{
		for (var i = 1; i < pos+1; ++i)
		{
			changeClass_f ( 'bidRating2', 'bidRatingMOver2', 'rate_'+i );
		}
	
		for (var i = pos+1; i < 5+1; ++i)
		{
			changeClass_f ( 'bidRatingMOver2', 'bidRating2', 'rate_'+i );
		}
	}

	if ( kind == 2 )
	{
		for (var i = 1; i < 5+1; ++i)
		{
			changeClass_f ( 'bidRatingMOver2', 'bidRating2', 'rate_'+i );
		}
		
		// preufen ob rating geaendert wurde
		if (document.getElementById('rate_calc_cur'))  { 
			var rate_calc_cur = document.getElementById('rate_calc_cur').value; 
			rate_calc_cur = parseInt(rate_calc_cur);
			if ( rate_calc_cur > 0 )  {
				rateCalc = rate_calc_cur; 
			}
		}
		
		for (var i = 1; i < rateCalc+1; ++i)
		{
			changeClass_f ( 'bidRating2', 'bidRatingMOver2', 'rate_'+i );
		}
	}	
	
	if ( kind == 3 )
	{
		var id_lab = 0;
		if (document.getElementById('id_labuyla_rate'))  { 
			id_lab = document.getElementById('id_labuyla_rate').value; 
			id_lab = parseInt(id_lab);
		} 
		
		if ( id_lab > 0 )  { 
			kind		= 61;
		}  else  { 
			document.getElementById('id_labuyla_rate').value = rateCalc; 
			document.getElementById('customer_rate_cur').value = pos;
			
			kind		= 6;
		} 
		
		requestUrl	= publicPhp + 'rating.php.php?idLabuyla='+rateCalc+'&position='+pos+'&e='+exist; 
		id			= rateCalc;	 

		request_f ( requestUrl, kind, id ); 
	}
}


/*
	add to favor
	
*/
function addToFavorite_f ( idLabuyla, idAuction, exist, single )
{
	requestUrl	= publicPhp + 'favorite.php.php?idLabuyla='+idLabuyla+'&idAuction='+idAuction+'&e='+exist;
	kind		= 5;
	id			= idLabuyla;
	
	if ( idAuction ) 
	{
		kind 	= 100;
		id		= idAuction;
		
		if( single == "true" )
		{
			kind 	= 101;	
		}
	}

	request_f ( requestUrl, kind, id );
}

/*
	realod captcha code
*/
function reloadCaptchaCodeFunc()
{
		
	var requestWriteNewCaptcha = new Request
	({
			url: tld + '/public/php/reloadCaptcha.php.php',
			method: 'get',
			update: null,
			onComplete: function(response) 
			{		
				//alert (window.document.getElementsByClassName("captchaCodeReload"));
				var ele = new Array();
				if ( document.getElementsByClassName ) {
				   ele = document.getElementsByClassName("captchaCodeReload");
				}
				else
				{

					var nodes = document.getElementsByTagName('img');
					var max = nodes.length;
					for ( var i = 0; i < max; i++ ) {
						if ( nodes[i].className == "captchaCodeReload" ) {
							 ele[ele.length] = nodes[i];
						 }
					}
				}
				//var ele = document.getElementsByClassName("captchaCodeReload");
					
				for (var i = 0; i < ele.length; i++)
				{
					ele[i].src = tld + "/public/php/captcha/captcha.php?url=" + mediaServer  + "design/&test="+response;
				}
	
			}
	})
		
	requestWriteNewCaptcha.send()
}




/*
	## fore del
*/
var test = new Array ('', 'black', 'green', 'red');
function change (color)
{
	innerHtml_f ( 1, 'tasche', '<img src="http://lv2.labuyla.ch/private/module/store/t_'+test[color]+'.jpg">' )
}

//$('bidMsg_'+index).setStyle('display', 'none');



function reloadBasket_f( paymentKind )
{
	
	var url			= "/public/php/reloadBasket.php.php?";
	var paymentKind = paymentKind;
	
	if(paymentKind)
	{
		url			= "/public/php/reloadBasket.php.php?paymentKind=" + paymentKind;
	}
	
	
	var requestWriteNewCaptcha = new Request
	({
		url: tld + url,
		method: 'get',
		update: null,
		onComplete: function(response) 
		{	
			if( document.getElementById("changeBasket") )
			{
				$("changeBasket").innerHTML = response;
			}
		}
	})
		
	requestWriteNewCaptcha.send()
}


window.addEvent('domready', function() 
									 
									 
{
	$$('.test3').addEvent('click', function(e)
	{	
		changeClass_f ( 'test3', 'test2', 'div_2' );
	});	
});



//##################################### search #################################################################################################
window.addEvent('domready', function () {
    //## bei texteingabe in suchfeld ruft javascript ein php auf, welches eine vorschlagsliste fuellt 
    $('fe_search_search').addEvent('keyup', function () {
        // shop-suche oder auction-suche													 
        var str = String(window.location);
        var land;

        if (tld == "http://127.0.0.1:40003") {
            land = "DE";
        }
        else {
            land = window.location.host;
            var arr = land.split("/");
            arr = arr[0].split(".");
            land = arr[2].toUpperCase();
        }
        var current_value = $('fe_search_search').value;
        
        var current_length = current_value.length;
        if (current_length > 1) {
            request_f(tld + "/public/php/shop_searchlist.php.php?searchstring=" + current_value + "&land=" + land, 9, "searchlist", false);
        }
        else {
            display_f(1, 'searchlist', 'none');
        }
    });

    //## sobald suchfeld den focus verliert verschwindet voeschlagsliste 
    $('fe_search_search').addEvent('blur', function () {
        window.setTimeout("search_defaulting()", 200);
    });
});

function search_defaulting()
{
	//## sobald suchfeld den focus verliert verschwindet voeschlagsliste
	display_f (1, 'searchlist', 'none');
	$('fe_search_search').value = "";	
}


function searchsubmitting( searchstring )
{
	//## bei klick auf einen vorschlag wird suchformular abgeschickt
	$('fe_search_search').value = searchstring + "######";
	//alert("OK");
	document.formSearchHeader.submit();

}
//################################## end search #################################################################################################



function lightboxFunc( images, smallPreview )
{

	var images    		= images;
	var smallPreview	= smallPreview;
	var tempArr   		= images.split("||");
	
	var title	  		= tempArr[0];
	var previewImages 	= tempArr[2];
	
	// Hauptbild bestimmen
	var mainImage 		= tempArr[1];
	if( document.getElementById(smallPreview) )
	{
		smallPreview = document.getElementById(smallPreview).src.split("x97.");
		mainImage 	 = smallPreview[0] + "x400." + smallPreview[1]; 
	}
	
	
	$("lightboxMainImage").innerHTML = '<img id="lightboxShowImage" src="' + mainImage + '" id="imageHolder" alt="' + title + '" title="' + title + '"></div>';
	
	// Bildvorschau
	var previewImages = previewImages.split(",");
	var countPreviews = previewImages.length;
	
	// Vorschau Bilder und Funktionsaufruf "switchImage" erstellen
	var previews = '';
	for( var i=0; i<countPreviews; ++i )
	{
		if( previewImages[i] )
		{
			previews 	  = previews + '<img onmouseover="switchImage(\'lightboxShowImage\', \'' + previewImages[i] + '\');" src="' + previewImages[i] + '" alt="' + title + '" title="' + title + '">';
			
		}
	}
	
	$("lightboxThumbs").innerHTML = previews;
	$("showLightBox").style.display = "block";
}

function switchImage( idImage, srcImage, isSmall )
{

	var idImage  = idImage;
	var srcImage = srcImage;
	var isSmall	 = isSmall;
	
	// groesse Anpassen
	if( isSmall != "true" )
	{
		srcImage 	= srcImage.split("x97.");
		srcImage 	= srcImage[0] + "x400." + srcImage[1];
	}

	document.getElementById(idImage).src = srcImage;
}


function reloadAuctionPrice_f( paymentKind, subtotal )
{
	
	var url			= "/public/php/reloadAuctionPrice.php.php?";
	var paymentKind = paymentKind;

	url			= "/public/php/reloadAuctionPrice.php.php?paymentKind=" + paymentKind + "&subtotal=" + subtotal;
	
	
	var requestAuctionPrice = new Request
	({
		url: tld + url,
		method: 'get',
		update: null,
		onComplete: function(response) 
		{	
			var tmpResponse = response.split("<||>");
			$("paymentKindHolder").innerHTML 	= tmpResponse[0];
			$("js_paymentType1").innerHTML 		= tmpResponse[1];
			$("js_paymentType2").innerHTML 		= tmpResponse[1];
			$("auctionPaymentCost").innerHTML 	= tmpResponse[2];
			$("auctionPaymentCost2").innerHTML 	= tmpResponse[2];
			$("auctionPriceTotal").innerHTML 	= tmpResponse[3];
		}
	})
		
	requestAuctionPrice.send()
}


function showDeliverAddress(id, kind)
{
	var id 			= id;
	var kind		= kind;
	var displayType = "";
	if( kind == 1 )
	{
		displayType = 'none';
		$("addressRadio2").checked = false;
		$("addressRadio1").checked = true;
		
	}
	else
	{
		displayType = 'block';
		$("addressRadio1").checked = false;
		$("addressRadio2").checked = true;
	}
	display_f(1, id, displayType);
}



function formValue_f (id, to1, to2)
{
	
	v 		= document.getElementById(to1).value;	
	v_new	= '';
	arr_v 	= v.split(",");
	inside 	= false;
	
	for ( i = 0; i < arr_v.length; ++i )
	{
		if ( arr_v[ i ] == id )
		{
			inside = true;
		}
		else
		{	
			if ( arr_v[ i ] )
			{
				v_new += arr_v[ i ] + ',';
			}
		}
		
		
		
	}
	
	if ( inside === false )
	{
		document.getElementById(to1).value = v + id + ',';
		document.getElementById(to2).value = v + id + ',';
	}
	else
	{
		document.getElementById(to1).value = v_new;
		document.getElementById(to2).value = v_new;
	}

}

function reloadAuctionTotalPrice_f( paymentKind, subtotal )
{
	var paymentKind = paymentKind;
	var subtotal	= subtotal;

	var url	= "/public/php/reloadAuctionPriceTotal.php.php?paymentKind=" + paymentKind + "&subtotal=" + subtotal;
	
	
	var requestAuctionPrice = new Request
	({
		url: tld + url,
		method: 'get',
		update: null,
		onComplete: function(response) 
		{	
			var tmpResponse = response.split("<||>");
			$("paymentKindId").innerHTML  = tmpResponse[0];
			$("payFormId").innerHTML		= tmpResponse[1];
		}
	})
		
	requestAuctionPrice.send()
	
}

function reloadBuylasPrice_f(paymentKind, subtotal, changePrice )
{
	var paymentKind = paymentKind;
	var subtotal	= subtotal;
	var changePrice = changePrice;

	var url	= "/public/php/reloadBuylasPriceTotal.php.php?paymentKind=" + paymentKind + "&subtotal=" + subtotal + "&changePrice=" + changePrice;
	
	var requestAuctionPrice = new Request
	({
		url: tld + url,
		method: 'get',
		update: null,
		onComplete: function(response) 
		{	
			if( changePrice == "true" )
			{
				var tmpResponse = response.split("<||>");
				$("paymentKindId").innerHTML  	= tmpResponse[0];
				$("paymentCostId1").innerHTML	= tmpResponse[1];
				$("paymentCostId2").innerHTML	= tmpResponse[1];
				$("paymentTypeId1").innerHTML	= tmpResponse[2];
				$("paymentTypeId2").innerHTML	= tmpResponse[2];
			}
			else
			{
				$("paymentKindId").innerHTML  = response;
			}
		}
	})
		
	requestAuctionPrice.send()
		
}

function sendPayment( formName )
{
	
	var form = document.forms[formName];

	var len = form.length;
	var url = "";
	
	// alle formnamen und werte uebermitteln
	for(i=0; i<len; ++i)
	{
		if(i>0)
		{
			url += "&";	
		}
		url += form[i].name + "=" + form[i].value;
	}

	
	var url = "/public/php/createHashcode.php.php?" + url;
	var requestSendPayment = new Request
	({
		url: tld + url,
		method: 'get',
		update: null,
		onComplete: function(response) 
		{	
			if(response)
			{
				form.SHASign.value = response;
				document.formPayment.submit();
			}
		}
	})
		
	requestSendPayment.send();
}

function popupFunc(w,h,url) 
{
	x = screen.availWidth/2-w/2;
	y = screen.availHeight/2-h/2;
	
	var popupWindow = window.open
	(
		url,'','width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y+',scrollbars'
	);
}

function changePaymentType( kind, totalPrice, paymentKind, shipment )
{
	var kind 		= kind;
	var totalPrice	= totalPrice;
	var paymentKind = paymentKind;
	var shipment	= shipment;
	
	var url  = "/public/php/changePaymentType.php.php?kind=" + kind + "&totalPrice=" + totalPrice + "&paymentKind=" + paymentKind + "&shipment=" + shipment;

	var requestPaymentTypes = new Request
	({
		url: tld + url,
		method: 'get',
		update: null,
		onComplete: function(response) 
		{	
			var tmpResponse = response.split("<||>");
			$("paymentKindId").innerHTML = tmpResponse[0];
			$("payFormId").innerHTML	 = tmpResponse[1];
		}
	})
	requestPaymentTypes.send()

} 

// passwort sicherheit
var nCrackrate = 1000000000;	// woe oft soll das pw in der sekunden geknackt werden
var nTreshholddays = 365 * 100;	// Schwellwert, ab wann das Passwort als Sicher gilt
var nSteps = 10;				// css schritte

function contains(strText, strPattern)
{
	for (i = 0; i < strText.length; i++)
	{
		if (strPattern.indexOf(strText.charAt(i)) > -1) return true;
	}
	return false;
}

function checkPass(strPass, strId, strClassname, strTextId, aTexts)
{
	//alert('strPass:'+strPass+', strId:'+strId+', strClassname:'+strClassname+', strTextId:'+strTextId+',aTexts:'+aTexts);
	nCombinationCount = 0;
	
	strToCheck = "0123456789";			
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
	strToCheck = "abcdefghijklmnopqrstuvwxyz";	
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
	strToCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";	
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
	strToCheck = ",;:-_=+\|//?^&!.@$??#*()%~<>{}[]";
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;

	var nDays = ((Math.pow(nCombinationCount, strPass.length) / nCrackrate) / 2) / 86400;	// Wieviele Tage ben??tigt man?
	var nStrongness = Math.round(nDays / nTreshholddays * 100);				// Staerke errechnen
	if (nStrongness < (strPass.length * 5)) nStrongness += strPass.length * 5;		// Zeichenl??nge f??r St??rke ber??cksichtigen
	if (nStrongness > 100) nStrongness = 100;						// Max 100% zulassen
	nStrongness = Math.round(nStrongness / (100 / nSteps));					// Max Schritte

	oId = document.getElementById(strId); 
	oId.className = strClassname + "-" + nStrongness;
	otId = document.getElementById(strTextId);
	
	if (aTexts)
	{
		nKey = Math.round((aTexts.length - 1) / nSteps * nStrongness);
		otId.innerHTML = aTexts[nKey];
	}
}


function changeClassGroups( nr, maxNr, strId, classy, classActive )
{
	
	var nr			= nr;
	var maxNr		= maxNr;
	var strId		= strId;
	var classy		= classy;
	var classActive = classActive;

	var id 			= "";
	
	for( var i=1; i<=maxNr; ++i )
	{
		id	= strId + i;
		
		if( i == nr )
		{
			document.getElementById( id ).className = classActive;
		}
		else
		{
			document.getElementById( id ).className = classy;	
		}		
	}
}