jQuery(document).ready(function(){
    if($("body").attr("class") == "no_fade"){
        $(".top_level .section_navigation, .content").fadeTo(0, 1);
    }else{
        $(".top_level .section_navigation, .content").fadeTo(850, 1);
    }
    // if(jQuery.browser.msie){
        // $("body").css({font-size: "1.25em"}).children().css({font-size: "0.5em"});
    // }
    body_id = $("body").attr("id");
    if(body_id !== "index"){
        $("h1.logo a").html("<img src=\"/images/persone_sub02sm.gif\">").css({textIndent: "0", background: "transparent"});
        // $("h1.logo a img").css({width: "15.5em", height: "4.7em"});
    }
    if(body_id == "index" || body_id == "services"){
        if(body_id == "index"){
            navigation_class = ".index_services_navigation";
            navigation_image_url = "/images/index/services_navigation.gif";
            $("h1.logo").html("<img src=\"/images/index/persone_sub01.gif\">").css({textIndent: "0", background: "transparent"});
            $("h1.logo img").css({width: "16.8em", height: "5.1em"});
        }else if(body_id == "services"){
            navigation_class = ".services_navigation";
            navigation_image_url = "/images/services/services_navigation.gif";
            $("body").append("<img src=\"/images/services/bg_splatter_04.jpg\" class=\"splatter\">").css({background: "transparent"});
            if(jQuery.browser.msie){
                $("img.splatter").css({zIndex: "-2", width: "42.4em", height: "17.5em", position: "absolute", left: "10em", top: "2.75em"});
            }else{
                $("img.splatter").css({zIndex: "-2", width: "84.8em", height: "35em", position: "absolute", left: "20em", top: "5.5em"});
            }
            // $("body").css({background: "transparent"});
        }
        $(navigation_class).css({background: "transparent"}).append("<img src=\"" + navigation_image_url + "\">")
        if(jQuery.browser.msie){
            $(navigation_class + " a").css({textIndent: "0", background: "transparent"}).html("<img src=\"" + navigation_image_url + "\">").hover(function(){
                $(this).find("img").fadeTo(200, 1);
            },function(){
                if(body_id == "index"){
                    $(this).find("img").fadeTo(200, 0.0001);
                }else{
                    $(this).find("img").fadeTo(200, 0.777);
                }
            });
        }else{
            $(navigation_class + " a").css({textIndent: "0", background: "transparent"}).html("<img src=\"" + navigation_image_url + "\">").hover(function(){
                $(this).find("img").fadeIn(200);
            },function(){
                $(this).find("img").fadeOut(200);
            });
        }
        $(navigation_class + " img").css({width: "59.6em", height: "8em", position: "absolute", left: "0", top: "0"});
        if(jQuery.browser.msie){
            if(body_id == "index"){
                $(navigation_class + " a img").fadeTo(0, 0.0001);
            }else{
                $(navigation_class + " a img").fadeTo(0, 0.777);
            }
        }else{
            $(navigation_class + " a img").css({display: "none"});
        }
        $(".creative_direction a img").css({left: "0", top: "-4.1em"});
        $(".animation a img").css({left: "-17.1em", top: "-4.1em"});
        $(".audio a img").css({left: "-17.1em", top: "-6.2em"});
        $(".branding a img").css({left: "-32.3em", top: "-4.1em"});
        $(".illustration a img").css({left: "-32.3em", top: "-6.2em"});
        $(".print a img").css({left: "-51.6em", top: "-4.1em"});
        $(".web a img").css({left: "-51.6em", top: "-6.2em"});
    }else if(body_id == "clients"){
        try{
            background_position = $("ul.client_icons li:first").css("backgroundPosition");
            if(background_position == ""){
                unsupported_browser = true;
            }else{
                background_position = background_position.split(" ");
                unsupported_browser = false;
            }
        }catch(err){
            unsupported_browser = true;
        }
        if(unsupported_browser === false){
            n=0;
            $("ul.client_icons").children("li").each(function(){
                if($(this).css("backgroundImage") == "none"){
                    background_image = $("> a", this).css("backgroundImage");
                    background_image = background_image.substring(4,background_image.length-1);
                    $("> a", this).css({backgroundImage:"none",textIndent:"0"}).html("<img src=\"" + background_image + "\">");
                    this_width = $("> a", this).css("width");
                    this_width = Math.round(parseFloat(this_width.substring(0,this_width.length-2)) * 10) / 100 + "em";
                    this_height = $("> a", this).css("height");
                    this_height = Math.round(parseFloat(this_height.substring(0,this_height.length-2)) * 10) / 100 + "em";
                    $("> a > img", this).css({width:this_width,height:this_height});
                }else{
                    background_image = $(this).css("backgroundImage");
                    background_image = background_image.substring(4,background_image.length-1);
                    background_position = $(this).css("backgroundPosition");
                    if(n==0){
                        // alert(background_position);
                    }
                    background_position = background_position.split(" ");
                    background_position[0] = Math.round(parseFloat(background_position[0].substring(0,background_position[0].length-2)) * 10) / 100;
                    background_position[1] = Math.round(parseFloat(background_position[1].substring(0,background_position[1].length-2)) * 10) / 100;
                    this_width = 20 - (background_position[0] * 2) + "em";
                    this_height = 9.3 - (background_position[1] * 2) + "em";
                    background_position[0] += "em";
                    background_position[1] += "em";
                    $(this).css({backgroundImage:"none",textIndent:"0"}).html("<img src=\"" + background_image + "\">");
                    $("> img", this).css({width:this_width,height:this_height,margin:background_position[1] + " 0 0 " + background_position[0]});
                }
            n+=1;
            });
        }
    }else if(body_id == "clients_previous"){
        $("body").append("<img src=\"/images/clients/bg_splatter_bw_droplet.jpg\" class=\"droplet\">").css({background: "transparent"});
        if(jQuery.browser.msie){
            $("img.droplet").css({zIndex: "-1", width: "25.05em", height: "17.55em", position: "absolute", left: "18.35em", top: "20em"});
        }else{
            $("img.droplet").css({zIndex: "-1", width: "50.1em", height: "35.1em", position: "absolute", left: "36.7em", top: "40em"});
        }
    }
});