// JavaScript Document
(function() {

// Localize jQuery variable
var jQuery;
/******** Load jQuery if not present *********/

	



if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.6.1') {
    var script_tag = document.createElement('script');
    script_tag.setAttribute("type","text/javascript");
    script_tag.setAttribute("src",
        "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js");
    script_tag.onload = scriptLoadHandler;
	

	 script_tag.onreadystatechange = function () { // Same thing but for IE
	
        if (this.readyState == 'complete' || this.readyState == 'loaded') {
            scriptLoadHandler();
        }
    };
   
 


	

	// Try to find the head, otherwise default to the documentElement
 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
    // The jQuery version on the window is the one we want to use
    jQuery = window.jQuery;
    main();
}

/******** Called once jQuery has loaded ******/
function scriptLoadHandler() {
    // Restore $ and window.jQuery to their previous values and store the
    // new jQuery in our local jQuery variable

	//load css first
	$("head").append("<link>");
	css = $("head").children(":last");
	css.attr({
	      rel:  "stylesheet",
	      type: "text/css",
	      href: "http://emailmebutton.com/stylesheets/colorbox.css" 
	    });
	
	var script_tag2 = document.createElement('script');
    script_tag2.setAttribute("type","text/javascript");
    script_tag2.setAttribute("src","http://emailmebutton.com/javascripts/jquery.colorbox-min.js");
	document.getElementsByTagName("head")[0].appendChild(script_tag2);
		
    jQuery = window.jQuery.noConflict();
    // Call our main function
    
	
	
	
	main(); 
}

/******** Our main function ********/
function main() { 

 

    jQuery(document).ready(function($) { 
      
		



		$(".emailme_link").colorbox({width:"550px",height:"590px", iframe:true});
		
		//For Tracking
		//Tracking on every refresh
			$.ajax( {
				type: "POST",
				url: "http://emailmebutton.com/index.php/tracking",
				data: "dname="+document.domain,
			});
		
		
    });
}

})(); // We call our anonymous function immediately
