jQuery(function() {
    jQuery('.wymeditor').wymeditor({
		
		toolsItems: [
        {'name': 'Bold', 'title': 'Strong', 'css': 'wym_tools_strong'}, 
        {'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'},
        {'name': 'InsertOrderedList', 'title': 'Ordered_List',
            'css': 'wym_tools_ordered_list'},
        {'name': 'InsertUnorderedList', 'title': 'Unordered_List',
            'css': 'wym_tools_unordered_list'},
				{'name': 'Undo', 'title': 'Undo', 'css': 'wym_tools_undo'},
        {'name': 'Redo', 'title': 'Redo', 'css': 'wym_tools_redo'},
		//		{'name': 'InsertImage', 'title': 'Image', 'css': 'wym_tools_image'},
        {'name': 'CreateLink', 'title': 'Add Link', 'css': 'wym_tools_link'},
        {'name': 'Unlink', 'title': 'Remove Link', 'css': 'wym_tools_unlink'},
        {'name': 'Preview', 'title': 'Preview', 'css': 'wym_tools_preview'}
    ],
		boxHtml:   "<div class='wym_box'>"
              + "<div class='wym_area_top'>" 
              + WYM_TOOLS
              + "</div>"
              + "<div class='wym_area_main'>"
              + WYM_HTML
              + WYM_IFRAME
              + WYM_STATUS
              + "</div>"
              + "</div>",
		});
		jQuery('.wymeditorIntro').wymeditor({
		
		toolsItems: [
        {'name': 'Bold', 'title': 'Strong', 'css': 'wym_tools_strong'}, 
        {'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'},
        {'name': 'InsertOrderedList', 'title': 'Ordered_List',
            'css': 'wym_tools_ordered_list'},
        {'name': 'InsertUnorderedList', 'title': 'Unordered_List',
            'css': 'wym_tools_unordered_list'},
				{'name': 'Undo', 'title': 'Undo', 'css': 'wym_tools_undo'},
        {'name': 'Redo', 'title': 'Redo', 'css': 'wym_tools_redo'},
				{'name': 'CreateLink', 'title': 'Add Link', 'css': 'wym_tools_link'},
        {'name': 'Unlink', 'title': 'Remove link', 'css': 'wym_tools_unlink'},
        {'name': 'Preview', 'title': 'Preview', 'css': 'wym_tools_preview'}
    ],
		boxHtml:   "<div class='wym_box'>"
              + "<div class='wym_area_top'>" 
              + WYM_TOOLS
              + "</div>"
              + "<div class='wym_area_main'>"
              + WYM_HTML
              + WYM_IFRAME
              + WYM_STATUS
              + "</div>"
              + "</div>",
		});
});
$(document).ready(function(){
  if($("form#comment").length && !$("p.error").length) {
    $(".comments h3")
	  .append("<p class='small'><a href='' id='showThis' title='Add comment'>Add your comment [+]</a></p>");
    $("form#comment").hide();
  } 
  if($("form#comment").length && $("p.error").length) {
    $(".comments h3")
	  .append("<p class='small'><a href='' id='showThis' title='Hide Form'>Hide Form [-]</a></p>");
	$('input#name').focus();
  }
  if($("form#comment").length) {
  $("p.small a#showThis").toggle(function() {
		  $("form#comment").slideDown();
			$("a#showThis").text('Hide Form [-]');
			$("a#showThis").attr({ title: "Hide Form" });
			$('input#name').focus();
	}, function() {
		  $("form#comment").slideUp();
			$("a#showThis").text('Add your comment [+]');
			$("a#showThis").attr({ title: "Add comment" });
	});
	}
		/*click(function(){
		$("form#comment").
		return false;
	});*/
	
	
	/*	
	if ($("form#comment").show()) {
		  $("p.small a").text("Hide comment");
			$("p.small a").attr({ title: "Hide Comment" });
	} else {
		  $("p.small a").text("Add comment");
			$("p.small a").attr({ title: "Add Comment" });
	};
  */
 	$("#comment input").focus(function() {
	  $(this).addClass("hasFocus");
	});
	$("#comment input").blur(function() {
	  $(this).removeClass("hasFocus");
	});
	$("#comment textarea").focus(function() {
	  $(this).addClass("hasFocus");
	});
	$("#comment textarea").blur(function() {
	  $(this).removeClass("hasFocus");
	});
	$("div.snappio ul img").wrap("<div class='wrap'></div>");
	$("div#sidebar ul.gallery img").wrap("<div class='wrap'></div>");
    $("div.wrap").append("<img class='hover' src='/img/hover.png' />");
		
	$("div.wrap").hover(function() {
	  $(this).append("<img class='hover_gloss' src='/img/hover_gloss.png' />");
	},function() {
	  $('img').remove(".hover_gloss");
	});
	
});
