function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();	
	var textlength = text.length;
	if(textlength > limit)
	{
		$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html('noch '+ (limit - textlength) +' Zeichen übrig.');
		return true;
	}
}

$(function(){
 	$('#comment').keyup(function(){
 		limitChars('comment', 160, 'charlimitinfo');
 	})
	$('#comment1').keyup(function(){
 		limitChars('comment1', 1000, 'charlimitinfo');
 	})
});

function findeFlash (flash) {
if (document.all) {
  if (document.all[flash]) {
	return document.all[flash];
  }
  if (window.opera) {
	var movie = eval(window.document + flash);
	if (movie.SetVariable) {
	  return movie;
	}
  }
  return;
}
if(document.layers) {
  if(document.embeds) {
	var movie = document.embeds[flash];
	if (movie.SetVariable) {
	  return movie;
	}
  }
  return;
}
if (!document.getElementById) {
  return;
}
var movie = document.getElementById(flash);
if (movie.SetVariable) {
  return movie;
}
var movies = movie.getElementsByTagName('embed');
if (!movies || !movies.length) {
  return;
}
movie = movies[0];
if (movie.SetVariable) {
  return movie;
}
return;
}

function startm(id, path){
	var movie = findeFlash('player');
	if (id < 10) id='000'+id;
	else if (id < 100) id='00'+id;
	else if (id < 1000) id='0'+id;
	movie.StopPlay();
	movie.SetVariable('autostart', 'yes');
	movie.SetVariable('src', 'sounds'+path+'/agent_'+id+'.mp3');
	movie.Rewind();
	movie.Play();
}

function stopm(){
	var movie = findeFlash('player');
	movie.StopPlay();
	movie.SetVariable('autostart', 'no');
	movie.Rewind();
	movie.Play();
}
