jQuery(window).load(function(){
    var startValue = jQuery('#CustomAdvancedSearchForm_GlobalSearchForm_Search').val();
    var searchField = jQuery("#CustomAdvancedSearchForm_GlobalSearchForm_Search");
    searchField.focus(function() {
        if (jQuery(this).val() == startValue) {
            jQuery(this).val('');
        }
    });

    searchField.blur(function() {
        if (searchField.val() == '') {
            searchField.val(startValue);
        }
    });

    // pop boxes: order page
    jQuery('.footOrderPage').ajaxPopup({
        wrapper:'OrderGIBKit',
        successMesg:'' // handled in OrderPage.php
    });

    // popbox: iframe
    jQuery('.storySubmitForm').ajaxIframePopup({
        wrapper:'StorySubmit'
    });

    // find multifileuploads when clicked
    jQuery('.storySubmitForm').click(function(){
        jQuery('iframe').load(function (){

            jQuery(this).contents().findMultiFiles();

            // resize the div box upon submition
            jQuery('iframe').load(function(){
                if(jQuery('iframe').contents().find('form').size()==0){
                    var iframeHeight = jQuery('iframe').contents().find('#PopupContainer').height();
                    jQuery('iframe').animate({'height': iframeHeight+7}, 1000);
                }
            });
        });
    });
    jQuery('#Footer').find('li.toggler span').each(function(){
        jQuery(this).hover(function(){
            jQuery(this).css('text-decoration','underline');
        },function(){
            jQuery(this).css('text-decoration','none');
        });
        jQuery(this).click(function(){
            jQuery(this).next('ul').slideToggle();
        });
    });

	if (jQuery('#FinalistImages').length) {
		jQuery('#Banner').imagerotator({
			itemSelector : '.large',
			indicators : jQuery('#FinalistImages img.thumb')
		});
	}
});