

function create_video(afile, id, height){
	
	if(!height){
		var height = 300;
	}
	//alert(afile);
	var s1 = new SWFObject('http://www.eatv.tv/javascript/player.swf','player','100%',height,'9');
	s1.addParam('allowfullscreen','true');
	s1.addParam('flashvars','autostart=false&skin=http://www.eatv.tv/tools/glow.zip&file='+afile);
	s1.write(id);
	return true;
}

function create_audio(afile, id, height){
	
	if(!height){
		var height = 94;
	}
	
	var s1 = new SWFObject('http://www.eatv.tv/javascript/player.swf','player','100%','24','9');
	s1.addParam('allowfullscreen','true');
	s1.addParam('flashvars','autostart=false&skin=http://www.eatv.tv/tools/glow.zip&file=http://www.eatv.tv/media/audio/'+afile);
	s1.write(id);
}

function create_image(afile, id, height, caption){
	
	if(!height){
		var height = 500;
	}
	// get element by id and set img to the file
	var s1 = new SWFObject('http://www.eatv.tv/javascript/player.swf','player','100%',height,'9');
	s1.addParam('allowfullscreen','true');
	s1.addParam('flashvars','file=http://www.eatv.tv/media/picture/large/'+afile+'&controlbar=none&autostart=true');
	s1.write(id);
	
	if(caption){
		var cid = 'c_'+id;
		document.getElementById(cid).innerHTML = caption;
	}
	
	
}


$(document).ready(function(){
	
	//$('#gallery_wrp_xxx').hide();
	$(".hidden").hide();
	
	$("#gotoshow").change(function(){
		
		var newlink		= $(this).val();
		$('#gotolink').attr("href",newlink);
								   });
	
	//$(".comment_textarea").elastic();
	
	$(".comment_textarea").textlimit('div.ccounter',300);
					
	$(".comment_button").click(function(){
		
		var item_id		= $(this).attr("item_id");
		var element_id	= $(this).attr("element_id");
		var user_id		= $(this).attr("user_id");
		
		var txt			= $("#comment_"+item_id).val();
		
		$("#comment_box_area").empty().html('<img class="loading_gif"  src="../media/picture/large/loading.gif" />');
		 
		$.get("http://www.eatv.tv/frontend/display/add_comment.php", 
		  { item_id: item_id, element_id: element_id, comment: txt }, 
		  function(data){
			//$("#comment_"+item_id).val("")
			$("#comment_box_area").html(data);
			$("#comment_box_area").addClass("loading_gif");
			//alert(data); 
		  } 
		);
	});
	
	$('#toggle_comments').click(function(){
		var sta	= $(this).attr('state');
		if(sta == 0){
			$(this).attr('state',1);
			$(this).html('Show less');
		}else{
			$(this).attr('state',0);
			$(this).html('Show all');			
		}
		$('.comment_wrapper').filter('.hidden').toggle('slow');
	
	});
					
					
	$("a[ href='#']").click(function(){											
								
		$(this).parent().siblings().removeClass('gallery_link_on');
		$(this).parent().addClass('gallery_link_on');
	});
	
	$('a[rel*=facebox]').prettyPhoto() ;
	
	$(".gallery_link").click(function(){
		var s = $(this).attr('rel');
		
		
		$.get("http://www.eatv.tv/frontend/display/gallery.php", { name: s}, 
			function(data){ 
				$("#gallery_wrp_xxx").html(data);
		});
		
		if($('#gallery_wrp_xxx').is(':hidden')){
			$('#gallery_wrp_xxx').slideDown(1500,'easeInQuad', function(){});
		}
		
		$("#gallery_wrp_xxx").next(".wrapper_css_section").hide();
	});
});		

