﻿$(document).ready(function ()
{
	// replace the search area button with a custom one
	$("img[src$=/_layouts/images/gosearch15.png]").attr({src:"/Style%20Library/resourcesCustoms/images/searchBtnGo.png", alt:"new alt title"}).removeAttr("onmouseover").removeAttr("onmouseout");
	
    //hide private or business options when javascript enabled
    $('span.nojs').hide();

    //POPUP 1//
    $('a.popupnav1').click(function ()
    {
	    if( $('.popup1').css('display') == 'block')
	    //we check if we already see the popup, if we can see it we want to hide it
	    {
		    //hide the popup because they clicked a second time
		    $(this).parent().removeClass('selected');
		    $('.popup1').fadeOut("50");
		} 
		else
		{
		//if we can't see it, carry on as normal
		//keep the original tab selected
		$(this).parent().addClass('selected');
		//now show popup 1
	    $('.popup1').fadeIn("50");
		//while hiding popup 2
		$('.popup2').fadeOut("50");
	    //and hiding popup 2's selected tab
	    $('.popupnav2').parent().removeClass('selected');
	    }
	     return false;
		})
		//if popup 1 loses focus...
		//hide it, this happens if the user clicks away from the popup
	    $("*:not(.popup1)").live("click", function(){
		$(".popup1").fadeOut("50");
		//and hide remove the class we added
		$('.popupnav1').parent().removeClass('selected');
	})
	;
        
    //POPUP 2//
    $('a.popupnav2').click(function ()
    {
	    if( $('.popup2').css('display') == 'block')
	    //we check if we already see the popup, if we can see it we want to hide it
	    {
		    //hide the popup because they clicked a second time
		    $(this).parent().removeClass('selected');
		    $('.popup2').fadeOut("50");
		} 
		else
		{
		//if we can't see it, carry on as normal
		//keep the original tab selected
		$(this).parent().addClass('selected');
		//now show popup 1
	    $('.popup2').fadeIn("50");
		//while hiding popup 2
		$('.popup1').fadeOut("50");
	    //and hiding popup 2's selected tab
	    $('.popupnav1').parent().removeClass('selected');
	    }
	     return false;
		})
		//if popup 1 loses focus...
		//hide it, this happens if the user clicks away from the popup
	    $("*:not(.popup2)").live("click", function(){
		$(".popup2").fadeOut("50");
		//and hide remove the class we added
		$('.popupnav2').parent().removeClass('selected');
	})
	;
});
