// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var html_box;

$(document).ready(function() {
  $('.kwicks').kwicks({  
    max: 205,  
    //min: 20,
    spacing: 5  
  });

  //$(document).everyTime(5000, function(i) {
  //  $.jGrowl("Somebody just logged in!!!");
  //}, 0);

  $('.kwicks a').each(function(kwick_link) {
    $(this).pageSlide({
      width: "600px",
      modal: true
    })
  });

	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");	
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});		

  $('#recently_published_rooms').each(function() {
    $.getJSON("/recently_published_rooms",
      function (data) {
        $('#recently_published_rooms_cross_fader').crossSlide({
          sleep: 2,
          fade: 2
        }, data);
    })
  });

  $("#newsletter_form").each(function() {
    html_box = $("#newsletter").htmlbox()
     // Cut, Copy, Paste
     .separator("dots").button("cut").button("copy").button("paste")
     // Undo, Redo
     .separator("dots").button("undo").button("redo")
     // Bold, Italic, Underline, Strikethrough, Sup, Sub
     .separator("dots").button("bold").button("italic").button("underline").button("strike")
     .button("sup").button("sub")
     // Left, Right, Center, Justify
     .separator("dots").button("left").button("center").button("right").button("justify")
     // Ordered List, Unordered List, Indent, Outdent
     .separator("dots").button("ol").button("ul").button("indent").button("outdent")
     // Hyperlink, Image
     .separator("dots").button("hyperlink").button("unlink").button("image")
     // Show code
     .separator("dots",2).button("code",2)
     // Formats, Font size, Font family, Font color, Font, Background
     .separator("dots",2).button("formats",2).button("fontsize",2).button("fontfamily",2)
     .button("fontcolor",2).button("highlight",2)
     // Strip tags
     .separator("dots",2).button("removeformat",2).button("striptags",2).button("hr",2).button("paragraph",2)
     // Styles
     .separator("dots",3).button("quote",3)
     // Styles
     .separator("dots",3).button("styles",3)
     // Source code syntax buttons
     .separator("dots",3).button("syntax",3);
    html_box.init();
    $(this).submit(function(event) {
      $("#newsletter").innerHTML = html_box.get_html();
    });
  });
});
