jQuery(document).ready(function(){
	
	// Resize.
	jQuery('#tendersCalender td').each(function() {
	
		var cHeight = jQuery(this).height();
		
		if(cHeight < 92) {
		
			jQuery(this).height(92);
		
		}
	
	});

});

function AppendItem(id, content, dId){
	
	jQuery('#'+id).append('<div class="tCalItem"><a href="javascript:void(0);" detailId="' + dId + '">' + content + '</a></div>');

}

function GetDetails(dId){

	ShowMask();

}

function ShowMask(){

	// height
	//var newHeight = screen.width;
	var newHeight = jQuery('#tendersCalender').height() + 571;
	
	jQuery('#maskLayer').css({ 'height' : newHeight, 'width' : screen.width, 'opacity' : '0.6' });
	jQuery('#maskLayer').fadeIn('slow');	

}

function RemoveMask(){

	jQuery('#cPopClose').unbind();
	jQuery('#cCalPop').remove();
	jQuery('#maskLayer').fadeOut('slow');

}

function CreateEvents(){

	jQuery('a[detailId]').bind('click', function(){
	
		ShowMask();
		
		var thisId = jQuery(this).attr('detailId');
		
		jQuery.get('tenders-calender-details.asp?id='+thisId, function(data){
			jQuery('#maskLayer').before(data);
			var halfPosition = screen.width / 2;
			var offsetPosition = jQuery('#cCalPop').width() / 2;
			var truePosition = halfPosition - offsetPosition;
			var halfPosition2 = screen.height / 2;
			var offsetPosition2 = jQuery('#cCalPop').height() / 2;
			var truePosition2 = halfPosition2 - offsetPosition2;
			jQuery('#cCalPop').css({ 'left' : truePosition+'px', 'top' : truePosition2+'px' });
			
			RegisterPopUpEvents();
		
		});
	
	});

}

function RegisterPopUpEvents() {

	jQuery('#cPopClose').bind('click', function(){
	
		RemoveMask();
	
	});

}
