$(document).ready(function() {

	// START LOGIN
	$('a[rel=myaccountlogin], #myaccountlogin-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) - ($('#myaccountlogin-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 = encodeURIComponent(value[0]);
		var title = encodeURIComponent(value[1]);
		
		//assign the height for the header, so that the link is cover
		$('#myaccountlogin-header').height(height);
		
		//display the box
		$('#myaccountlogin-box').show();
		
		//set the position, the box should appear under the link and centered
		$('#myaccountlogin-box').css({'top':top, 'left':left});
		
		//assign the url to the textfield
		$('#myaccountlogin-field').val(field);
		
		//make the bookmark media open in new tab/window
		$('a.myaccountlogin-sm').attr('target','_blank');
		
		//Setup the bookmark media url and title;
		$('a[rel=myaccountlogin-stumbleupon]').attr('href', 'https://myaccount.alphatelecom.com');
		$('a[rel=myaccountlogin-twitter]').attr('href', 'https://myaccounteu.alphatelecom.com');
		
	});

	//onmouse out hide the myaccountlogin box
	$('#myaccountlogin-box').mouseleave(function () {
		$('#myaccountlogin-field').val('');
		$(this).hide();
	});
	
	//hightlight the textfield on click event
	$('#myaccountlogin-field').click(function () {
		$(this).select();
	});
	
	
	// START JOIN US
	$('a[rel=myaccountjoinus], #myaccountjoinus-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) - ($('#myaccountjoinus-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 = encodeURIComponent(value[0]);
		var title = encodeURIComponent(value[1]);
		
		//assign the height for the header, so that the link is cover
		$('#myaccountjoinus-header').height(height);
		
		//display the box
		$('#myaccountjoinus-box').show();
		
		//set the position, the box should appear under the link and centered
		$('#myaccountjoinus-box').css({'top':top, 'left':left});
		
		//assign the url to the textfield
		$('#myaccountjoinus-field').val(field);
		
		//make the bookmark media open in new tab/window
		$('a.myaccountjoinus-sm').attr('target','_blank');
		
		//Setup the bookmark media url and title;
		$('a[rel=myaccountjoinus-stumbleupon]').attr('href', 'https://myaccount.alphatelecom.com');
		$('a[rel=myaccountjoinus-twitter]').attr('href', 'https://myaccounteu.alphatelecom.com');
		
	});

	//onmouse out hide the myaccountjoinus box
	$('#myaccountjoinus-box').mouseleave(function () {
		$('#myaccountjoinus-field').val('');
		$(this).hide();
	});
	
	//hightlight the textfield on click event
	$('#myaccountjoinus-field').click(function () {
		$(this).select();
	});
	
});
