/* Create the new window */
function openInNewWindow(e) {
    var event;
    if (!e) event = window.event;
    else event = e;
    // Abort if a modifier key is pressed
    if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) {
        return true;
    }
    else {
        // Change "_blank" to something like "newWindow" to load all links in the same new window
        var newWindow = window.open(this.getAttribute('href'), '_blank');
        if (newWindow) {
            if (newWindow.focus) {
                newWindow.focus();
            }
            return false;
        }
        return true;
    }
}

/*
Add the openInNewWindow function to the onclick event of links with a class name of "new-window"
*/
function getNewWindowLinks() {
    // Check that the browser is DOM compliant
    if (document.getElementById && document.createElement && document.appendChild) {
        // Change this to the text you want to use to alert the user that a new window will be opened
        //var strNewWindowAlert = " (opens in a new window)";
        // Find all links
        var links = document.getElementsByTagName('a');
        //var objWarningText;
        var link;
        for (var i = 0; i < links.length; i++) {
            link = links[i];
            // Find all links with a class name of "non-html"
            if (/\bblank\b/.test(link.className)) {
                // Create an em element containing the new window warning text and insert it after the link text
                //objWarningText = document.createElement("em");
                //objWarningText.appendChild(document.createTextNode(strNewWindowAlert));
                //link.appendChild(objWarningText);
                link.onclick = openInNewWindow;
            }
        }
    //objWarningText = null;
    }
}

$(document).ready(function(){
    getNewWindowLinks();

    $(".colorbox").colorbox();
    //$(".colorbox").colorbox({innerHeight:"80%"});
    $("a[href='../../utilizzo']").colorbox({opacity: 0.1,iframe:true,width:350, height:450});
    $(".colorbox_iframe").colorbox({iframe:true, width:650, height:550});

    $(".button_info").colorbox({width:"50%", inline:true, href:"#product_description", opacity: 0.1});
    $(".button_instructions").colorbox({width:"50%", inline:true, href:"#instructions_info", opacity: 0.1});

});


function formatText(index, panel) {
    return index + "";
}

$(function () {
    $('.anythingSlider').anythingSlider({
        easing: "easeInOutExpo",            // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                     // This turns off the entire FUNCTIONALY, not just if it starts running or not.
        delay: 10000,                       // How long between slide transitions in AutoPlay mode
        startStopped: true,                 // If autoPlay is on, this can force it to start stopped
        animationTime: 600,                 // How long the slide transition takes
        hashTags: true,                     // Should links change the hashtag in the URL?
        buildNavigation: true,              // If true, builds and list of anchor links to link to each slide
        pauseOnHover: true,                 // If true, and autoPlay is enabled, the show will pause on hover
        startText: "Play",                  // Start text
        stopText: "Stop",                   // Stop text
        navigationFormatter: formatText     // Details at the top of the file on this use (advanced use)
    });

    $("#slide-jump").click(function(){
        $('.anythingSlider').anythingSlider(6);
    });
});
