    var _ErrorMessage = "JavascriptError: \n\tFile:\n\t\t{0} \n\tFunction:\n\t\t{1} \n\tError Message:\n\t\t {2}";

    /// <summary>
    /// Throw the exception formated for the user
    /// </summary>
    function ShowException(file,fcn,msg)
    {
        alert(_ErrorMessage.toString().replace('{0}',file).replace('{1}',fcn).replace('{2}',msg));
    }
    
    /// <summary>
    /// Adjust the page layout, called every request
    /// </summary>
    function AdjustLayout()
    {
        try
        {
			if (!($.browser.msie && $.browser.version == '6.0')) {
				AdjustGalleryLightBox();
			}
			AdjustCycle();
			AdjustImageToolTip();
			AdjustToolTip();
			AdjustConfirmButton();
			AdjustInputFocus();
			AdjustjCarousel();
			AdjustPng();
			
			$('.Atria_BaseEadControl_Surveys_Survey_ResultBar').each(function() {
				$(this).css('width',$(this).html().replace(',','.') + '%');
				$(this).html('&nbsp;');
			});
			
			$('.global_middle_center_interna_formContato').parent().parent().parent().css('float','left');
 		}
        catch(ex)
        {
            ShowException('Portal.js','AdjustLayout();',ex.message);
        }
    }

    function AdjustPng()
    {
        try
        {
			if ($.browser.msie) {
				$(document).pngFix(); 
			}
		}
		catch(ex)
		{
            ShowException('Portal.js','AdjustPng();',ex.message);
		}
	}

    /// <summary>
    /// Adjust the gallery lightbox plugin
    /// </summary>
    function AdjustGalleryLightBox()
    {
        try
        {
			//$('. > a > img').lightbox();
		}
		catch(ex)
		{
            ShowException('Portal.js','AdjustGalleryLightBox();',ex.message);
		}
	}
	
	/// <summary>
    /// Adjust the jCarousel plugin
    /// </summary>
    function AdjustjCarousel()
    {
        try
        {
			$('.global_middle_logos .Atria_BaseMiniSiteControl_MiniSites_Group').Atria_Carousel({effect:'drop'});
			$('.Atria_Carousel_Holder').hover(function() {
				$.Atria_CarouselDefaults_Stop = true;
			}, function() {
				$.Atria_CarouselDefaults_Stop = false;
			});
		}
		catch(ex)
		{
            ShowException('Portal.js','AdjustjCarousel();',ex.message);
		}
	}
	
    /// <summary>
    /// Adjust the cycle plugin
    /// </summary>
    function AdjustCycle()
    {
        try
        {
		}
		catch(ex)
		{
            ShowException('Portal.js','AdjustCycle();',ex.message);
		}
	}
	
	/// <summary>
    /// Display a confirm message in all delete buttons
    /// </summary>
    function AdjustConfirmButton()
    {
        try
        {
            //bind the click function with the oldhref attr value
            $('.ConfirmButton').bind('click', function(){
            
                var button = $(this);
                var text = button.attr('ConfirmText') == undefined ? 'Confirm delete?' : button.attr('ConfirmText');
                var ok = button.attr('ConfirmTextOk') == undefined ? 'Yes' : button.attr('ConfirmTextOk');
                var cancel = button.attr('ConfirmTextCancel') == undefined ? 'No' : button.attr('ConfirmTextCancel');
               
                $.prompt(
                    text,
                    { 
                        buttons: { Ok: ok, Cancel: cancel }, 
                        zIndex: 99999999,
                        focus: 1, 
                            prefix:'Atria_Global_Warning',   
                        callback : function(v,m) { 
                            if (v == ok) { 
                                eval(button.attr('oldhref').substring(11)); 
                            } 
                        }
                    }
                );
            });
            
            //remove href and puts in the oldhref
            $('.ConfirmButton').each(function(){
                    $(this).attr('oldhref',$(this).attr('href'));
            });
                
            //clear href
            $('.ConfirmButton').attr('href','#');

            //make confirm required
        }
        catch(ex)
        {
            ShowException('Atria.Base.js', 'AdjustConfirmButton();', ex.message);
        }
    }

    /// <summary>
    /// Adjust the tool tip plugin
    /// </summary>
    function AdjustToolTip()
    {
        try
        {
			$('[title]').tooltip({
				fade: false,
				showURL: false,
				track: true
			});
        }
        catch(ex)
        {
            ShowException('Atria.Base.js', 'AdjustToolTip();', ex.message);
        }
    }
	
	function AdjustImageToolTip()
	{
        try
        {
			$('.global_middle_center_interna_participantes_row_content_gallery_item>a').tooltip({ 
				delay: 0, 
				showURL: false, 
				track: true, 
				bodyHandler: function() { 
					return $("<img/>").attr("src", $(this).attr('imgtip'));
				} 
			});
			$('.global_middle_restaurante_right_imagemPrincipal a').tooltip({ 
				delay: 0, 
				showURL: false, 
				track: true, 
				bodyHandler: function() { 
					return $("<img/>").attr("src", $(this).attr('imgtip'));
				} 
			});
        }
        catch(ex)
        {
            ShowException('Atria.Base.js', 'AdjustImageToolTip();', ex.message);
        }
	}

    /// <summary>
    /// Change the inputs border on focus
    /// </summary>
    function AdjustInputFocus() 
    { 
        try
        {
			$("input[type=text],input[type=password],input[type=file],textarea").focus(
				function() { 
					$(this).css("border","1px solid #05ADED"); 
				}
			); 
			$("input[type=text],input[type=password],input[type=file],textarea").blur(
				function() { 
					$(this).css("border","1px solid #E2E2E2"); 
				}
			);
        }
        catch(ex)
        {
            ShowException('Atria.Base.js','AdjustInputFocus();',ex.message);
        }
    }
	
    function ApiBminds_Atria_LogoutUser()
    {
        $.getScript('/Services/User/Logout.aspx');
    }

	//Abrir popups
	function openPopUpIndicacao(url){window.open(url, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=560,height=450,left=10,top=10');}

	function openPopUpMultimidia(url){window.open(url, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=560,height=500,left=10,top=10');}

	function openPopUpLocalizacao(url){window.open(url, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=560,height=700,left=10,top=10');}

	//Carregamento de imagens para hover
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
