$(document).ready(function(){
    //Zebra striping on tables
    $('tr:odd').css({'background-color':'#F9F9F9'});

    $("#page_branding #photos").append('<div id="preload"><\/div><div id="loading_bgd"><div id="loading"><\/div><\/div>');
    
    $("div#preload, div#loading_bgd").css({opacity:0}).hide();

	$(".photonav a[class!=website], .design_nav a").live("click", function(){
		$(".photonav a").removeClass("current");
		$(this).addClass("current");
		var mult = ($(this).text()-1)*-590;
		$("#portfolio_photos").animate({left:mult},500);
		return false;
	});

	$("a.current").live("click", function(){return false;});

	$(".download a:first").hover(function(){
			$(".download_hover").stop().fadeTo(200, 0);
		}, function(){
			$(".download_hover").stop().fadeTo(200, 1);
		}
	);

    $("#branding_thumbs a").click(function(){
        if($(this).attr("class") == "current"){
            return false;
        }
        else {
            $("#branding_thumbs a").removeClass();
            $(this).addClass("current");
            var tempUrl = $(this).attr("name");
            $("div.branding_info").slideUp("normal", function(){
                $("div#preload").show().fadeTo("fast",0.75);
                $("div#loading_bgd").show().fadeTo("fast", 1, function(){
                    $("div#branding_content").load("branding.inc.php?portfolio=" + tempUrl, {}, function(){
                        $("div#preload, div#loading_bgd").fadeTo("normal", 0, function(){
							$(this).hide()
						});
                    });
                });
            });
            return false;
        }
    });

    //CONTACT
    $('a.contact_link').colorbox({href:"/_contact.inc.php", initialWidth:635, initialHeight:340, width:635, height:340, transition:"fade", opacity:0.7, speed:0});

    $("input[name='submit']").live("mouseover", function(){
			if($.browser.msie){
				$(this).css({"background-position":"left bottom"});
			} else {
				$(this).stop().fadeTo(300, 0);
			}
		}).live("mouseout", function(){
			if($.browser.msie){
				$(this).css({"background-position":"left top"});
			} else {
				$(this).stop().fadeTo(300, 1);
			}
		}).live('click', function() {
			$('#contact_form').fadeTo("fast", 0, function () {
			 $(this).hide();
			 postit();
		});
        return false;
    });

    function postit(){
            $.post('/_contact.inc.php', {'update':'update', 'name': $("input[name='name']").val(), 'email' : $("input[name='email']").val(), 'subject' : $("input[name='subject']").val(), 'message' : $("textarea[name='message']").val(), 'submit' : 'submit'}, 
            function(data){
				$('#contact_form').html(data);
				$('#contact_form').show().fadeTo("fast",1);
            }, "html");
    }
});