// CSS document for Grosvenor Lettings Portal
// build: PR 13/08/2009

var fadein_speed = 200;
var fadeout_speed = 400;
var fadein_opacity = 1;
var fadeout_opacity = 0;

// Apply the Javascript-enabled styles (hidding expandable boxes for instance)
$('html').addClass('js');

$(document).ready(function() {
	//Fix IE6 background image caching problem
    if (jQuery.browser.msie) {
        try { 
            document.execCommand("BackgroundImageCache", false, true); 
        } catch(err) {}
    }    
    
    //initialise opacity css value
    $('.module a.image_link span', this).css('opacity', '0');
        
    //dropdown navigation hover class, current state, rollover of image
    $('div.module ul li.head_link').hover(
			function() { 
			    $(this).addClass('current');  
			    OpenSubnav($('ul', this));
			    FadeImageIn($('> a.image_link span', this));
			},
			function() { 
			    $(this).removeClass('current'); 
			    //$('ul', this).css('display', 'none'); 
			    CloseSubnav($('ul', this));
			    FadeImageOut($('> a.image_link span', this));
			});
			
	$('div.module ul li.text').hover(
			function() { 
			    $(this).find('~ li.head_link').addClass('current');
			    OpenSubnav($(this).find('~ li.head_link').find('ul'));
			    FadeImageIn($(this).find('~ li.head_link').find('a.image_link span'));
			},
			function() { 
			    $(this).find('~ li.head_link').removeClass('current'); 
			    CloseSubnav($(this).find('~ li.head_link').find('ul'));
			    FadeImageOut($(this).find('~ li.head_link').find('a.image_link span'));
			});	
   
});

function OpenSubnav(currentList) {       
    currentList.stop().animate({ top: 345 }, 350);
}

function CloseSubnav(currentList) {       
    currentList.stop().animate({ top: 150 }, 450);
}

function FadeImageIn(fade) {      
    fade.stop().fadeTo(fadein_speed, fadein_opacity);       
}

function FadeImageOut(fade) {                
    fade.stop().fadeTo(fadeout_speed, fadeout_opacity);
}