function slide_init() {
    if ($('img', '#areaImg').length > 1) {
        $('#areaImg').cycle({ 
            fx: 'fade', 
            speed: 1500, 
            timeout: 3500 
        });
    } else {
        $('img', '#areaImg').show();
    }
}

function setViewportHeight() {
    $('.viewport').css('height', $('#scroller').height());
}

function showCurrentSubNav() {
    if (currentMenuId == '') {
        $("#menu ul li ul").hide();
        $('#menu ul li ul.static').show();
    }
}
    
var currentMenuId = '';

$(function() {
    displayTime("time");
    slide_init();
    
    //setupResizeSlideshow();
    //setupVideo();
    
    if ($('.viewport').height()) {
        //need to set the height of the viewport as IE6 doesnt like height:auto!
        setViewportHeight();
        $('#areaContent a').bind("click", function() {
            var question = $(this).attr('href').substring(2);
            var divOffset = $('.viewport').offset().top;
            var pOffset = $('#scroller p:eq('+(question-1)+')').offset().top;
            var pScroll = pOffset - divOffset;
            //$('#scroller').animate({'top': '-=' + pScroll + 'px'}, 1500);
            $('#scroller').animate({'top': '-=' + pScroll + 'px'}, 1500, 'easeout');
            // alas the best that can be done - set the browser to the right place
            if (document.body.scrollTop) {
                document.body.scrollTop = divOffset;
            }
            else {
                document.documentElement.scrollTop = divOffset;
            }
            return false;
        });
    }
    
    /*try {
        $('#signup_response').val("");
    }
    catch(e) { }*/
    $('#marketSignupForm').bind("submit", function() {
        if (!$('#attribute_post:checked').length && !$('#attribute_contact_by_email:checked').length) {
            alert("You must select how you wish to recieve our reports");
            return false;
        }
    });
});



function setupResizeSlideshow() {
	$(window).resize(function() {
			//resizeSlideshow();
	});
	//resizeSlideshow();
}

function resizeSlideshow() {
	var relImg = document.getElementById('slide1');
	var absImg = document.getElementById('slide2');
	var width = relImg.parentNode.offsetWidth;
	var height = relImg.parentNode.offsetHeight;
	
	relImg.style.width = width+'px';
	relImg.style.height = height+'px';
	absImg.style.width = width+'px';
	absImg.style.height = height+'px';
}

/*function flashPlay() {
	$('#areaImg').cycle('pause');
    so.write("flashPlayer");
    $('#flashPlayButton').css('display', 'none');
}

function flashComplete() {
	$('#areaImg').cycle('resume');
    $("#flashPlayer").html("");
    $("#flashPlayButton").attr("src", "./img/replay-film-trans.png");
    $('#flashPlayButton').css('display', 'block');
}*/