function curtainChange(msg) {
	if (msg == "open") {
		$('#Animation').height(700);
		$('#zoltanBeta').height(700);
	} else if (msg == "close") {
		$('#Animation').height(200);
		$('#zoltanBeta').height(200);
	}
}

if (typeof trapeze == 'undefined') trapeze = new Object();

trapeze = {

	assets_path : '/assets/',
    
    toggle_src_rel_witheffect : function(object, speedIn, speedOut) {
        $(object).fadeOut(speedOut,function(speedIn){
            tmp_src = $(this).attr('src');
            $(this).attr('src', $(this).attr('rel'));
            $(this).attr('rel', tmp_src);
            $(this).fadeIn(speedIn);
        });
    },
    
    toggle_src_rel : function(object) {
        $(object).fadeTo(5,0,function() {
            tmp_src = $(this).attr('src');
            $(this).attr('src', $(this).attr('rel'));
            $(this).attr('rel', tmp_src);
            $(this).fadeTo(10,100);
        });
    },
    
    rollover_clients: function(selector) {
        $(selector).mouseover(function() {
            trapeze.toggle_src_rel(this); /* 280 450 */
        });
        $(selector).mouseout(function() {
            trapeze.toggle_src_rel(this); /* 150 250 */
        });
    },

	sifr : function() {
		if (typeof sIFR == "function") {
			//sIFR.replaceElement(named({sSelector:"h1.page-title", sFlashSrc:this.assets_path + "fla/avenir-65m.swf", sColor:"#961921", sLinkColor:"#961921", sBgColor:"#961921", sHoverColor:"#961921", sWmode:"transparent", nPaddingTop:0, nPaddingBottom:0}));
            sIFR.replaceElement(named({sSelector:"h3.block-title", sFlashSrc:this.assets_path + "fla/avenir-95b.swf", sColor:"#8F8A3F", sLinkColor:"#8F8A3F", sBgColor:"#8F8A3F", sHoverColor:"#8F8A3F", sWmode:"transparent", nPaddingTop:0, nPaddingBottom:0}));
            sIFR.replaceElement(named({sSelector:"h3.header-box", sFlashSrc:this.assets_path + "fla/avenir-95b.swf", sColor:"#8F8A3F", sLinkColor:"#8F8A3F", sBgColor:"#8F8A3F", sHoverColor:"#8F8A3F", sWmode:"transparent", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=center"}));
            //sIFR.replaceElement(named({sSelector:"li.nav-item", sFlashSrc:this.assets_path + "fla/avenir-95b.swf", sColor:"#473620", sLinkColor:"#473620", sBgColor:"#473620", sHoverColor:"#473620", sWmode:"transparent", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=center"})); 
		};
	},
    
    init_zoltanBeta : function(path) {
        if ($("#Animation").size() > 0 && (document.player_path || path)) {
            var so = new SWFObject(this.assets_path + "fla/zoltanBeta.swf", "zoltanBeta", "222", "200", "9", "#fcf8ec");
            so.addParam("allowScriptAccess", "sameDomain");
            so.addParam("scale", "noscale");
            so.addParam("salign", "T");
            so.addParam("wmode", "transparent");
            so.addVariable("xmlPath", trapeze.fortunesPath);
            so.addVariable("pageID", ((trapeze.showZoltanIntro) ? 'home' : 'sub-page'));
            so.write("Animation");
        }
    },


    init_navigation : function(){
        if ($("#SiteNav").size() > 0){
            $("#SiteNav li.nav-item a").each(function() {
                $(this).html('<img src="'+trapeze.assets_path+'img/nav_'+$(this).text().toLowerCase().replace(/ /g, "_")+'.gif" alt="'+$(this).attr('rel')+'" />');
            });
            $("#SiteNav li.nav-item a").not('.active').next().hide();
            $("#SiteNav li.nav-item a.active img").each(function() {
                $(this).attr('src', $(this).attr('src').replace('.gif','_down.gif'));
            });
            $("#SiteNav").show();

            //Accordion Effect
            $("#SiteNav li.nav-item a.top-item img").mouseover(function(){
                object = $(this).parent().parent().find('ul.sub-nav-list');
                if ($(object).is(":hidden")){
                    $("#SiteNav li.nav-item a.top-item:not('.active') + ul.sub-nav-list").each(function(){
                        if (!$(this).is(":hidden")) {
                            $(this).slideUp(300);
                        }
                    });
                    if ($(object).is(":hidden")) {
                        $(object).slideDown("slow");
                    }
                }
            });

            //Rollover effect top nav items
            $("#SiteNav li.nav-item a.top-item:not('.active') img").hover(function(){
                if ($(this).attr('src').indexOf('_down.gif') >= 0) {
                    $(this).attr('src',$(this).attr('src').replace(/_down.gif/,'_over.gif'));
                } else {
                    $(this).attr('src', $(this).attr('src').replace(/.gif/,'_over.gif'));
                }
            }, function(){
                $(this).attr('src', $(this).attr('src').replace(/_over.gif/,'.gif'));
            });
            
            //Rollover effect sub nav items
            $("#SiteNav li.nav-item ul.sub-nav-list li.nav-item a:not('.active') img").hover(function(){
                if ($(this).attr('src').indexOf('_down.gif') >= 0) {
                    $(this).attr('src',$(this).attr('src').replace(/_down.gif/,'_over.gif'));
                } else {
                    $(this).attr('src', $(this).attr('src').replace(/.gif/,'_over.gif'));
                }
            }, function(){
                $(this).attr('src', $(this).attr('src').replace(/_over.gif/,'.gif'));
            });
        }
    },

    project_gallery : function() {
        $("#ProjectGallery .gallery-thumbs ul li").click(function() {
			var crtItem = $(this);
			$('#ProjectGallery .gallery-main-image div').hide();
			$('#ProjectGallery .gallery-main-image div.' + $(this).find('div').attr('class').replace(/thumb-image-/, 'main-image-')).show();

			//$('#ProjectGallery .gallery-main-image div').hide();
			//$('#projectGallery .gallery-main-image div.' + $(this).find('div').attr('class').replace(/thumb-image-/, 'main-image-')).show();
			//$('#ProjectGallery .gallery-main-image div.' + $(this).find('div').attr('class').replace(/thumb-image-/, 'main-image-')).fadeTo(0,100);


            $(this).parent().find("li").removeClass().addClass('project-thumb');
            $(this).removeClass().addClass('project-thumb-selected');
        });    
    },
    
    init_quotes : function() {
        $('.quote .quote-wrapper ul li.last-child').attr('style', 'margin-top:'+($('.quote .quote-wrapper ul').height() - 42)+'px;');    
    },
    
    fix_email_images_ie : function () {
        if ($("#ContactDetail").size() > 0) {
            $('.email-image').each(function() {
                $(this).css('background', 'transparent url("' + $(this).children("img").attr("src") + '") no-repeat top left;');
                $(this).css('height', '18px');
            });
        }
    },
    
    init : function() {
        this.init_navigation();
        this.rollover_clients('.logo-image');
        this.init_zoltanBeta(this.assets_path + "xml/fortunes.xml");
        this.sifr();
        this.project_gallery();
        this.init_quotes();
        this.fix_email_images_ie();
    }    
};

$(document).ready(function(){
    trapeze.init();
});

