// ------------------------------------
//  Highlight Comment - Form
// -------------------------------------
$(function() { 
    $("div.entry").bind("click keydown", function() { 

        $(this).expose({ 

            // custom mask settings with CSS 
            maskId: 'mask', 
			color: '#000', 
		    opacity: 0.7,

            onLoad: function() { 
				var cssObj = {
			        'background-color' : '#FFFFFF'
			     }
                this.getExposed().css(cssObj); 
            }, 

            onClose: function() { 
				var cssObj = {
			        'background-color' : 'transparent'
			     }
                this.getExposed().css(cssObj); 
            }, 

            api: true 
        }).load(); 
    }); 
});				
// ------------------------------------
//  Videos - Youtube
// -------------------------------------
$(document).ready(function() { 
	$("a.youtube").click(function(){
		var id = $(this).attr('id');
		var objclass = "y" + id;
		
		var obj = $(objclass);
		
		if ( $('div.' + objclass).length )
		{
			var iheight = $('div.'+objclass).height() * -1;
			$('div.' + objclass).remove();
			cols_resize_col1(iheight);
		} else 
		{
			$(this).after(
				"<div class='comment_video " + objclass + "'>" +
				"<object width='100%' height='100%'><param name='movie' value='http://www.youtube-nocookie.com/v/" + id + "&fs=1&color1=0x234900&color2=0x4e9e00'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always' wmode='transparent'></param><embed src='http://www.youtube-nocookie.com/v/" + id  +"&fs=1&color1=0x234900&color2=0x4e9e00' type='application/x-shockwave-flash' allowscriptaccess='always' wmode='transparent' allowfullscreen='true' width='100%' height='100%'></embed></object>" + 
				"<p> <a href='http://www.youtube.com/v/" + id +"&amp;fs=1&amp;rel=0&amp;hd=1&amp;autoplay=1' toptions='width = 853, height = 505, type = flash'>Video vergrössern</a>" + 
				" | <a href='http://www.youtube.com/watch?v=" + id + "' target='_blank'>Youtube-Link</a>"+
				" | <a href='#' onclick='remove_video(\"" + objclass +  "\"); return false;'>Video ausblenden</a>" +
				"</p>" + 
				"</div>"
			);
			cols_resize_col1($('div.'+objclass).height());
		}
		return false;
	});
});	
// ------------------------------------
//  Videos - Sevenload
// -------------------------------------
$(document).ready(function() { 
	$("a.sevenload").click(function(){
		var id = $(this).attr('id');
		var objclass = "s" + id;
		
		var obj = $(objclass);
		
		if ( $('div.' + objclass).length )
		{
			var iheight = $('div.'+objclass).height() * -1;
			$('div.' + objclass).remove();
			cols_resize_col1(iheight);
		} else 
		{
			$(this).after(
				"<div class='comment_video " + objclass + "'>" +
				"<object type='application/x-shockwave-flash' data='http://de.sevenload.com/pl/" + id + "/400x219/swf' width='100%' height='100%'><param name='allowFullscreen' value='true' /><param name='allowScriptAccess' value='always' /><param name='movie' value='http://de.sevenload.com/pl/" +  id + "/400x219/swf' /></object>"+
				"<p><a href='http://de.sevenload.com/videos/" + id + "' toptions='width = 853, height = 505, type = flash'>Video vergrössern</a>" + 
				" | <a href='http://de.sevenload.com/videos/" + id + "' target='_blank'>Sevenload-Link</a>" +
				" | <a href='#' onclick='remove_video(\"" + objclass +  "\"); return false;'>Video ausblenden</a>" +
				"</p>" + 
				"</div>"
			);
			cols_resize_col1($('div.'+objclass).height());
		}
		return false;
	});
});
// ------------------------------------
//  Videos - Vimeo
// -------------------------------------
$(document).ready(function() { 
	$("a.vimeo").click(function(){
		var id = $(this).attr('id');
		var objclass = "s" + id;
		
		var obj = $(objclass);
		
		if ( $('div.' + objclass).length )
		{
			var iheight = $('div.'+objclass).height() * -1;
			$('div.' + objclass).remove();
			cols_resize_col1(iheight);
		} else 
		{
			$(this).after(
				"<div class='comment_video " + objclass + "'>" +
				"<object width='400' height='225'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=" + id + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=298c12&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=" + id + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=298c12&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='400' height='225'></embed></object>" + 
				"<p><a class='tu_iframe_640x460' href='http://bildschirmarbeiter5/topup/vimeo/" + id + "/'>Video vergrössern</a>" + 
				" | <a href='http://vimeo.com/" + id + "' target='_blank'>Vimeo-Link</a>" +
				" | <a href='#' onclick='remove_video(\"" + objclass +  "\"); return false;'>Video ausblenden</a>" +
				"</p>" + 
				"</div>"
			);
			cols_resize_col1($('div.'+objclass).height());
		}
		return false;
	});
});
// ------------------------------------
//  Videos - MyVideo
// -------------------------------------
$(document).ready(function() { 
	$("a.myvideo").click(function(){
		var id = $(this).attr('id');
		var objclass = "s" + id;
		
		var obj = $(objclass);
		
		if ( $('div.' + objclass).length )
		{
			var iheight = $('div.'+objclass).height() * -1;
			$('div.' + objclass).remove();
			cols_resize_col1(iheight);
		} else 
		{
			$(this).after(
				"<div class='comment_video " + objclass + "'>" +
				"<object style='width:425px;height:260px;' width='425' height='260'><param name='movie' value='http://www.myvideo.de/movie/" + id + "'></param><param name='AllowFullscreen' value='true'></param><param name='AllowScriptAccess' value='always'></param><embed src='http://www.myvideo.de/movie/" + id + "' width='425' height='260' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true'></embed></object>"+
				"<p><a class='tu_iframe_640x460' href='http://bildschirmarbeiter5/topup/myvideo/" + id + "/'>Video vergrössern</a>" + 
				" | <a href='http://www.myvideo.de/watch/" + id + "/' target='_blank'>MyVideo-Link</a>" +
				" | <a href='#' onclick='remove_video(\"" + objclass +  "\"); return false;'>Video ausblenden</a>" +
				"</p>" + 
				"</div>"
			);
			cols_resize_col1($('div.'+objclass).height());
		}
		return false;
	});
});
// ------------------------------------
//  Videos - clipfish
// -------------------------------------
$(document).ready(function() { 
	$("a.clipfish").click(function(){
		var id = $(this).attr('id');
		var objclass = "s" + id;
		
		var obj = $(objclass);
		
		if ( $('div.' + objclass).length )
		{
			var iheight = $('div.'+objclass).height() * -1;
			$('div.' + objclass).remove();
			cols_resize_col1(iheight);
		} else 
		{
			$(this).after(
				"<div class='comment_video " + objclass + "'>" +
				"<object width='400' height='331'><param name='allowScriptAccess' value='always' /><param name='movie' value='http://www.clipfish.de/cfng/flash/clipfish_player_3.swf?as=0&videoid=" + id + "&r=1&angebot=extern&c=319700' /><param name='bgcolor' value='#ffffff' /><param name='allowFullScreen' value='true' /><embed src='http://www.clipfish.de/cfng/flash/clipfish_player_3.swf?as=0&vid="+ id +"&r=1&angebot=extern&c=319700' quality='high' bgcolor='#319700' width='400' height='331' name='player' align='middle' allowFullScreen='true' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>"+
				"<p><a class='tu_iframe_640x460' href='http://bildschirmarbeiter5/topup/clipfish/" + id + "/'>Video vergrössern</a>" + 
				" | <a href='http://www.clipfish.de/video/" + id + "/' target='_blank'>Clipfish-Link</a>" +
				" | <a href='#' onclick='remove_video(\"" + objclass +  "\"); return false;'>Video ausblenden</a>" +
				"</p>" + 
				"</div>"
			);
			cols_resize_col1($('div.'+objclass).height());
		}
		return false;
	});
});
// ------------------------------------
//  Videos - google
// -------------------------------------
$(document).ready(function() { 
	$("a.google").click(function(){
		var id = $(this).attr('id');
		var objclass = "s" + id;
		
		var obj = $(objclass);
		
		if ( $('div.' + objclass).length )
		{
			var iheight = $('div.'+objclass).height() * -1;
			$('div.' + objclass).remove();
			cols_resize_col1(iheight);
		} else 
		{
			$(this).after(
				"<div class='comment_video " + objclass + "'>" +
				"<embed id=VideoPlayback src=http://video.google.de/googleplayer.swf?docid="+ id +"&hl=de&fs=true style=width:400px;height:326px allowFullScreen=true allowScriptAccess=always type=application/x-shockwave-flash> </embed>"+
				"<p><a class='tu_iframe_640x460' href='http://bildschirmarbeiter5/topup/google/" + id + "/'>Video vergrössern</a>" + 
				" | <a href='http://video.google.de/videoplay?docid=" + id + "#' target='_blank'>Video.Google-Link</a>" +
				" | <a href='#' onclick='remove_video(\"" + objclass +  "\"); return false;'>Video ausblenden</a>" +
				"</p>" + 
				"</div>"
			);
			cols_resize_col1($('div.'+objclass).height());
		}
		return false;
	});
});






function remove_video(objclass)
{
	if ( $('div.' + objclass).length )
	{
		var iheight = $('div.'+objclass).height() * -1;
		$('div.' + objclass).remove();
	} 
	return false;
}




$(document).ready(function() { 
	$("a.image_preview").mouseover(function(){
		var rel = $(this).attr( 'rel' );
		var src = $("#" + rel).attr( 'src' );
		var width = $("#" + rel).attr( 'width' );
		var height = $("#" + rel).attr( 'height' );
		var div = width / height;
		var newheight = 150 / div;
		$("div.image_tooltip").html("<img src=\"" + src + "\" width=\"" + 150 + "\" height=\"" + newheight + "\"/>");
//		$("a.image_preview").tooltip('.image_tooltip');
		$("a.image_preview").tooltip({ 


		    // a little tweaking of the position 
		    offset: [-10, -130], 

		    // use the built-in fadeIn/fadeOut effect 
		    effect: "fade", 

		    // custom opacity setting 
		    opacity: 0.9, 

		    // use this single tooltip element 
		    tip: '.image_tooltip' 

		});		
	});
});
	// ------------------------------------
//  Edit Comment Box
// -------------------------------------
function edit_comment(comment_id)
{
	var ourBox = document.getElementById('edit_comment_box_'+comment_id);
	
	if (ourBox.style.display == 'none') {
		ourBox.style.display = 'block';
		$('div#col1').height($("#col1").height() + $("div.editCommentBox").height());
		$('div#col2').height($("#col2").height() + $("div.editCommentBox").height());

	}
	else {
		ourBox.style.display = 'none';
		$('div#col1').height($("#col1").height() - $("div.editCommentBox").height());
		$('div#col2').height($("#col2").height() - $("div.editCommentBox").height());
	}
}

// ------------------------------------
//  Handles the AJAX Requests
// -------------------------------------    
function submit_edited_comment(comment_id)
{
	try
	{
		XMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e2)
		{
			XMLHttp = null;
		}
	}
	
	if( ! XMLHttp && typeof XMLHttpRequest != "undefined")
	{
		XMLHttp = new XMLHttpRequest();
	}
	
	if ( ! XMLHttp)
	{
		alert('Browser Not Support'); return false;
	}
	
	var bleah = document.getElementById('edit_comment_box_'+comment_id);
	
	var content = bleah.getElementsByTagName('textarea')[0].value;
	
	var data =  "comment_id=" + encodeURIComponent(comment_id) + 
				"&comment=" + encodeURIComponent(content);
	
	XMLHttp.onreadystatechange = function () { result_of_comment_edit(comment_id); }
	XMLHttp.open("POST", "http://www.bildschirmarbeiter.com/global/edit_comment/", true);
	XMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	XMLHttp.setRequestHeader("Connection", "close");
	XMLHttp.send(data);
}


function result_of_comment_edit(comment_id)
{
	if (XMLHttp.readyState == 4)
	{
		document.getElementById('edit_comment_box_'+comment_id).style.display = 'none';
	
		if (XMLHttp.status != 200) 
		{
			alert("An error was encountered: " + XMLHttp.status);
			return;
		}
		
		var response = XMLHttp.responseText;
		
		if (response == 'null')
		{
			alert('Invalid Comment Edit');
			return;
		}
		
		document.getElementById('comment_box_' + comment_id).innerHTML = response;
	}
}