// ==UserScript==
// @name            Flickr-comment-gen
// @description     This generates a generic comment for use on Flickr 
// @author          Ramin Hossaini - http://www.ramin-hossaini.com
// @version         1.0 (11-08-2009)
// @namespace       http://dev.ramin-hossaini.com/flickr-comments/
// @include         http://www.flickr.com/*
// @include         http://flickr.com/*
// @exclude         http://www.flickr.com/photos/organize*
// @exclude         http://flickr.com/photos/organize*
// ==/UserScript==

// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need FireFox  http://www.mozilla.org/firefox and 
// the firefox extension called Greasemonkey: http://greasemonkey.mozdev.org/
// Install the Greasemonkey extension then restart Firefox and revisit this script.
// There will be a button at the top right of the page saying "Install User Script".
// Click the button + accept the default configuration to install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Flickr-comment-gen", and click Uninstall.
//
// --------------------------------------------------------------------


function getresult() {
    GM_xmlhttpRequest({
        method: 'GET',
        url: 'http://dev.ramin-hossaini.com/flickr-comments/get_comment.php',
        headers: {
            'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
        },
        onload: function(responseDetails) {
            /*alert('Request for Atom feed returned ' + responseDetails.status +
                  ' ' + responseDetails.statusText + '\n\n' +
                  'Feed data:\n' + responseDetails.responseText);*/

/*replace text in textbox*/
document.getElementById("message").innerHTML = responseDetails.responseText;
                  
        }
    });
}


( function () {

var customhtml = "<div id='flickrgen'><a href='javascript:void'>[ Flickr comment-generator ]</a></div>";

var commentsDiv = document.getElementById("comments");

if (commentsDiv) {
	
	commentsDiv.innerHTML += customhtml;
	
	var button = document.getElementById("flickrgen");

	button.addEventListener('click', function(event) {
		document.getElementById("message").innerHTML = "Loading...";
		getresult();
	}, true);

}


})();


