/*var blogtags=[];

$(window).load(function(){
	syncTags();
});*/

$(document).ready(function(){
	$("#suche").keyup(function (e) {
		search();
	});
});

function tagsuche(elem){
	$("#suche").attr('value',$(elem).text());
	search();
}

function embedFilm(vidsrc,id){
	var flashvars = {
		flv: vidsrc,
		width: '510',
		height: '383',
		showvolume: '1',
        autoplay: '0',
        allowFullScreen: true,
        showfullscreen:'1',
        bgcolor: '000000',
        bgcolor1: '000000',
        bgcolor2: '000000',
        loadingcolor: 'ffffff',
        sliderovercolor: 'ffffff',
        buttonovercolor: 'ffffff',
        showiconplay: '1',
        showtime: '1'
    };
    
    var params = {
	  allowFullScreen: true
	};

	new swfobject.embedSWF('flash/videoplayer.swf', id, "510", "383", "9.0.0", "public/expressInstall.swf", flashvars, params);
}

/*
function addTag(tagname){
	// kommt tagname in tags bereits vor?
	var kommt_vor = false;
	for (var pos in blogtags){
		if (blogtags[pos] == tagname)
			kommt_vor = true;
	}
	
	// Falls nicht, dann einfügen
	if (kommt_vor == false){
		blogtags.push(tagname);
		var removehtml = "$(this).remove(); for (var pos in blogtags){ if (blogtags[pos] == '"+tagname+"') blogtags.splice(blogtags.indexOf('"+tagname+"'), 1); } delTag('"+tagname+"'); getAllByTags()";
		var html = '<input type="button" id="tag_'+tagname+'" value="'+tagname+'" onclick="'+removehtml+'" />';
		$(".tags_container").append(html);
		getAllByTags();
	}
}

function delTag(name){
	$.post("./Blogentries/deltag", {'tag': name} ,function(data){});
	getAllByTags()
}

function getAllByTags(){
	$.post("./Blogentries/allbytags", {'tags[]': blogtags} ,function(data){
		$(".rightSide .dynamic").html(data);
	});
}

function syncTags(){
	// wird beim Laden einer Blog oder Know Seite ausgelöst, um die bisher gebrauchten Tags anzuzeigen
		$.get("./Blogentries/getallusedtags", {} ,function(data){
			var tags = eval('(' + data + ')');
		
			for ( var pos in tags.tags ){				
				blogtags.push(tags.tags[pos]);
				var removehtml = "$(this).remove(); for (var pos in blogtags){ if (blogtags[pos] == '"+tags.tags[pos]+"') blogtags.splice(blogtags.indexOf('"+tags.tags[pos]+"'), 1); } delTag('"+tags.tags[pos]+"');";
				var html = '<input type="button" id="tag_'+tags.tags[pos]+'" value="'+tags.tags[pos]+'" onclick="'+removehtml+'" />';
				$(".tags_container").append(html);	
			}
			getAllByTags();
		});
}
*/
function search(){
	//wird ausgelöst, wenn im seitlichen Suchfeld etwas eingegeben wurde.
	$.post("./Blogentries/search", {'search': $("#suche").val()} ,function(data){
		$(".rightSide .dynamic").html(data);
	});
}
