$(function($)
{
  $('#textnews').wysiwyg({
    controls: {
      strikeThrough : { visible : true },
      underline     : { visible : true },
      
      
      justifyLeft   : { visible : true },
      justifyCenter : { visible : true },
      justifyRight  : { visible : true },
      justifyFull   : { visible : true },
      
      
      indent  : { visible : true },
      outdent : { visible : true },
      
      
      subscript   : { visible : true },
      superscript : { visible : true },
      
      
      undo : { visible : true },
      redo : { visible : true },
      
      
      insertOrderedList    : { visible : true },
      insertUnorderedList  : { visible : true },
      insertHorizontalRule : { visible : true },

      
      cut   : { visible : true },
      copy  : { visible : true },
      paste : { visible : true },
	  html : { visible : true },
	  
     youtube: {
            visible: true,
			icon: "/template/images/youtube.jpg",
            exec: function(){
				var $dialog = $("#dialog").html('<input type="text" id="youtubelink">').dialog({
					title: 'Youtube',
				    autoOpen: false,
				    buttons: [{
						  text: 'Add',
						  click: function(e) {
							if($(this).is(':visible')){
								var idtube = $('#youtubelink').attr('value');
								var youtubecode = '<object width="650" height="500"><param name="movie" value="http://www.youtube-nocookie.com/v/'+idtube+'?fs=1&amp;hl=ru_RU"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/'+idtube+'?fs=1&amp;hl=ru_RU" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="650" height="500"></embed></object>';
								$('#textnews').wysiwyg('insertHtml', youtubecode);
							}
						  }
				    },
					{
					text: 'Close',
					click: function(e) {
						if($(this).is(':visible')){
						
						}else{
				        $(this).dialog('close');
						}
				      }
					}
					]
				  });
				  $dialog.dialog('open');
				//insertHtml('Hello World'); 
			},
            className: 'youtube'
        },
		
		video: {
            visible: true,
			icon: "/template/images/video.jpg",
            exec: function(){
				
				var $dialog = $("#dialogv").html('<input type="text" id="vlink">').dialog({
					title: 'Video',
				    autoOpen: false,
				    buttons: [{
						  text: 'Add',
						  click: function(e) {
							if($(this).is(':visible')){
								var idtube = $('#vlink').attr('value');
								var yaxaxa = 'http://ya-xa-xa.ru/template/uflvplayer_500x375.swf';
								var youtubecode = '<OBJECT height=300 width=400><PARAM NAME="movie" VALUE="'+yaxaxa+'"><param name="wmode" VALUE="transparent"><param name=FlashVars value="way='+idtube+'&swf='+yaxaxa+'&time_seconds=500&w=400&h=300&pic=http://&autoplay=0&tools=1&skin=white&volume=70&comment="><embed src='+yaxaxa+' type="application/x-shockwave-flash" wmode="transparent" flashvars="way='+idtube+'&swf='+yaxaxa+'&time_seconds=500&w=400&h=300&skin=white&pic=http://&autoplay=0&tools=1&volume=70&comment=" width="400" height="300"></embed></OBJECT>';
								$('#textnews').wysiwyg('insertHtml', youtubecode);
							}
						  }
				    },
					{
					text: 'Close',
					click: function(e) {
				        if($(this).is(':visible')){
						
						}else{
				        $(this).dialog('close');
						}
				      }
					}
					]
				  });
				 
				  $dialog.dialog('open');
				   
			},
            className: 'video'
        }

    }
  });
  
  /*shorturl*/
  $('#shorturl').click(function(){
	var value = $('#title').attr('value').replace(' ','-');
	value = value + '.html';
	$('#shorturl').attr('value', value);
  });
  
  $( "#datepicker" ).datepicker();
  
  $("#clock").clock({"format":"24","calendar":"true","langSet":"ru"});
  
  	$('#gallery a').lightBox(); // Select all links in object with gallery ID
});

