// Browse Estates AJAX Functions

function ajaxit() {
    /*jQuery("a.ajax").removeClass("current");
    jQuery("a.ajax").addClass("current"); //adds class current to the category menu item being displayed so you can style it with css
    jQuery("#loading-animation-2").show();*/
    var ajaxurl = 'http://' + document.location.hostname + '/wp-admin/admin-ajax.php';
    jQuery.ajax({
        type: 'GET',
        url: ajaxurl + '?' + jQuery('#listing_filters').serialize(),
        beforeSend : function(){  
        	//jQuery("#venue-listings").fadeOut("slow");
        	jQuery('#venue-listings').empty();
        	//jQuery("#venue-listings").fadeIn("slow");
        	jQuery('#venue-listings').prepend('<div id="temp_load" style="text-align:center">\<img src="http://' + document.location.hostname + '/wp-content/themes/ewe/img/ajax-loader.gif" />\</div>');  
		},
		success: function(response){
			if ( response == 0 || response == -1) {
				jQuery('#venue-listings').empty();
				jQuery('#venue-listings').prepend('<div id="no-results"><h2>No Results Found</h2><h3 class="no_results">It looks like there are no venues which match your selections.  Please try some different filtering options or <a href=""#>click here to reset your search</a>.</h3><p>Can\'t find what you are looking for?  If you would like to send a general inquiry to our staff, we would be happy to personally assist you in your search.  <a href="/proposal-request/">Click here to submit a general inquiry</a>.</div>');
			} else if( response != 0 ) {
        		    jQuery('#venue-listings').empty();
        		    jQuery('#venue-listings').prepend(response);
        		    return false;
        	}
        },
    });
}

//END Browse Estates AJAX

jQuery(document).ready(function() {

    jQuery('#menu-top-menu li:last-child').addClass('last');
    jQuery('.left-menu li:first-child').addClass('first');
    jQuery('.sub-menu').append('<li class="last"></li>');
    
    // adding a class for menu items with sub items
    jQuery('#menu-main-menu li').each(function(index) {
        if ( jQuery(this).children().size() > 1 ) {
            jQuery(this).addClass('parent-item');
        }
    });

    
    // exclusive listing modal window
    jQuery('.exclusive_pop').click(function(e) {
        e.preventDefault();

        var id = '#exclusive_modal';

        var maskHeight = jQuery(document).height();
        var maskWidth = jQuery(window).width();

        var winH = jQuery(window).height();
        var winW = jQuery(window).width();

        jQuery(id).css('top',  winH/2-jQuery(id).height()/2);
        jQuery(id).css('left', winW/2-jQuery(id).width()/2);
        
        jQuery('body, html').scrollTop(0);
        
        jQuery(id).fadeIn(200); 
        jQuery('#mask').fadeIn(200);
        jQuery('body').css('overflow','hidden');
    });
    jQuery('#exclusive_modal .close').click(function (e) {
        e.preventDefault();
        
        jQuery('#mask').fadeOut(200);
        jQuery('#exclusive_modal').fadeOut(200);
        jQuery('body').css('overflow','visible');
    });        
    jQuery('#mask').click(function () {
        jQuery(this).fadeOut(200);
        jQuery('#exclusive_modal').fadeOut(200);
        jQuery('body').css('overflow','visible');
    });
});

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
    window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
} 
else if(document.all)// ie
    window.external.AddFavorite(url, title);
}
