﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />

var Garant = {};
Garant.menuHover = {
    init: function() {
        jQuery('#main-menu ul li').hover(
        function() {
            jQuery(this).addClass('hover');
        },
        function() {
            jQuery(this).removeClass('hover');
        });
    }
};

Garant.Tabs = {
    inst: null,
    init: function() {
        this.inst = jQuery("ul.tabs").tabs("div.panes > div", { 
            history: true,
            onClick: function(evt, index) {
                jQuery("input[id$='SelectedTab']").attr("value", index);
            },
            initialIndex: jQuery("input[id$='SelectedTab']").attr("value")
        });
    }
};
Garant.Popup = {
    printIt: function(url) {
        var win = window.open('', 'Image', 'resizable=yes,...');
        if (win.document) {
            win.document.writeln('<img src="' + url + '" alt="image" />');
            win.document.close();
            win.focus();
            win.print();
        }
        return false;
    }
};

jQuery(document).ready(function () {
    Garant.menuHover.init();
    jQuery(".drop-down").styleSelect({ styleClass: "fancy-select", optionsWidth: 1, speed: 'fast' });
    Garant.Tabs.init();
    jQuery("#product-list ul li a.image-link").simpletooltip();
    jQuery(".rating-area .average-rating").hover(function () { jQuery(this).addClass("hover"); }, function () { jQuery(this).removeClass("hover"); });
    //    jQuery('#slideshow').innerfade({
    //        speed: 2000,
    //        timeout: 10000,
    //        containerheight: '605px'
    //    });
    var $slideshow = $('#slideshow');
    if ($slideshow.length > 0) {
        var timeout = 6000;
        var confAttr = $slideshow.attr('rel');
        if (typeof confAttr !== 'undefined' && confAttr !== false) {
            var conf = $.parseJSON(confAttr.replace(/'/g, '"'));
            if (conf != null)
                timeout = conf.timeout;
        }
        $('#slideshow').cycle({
            fx: 'scrollLeft',
            timeout: timeout,
            speed: 600,
            delay: -1000,
            prev: '#prev-prod',
            next: '#next-prod',
            pause: 1
        });
    }
    jQuery(".start-talk .talk-text").click(function () {
        if (jQuery(this).hasClass("no-text")) {
            jQuery(this).removeClass("no-text");
            jQuery(this).val('');
        }
    });
    jQuery(".start-talk .talk-text").blur(function () {
        if (jQuery(this).val() == '') {
            jQuery(this).addClass("no-text");
            jQuery(this).val('Jag tycker...');
        }
    });
    jQuery('.report-post a').click(function (e) {
        if (!confirm('Vill du anmäla denna kommentar?')) return false;
    });

    //bad hack for a link to work in IE7 on slideshow images:
    //    jQuery('#page #slideshow img').click(function(e) {
    //        var link = jQuery('#page a.slideshow');
    //        window.location = link.attr('href').toString();
    //    });

});
