$(document).ready(function(){

    //Activate png fix
    $(document).pngFix();

    
    //Sets active class to links where page is active
    var url = window.location;
    var urlString = String(url);
    var path1 = urlString.replace('http://www.kirstenhendrich.com', '')
    var path = path1.replace('#', '');

    if (path != '/') {
        $('a[href='+path+']').addClass('active');
    }else{
        $('a[href=/]').addClass('active');
        $('a[href=/index.php]').addClass('active');
    }
    if (path.match('/blog/') != null) {
        $('a[href=/blog/]').addClass('active');
    }

   //Homepage frames fade in
   $('#frame-1, #frame-2, #frame-3, #frame-4').css('display', 'none');
   $('#frame-1, #frame-2, #frame-3, #frame-4').fadeIn('slow');

   //Drop down nav functions
   $('#main-nav ul li ul.sub-nav').css('display', 'none');
   $('ul.sub-nav li a.active').parent('li').parent('ul').parent('li').find('a:first').addClass('active');

   $('#main-nav ul li').hover(function(){
        $(this).children('ul.sub-nav').fadeIn();
   }, function(){
	$(this).children('ul.sub-nav').css('display', 'none');
   });

   //Gallery Thumbs Cursor on Hover
   $('#gallery-thumbs img').hover(function ()
    {
        $(this).css('cursor', 'pointer');
    }, function ()
    {
        $(this).css('cursor', 'auto');
    });

    //Product thumbs border change on hover (category page)
    $('.product-summary .summary-thumb img').hover(function ()
    {
        $(this).css('border-color', '#ccc');
    }, function ()
    {
        $(this).css('border-color', '');
    });

    /////##################### PRODUCT PAGE GALLERIES #################////////

    //When page loads hide all images, then fade in the first
    $('#gallery-container .large-image img').css('display', 'none');
    $('#gallery-container .large-image img:first').fadeIn();

    //css mouse pointer on hover over arrows and thumbnails
    $('#gallery-container .thumbs .inner').hover(function(){
	$(this).css({'cursor' : 'pointer', 'border-color' : '#2e2e2e'});
    }, function(){
        $(this).css({'cursor' : 'auto', 'border-color' : '#ccc'});
    });

    //When a thumbnail is clicked, fade out current image/caption and fade in the next
    $('#gallery-container .thumbs .inner img').click(function(){

    //get thumbnail class and split to get ID number, which is the class of the relative main image.
    var newClass = $(this).attr('class');

    $('#gallery-container .large-image img').css('display', 'none');

    $('#gallery-container .large-image img.'+newClass).fadeIn();
    });

    ////////############################################################////////////

    //pre select value for country dropdowns...
    var country = $('select.countries').attr('title');
    $('select.countries option[value='+country+']').attr('selected', 'selected');

});

