// author : michele pasin
// generic utilities (to use with jquery)
// **************************



/*** Temporary text filler function. Remove when deploying template. ***/
var gibberish=["This is just some filler text", "Sometimes some gibberish may mean more than what you think", "Amore non amato amar perdona"]
function filltext(words){
	var output = "";
	for (var i=0; i<words; i++) 
		output = output + (gibberish[Math.floor(Math.random()*3)]+" ");
		return output;
}

// addGibberish(20, 'results');  results is the ID name
function addGibberish(number, location) {
	var stuff = filltext(number);
	$("#" + location).empty().append(stuff);
}


function changeScreenSize(w,h)
     {
       window.resizeTo( w,h )
     }




function make_nextelement_collapsable(element) {
	"wrapper for the convenient toggle function"
	
	$(element).toggle(
	      function () {
	        $(this).next().slideUp("slow");
	      }, 
	      function () {
	        $(this).next().slideDown("slow");
	      }
	    );
	
}



/*
generic functions for jquery operations
*/

function updateDiv(selector, ajaxcall) {
    $.get(ajaxcall,
   		 {  },
              function(data){
                 $(selector).append(data);
              }
   );  
}

function clear_and_update(selector, ajaxcall) {
    $.get(ajaxcall,
   		 { },
              function(data){
                 $(selector).empty().append(data);
              }
   );  
}




//  old version:

// function clear_and_updateDiv(div_id, ajaxcall) {
//     $.get(ajaxcall,
//    		 { },
//               function(data){
//                  $("#" + div_id).empty().append(data);
//               }
//    );  
// }



