//Cufon text
Cufon.replace('#header .bottom-bar p.phone-number',{fontFamily:'Futura Bk BT'});
Cufon.replace('#header .top-bar .slogan', {
	fontFamily:'Futura Bk BT',
	textShadow: '2px 2px rgba(0,0,0, 0.1), -2px -2px rgba(0,0,0, 0.1), -2px 2px rgba(0,0,0, 0.1), 2px -2px rgba(0,0,0, 0.1)'
})
Cufon.replace('#navigation a, #footer .links a, #footer .links span, #main .portfolio .categories li a, #main .portfolio .control a',{fontFamily:'Futura Bk BT', hover: true});
//Cufon.replace('#navigation li.current_page_item a, #main .portfolio .categories li.current_category a',{fontFamily:'Futura Md BT Bold' });
Cufon.replace('#header .bottom-bar .nav li a',{fontFamily:'Futura Md BT Medium', hover: true });
Cufon.replace('.widgettitle, #content h1, #content h2, #content h3, #content h4, #content h5, #content h6',{fontFamily:'Futura Md BT Medium' });

//Document Ready
jQuery(function($){ 
	
	$.extend($.fn, {
		rightClick: function(handler) {
			$(this).each( function() {
				$(this).mousedown( function(e) {
					var evt = e;
					$(this).mouseup( function() {
						$(this).unbind('mouseup');
						if( evt.button == 2 ) {
							handler.call( $(this), evt );
							return false;
						} else {
							return true;
						}
					});
				});
				$(this)[0].oncontextmenu = function() {
					return false;
				}
			});
			return $(this);
		},		
		
		rightMouseDown: function(handler) {
			$(this).each( function() {
				$(this).mousedown( function(e) {
					if( e.button == 2 ) {
						handler.call( $(this), e );
						return false;
					} else {
						return true;
					}
				});
				$(this)[0].oncontextmenu = function() {
					return false;
				}
			});
			return $(this);
		},
		
		rightMouseUp: function(handler) {
			$(this).each( function() {
				$(this).mouseup( function(e) {
					if( e.button == 2 ) {
						handler.call( $(this), e );
						return false;
					} else {
						return true;
					}
				});
				$(this)[0].oncontextmenu = function() {
					return false;
				}
			});
			return $(this);
		},
		
		noContext: function() {
			$(this).each( function() {
				$(this)[0].oncontextmenu = function() {
					return false;
				}
			});
			return $(this);
		}
		
	});
	
    $.fn.change_slide = function(item) {
        $(this).each(function() {
            var cnt = $(this);
            var total = cnt.find(item).length;
        	if ($(item).hasClass('testimonial')) {
        		var h = 0;
        		$(item).each(function() {
        			if ($(this).height() > h) {
        				h = $(this).height();
        			}
        		});
        		
        		cnt.height(h);
    		}
            if (total > 1) {
                setInterval(function() {
                    var current = cnt.find(item).index(cnt.find(item + ':visible'));
                    if (current < total - 1) {
                        current++;
                    } else {
                        current = 0;
                    }
                    cnt.find(item + ':visible').fadeOut(1000);
                    cnt.find(item + ':eq(' + current + ')').fadeIn(1000);
                    
                }, 6000);
            }
        });
    }
    
    $('#header #slider').change_slide('li');
	
	$('#navigation li:last, .nav li:last').addClass('last');
	$('#footer .links ul').each(function() {
		$(this).find('span:last').remove();
	});
	
	$(".thumbs-slider li a:odd").addClass('right');
	$(".thumbs-slider li a:even").addClass('left');
	
	//Portfolio Thumbs Slider
	if ($('.portfolio .thumbs-slider ul').length) {
		$('.portfolio .thumbs-slider ul').cycle({
			fx: 'fade',
			timeout: 0
		});
	}
	
    jQuery('.thumbs-slider .control .next').bind('click', function() {
        $('.portfolio .thumbs-slider ul').cycle('next');
        return false;
    });

    jQuery('.thumbs-slider .control .prev').bind('click', function() {
        $('.portfolio .thumbs-slider ul').cycle('prev');
        return false;
    });
    
    jQuery('.thumbs-slider li a').click(function() {
    	$('.portfolio .main-slider ul').cycle(jQuery('.thumbs-slider li a').index($(this)));
    });
    
    //Main Portfolio Slider
	
    if ($('.portfolio .main-slider ul').length) {
	    $('.portfolio .main-slider ul').cycle({
			fx: 'fade',
			timeout: 6000
		}).cycle('pause');
    }
	
    jQuery('.stop-carousel').bind('click', function() {
		$('.portfolio .main-slider ul').cycle('pause');
    	return false;
    });
    
    jQuery('.start-carousel').bind('click', function() {
    	$('.portfolio .main-slider ul').cycle('resume');
    	return false;
    });
    
    jQuery('.main-slider .control .next').bind('click', function() {
        $('.portfolio .main-slider ul').cycle('next');
        return false;
    });

    jQuery('.main-slider .control .prev').bind('click', function() {
        $('.portfolio .main-slider ul').cycle('prev');
        return false;
    });
	
	//PNG Fix
	if($.browser.msie && $.browser.version == 6){
		DD_belatedPNG.fix('#logo a, #wrapper-bg, .top-bar, .bottom-bar, #header .inner, #footer, .caption');
	}
	
	$('#slider img, .portfolio img, .page-main-image img').noContext();
	
	$('#slider img, .page-main-image img').each(function() {
		var img = new Image();
		img.src = $(this).attr('src');
	});
	
	$('.testimonials-cnt').each(function() {
		$(this).change_slide('.testimonial');
		
		if ($(this).find('.testimonial').length < 2) {
			return true;
		}
		
	});

	$('.fancybox-swf').fancybox({
		'padding': 0,
		'autoScale': false,
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'width': 720,
		'height': 396
	});
	
});


