//var feedbackbubble = {};


feedbackbubble.clickFeedback = function(e) {
e = e || window.event;
var target = e.target || e.srcElement
document.getElementById('feedbackbubbleLink').style.visibility = "hidden";
//feedbackbubble.email = document.getElementById('feedbackbubbleSpace').eml;

feedbackbubble.getTextWithScript = function(url){
    var script = document.createElement("script");
    document.body.appendChild(script);
   

    // Encode the URL we want to fetch and the name of the function
    // as arguments to the jsquoter.php server-side script.  Set the src
    // property of the script tag to fetch the URL
    script.src = url
}

// We use this to generate unique function callback names in case there
// is more than one request pending at a time.



feedbackbubble.ourdiv = document.createElement("div");
feedbackbubble.ourdiv.style.position = "absolute";
feedbackbubble.ourdiv.style.backgroundColor= "#FFFFFF";
feedbackbubble.ourdiv.style.borderColor= "#999999";
feedbackbubble.ourdiv.style.borderWidth= "3";
feedbackbubble.ourdiv.style.borderStyle= "Solid";
feedbackbubble.ourdiv.style.zIndex="9999"
feedbackbubble.ourdiv.style.padding="5px"

//feedbackbubble.ourdiv.style.width="481px"
//feedbackbubble.ourdiv.style.height="363px"
//feedbackbubble.ourdiv.style.backgroundImage="url(http://www.makeitconnect.com/shapeimage_2.png)"






























/**
 * Geometry.js: portable functions for querying window and document geometry
 *
 * This module defines functions for querying window and document geometry.
 * 
 * getWindowX/Y(): return the position of the window on the screen
 * getViewportWidth/Height(): return the size of the browser viewport area
 * getDocumentWidth/Height(): return the size of the document.
 * getHorizontalScroll(): return the position of the horizontal scrollbar
 * getVerticalScroll(): return the position of the vertical scrollbar
 *
 * Note that there is no portable way to query the overall size of the 
 * browser window, so there are no getWindowWidth/Height() functions.
 * 
 * IMPORTANT: This module must be included in the <body> of a document
 *            instead of the <head> of the document.
 */
/*
var Geometry = {};

if (window.screenLeft) { // IE and others
    Geometry.getWindowX = function() { return window.screenLeft; };
    Geometry.getWindowY = function() { return window.screenTop; };
}
else if (window.screenX) { // Firefox and others
    Geometry.getWindowX = function() { return window.screenX; };
    Geometry.getWindowY = function() { return window.screenY; };
}

if (window.innerWidth) { // All browsers but IE
    Geometry.getViewportWidth = function() { return window.innerWidth; };
    Geometry.getViewportHeight = function() { return window.innerHeight; };
    Geometry.getHorizontalScroll = function() { return window.pageXOffset; };
    Geometry.getVerticalScroll = function() { return window.pageYOffset; };
}
else if (document.documentElement && document.documentElement.clientWidth) {
    // These functions are for IE6 when there is a DOCTYPE
    Geometry.getViewportWidth =
        function() { return document.documentElement.clientWidth; };
    Geometry.getViewportHeight = 
        function() { return document.documentElement.clientHeight; };
    Geometry.getHorizontalScroll = 
        function() { return document.documentElement.scrollLeft; };
    Geometry.getVerticalScroll = 
        function() { return document.documentElement.scrollTop; };
}
else if (document.body.clientWidth) {
    // These are for IE4, IE5, and IE6 without a DOCTYPE
    Geometry.getViewportWidth =
        function() { return document.body.clientWidth; };
    Geometry.getViewportHeight =
        function() { return document.body.clientHeight; };
    Geometry.getHorizontalScroll =
        function() { return document.body.scrollLeft; };
    Geometry.getVerticalScroll = 
        function() { return document.body.scrollTop; };
}

// These functions return the size of the document.  They are not window 
// related, but they are useful to have here anyway.
if (document.documentElement && document.documentElement.scrollWidth) {
    Geometry.getDocumentWidth =
        function() { return document.documentElement.scrollWidth; };
    Geometry.getDocumentHeight =
        function() { return document.documentElement.scrollHeight; };
}
else if (document.body.scrollWidth) {
    Geometry.getDocumentWidth =
        function() { return document.body.scrollWidth; };
    Geometry.getDocumentHeight =
        function() { return document.body.scrollHeight; };
}


*/











































//feedbackbubble.ourdiv.style.top = e.clientY + Geometry.getVerticalScroll() ;
//feedbackbubble.ourdiv.style.left = e.clientX + Geometry.getHorizontalScroll(); 

	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information

//http://www.quirksmode.org/js/events_properties.html

feedbackbubble.ourdiv.style.top = (posy-20) + "px";
feedbackbubble.ourdiv.style.left = (posx-20) + "px";


























//feedbackbubble.ourdiv.style.top = "0px";
//feedbackbubble.ourdiv.style.left = "0px";

//document.body.appendChild(feedbackbubble.ourdiv);
//document.getElementById('feedbackbubbleSpace').appendChild(feedbackbubble.ourdiv);
document.body.appendChild(feedbackbubble.ourdiv);




feedbackbubble.message = document.createElement("textarea");
feedbackbubble.message.rows = "4"

feedbackbubble.message.id = "feedbackbubbleMessage"
feedbackbubble.message.style.color = "#000000"
feedbackbubble.message.style.font = "12px arial"
feedbackbubble.message.style.width = "225px"; //jellyfish

feedbackbubble.ourdiv.appendChild(feedbackbubble.message);








feedbackbubble.ourdiv.appendChild(document.createElement("br"));
feedbackbubble.useremail = document.createElement("input");
feedbackbubble.useremail.type = "text";
feedbackbubble.useremail.id = "feedbackbubbleuseremail";
feedbackbubble.useremail.value = "Your email (optional)"
feedbackbubble.useremail.style.font = "italic 12px arial"
feedbackbubble.useremail.style.color = "#BBBBBB"
feedbackbubble.useremail.style.width = "225px"
feedbackbubble.useremailclicked= 0

feedbackbubble.useremail.onclick = function()
{
     if (feedbackbubble.useremailclicked == 0)
     {
           feedbackbubble.useremail.style.font = "normal 12px arial" //i say normal because of opera.
           feedbackbubble.useremail.style.color = "#000000"
           feedbackbubble.useremail.value = "";
     }


feedbackbubble.useremailclicked = 1;



}

feedbackbubble.ourdiv.appendChild(feedbackbubble.useremail);


//feedbackbubble.useremailtext= document.createElement("span");
//feedbackbubble.useremailtext.style.fontSize = "8pt";
//feedbackbubble.useremailtext.innerHTML = "Email (optional)";

//feedbackbubble.ourdiv.appendChild(feedbackbubble.useremailtext);














feedbackbubble.ourdiv.appendChild(document.createElement("br"));
feedbackbubble.sendButton = document.createElement("input");
feedbackbubble.sendButton.type = "button";
feedbackbubble.sendButton.value = "Send!";
feedbackbubble.ourdiv.appendChild(feedbackbubble.sendButton);

feedbackbubble.ajaxloader = document.createElement("img");
feedbackbubble.ajaxloader.style.visibility="hidden";
feedbackbubble.ajaxloader.src = "http://www.thinknumber.com/feedbackbubble/ajax-loader.gif";

feedbackbubble.ourdiv.appendChild(feedbackbubble.ajaxloader);
feedbackbubble.ourdiv.appendChild(document.createElement("br"));

feedbackbubble.alert = document.createElement("span")
feedbackbubble.alert.innerHTML = ""//"Please leave an email address <br>or phone number if you wish <br>to be contacted."
feedbackbubble.alert.id = "feedbackbubbleAlert"
feedbackbubble.ourdiv.appendChild(feedbackbubble.alert)


feedbackbubble.ourdiv.appendChild(document.createElement("br"));
feedbackbubble.close= document.createElement("a");
feedbackbubble.close.href= "#"





feedbackbubble.close.innerHTML = "close"
feedbackbubble.close.onclick = function(){
//document.getElementById("feedbackbubbleSpace").removeChild(feedbackbubble.ourdiv)
document.body.removeChild(feedbackbubble.ourdiv)

document.getElementById('feedbackbubbleLink').style.visibility = "visible";
return false;
}
feedbackbubble.ourdiv.appendChild(feedbackbubble.close);
feedbackbubble.message.focus();


feedbackbubble.sendButton.onclick = function(){
     feedbackbubble.alert.innerHTML = "";
     feedbackbubble.ajaxloader.style.visibility="visible"; 
          feedbackbubble.getTextWithScript(
                                    "http://www.thinknumber.com/feedbackbubble/sendsave.php?email=" 
                                    + encodeURIComponent(feedbackbubble.email)
                                    + "&message=" + encodeURIComponent(document.getElementById('feedbackbubbleMessage').value)
                                    + "&useremail=" + encodeURIComponent(feedbackbubble.useremail.value)
                                   + "&time=" + (new Date()).getTime()
                                     )
         feedbackbubble.message.focus();
                                           }


feedbackbubble.diditwork = function(yn)
{
feedbackbubble.alert.innerHTML = yn;
     feedbackbubble.ajaxloader.style.visibility="hidden";
     feedbackbubble.message.value = ""

}

return false;
}
//document.getElementById('feedbackbubbleLink').innerHTML= "Feedback";
document.getElementById('feedbackbubbleLink').onclick= feedbackbubble.clickFeedback
