// Open / close a case
$(function(){    
    //sharepoint fix img alignment
    $('img[align="right"]').css('float', 'right');
    $('img[align="left"]').css('float', 'left');
	$('img[hspace]').each(function() {
		var oImage = $(this);		
		oImage.css('margin-right', oImage.attr('hspace') + 'px');
		oImage.css('margin-left', oImage.attr('hspace') + 'px');
	});
	$('img[vspace]').each(function() {
		var oImage = $(this);
		oImage.css('margin-top', oImage.attr('vspace') + 'px');
		oImage.css('margin-bottom', oImage.attr('vspace') + 'px');
	});
});
    
function SetPopupLocation(refLink, popupId, iframId)
{
	var popup = $("#" + popupId);
	var height = popup.height();
	var width = popup.width();
	
	if (refLink.id.indexOf('MakeAppointment') > -1)
	{
		var pos = $(refLink).offset();
		var left = pos.left - 382;
		var top = pos.top - 35;
		
		popup.css("left", left + "px");
		popup.css("top", top + "px");
	}
	else
	{
		var pos = $(refLink).position();
		var left = pos.left;
	
		var top = pos.top - height - 10;
		if (top < 0)
		{
			top = 0;
		}
		var bottom = $(window).height() - top - height;
		
		popup.css("top", "auto");
		popup.css("bottom", bottom + "px");
		popup.css("left", left + "px");
	}

	$("#" + iframId).height($('.container').height()); 
	HandleSmokeLayer();
}

function HandleSmokeLayer()
{
    var SmokeLayer = $('.popupBgr');
   
   
        /*SmokeLayer.css('height', $('.main').height());*/
        if ($.browser.msie && parseFloat($.browser.version) <= 6)
        {
            if ($(SmokeLayer.children('iframe').length == 0))
            {
                SmokeLayer.html('<iframe></iframe>');
            }
            var oIFrame = $(SmokeLayer.children('iframe').get(0));
            oIFrame.css('height', SmokeLayer.height());
        }
   
}
function ToggleOtherBox(oDropDown)
{
	if (oDropDown.selectedIndex == oDropDown.options.length - 1)
	{
		$('#OtherBox').show();
	}
	else
	{
		$('#OtherBox').hide();
	}
}

function ToggleInformedBy(oCheckBox)
{
	if (oCheckBox.checked)
	{
		$('#InformedBy').show();
	}
	else
	{
		$('#InformedBy').hide();
	}
}
