/** Cufon **/

Cufon.replace('h1, h2, h3, h5, #menu a');

/** SWFObject **/
var flashvars = {};
var params = {};
var attributes = {};
swfobject.embedSWF("http://www.youtube.com/v/8Qwi7TeDhhg&hl=en_US&fs=1&rel=0", "video", "456", "280", "8");

/** Search label swap **/

(function($) {
    function toggleLabel() {
        var input = $(this);
        setTimeout(function() {
            var def = input.attr('title');
            if (!input.val() || (input.val() == def)) {
                input.prev('span').css('visibility', '');
                if (def) {
                    var dummy = $('<label></label>').text(def).css('visibility','hidden').appendTo('body');
                    input.prev('span').css('margin-left', dummy.width() + 3 + 'px');
                    dummy.remove();
                }
            } else {
                input.prev('span').css('visibility', 'hidden');
            }
        }, 0);
    };

    function resetField() {
        var def = $(this).attr('title');
        if (!$(this).val() || ($(this).val() == def)) {
            $(this).val(def);
            $(this).prev('span').css('visibility', '');
        }
    };

    $('input, textarea').live('keydown', toggleLabel);
    $('input, textarea').live('paste', toggleLabel);
    $('select').live('change', toggleLabel);

    $('input, textarea').live('focusin', function() {
        $(this).prev('span').css('color', '#4b4031');
    });
    $('input, textarea').live('focusout', function() {
        $(this).prev('span').css('color', '#c5c2be');
    });

    $(function() {
        $('input, textarea').each(function() { toggleLabel.call(this); });
    });

})(jQuery);

// Validate form

$(document).ready(function(){
	$("#contactForm").validate({
		rules: {
			email: {
				required:true,
				email:true
			}
		}
	});

	$("#newsletterForm").validate({
		rules: {
			email: {
				required:true,
				email:true
			}
		}
	});
});

// Form highlights

$(document).ready(function() {  
    $('input[type="text"], textarea').focus(function() {  
        $(this).addClass("active");  
    });  
    $('input[type="text"], textarea').blur(function() {  
        $(this).removeClass("active");
    });  
});



