$(function() {
	$('.field, textarea').focus(function() {
        if(this.title==this.value) {
            this.value = '';
        }
    }).blur(function(){
        if(this.value=='') {
            this.value = this.title;
        }
    });

	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
        DD_belatedPNG.fix('#logo a, #paper, #paper-top, #paper-bottom, .box, .box .top, .box .bottom, #contact h2, .arrow, #header');
        $('#header').css({position: 'absolute'});
    }

	
    $("a[rel^='prettyPhoto']").prettyPhoto({
        animation_speed: 'fast', /* fast/slow/normal */
        slideshow: 5000, /* false OR interval time in ms */
        autoplay_slideshow: false, /* true/false */
        opacity: 0.80, /* Value between 0 and 1 */
        show_title: false, /* true/false */
        allow_resize: true, /* Resize the photos bigger than viewport. true/false */
        default_width: 500,
        default_height: 344,
        counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
        theme: 'pp_default', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
        horizontal_padding: 20, /* The padding on each side of the picture */
        hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
        wmode: 'opaque', /* Set the flash wmode attribute */
        autoplay: true, /* Automatically start videos: True/False */
        modal: false, /* If set to true, only the close button will close the window */
        deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */
        overlay_gallery: false, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
        keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
        ie6_fallback: true,
        social_tools: false
    });

    $('a').has('img').hover(function(){
        $(this).find('img').stop(true, true).fadeTo(300, 0.7);
    }, function(){
        $(this).find('img').stop(true, true).fadeTo(300, 1);
    }); 

    var scrollTop = $(window).scrollTop();
    $(window).scroll(function () {
       
            scrollTop = $(window).scrollTop();
            if ( scrollTop <= $('#general-info').offset().top && scrollTop >= $('#general-info').offset().top - 200 ) {
                $('.arrow').stop(true).animate({ width: $('#navigation ul li:eq(0) a').width(), left: $('#navigation ul li:eq(0) a').position().left }, {duration: 500, easing: 'easeInOutQuad'});
                return false;
            }  else if ( scrollTop <= $('#work').offset().top && scrollTop >= $('#work').offset().top - 200 ) {
                $('.arrow').stop(true).animate({ width: $('#navigation ul li:eq(1) a').width(), left: $('#navigation ul li:eq(1) a').position().left }, {duration: 500, easing: 'easeInOutQuad'});
                return false;
            } else if ( scrollTop <= $('#contact').offset().top &&  scrollTop >= $('#contact').offset().top - 700 ) {
                $('.arrow').stop(true).animate({ width: $('#navigation ul li:eq(2) a').width(), left: $('#navigation ul li:eq(2) a').position().left }, {duration: 500, easing: 'easeInOutQuad'});
                return false;
            }
       
        return false;
    }); 

    jQuery.easing.def = 'easeInOutQuad';

    $('a[href*=#]').click(function() {
    	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      		var $target = $(this.hash);
      		$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
      		if ($target.length) {
        		var targetOffset = $target.offset().top;
        		$('html, body').animate({scrollTop: targetOffset - 115}, 500);
       			return false;
      		}
    	}
  	});
});
