$(document).ready(function() {

    // topmenu hover function ie6 fix.
    $('li.headlink').hover(function() {
        $('a', this).css('color', '#bb016e');
        $('ul', this).css('left', '0px');
        $('a', this).css('background', '#000');
    }, function() {
        $('ul', this).css('left', '-5000000px');
        $('a', this).css('color', '#FFF');
        $('a', this).css('background', '#bb016e');
    });


    // Clear field value when clicked
    $(".has_default_value").focus(function() {
        if ($(this).val() == $(this).attr("title")) {
            $(this).val("");
        }
    });
    $(".has_default_value").blur(function() {
        if ($(this).val() == "") {
            $(this).val($(this).attr("title"));
        }
    });
    // Colorbox
    try {
        $('a.colorbox').colorbox({ transition: 'slide', speed: 500 });
    }
    catch (err) { }
    // Fading testimonials
    //    $('ul.testimonials li').css({
    //        'display': 'none',
    //        'visibility': 'visible'
    //    });
    //    $('ul.testimonials li').animate({
    //        'opacity': '0.99'
    //    });
    //    $('ul.testimonials li.active').css({
    //        'display': 'block'
    //    });
    ////    $('ul.testimonials').everyTime(6000, function() {
    ////        if ($(this).children('li.active').next('li').length != 0) {
    ////            $(this).children('li.active').next('li').addClass('active').fadeIn(2000).prev('li').removeClass('active').fadeOut(2000);
    ////        }
    ////        else {
    ////            $(this).children('li:last').removeClass('active').fadeOut(2000);
    ////            $(this).children('li:first').addClass('active').fadeIn(2000)
    ////        }
    ////    });
    //    $('ul.testimonials_2 li').css({
    //        'display': 'none',
    //        'visibility': 'visible'
    //    });
    //    $('ul.testimonials_2 li').animate({
    //        'opacity': '0.99'
    //    });
    //    $('ul.testimonials_2 li.active').css({
    //        'display': 'block'
    //    });
    //    $(document.body).oneTime(3000, function() {
    //        $('ul.testimonials_2').children('li.active').next('li').addClass('active').fadeIn(2000).prev('li').removeClass('active').fadeOut(2000);
    //    });
    //    $(document.body).oneTime(3000, function() {
    //        $('ul.testimonials_2').everyTime(10000, function() {
    //            if ($(this).children('li.active').next('li').length != 0) {
    //                $(this).children('li.active').next('li').addClass('active').fadeIn(2000).prev('li').removeClass('active').fadeOut(2000);
    //            }
    //            else {
    //                $(this).children('li:last').removeClass('active').fadeOut(2000);
    //                $(this).children('li:first').addClass('active').fadeIn(2000)
    //            }
    //        });
    //    });
    // FadeRoll
    $('a').hover(function() {
        $(this).find('.faderoll').stop().fadeTo(0, 0.60);
    }, function() {
        $(this).find('.faderoll').stop().fadeTo(200, 1.00);
    });
    // jQZoom
    try {
        $('.zoomable').jqzoom({
            fadeoutSpeed: 'fast',
            hideEffect: 'fadeout',
            imageOpacity: '0.25',
            preloadText: 'Loading',
            title: false,
            xOffset: 14,
            yOffset: 0,
            zoomHeight: 430,
            zoomWidth: 440
        });
    }
    catch (err) {

    }

    // Changable tabs
    $('div.changable_tabs ul.tabs').show();
    $('div.changable_tabs div.content h2').hide();

    $('div.changable_tabs ul.tabs li.tab_1 a').click(function() {
        setTab1();
    });
    $('div.changable_tabs ul.tabs li.tab_2 a').click(function() {
        setTab2();
    });
    $('div.changable_tabs ul.tabs li.tab_3 a').click(function() {
        setTab3();
    });
    $('div.changable_tabs ul.tabs li.tab_4 a').click(function() {
        setTab4();
    });

    // Remove focus outline on click
    $("a").mousedown(function() {
        this.blur();
        this.hideFocus = true;
        this.style.outline = 'none';
    });

    // Rollovers
    $(".rollover").hover(function() {
        this.src = this.src.replace("_off.", "_on.");
    },
	function() {
	    this.src = this.src.replace("_on.", "_off.");
	});
    $(".rollover").each(function() {
        source_image = $(this).attr("src");
        rename_image = source_image.replace(/\_off./gi, "_on.");
        $("<img>").attr("src", rename_image);
    });

});

    function setTab1() {
        $('div.changable_tabs ul.tabs li a').removeClass('current');
        $('div.changable_tabs ul.tabs li.tab_1 a').addClass('current');
        $('div.changable_tabs div.content').hide();
        $('div.changable_tabs div.content_1').show();
        return false;
    }

    function setTab2() {
        $('div.changable_tabs ul.tabs li a').removeClass('current');
        $('div.changable_tabs ul.tabs li.tab_2 a').addClass('current');
        $('div.changable_tabs div.content').hide();
        $('div.changable_tabs div.content_2').show();
        return false;
    }

    function setTab3() {
        $('div.changable_tabs ul.tabs li a').removeClass('current');
        $('div.changable_tabs ul.tabs li.tab_3 a').addClass('current');
        $('div.changable_tabs div.content').hide();
        $('div.changable_tabs div.content_3').show();
        return false;
    }




    function setTab4() {
        $('div.changable_tabs ul.tabs li a').removeClass('current');
        $('div.changable_tabs ul.tabs li.tab_4 a').addClass('current');
        $('div.changable_tabs div.content').hide();
        $('div.changable_tabs div.content_4').show();
        return false;
    }