	

$(document).ready(function() {

	//grab all the anchor tag with rel set to shareit
	$('a[rel=shareit], #shareit-box').mouseenter(function() {		
		
		//get the height, top and calculate the left value for the sharebox
		var height = $(this).height();
		var top = $(this).offset().top;
		
		//get the left and find the center value
		var left = $(this).offset().left + ($(this).width() /2) - ($('#shareit-box').width() / 2);		
		
		//grab the href value and explode the bar symbol to grab the url and title
		//the content should be in this format url|title
		var value = $(this).attr('href').split('|');
		
		//assign the value to variables and encode it to url friendly
		var field = value[0];
		var url = window.location.href;
		var title = document.getElementById('title').innerHTML;
		
		//assign the height for the header, so that the link is cover
		$('#shareit-header').height(height);
		
		//display the box
		$('#shareit-box').show();
		
		//set the position, the box should appear under the link and centered
		$('#shareit-box').css({'top':top, 'left':left});
		
		//assign the url to the textfield
		$('#shareit-field').val(field);
		
		//make the bookmark media open in new tab/window
		$('a.shareit-sm').attr('target','_blank');
		
		//Setup the bookmark media url and title
		$('a[rel=shareit-mail]').attr('href', 'http://mailto:?subject=' + title);
		$('a[rel=shareit-delicious]').attr('href', 'http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=' + url + '&title=' + title);
		$('a[rel=shareit-google]').attr('href', 'http://www.google.com/bookmarks/mark?op=edit&bkmk=' + url + '&title=' + title + '&annotation='  + url + '&title=' + title);
		$('a[rel=shareit-digg]').attr('href', 'http://digg.com/submit?phase=2&url=' + url + '&title=' + title);
		$('a[rel=shareit-yahoobuzz]').attr('href', 'http://buzz.yahoo.com/submit/?submitUrl=PERMALINK&submitHeadline=' + title + '&submitSummary=EXCERPT&submitCategory=science&submitAssetType=text');
		$('a[rel=shareit-twitter]').attr('href', 'http://twitter.com/home?status=' + title + '%20-%20' + title);
		
	});

	//onmouse out hide the shareit box
	$('#shareit-box').mouseleave(function () {
		$('#shareit-field').val('');
		$(this).hide();
	});
	
	//hightlight the textfield on click event
	$('#shareit-field').click(function () {
		$(this).select();
	});
});
		
		function fbs_click() { u=location.href; t=document.title; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),' sharer', 'toolbar=0, status=0, width=626, height=436'); return false; } 
function tw_click () {
    
    u2 = location.href;
    t2 = document.title;

    var windowString = 'http://twitter.com/home?status=';
    windowString += 'Check this out at PhoneScreen.com:';
    windowString += encodeURIComponent(u2);
    windowString += '&nbsp;';
    windowString += encodeURIComponent(t2);

    //window.open(windowString, 'sharer', 'toolbar=0,status=0,width=805,height=516');
    window.open('http://twitter.com/home?status=' + encodeURIComponent('Check this out at PhoneScreen.com:' + u2 + ' ' + t2), 'sharer', 'toolbar=0,status=0,width=805,height=516');
 return false;
}
function emailto(){
window.open('/xmlfiles/js/tell_a_friend.php', 'tellafriend_script','scrollbars=1,statusbar=1,resizable=1,width=454,height=400');
}
/*var changeIt, print_div;
changeIt = function()
{ print_div = document.getElementById("sec_content").innerHTML;
newwindow=window.open( '/content/targetpage.html', target="_blank" );
setTimeout('newwindow.document.getElementById("print_content").innerHTML=print_div',1000)
};*/

function printContent(id){
   str=document.getElementById(id).innerHTML
   newwin=window.open('','printwin')
   newwin.document.open();
   newwin.document.write('<html><head><style type="text/css">body,p,ul,li{font-family:verdana,tahoma,sans-serif;font-size:12px;text-align:left} h1,h2,h3{font-size:14px}</style></head>');
   newwin.document.write('<title>Print Page</title>\n')
   newwin.document.write('</HEAD>\n')
   newwin.document.write('<BODY>\n')
   newwin.document.write('<table width="100%" cellspacing="0" cellpadding="0" border="0" style="background: transparent url(/images/dot_bottom.gif) repeat-x scroll center bottom; margin-bottom:15px">' + '<tr>' + '<td width="26%" style="padding-bottom: 10px;">' + '<img src="http://www.phonescreen.com/images/acc-top.gif" alt="PhoneScreen.com" />' + '</td>' + '<td width="11%" valign="bottom" align="right" style="padding-bottom: 10px;">' + '<a href="#" onClick="window.print();return false;">' + '<img width="100" height="21" border="none" src="/images/print_page.gif" alt="PRINT PAGE" />' + '</a>' + '</td>' + '</tr>' + '</table>')
   
   newwin.document.write(str)
   newwin.document.write('<div style="border-top: 1px solid rgb(204, 204, 204); font-size: 9px; color: rgb(153, 153, 153); margin-top: 15px; padding-top: 10px;">' + '&copy; 2011 PhoneScreen All rights reserved' + '</div>')
   /*newwin.document.write('<<strong class="highlight">a</strong> href="#" onClick="window.print();"><strong class="highlight">Print</strong></a>')*/
   newwin.document.write('</body></html>');
   newwin.document.getElementById('bot_menu').style.display='none';
  /* newwin.document.write('</HTML>\n')*/
  /*  newwin.document.close();
   newwin.print();*/

}

