/*
 Theme Name: DesignStudio Portfolio
 Description: DesignStudio Portfolio for ThemeForest
 Author: Innovatics GmbH
 Author URI: http://www.innovatics.de/
 Version: 1.0
*/

document.write('<script type="text/javascript" src="js/jquery.tools.min.js"></script>');
document.write('<script type="text/javascript" src="js/cufon-yui.js"></script>');
document.write('<script type="text/javascript" src="js/jquery.fancybox-1.3.1.pack.js"></script>');
document.write('<script type="text/javascript" src="js/texgyreheros.font.js"></script>');
document.write('<script type="text/javascript" src="js/jquery.validate.min.js"></script>');
document.write('<script type="text/javascript" src="js/jquery.infieldlabel.min.js"></script>');

// Not necessary for the theme - only for preview!!!
document.write('<script type="text/javascript" src="js/jquery.cookie.js"></script>')

$(document).ready(function() {

	/********************************************************************************/
	// Not necessary for the theme - only for preview!!!

	// "color-switcher" animation
	if($.cookie('color-toggle') == null)
		$.cookie('color-toggle', 1);

	$('#color-switcher').attr('style', $.cookie('color-toggle') == 1 ? 'height: 0px' : 'height: 150px');
	$('#color-slider').attr('style', $.cookie('color-toggle') == 1 ? 'height: 35px' : 'height: 184px');

	$('#color-slider').live('click', function() {
		$('#color-switcher').animate({height: $.cookie('color-toggle') == 1 ? '0px' : '150px'}, 'slow');
		$(this).animate({height: $.cookie('color-toggle') == 1 ? '35px' : '184px'}, 'slow');

		$.cookie('color-toggle', $.cookie('color-toggle') == 0 ? 1 : 0);
    	$('#space').animate({height: $.cookie('color-toggle') == 0 ? '0px' : '150px'}, 'slow');
	});

	/********************************************************************************/

    // Replace fonts
    Cufon.replace('.texgyreheros');

    // In field labels
    $(function(){ $("label").inFieldLabels(); });

    // Fancy box gallery
	$("a.gallery").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600,
		'speedOut'		:	200,
		'overlayShow'	:	true
	})

	// Slider one - based on jquery tools scrollable
	$(".slider_navi #point1").addClass("active");

    $(".image_slider").scrollable({
        vertical: true,
        circular: true
    }).navigator({
        navi: ".slider_navi",
        naviItem: 'a',
        activeClass: 'active',
        history: true
    }).autoscroll({ autoplay: true, interval: 7000 });

	// Opens an outside link in a new tab
	$('a[href^=http]').click( function() {
		window.open(this.href);
 		return false;
	});

	// Form validation
	$("#form-contact").validate({
		messages: {
			name:    'Please enter your full name.',
			email:   'Please enter your email address.',
			subject: 'Please enter a subject.',
			message: 'Please enter your description.'
		}
	});

    // Smooth scrolling to anchors
    $(function(){

        $('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}, 1500);

                    return false;

                }

            }

        });

    });


});
