﻿// Fix iPhone viewport scaling bug on orientation change
// By @mathias, @cheeaun and @jdalton
(function (doc) {

    var addEvent = 'addEventListener',
	    type = 'gesturestart',
	    qsa = 'querySelectorAll',
	    scales = [1, 1],
	    meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];

    function fix() {
        meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
        doc.removeEventListener(type, fix, true);
    }

    if ((meta = meta[meta.length - 1]) && addEvent in doc) {
        fix();
        scales = [.25, 1.6];
        doc[addEvent](type, fix, true);
    }

} (document));


/*CUFON*/
Cufon.replace('h1,h2,h3, ul.main-nav li,#successMessage', { hover: true });


// jquery start
jQuery(document).ready(function ($) {

    //fake placeholder
    $(function () {
        if (!$.support.placeholder) {
            var active = document.activeElement;
            $(':text').focus(function () {
                if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
                    $(this).val('').removeClass('hasPlaceholder');
                }
            }).blur(function () {
                if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
                    $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
                }
            });
            $(':text').blur();
            $(active).focus();
            $('form').submit(function () {
                $(this).find('.hasPlaceholder').each(function () { $(this).val(''); });
            });
        }
    });

    /////////////////////////////////////////////
    // Scroll to top 							
    /////////////////////////////////////////////
    $('.back-top a').click(function () {
        $('body,html').animate({
            scrollTop: 0
        }, 800);
        return false;
    });



    /////////////////////////////////////////////
    // Screenshot overlay						
    /////////////////////////////////////////////

    // Overlay
    $('.screenshot').prepend('<div class="overlay"></div>');
    $('.overlay').live('click', function () {
        window.location = $(this).parent('.screenshot').find("a").attr("href");
        return false;
    });

    // fade in/out buttons
    $('.screenshot').hover(function () {
        $(this).find('.buttons').stop(true, true).fadeIn(300);
        $(this).find('.overlay').stop(true, true).fadeIn(800);
    }, function () {
        $(this).find('.buttons').stop(true, true).fadeOut(200);
        $(this).find('.overlay').stop(true, true).fadeOut(500);
    });

    


    /*fancybox*/
    $(".various").fancybox({
        width: 280,
        height: 260
    });



   

});




var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-4634955-2']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
