       $(document).ready(function(){
		   
		//rotate the background image
		var arrBg = ['sd','shoes' ];
		var bgImg = arrBg[Math.floor(Math.random()*2)];
		var srcBgImg = 'images/' + bgImg + '-bg.jpg';
		$('body').css('background-image','url(' + srcBgImg + ')');
		   
		   
		//fix footer issue on iPad and iPhone
		if (navigator.platform == 'iPad' || navigator.platform == 'iPhone') {
			$("footer").css("position", "static");
		}

		//get URL
		$url = window.location.href;
		$hash = $url.split('#')[1];

		//change the section height
		setSectionSize();

		$(window).resize(function() {
		  setSectionSize();
		});

		//hide or show tagline based on hash
		if($hash == 'top' || $hash=='' || !$hash){
				$('#tagline').show();
				$('#back-to-top').hide();
				}
			else{
				$('#tagline').hide();
				$('#back-to-top').show();
			}

		$('nav a').each(function(){
			if($(this).text()==$hash){
				$(this).addClass('active');
				}
			});
	
		
		
		//work 
		$('#workthumbs div').click(function(){
			$('#workthumbs').fadeOut();
			$('#workdetails').css('left','110px');	
			$('#work .grid').show();
			$('#work .single').hide();
			
			//get the id //show the correct site
			var $workIndex = parseInt($(this).attr('id').substring(4));
			var $workPos = $workIndex * -900;
			$('#slider').css('left', $workPos + 'px');
			
			//make the correct link active
			$('.thumbNav li a').removeClass('cur');
			$('.panel'+ $workIndex).addClass('cur');
			 });	
		
		$('#work .grid').click(function(){
			$('#workdetails').css('left','-9999px');	
			$('#workthumbs').fadeIn();
			$('#work .grid').hide();
			$('#work .single').show();
			});
		
		$('#work .single').click(function(){
			$('#workthumbs').fadeOut();
			$('#workdetails').css('left','110px');	
			$('#work .grid').show();
			$('#work .single').hide();
			});
		
		
		//about
		$('.key').click(function(){
			$keyClass = $(this).attr('class');
			$keyClass = $keyClass.split(' key')[0];

			//save the current height for each skill
			$("." + $keyClass).each(function(){
				$skillHeight = $(this).css('height');
				$(this).attr('title',$skillHeight);
				});
				
			//set the height of each skill to 0
			$("." + $keyClass).animate({height: "0%"}, 500 );
			
			//grow each skill to appropriate height
			setTimeout(skillGrow($keyClass),500);
			
			});
		
		//nav
		$('nav li a').click(function(){
			$('nav li a').removeClass('active')			 
			$(this).addClass('active');
			$('#tagline').hide();
			$('#back-to-top').show();
			});
								  
		$('#back-to-top').click(function(){
			$('nav li a').removeClass('active')			 
			$(this).hide();
			$('#tagline').show();
			});
	   
	   
	   $("#website").change(function () {
          var str = "";
          str += $("#website option:selected").text();
		  if(str == "I want more information and links to your best work, not featured here."){
			  $('#cms').hide();
			  $('#seo').hide();
			  $('#designspecs').hide();
			  $('#updates').hide();
			  }
			else{
			  $('#cms').show();
			  $('#seo').show();
			  $('#designspecs').show();
			  $('#updates').show();
				}
        })
        .change();

	   
	   });
	   
//begin functions

function website() {
     alert('change');
  }

function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 
function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}
		
function setSectionSize(){
		$('section').css('height', $(window).height());
	}
	
function skillGrow(key){
		$("." + key).each(function(){
		$skillToHeight = $(this).attr('title');
		$(this).animate({height: $skillToHeight}, 1500 );
		});
	}	
	
	
//fancy scroll


	   $(function() {
        
                function filterPath(string) {
                        return string
                        .replace(/^\//,'')
                        .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
                        .replace(/\/$/,'');
                }
        
                var locationPath = filterPath(location.pathname);
                var scrollElem = scrollableElement('html', 'body');
        
                // Any links with hash tags in them (can't do ^= because of fully qualified URL potential)
                $('a[href*=#]').each(function() {
        
                        // Ensure it's a same-page link
                        var thisPath = filterPath(this.pathname) || locationPath;
                        if (  locationPath == thisPath/**/
                                && (location.hostname == this.hostname || !this.hostname)
                                && this.hash.replace(/#/,'') ) {
        
                                        // Ensure target exists
                                        var $target = $(this.hash), target = this.hash;
                                        if (target) {
        
                                                // Find location of target
                                                var targetOffset = $target.offset().top;
                                                $(this).click(function(event) {
        
                                                        // Prevent jump-down
                                                        event.preventDefault();
        
                                                        // Animate to target
                                                        $(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
        
                                                                // Set hash in URL after animation successful
                                                                location.hash = target;
        
                                                        });
                                                });
                                        }
                        }
        
                });
        
                // Use the first element that is "scrollable"  (cross-browser fix?)
                function scrollableElement(els) {
                        for (var i = 0, argLength = arguments.length; i <argLength; i++) {
                                var el = arguments[i],
                                $scrollElement = $(el);
                                if ($scrollElement.scrollTop()> 0) {
                                        return el;
                                } else {
                                        $scrollElement.scrollTop(1);
                                        var isScrollable = $scrollElement.scrollTop()> 0;
                                        $scrollElement.scrollTop(0);
                                        if (isScrollable) {
                                                return el;
                                        }
                                }
                        }
                        return [];
                }
        });
			


