$(document).ready(function() 
{
var page = location.hash;
switch(page)
{
case "#bling":
$.fn.colorbox({open:"true", width:"90%", inline:true, href:"#inlineBlogBling"});
break;    
case "#signatures":
$.fn.colorbox({open:"true", width:"90%", inline:true, href:"#inlineEmailSignature"});
break;
}

	// lightbox
	$("#blogBling").colorbox({width:"90%", inline:true, href:"#inlineBlogBling"});
	$("#emailSignature").colorbox({width:"85%", inline:true, href:"#inlineEmailSignature"});
	  
	// spread the word
	var focusval = "";
	var focusfld = "";
	
	$(".spreadForm input").focus(function () {
		 if (focusval != "") { if ($(focusfld).val() == "") { $(focusfld).val(focusval); } }
         focusval = $(this).val();
		 focusfld = $(this);
		 if (focusval.substring(0,5) == "Your ") { $(this).val(''); }
    });
	$("#recipient_name").keyup( function(){ $(".friendName").html( $("#recipient_name").val() ); } );
	$("#sender_name").keyup( function(){ $(".yourName").html( $("#sender_name").val() ); } );
}); 

function sendAgain() 
{
	$.fn.colorbox.close();
}

function sendits(e) 
{
   var senddata = "recipient_name="+$("#recipient_name").val()+"&mailto="+$("#recipient_email").val()+"&sender_name="+$("#sender_name").val()+"&sender_email="+$("#sender_email").val();
   EP.send_mail('SpreadtheWord2',senddata,spreadResponse);
}

function spreadResponse(response) 
{
   if (response.success) {
	 var scriptObj = document.createElement("script");
     scriptObj.type = "text/javascript";
     scriptObj.src = "https://view.atdmt.com/jaction/mrtity_FY10TechEd2010DwnMClSpreadthewordemaiCo_1";
     document.getElementsByTagName("head")[0].appendChild(scriptObj);
	 /*newImg = $('<img width="1" height="1" src="https://view.atdmt.com/iaction/mrtity_FY10TechEd2010DwnMClSpreadthewordemaiCo_1" />');
	 $("#rioTT").append(newImg);*/
	 $(".friendName").html("Your friend's name");
	 $(".yourName").html("Your name");
	 $("#recipient_name").val("Your friend's name");
	 $("#recipient_email").val("Your friend's e-mail address");
	 $("#sender_name").val("Your name");
	 $("#sender_email").val("Your e-mail address");
	 $("#msgresult").html("Thank you for spreading the word!");
	 $("#msgsendagain a").html("Why not send another e-mail?");
	 $("#msgsendagain a").attr("href", "javascript:sendAgain();");
	 $.fn.colorbox({open:"true", width:"30%", inline:true, href:"#inlineSpreadAgain"});
   } else { 
     alert(response.message);
   }
} 
