// 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');
});
	$('#dialognamechange').DialogNameChange();
});

jQuery.fn.DialogNameChange = function() {
    var $this = $(this);

    if ($this.length > 0) {

        var $dialog;
        var cookie = document.cookie.split($this.attr('id') + '=');

        if (!cookie[1]) {

            $dialog = $this.dialog({
                autoOpen: true,
                width: parseInt($this.css('width')),
                modal: true,
                closeText: 'Sluiten'
            });

        }
        $('a.pecoma', $this).click(function() {
            $dialog.dialog('close');
            return false;
        });
        $('.dialog_footer input[type=checkbox]', $this).click(function() {
            document.cookie = $this.attr('id') + '=1; expires=' + (new Date + 86400000) + '; path=/';
            $dialog.dialog('close');
            return false;
        });
    }
};  

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();
	}
}

