function showDiv(id, value)
	{
		if (value == true)
			document.getElementById(id).style.display = "block";
		else
			document.getElementById(id).style.display = "none";
	}

function acceptAGB()
{
    if(document.getElementById('agb_checkbox').checked) {
        document.getElementById('checkbox_upload').disabled = false;
        document.getElementById('checkbox_record').disabled = false;
        }
    else {
        document.getElementById('checkbox_upload').disabled = "disabled";
        document.getElementById('checkbox_record').disabled = "disabled";
        showDiv('videoAufnehmen', false);
        showDiv('dateiHochladen', false);
        }
}

function countSms()
	{
		anzahl = document.nachricht.kommentar.value.length + 1;
		document.nachricht.zeichen.value = anzahl;
		document.getElementById("smsVersand").innerHTML = Math.ceil(anzahl/160)+" SMS";
	}
	
var bubbleTemplate = new Template('<div id="#{id}" class="bubble"><div class="bubbleTop"></div><div class="bubbleCenter">#{content}</div><div class="bubbleBottom"></div>');
var bubbles = new Array();

//create a bubble
function createBubble(id, targetId, content) {
	 code = bubbleTemplate.evaluate({id: id, content: content});
	 if(new Insertion.Bottom(targetId, code)) { return true; }
	 else { return false; }
}

//showBubble('bubble_5', 'avatar', 'hello world', 40, 50);
function showBubble(id, targetId, content, topOffset, leftOffset) {
	tOffset = Position.cumulativeOffset($(targetId));
	if(bubbles[id] == null)
		bubbles[id] = createBubble(id, targetId, content);
	
	if(bubbles[id] == false)
		return;
					
	$(id).style.top =	-$(id).getHeight()-topOffset+"px";
	$(id).style.left =  -$(id).getWidth()+leftOffset+"px";
	
	$(id).setStyle({opacity:0.95, display: "block"});
}

function hideBubble(id) {
	$(id).setStyle({ display: "none"});
}

var ratingStars = new Array();

function hoverRatingStar(num) {
	for (i = 0; i <= num; i++) {
		ratingStars[i] = $('rating_star_'+i).src;
		$('rating_star_'+i).src = '/images/ico/star_hover.gif';
	}
}

function hoveroutRatingStar(num) {
	for (i = 0; i <= num; i++) {
		if (ratingStars[i])
			$('rating_star_'+i).src = ratingStars[i];
	}
}

function selectAllReceivers(set) {
    elements = document.getElementsByClassName('receiverCheckbox');
    
    var len = elements.length;
    for (var i = 0; i <= len-1; i++) {
        elements[i].checked = set;
    }
  
}