/* Bottom Bar Start */

$(window).scroll(function()
{	
	var bottomBarTop = (document.body.clientHeight + $(window).scrollTop()) - 29;
	if (browserName == "Microsoft Internet Explorer" )
	{
		bottomBarTop = (document.body.clientHeight + $(window).scrollTop()) - 28;		
		var infoDivTop = bottomBarTop - 319;
	}
	else
	{
		var infoDivTop = bottomBarTop - 329;
	}

	//$('#bottomBar').animate({top:bottomBarTop + "px"},{queue:false,duration:"slow"});
	//$('.infoDiv').animate({top:infoDivTop + "px"},{queue:false,duration:"slow"});
	$('#bottomBar').css("top", bottomBarTop + "px");
	$('#bottomBarShow').css("top", bottomBarTop + "px");
	$('.infoDiv').css("top", infoDivTop + "px");
	//$('#bottomBar').show("fast");
	//$('.infoDiv').show("fast");

});


/* Function to get the total offset position */
function getposOffset(overlay, offsettype)
{
	/* To get the total offset depending on the offset type */
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	/* To get the parent offset of the overlay passed as the parameter */
	var parentEl=overlay.offsetParent;
	/* To check if the parent offset is not NULL */
	while (parentEl!=null)
	{
		/* To get total offset depending on the offset type */
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		/* To assign offset parent to the parent offset */
		parentEl=parentEl.offsetParent;
	}
	/* To return the total offset */
	return totaloffset;
}

function showDiv(obj)
{
	//$('#bottomBar ul li').css("background","#e5e5e5");
	//$('#' + obj.id).css("background","#f1f1f1");

	$('.infoDiv').fadeOut('slow');

	var xpos = 0;
	var ypos = 0;
	xpos=getposOffset(obj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-obj.offsetWidth) : 0)
	/* To get the Y co-ordinate */
	ypos=getposOffset(obj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? obj.offsetHeight : 0)

	var divName = 'div_' + obj.id;

	$('#' + divName).toggle();
	var aaaa = $('#' + divName).height() + 9;
	/* To assign X-Y co-ordinate values to the div style positioning */
	ypos -= aaaa;

	$('#' + divName).css("left", xpos+"px");
	$('#' + divName).css("top", ypos+"px");
}

$(document).ready(function(){

	$('#bottomBar ul li, #hideBottomBar, #showBottomBar').hover( 
		function () {
			$(this).addClass("activeBotTab");
		},
		function () {
			$(this).removeClass("activeBotTab");
		}
	);

	$('.closeInfoDiv').click(function () {
		$('.infoDiv').fadeOut('slow');
	});

	$('#hideBottomBar').click(function () {
		updateBottomBarStatus('0')
		$('.infoDiv').fadeOut('slow');
		$('#bottomBar').fadeOut('slow');
		$('#bottomBarSepTable').hide();
		$('#bottomBarShow').fadeIn('slow');
	});

	$('#showBarImg').click(function () {
		updateBottomBarStatus('1');
		$('.infoDiv').fadeOut('slow');
		$('#bottomBarShow').fadeOut('slow');
		$('#bottomBarSepTable').fadeIn('slow');
		$('#bottomBar').fadeIn('slow');
	});
});

function updateBottomBarStatus(intVal)
{
	strParams = "&actionType=UPDATE_BOTTOMBAR_STATUS&val="+intVal;

	$.ajax({
			url: HTTP_SERVER+DIR_WS_HTTP+'ajaxUpdateBottomBarStatus.php',
			type: 'POST',
			data: strParams,
			timeout: 3000,
			error: function(strReponseResult){},
			success: function(strReponseResult){
				return (strReponseResult);
			}
	});
}
/* Bottom Bar End */
