/* * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * 
  
   THIS IS FIRED AS NEEDED   

* * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * **/	



	jQuery.fn.clearForm = function() {
  		return this.each(function() {
			 var type = this.type, tag = this.tagName.toLowerCase();
			 if (tag == 'form')
			   return $(':input',this).clearForm();
			 if (type == 'text' || type == 'password' || tag == 'textarea')
			   this.value = '';
			 else if (type == 'checkbox' || type == 'radio')
			   this.checked = false;
			 else if (tag == 'select')
			   this.selectedIndex = -1;
		});
	};   

jQuery.fn.enableLinks = function(){
	$("[id^='thing_wrapper_']").each(function() {
		var orig_url = $(this).parent('a').attr("tempref");
		$(this).parent('a').attr("href", orig_url);
		$(this).parent('a').addClass("external");		
		$(this).parent('a').removeAttr("tempref");		
	});
};	

jQuery.fn.enableItemTools = function(){
	$(".list_item").hover(function(){
		$(this).find(".item_tools").show(); 
	}, 
	function(){
		$(this).find(".item_tools").hide();
	});
};


// Jukebox *************************************************************************************************
$('#sortable > .mp3 > .clickable').live('click', function() {                                              
		var thing_id = this.id.replace("thing_wrapper_", "");         
		$("#jukebox_"+thing_id).slideToggle("fast"); 
		$("#jukebox_"+thing_id).load("/lists/audioplayer/" + thing_id);
		});

// Fancybox *************************************************************************************************

			jQuery.fn.enableFancyBox = function(){
				$(".modal").fancybox({
						'padding'	   			: 0,
						'autoScale'	   			: true,
						'transitionIn' 			: 'elastic',
						'transitionOut'			: 'fade',
						'zoomSpeedIn'			: 600,
						'zoomSpeedOut'			: 500,
						'easingIn'				: 'easeOutBack',
						'easingOut'				: 'easeInBack',
						'showTitle'				: 'false',
						'scrolling'				: 'no',
						'onComplete'		:	function() {
							$.fancybox.resize();
						}
					});
				};


// Bumps *************************************************************************************************

			jQuery.fn.Bumpit = function(intShakes /*Amount of shakes*/, intDistance /*Shake distance*/, intDuration /*Time duration*/) {
			    this.each(function() {
			    $(this).css({position:'relative'});
			    for (var x=1; x<=intShakes; x++) {
			    $(this).animate({top:(intDistance*-1)}, (((intDuration/intShakes)/4)))
			    .animate({top:intDistance}, ((intDuration/intShakes)/2))
			    .animate({top:0}, (((intDuration/intShakes)/4)));
			    }
			});
			return this;
			};

			jQuery.fn.NoNo = function(intShakes /*Amount of shakes*/, intDistance /*Shake distance*/, intDuration /*Time duration*/) {
			    this.each(function() {
			    $(this).css({position:'relative'});
			    for (var x=1; x<=intShakes; x++) {
			    $(this).animate({left:(intDistance*-1)}, (((intDuration/intShakes)/4)))
			    .animate({left:intDistance}, ((intDuration/intShakes)/2))
			    .animate({left:0}, (((intDuration/intShakes)/4)));
			    }
			});
			return this;
			};


// Email Sharing *************************************************************************************************

	// set up ajax share by email form
	function showEmailFormRequest()  {
	    $('#email_form_result').effect('highlight');
	    $('#email_form_container').fadeTo('1').slideUp();
		}

	function HideThisDiv(id) { 
	    $(id).slideUp();		
		}

		function ShowThisDiv(id) { 
		    $(id).slideDown();		
			}

	// settings for email form 
	var ajax_text_form_options = { 
	    target:        '#email_form_result',    // target element(s) to be updated with server response 
	    beforeSubmit:  showEmailFormRequest,  		    // pre-submit callback 
	    success:       HideThisDiv('.email_results'), 		    // post-submit callback 
	    clearForm: false,       			    // clear all form fields after successful submit 
	    resetForm: true,        			    // reset the form after successful submit 
	    timeout:   3000                         
	} 	




// Pagination *************************************************************************************************


	// initializes links for ajax requests
	$(".endless_more").live("click", function(){
	    var container = $(this).closest(".endless_container");
	    var loading = container.find(".endless_loading");
	    $(this).hide();
	    loading.show();
	    $.get($(this).attr("href"), function(data){
	        container.before(data);
        	    container.enableFancyBox();
	        container.remove();
	    });
	    return false;
	});

		
// Togglers *************************************************************************************************

		function toggleFavorite(cid){
			$("#update_favorite_" + cid).children('.toggleFavorite').html('<img src="/media/images/waiting-small.gif"/>').load("/lists/toggle_favorite/" + cid);
		}   

		function flagList(cid){
		    $("#inappropriate_flag").load("/lists/flag/" + cid);
		}

		function toggleOrdering(cid){
			$("#ordering").html('<img src="/media/images/waiting-small.gif"/>');
			$("#sortable").toggleClass("numbered");
			$("#ordering").load("/lists/toggle_ordering/" + cid + "/", {}, function(){
				// ADD LOGIC TO TOGGLE CHECKLISTS
			}).effect("highlight", {}, 2000);
		}

		function togglePrivacy(cid){
			$("#privacy").html('<img src="/media/images/waiting-small.gif"/>');
			$("#privacy").load("/lists/toggle_visible/" + cid + "/", {}, function(){
			}).effect("highlight", {}, 2000);
		}
		
		function toggleChecklist(cid){
			$("#checklist").html('<img src="/media/images/waiting-small.gif"/>');
			$("#checklist").load("/lists/toggle_checklist/" + cid + "/", {}, function(){
				$("#sortable input").toggle();
			}).effect("highlight", {}, 2000);
		}
		
		
		
// AJAX form functions (non doc ready) **************************************************************************

	/* show loading indicators when request is submitted */
    function showTextRequest()  {
        $("#text_response").html('<img src="/media/ajaxcomments/img/ajax-wait.gif">');
    }
    function showLinkRequest()  {
        $("#link_response").html('<img src="/media/ajaxcomments/img/ajax-wait.gif">');
    }
    function showVideoRequest()  {
        $("#video_response").html('<img src="/media/ajaxcomments/img/ajax-wait.gif">');
    }
    function showImageUploadRequest()  {
        $("#image_response").html('<img src="/media/images/progressbar.gif">');
    }
    function showImageLinkRequest()  {
        $("#image_response").html('<img src="/media/ajaxcomments/img/ajax-wait.gif">');
    }
    
    function showListRequest()  {
        $("#list_response").html('<img src="/media/ajaxcomments/img/ajax-wait.gif">');
    }
    
    
    /* handle error messages */
    function showTextError(){
        $('#text_response').html("Request timed out.  Please try again.");
    }
    function showLinkError(){
        $('#link_response').html("Request timed out.  Please try again.");
    }
    function showVideoError(){
        $('#video_response').html("Request timed out.  Please try again.");
    }
    function showImageUploadError(){
        $('#image_response').html("Upload timed out.  Please try again.");
    }
    function showImageLinkError(){
        $('#image_response').html("Request timed out.  Please try again.");
    }
    
    function showListError(){
        $('#list_response').html("Edit attempt timed out.  Please try again.");
    }
    function showListResponse(responseText, statusText) {
        if (responseText.success == true) {
				$('#list_title').html(responseText.title).effect("highlight", 1000);
				$('#list_description').html(responseText.description).effect("highlight", 1000);
				$('#list_response').html("");				
        }else{
            // show error, fade out
            $('#list_response').html(responseText.msg);
            $('#list_response').hide("highlight", 2000); 
        } 
    }

    function showTextResponse(responseText, statusText) {
        if (responseText.success == true) {
	     	var cid = responseText.cid;
	    	var tid = responseText.tid;
	 		if (!responseText.edit){
            	// behave differently if creating new item vs. editing existing
	        	$.get('/lists/get_newest_thing/' + cid, function(data){
	                $(data).appendTo('#sortable');
	                $("#sortable").enableFancyBox();
	                $('#text_response').html("");
            		$("#sortable").enableItemTools();
	            });
            }else{
	        	$.get('/lists/refresh_thing/' + tid + '/', function(data){	
	                $("#thing_" + tid).replaceWith(data);
	                $("#thing_" + tid).effect("highlight",2000);
	                $("#sortable").enableFancyBox();
	                $('#text_response').html("");
            		$("#editing_dashboard").slideUp('fast'); 
            		$("#sortable").enableItemTools();
	            });
            }
        }else{
            // show error, fade out
            $('#text_response').html(responseText.msg);
            $('#text_response').hide("highlight", 2000); 
        } 
    }

    function showLinkResponse(responseText, statusText) {
        if (responseText.success == true) {
        	var cid = responseText.cid;
        	var tid = responseText.tid;
            if (!responseText.edit){
            	// behave differently if creating new item vs. editing existing
	            $.get('/lists/get_newest_thing/' + cid, function(data){
	                $(data).appendTo('#sortable');
	                $("#sortable").enableFancyBox();
	                $('#link_response').html("");
            		$("#sortable").enableItemTools();
	            });
			}else{
	        	$.get('/lists/refresh_thing/' + tid + '/', function(data){	
	                $("#thing_" + tid).replaceWith(data);
	                $("#thing_" + tid).effect("highlight",2000);
	                $("#sortable").enableFancyBox();
	                $('#link_response').html("");
            		$("#editing_dashboard").slideUp('fast'); 
            		$("#sortable").enableItemTools();
	            });				
			}
        }else{
            // show error, fade out
            $('#link_response').html(responseText.msg);
            $('#link_response').hide("highlight", 2000); 
        } 
    }
    
    function showVideoResponse(responseText, statusText) {
        if (responseText.success == true) {
        	var cid = responseText.cid;
        	var tid = responseText.tid;
            if (!responseText.edit){
            	// behave differently if creating new item vs. editing existing
	            $.get('/lists/get_newest_thing/' + cid, function(data){
	                $(data).appendTo('#sortable');
	                $("#sortable").enableFancyBox();
	                $('#video_response').html("");
            		$("#sortable").enableItemTools();
	            });
			}else{
	        	$.get('/lists/refresh_thing/' + tid + '/', function(data){	
	                $("#thing_" + tid).replaceWith(data);
	                $("#thing_" + tid).effect("highlight",2000);
	                $("#sortable").enableFancyBox();
	                $('#link_response').html("");
            		$("#editing_dashboard").slideUp('fast'); 
            		$("#sortable").enableItemTools();
	            });			
			}
        }else{
            // show error, fade out
            $('#video_response').html(responseText.msg);
            $('#video_response').hide("highlight", 2000); 
        } 
    }
    

    function showImageResponse(responseText, statusText) {
        if (responseText.success == true) {
        	var cid = responseText.cid;
        	var tid = responseText.tid;
            if (!responseText.edit){
            	// behave differently if creating new item vs. editing existing
	            $.get('/lists/get_newest_thing/' + cid, function(data){
	                $("#sortable").append(data);
	                $("#sortable").enableFancyBox();
	                $('#image_response').html("");
            		$("#sortable").enableItemTools();
	            });
			}else{
	        	$.get('/lists/refresh_thing/' + tid + '/', function(data){	
	                $("#thing_" + tid).replaceWith(data);
	                $("#thing_" + tid).effect("highlight",2000);
	                $("#sortable").enableFancyBox();
	                $('#image_response').html("");
            		$("#editing_dashboard").slideUp('fast'); 
            		$("#sortable").enableItemTools();
	            });				
			}
        }else {
            //show error, fade out
            $('#image_response').html(responseText.msg);
            $('#image_response').hide("highlight", 2000); 
        }
    }
		



    var ajax_list_form_options = { 
        beforeSubmit:  showListRequest,  // pre-submit callback 
        success:       showListResponse,  // post-submit callback 
        timeout:   7000,
        error: 	   	showListError,
        dataType: 'json',
        async: false
    }  
    
    var ajax_text_form_options = { 
        beforeSubmit:  showTextRequest,  // pre-submit callback 
        success:       showTextResponse,  // post-submit callback 
        clearForm: true,        // clear all form fields after successful submit 
        resetForm: true,        // reset the form after successful submit 
        timeout:   7000,
        error: 	   	showTextError,
        dataType: 'json',
        async: false
    }  

    var ajax_link_form_options = { 
        beforeSubmit:  showLinkRequest,  // pre-submit callback 
        success:       showLinkResponse,  // post-submit callback 
        clearForm: true,        // clear all form fields after successful submit 
        resetForm: true,        // reset the form after successful submit 
        timeout:   7000,
        error: 	   	showLinkError,
        dataType: 'json',
        async: false
    }  
    var ajax_video_form_options = { 
        beforeSubmit:  showTextRequest,  // pre-submit callback 
        success:       showTextResponse,  // post-submit callback 
        clearForm: true,        // clear all form fields after successful submit 
        resetForm: true,        // reset the form after successful submit 
        timeout:   7000,
        error: 	   	showVideoError,
        dataType: 'json',
        async: false
    }  

    var ajax_image_upload_form_options = { 
        beforeSubmit:  showImageUploadRequest,  // pre-submit callback 
        success:       showImageResponse,  // post-submit callback
        clearForm: true,        // clear all form fields after successful submit 
        resetForm: true,        // reset the form after successful submit 
        timeout:   30000,
        error:     showImageUploadError,
        dataType: 'json',
        async: false
    }  		

    var ajax_image_link_form_options = { 
        beforeSubmit:  showImageLinkRequest,  // pre-submit callback 
        success:       showImageResponse,  // post-submit callback
        clearForm: true,        // clear all form fields after successful submit 
        resetForm: true,        // reset the form after successful submit 
        timeout:   7000,
        error:     showImageLinkError,
        dataType: 'json',
        async: false
    }  		
    
/* * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * 

 	THIS IS FIRED ON DOCUMENT READY  

* * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * * *  * * * * **/

$(document).ready(function(){


// xml compliant handling of external links
  $('.external').live('click', function() {
      window.open( $(this).attr('href') );
      return false;
  });

/* can probably make a generic function here */
// Set up email functions
$("#email_form").ajaxForm(ajax_text_form_options);
$("#emailshare").click(function(){
	$("#email_form_container").slideToggle("slow");
});

// Make Sortable ***************************************************************************************************

$("#sortable").sortable({
	axis: 'y',
    placeholder: 'highlight user_edit',
    handle: '.icon.edit_tools.drag',
	items: 'li',
	tolerance: 'pointer',
    update: function() { 
	    //var collection_id = this.id.replace("thing_", "");
	    var listid = $(this).attr("list_id");
	    var order = $('#sortable').sortable('serialize'); 	   
        $.post("/lists/reorder/" + listid,{data: order});
    }
});


// Mark as checked ************************************************************************************************* 
                                                                                                                     
		$('#sortable > .list_item > input ').live('click', function() {                                              
			var thing_id = this.id.replace("check_thing_", "");                                                      
			$(this).load("/lists/toggle_thing_checked/" + thing_id +"/").effect("highlight", {}, 500);               
			$(this).parent().children('.thing_content, a').toggleClass('struck');                                    
		});                                                                                                          
                                                                                                                     
// Delete Comment *************************************************************************************************  
		                                                                                                             
		$('#comments_pages > li > .delete').live('click', function(){		                                         
			var this_id = this.id.replace("delete_comment_", "");                                                    
			var answer = confirm("Are you sure you want to delete this comment?");                                   
			if (answer){                                                                                             
				$.get("/lists/delete_comment/" + this_id);                                      
				$(this).parents('li').hide("highlight", {}, 500);                                                    
			}                                                                                                        
			return false;                                                                                            
		});                                                                                                          
                                                                                                                     
// Delete List Item ************************************************************************************************ 
                                                                                                                     
		$('.item_tools > .delete').live('click', function(){		                                                 
			var this_id = this.id.replace("delete_thing_", "");                                                      
			var answer = confirm("Are you sure you want to delete this list item?");                                 
			if (answer){                                                                                             
				$.get("/lists/delete/thing/" + this_id);                                        
				$(this).parents('li').hide("highlight", {}, 500);                                                    
			}                                                                                                        
			return false;                                                                                            
		});                                                                                                          
                                                                                                                     


// Dashboard Edit In Place, file upload slide ***************************************************************************************************
	$(".avatar.clickable").click(function(){
		$("#upload_photo").slideToggle("slow");
	});

     $("#profile_location").editable("/dashboard/location_edit/", { 
	     type      : "charcounter_field",
         onblur    : "submit",
         cssclass  : "user_input_location",
		 event	   : "dblclick",
         placeholder : "add your location...",
         indicator : "<img src='/media/images/waiting-small.gif'/>",
	     tooltip   : "Double click to edit...",
    	 charcounter : {
	         characters : 50
	      }
     });

     $("#profile_description").editable("/dashboard/description_edit/", { 
	     type      : "charcounter_area",
         cssclass  : "user_input_bio",
 		 rows	    : 4, 
         cols		: 10,
        onblur    : "submit",
		 event	   : "dblclick",
         placeholder   : "share something about yourself...",
         indicator : "<img src='/media/images/waiting-small.gif'/>",
	     tooltip   : "Double click to edit...",
		 charcounter : {
	     	characters : 140
	      }
     });






						
// Edit Tools Behavior (Drag, Delete, Edit... ) *************************************************************************************************

	$(".icon.edit_tools.drag").mousedown(function(){
		$(this).parents('li').effect("highlight", {}, 500);
	});

	$(".icon.edit_tools.drag").mouseup(function(){
		$(this).parents('li').effect("highlight", {}, 500);
	});

	$(".icon.edit_tools.drag").click(function(){
      	$(this).parents('li').effect("highlight", { color: "#F8E1E8" }, 500);
	});
	
	$("#error").hide("highlight", 2000);

	$(document).enableFancyBox();

	// clears search box onfocus, restores onblur if blank
	$('input#s').val('Search tastiq').focus(function() { 
	if($(this).val()=='Search tastiq') { $(this).val(''); } } );
	$('input#s').val('Search tastiq').blur(function() { 
	if($(this).val()=='') { $(this).val('Search tastiq'); } } );

	// clears comment box onfocus, restores onblur if blank
	$('textarea#comment_box').val('Your comment here...').focus(function() { 
	if($(this).val()=='Your comment here...') { $(this).val(''); } } );
	$('textarea#comment_box').val('Your comment here...').blur(function() { 
	if($(this).val()=='') { $(this).val('Your comment here...'); } } );

	// clears description box onfocus, restores onblur if blank
	$('textarea#new_list_description').val('Your description here...').focus(function() { 
	if($(this).val()=='Your description here...') { $(this).val(''); } } );
	$('textarea#new_list_description').val('Your description here...').blur(function() { 
	if($(this).val()=='') { $(this).val('Your description here...'); } } );

	// catches empty comments
	$('#submit_comment').click(function(){
	if( ($("textarea#comment_box").val()=='') || ($("textarea#comment_box").val()=='Your comment here...') ) { $(this).attr("msg","Your comment cannot be blank...");
	$("textarea#comment_box").NoNo(2, 10, 400); return false; }
	else { $(this).attr("msg","Your comment has been recorded..."); }
	}); 

	// catches empty list name create/reply page
	$('#CreateList').click(function(){ 
	if( $("#new_list_title").val()=='') { $(this).attr("msg","Your title cannot be blank...");
	$("#new_list_title").NoNo(2, 10, 400); return false; }
	else { $(this).attr("msg","Creating list..."); if ($('textarea#new_list_description').val()=='Your description here...') {
	$('textarea#new_list_description').val('No description yet.');
	$(this).attr("msg","Your list is being created...");
	 }
	}
	}); 

	// catches empty list item
	$('#add_line_item').click(function(){ 
	if( $("#text_content").val()=='') { 
	$(this).attr("msg","Your item cannot be blank...");
	$("#text_content").NoNo(2, 10, 400); return false; } else 
	{ 
		$(this).attr("msg","Adding item...");
	
	}
	}); 
		
	 // feedback ui 
	 $(".has_feedback").click(function() {      
	 var action_feedback = $(this).attr('msg');
	 $("#feedback_msg").html(action_feedback);
	 //pause to allow other animations (ie, shaking)
	 $(this).animate({opacity:.8},500);
	 $("#feedback_ui").
	 animate({
	 height: '17px',
	 padding: '5px',
	 opacity: .8
	 }, 500).
	 // pause for 3 seconds 
	 animate({opacity:.8},3000). 
	 animate({
	 height: '0',
	 padding: '0px',
	 opacity: .0
	 }, 400);
	 });

    // initialize forms slider
	$('#add_forms').cycle({
		fx:'fade', 
		slideExpr:'.adding',
		startingSlide: 1,
		speed:'10',
		timeout: 0, 
		pager:  '#content_type_selector', 
		pagerAnchorBuilder: function(i, slideEl, title) { 
		return '<li><a class="rounded_bevel" href="#'+i+'">'+ slideEl.title + '</a></li>';  
		}
	});	



    $("#edit_list_form").ajaxForm(ajax_list_form_options);
    $("#add_thing_text").ajaxForm(ajax_text_form_options);
    $("#add_thing_image").ajaxForm(ajax_image_upload_form_options);
    $("#add_thing_link").ajaxForm(ajax_link_form_options);
    $("#add_thing_video").ajaxForm(ajax_video_form_options);
    
    // Character Limiters
	$('input.list_item').charCounter('150');	
    $('input.edit_title').charCounter('85');
    $('textarea.edit_description').charCounter('250');


	$("#close_feedback").click(function() {      
		$("#feedback_ui").stop(); 
	});

	$(".close_editor").click(function() {      
		$('#list_viewer').effect("highlight", 500);
		$("#editing_dashboard").slideUp(); 
	});

	$(".open_editor_clean").click(function() { 
		var collection_id = $(this).attr("collection_id");
		$("#editing_dashboard_content input[name$='content']").val("");
		$("#editing_dashboard_content input[name$='caption']").val("");
		//$("#editing_dashboard_content input[name$='title']").val("");			
		$("#editing_dashboard_content input[name$='url']").val("");
		$("#editing_dashboard_content textarea[name$='notes']").val("");
		$("#editing_dashboard_content input[name$='thing_id']").val("");
		

		$("#editing_dashboard_content :text").removeClass("user_edit");		
		$("#editing_dashboard_content textarea[name$='notes']").removeClass("user_edit");

		// set css class to user_input on all inputs
		$("#editing_dashboard_content :text").addClass("user_input");		
		$("#editing_dashboard_content textarea[name$='notes']").addClass("user_input");
		$("#editing_dashboard_content input[name$='list_title']").addClass("user_edit");
				
		
		$("#add_forms").cycle(0);
		$('#list_viewer').effect("highlight", 500);
		$("#editing_dashboard").slideDown('fast'); 
		
		$("#image_present").hide();
		$("#link_image_field").hide();
		$("#upload_image_field").show();
	 }); 

	$(".open_editor").live('click', function() {
		var content_type = $(this).attr("content_type");
		var editorStatus = $("#editing_dashboard").css('display');

		// determine which tab to cycle to
		if (content_type == "text")	{$("#add_forms").cycle(1);}
		if (content_type == "url")	{$("#add_forms").cycle(2);}
		if (content_type == "file")	{$("#add_forms").cycle(3);}
		if (content_type == "mp3")	{$("#add_forms").cycle(3);}
		if (content_type == "broken")	{$("#add_forms").cycle(3);}
		if (content_type == "video")	{$("#add_forms").cycle(4);}


		if ($(this).attr("thing_id")){
			var collection_id = $(this).attr("collection_id");
			var thing_id = $(this).attr("thing_id");
			
			//$("#editing_dashboard_content").animate({opacity:1},600)
			//.load("/lists/submit_thing/" + collection_id);
			$.getJSON("/lists/get_thing_json/" + thing_id, function(data){
				$("#editing_dashboard_content input[name$='content']").val(data.content);
				$("#editing_dashboard_content input[name$='caption']").val(data.content);
				//$("#editing_dashboard_content input[name$='title']").val(data.content);			
				$("#editing_dashboard_content input[name$='url']").val(data.url);
				$("#editing_dashboard_content textarea[name$='notes']").val(data.notes);
				$("#editing_dashboard_content input[name$='thing_id']").val(data.id);
				$("#modal_image_link").attr("href", data.url);					
				if (content_type == "image")	{
					if (data.url){
						$("#upload_image_field").hide();
						$("#link_image_field").hide();
						$("#image_present").show();
					} else{
						$("#upload_image_field").show();
						$("#link_image_field").hide();
						$("#image_present").hide();				
					}
					$("#add_forms").cycle(3);
				}
			});
			
		}     
	

		$("#editing_dashboard_content :text").removeClass("user_input");		
		$("#editing_dashboard_content textarea[name$='notes']").removeClass("user_input");


		// set css class to user_input on all inputs
		$("#editing_dashboard_content :text").addClass("user_edit");		
		$("#editing_dashboard_content textarea[name$='notes']").addClass("user_edit");		
		
		// only slide down if not there already
		if (editorStatus = 'none') {
			$('#list_viewer').effect("highlight", 500);
			$("#editing_dashboard").animate({opacity:1},600).slideDown('fast');
		}
	});
	
	// initialize tooltips

    $(".help_tips").tipsy({live:true, html:true });
      $(".tips").tipsy({live:true, html:true });
    $(".tips-s").tipsy({live:true, html:true, gravity: 's'});
    $(".tips-e").tipsy({live:true, html:true, gravity: 'e'});
    $(".tips-w").tipsy({live:true, html:true, gravity: 'w'});
    $(".tips-n").tipsy({live:true, html:true, gravity: 'n'});

		// make li element clickable when contains a.list_title
		$(".clickable_list li").click(function(){
		window.location=$(this).find("a.list_title").attr("href"); return false;
		return false;
		});

		// make li element and sub element style on hover 
		$(".clickable_list li").hover(
		function(){
		$(this).find("a.list_title").css("text-shadow","1px 1px 3px #FFF");
		}, 
		function(){
		$(this).find("a.list_title").css("text-shadow","none");
		});



});

