/**
 * 19:56 23td apríl 2010
 *
 * general.js
 *
 * by Branislav Zvolensky
 */

// jQuery code
jQuery(document).ready(function($){
   // Error and Flash Messages
   $('div.flash-errors').delay(5000).fadeOut('slow');
   $('div.flash-messages').delay(5000).fadeOut('slow');
   
   // DELETE Confirmation
   $('a.delete').click(function(){
     var redirect = $(this).attr('href');
	 if(confirm('Ste si istý? Táto operácia je nezvratná!')){
	    self.location = redirect;
	 }
	 else{
	    return false;
	 }
   });
   
   // Svdobny salon submenu
   $("#sidebar1 .left_menu ul.submenu-179").css({"display":"none"});
	$("li.menu-item-179").mouseover(function(){
		$("#sidebar1 .left_menu ul.submenu-179").show();
	});
	$("li.menu-item-179").mouseleave(function(){
	    $("#sidebar1 .left_menu ul.submenu-179").hide();
	});

   
   /*
    * Following code set the same height to div #sidebar1 and div #mainContent
	* Uncomment if you want it applied
	*/
	/*
	var sidebarLeftHeight = $('#sidebar1').height();
	var sidebarRightHeight = $('#sidebar2').height();
	var contentHeight = $('#mainContent').height();
	if(contentHeight > sidebarLeftHeight){
	  $('#sidebar1').height(contentHeight);
	}
	if(contentHeight > sidebarRightHeight){
	  $('#sidebar2').height(contentHeight);
	}
	*/
   
   
   //Gallery page hacks Fancybox
   $("a.gallery_elements").fancybox();
   $(".img-link a").fancybox();
   
   // navBar hover
   $('div.menu-nav-bar .menu-item').mouseover(function(){
     $(this).addClass('hover');
   });
   
   $('div.menu-nav-bar .menu-item').mouseout(function(){
     $(this).removeClass('hover');
   });
   
   // loadForm Check
   var mrgTop = Math.round(($(window).height() - $("div.loader").height()) / 2) + 'px';
   var mrgLeft = Math.round(($(window).width() - $("div.loader").width()) / 2) + 'px';
   $("div.loader").css({"left":mrgLeft, "top":mrgTop});
   
   $("form").submit(function(){
   
   		$("div.loader").show();
		$(".frm-submit").attr('disabled', 'disabled');
		$("#buttonUpload").attr('disabled', 'disabled');
   
   });
   
   
   // Date picker
   $(function() {
		$("input[name=date]").datepicker();
	});
	
	//Texyla for content body
	$.texyla.setDefaults({
			texyCfg: "admin",
			//baseDir: 'texyla',
			previewPath: "preview.php",
			filesPath: "filesplugin/files.php",
			filesThumbPath: "filesplugin/thumbnail.php?image=%var%",
			filesUploadPath: "filesplugin/files/upload.php"
		});
		
		$(function () {			
			/*$("#formContentEdit-body").texyla({
				toolbar: [
					'h1', 'h2', 'h3',
					null,
					'bold', 'italic',
					null,
					'center', ['left', 'right', 'justify'],
					null,
					'ul', 'ol', ["olAlphabetSmall", "olAlphabetBig", "olRomans", "olRomansSmall"],
					null,
					{type: "label", text: "Vložiť"}, 'link', 'img', 'table', /*'emoticon',*/ /*'symbol',
					null,
					'color', //'textTransform',
					//'files', 'youtube',
					null,
					'div', ['html', 'blockquote', 'text', 'comment'],
					//null,
					//'code',	['codeHtml', 'codeCss', 'codeJs', 'codePhp', 'codeSql'], 'codeInline',
					null,
					{type: "label", text: "Ostatné"}, ['sup', 'sub', 'del', 'acronym', 'hr', 'notexy', 'web']
					
				],
				texyCfg: "admin",
				bottomLeftToolbar: ['edit', 'preview', 'htmlPreview'],
				buttonType: "span",
				tabs: true,
				language: "sk"
			});*/

			$("#formContentEdit-body").texyla({
				texyCfg: "admin",
				buttonType: "button",
				language: "sk"
			});
			
		});
});
