// Nicer margins for content images based on their position
$(".textpage img").each(function() {
    if ( $(this).css("float") == "left" ) {
        $(this).css("margin-left", "0px");
    } else if ( $(this).css("float") == "right" ) {
        $(this).css("margin-right", 0);
    }
});
// Hide input text on click
$("input.placeholder").placeholder();
// IE Safari detect ( for button fixes )
(function($) {
    var userAgent = navigator.userAgent.toString().toLowerCase();
    if ((userAgent.indexOf('safari') != -1) && !(userAgent.indexOf('chrome') != -1) && (navigator.platform=="Win32" || navigator.platform=="Win64")) {
        $("body").addClass("safari");
    }
})(jQuery);

var basehref = location.href;

if(basehref.indexOf("#") != -1) {
    basehref = basehref.substr(0,basehref.indexOf("#"));
}

$("a").each(function() {
    var url = $(this).attr("href");
    if(url) {
        if(url.indexOf("#") == 0) {
            $(this).attr("href",basehref+url);
        }
    }
});

$(document).ready(function() {
    swfobject.registerObject("karuke", "9.0.0");
    $(window).load(function() {
        $("div#logos").smoothDivScroll({
            scrollStep: 2,
            autoScroll: "onstart",
            autoScrollDirection: "endlessloopright",
            autoScrollStep: 2,
            autoScrollInterval: 40
        });
        $("div#logos").bind("mouseover", function() {
            $(this).smoothDivScroll("stopAutoScroll");
        }).bind("mouseout", function() {
            $(this).smoothDivScroll("startAutoScroll");
        });
    });

    // slideshow

    $('.slideshow').cycle({
        fx: 'fade'
    });

    // image vertical align
    $('.vert').each(function() {
        var img = $(this);
        var img_height = img.height();
        img.css({
            'margin-top': (img_height/2)*-1.1
        });
    });
});
