
$(document).ready(function() {


// hide the sms-servant-links...
//$(".bo-buy-smslink").hide();
$(".bo-buy-smslink").css("height", "auto");
$(".bo-buy-smslink").css("position", "absolute");

$(".bo-buy-smslink").css("display", "none");
//$(".bo-buy-smslink").hide();



//$(".bo-cell").css("float", "left");


// uncheck and show the checkboxes...

$(".bo-buy-checkbox :checked").removeAttr('checked');

//$(".bo-buy-checkbox").show();

$(".bo-buy-checkbox").attr("class", "bo-buy-checkbox bo-buy-checkbox-visible");

// add float to buy-buttons...
$(".bo-buy-button").css("float", "left");


// minor height to cells...
$(".bo-cell").css("height", "145px");

// get orig prices

pricesOrig = new Array ();
pricesAdd = new Array ();
pricesNew = new Array ();

var origPrice;
var addPrice;
var newPrice;

var count = 0;      			
$("strong").children(".bo-price").each(function (i) {
	
	origPrice = this.firstChild.data;
	
	
	pricesOrig[i] = origPrice;
	
	count++;
	
});

var count = 0;  
var temp;    			
$("label").children(".bo-price").each(function (i) {

	addPrice = this.firstChild.data;
	addPrice = Number(addPrice.replace(",", "."));
	
	//alert(addPrice);
	
	pricesAdd[i] = addPrice;
	
	
	temp = pricesOrig[i];
	temp = Number(temp.replace(",", "."));
	
	newPrice = temp + addPrice;
	
	newPrice = String(newPrice);
	
	// http://forum.de.selfhtml.org/archiv/2002/8/t19887/
	if(newPrice.length-newPrice.lastIndexOf(".")-1==1)newPrice+="0";
	
	// Und fuer die Faelle ohne Nachkommastelle:
	if(newPrice.length-newPrice.lastIndexOf(".")-1==newPrice.length)newPrice+=".00";
	
	newPrice = newPrice.replace(".", ",");
	
	pricesNew[i] = String(newPrice + ' incl.');
	
	count++;
});
      			
      			
      			

np = new Array ();
op = new Array ();
var count = 0; 
$(".bo-buy-checkbox :checkbox").each(function (i) {
	
	// neue preise in neuem array sepichern...
	op[i]= String(pricesOrig[i]);
	
	// neue preise in neuem array sepichern...
	np[i]= String(pricesNew[i]);
	
	$(this).click(function () {
	

			// var allText = $(this).next().text();
			//allText = allText.replace('incl. ', '+');
			//$(".bo-buy-checkbox :checkbox").next().text(allText);
	
		
	
		if ($(this).parent().prev().prev().prev().children().children().children().text() == op[i] ) {
		


			var urlsms = $(this).parent().prev().prev().children("a").attr( 'href' );
			urlsms = urlsms.replace('.html', 'sms.html');
			$(this).parent().prev().prev().children("a").attr( 'href', urlsms );

			//alert(urlsms);


			$(this).parent().prev().prev().prev().children().children().children().text(np[i]);
			
			var newText = $(this).next().text();
			newText = newText.replace('+', 'incl. ');
			$(this).next().text(newText);
			
			
			
			//alert(newText);
			



		
		} else {
		
		
			var url = $(this).parent().prev().prev().children("a").attr( 'href' );
			url = url.replace('sms.html', '.html');
			$(this).parent().prev().prev().children("a").attr( 'href', url );

			//alert(url);		
		

			$(this).parent().prev().prev().prev().children().children().children().text(op[i]);
			
			
			var newText = $(this).next().text();
			newText = newText.replace('incl. ', '+');
			$(this).next().text(newText);
			
		
		}	
			$(this).parent().prev().prev().prev().children().children().children().hide();
			$(this).parent().prev().prev().prev().children().children().children().fadeIn("slow");
			
			
			
	
		
	});	
	
	count++;
	
});


pricesOrig = pricesOrig.join(" | ");      			
pricesAdd = pricesAdd.join(" | ");      			
pricesNew = pricesNew.join(" | ");      			

//alert(pricesOrig + '\n' + pricesAdd + '\n' + pricesNew);




  
    




}); 
 
 
 
