
var str = window.location.pathname;
if(str.search(/kopprocess/i) == -1)
{
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-9459057-1']);
    _gaq.push(['_trackPageview']);


    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
    })();
}
$(function() {    
    $('a[href^=mailto:]').click(function () {
        var mailto = "/mailto/" + $(this).text() + "/";
        _gaq.push(['_trackPageview', mailto]);
    });
    
    $('a[href^="http"]').not("[href*='dinel.se']").click(function () {
        var exit = "/exit/" + $(this).attr("href");
        _gaq.push(['_trackPageview', exit.replace(/https?:\/+/i,"")]);
    });
     
    $('a[href*=.doc], a[href*=.xls], a[href*=.docx], a[href*=.xlsx], a[href*=.pdf]').click(function () {
        _gaq.push(['_trackPageview', $(this).attr("href")]);
    }); 

    $('a[href^=javascript:window.print]').click(function () {
        _gaq.push(['_trackEvent', 'Utskrifter', window.location.pathname]);
    }); 

    $(".contactButton").click(function () {
        _gaq.push(['_trackPageview', '/kontakta-kundtjanst/']);
    });

    $(".forumCreate").click(function () {
        var forum = window.location.pathname + 'skapat-trad/';
        _gaq.push(['_trackPageview', forum]);
    });
    $(".forumReply").click(function () {
        var forum = window.location.pathname + 'svarat/';
        _gaq.push(['_trackPageview', forum]);
    });   
    
    $(".commentButton").click(function () {
        var comment = window.location.pathname + 'kommenterat/';
        _gaq.push(['_trackPageview', comment]);
    }); 
    
    $(".feedbackButton").click(function () {
        if ($(".thankYouFeedbackValue").val().length > 0 )
        {
            var value = $(".thankYouFeedbackValue").val();
            resGrade = "";
            if (value < 33){
                resGrade = "Mycket latt";
            }
            else if (value < 66){
                resGrade = "Latt";
            }
            else if (value < 100){
                resGrade = "Svart";
            }
            else{
                resGrade = "Mycket svart";
            }
            var valueInt = parseInt(value);
            _gaq.push(['_trackEvent', 'Nojdhet', 'Kopprocess', resGrade, valueInt]);
        }
    });  
    
    $('a[title="Ja"]').click(function () {
        var question = $(this).attr("href");
        $(this).parent().prev().html('Tack! Ditt svar hj&auml;lper oss att f&ouml;rb&auml;ttra v&aring;r webbplats.').text();
        $(this).parent().hide();
        $(this).removeAttr("href");
        var resQuestion = question.replace(/#/i,"");
        _gaq.push(['_trackEvent', 'FAQ', 'Ja', resQuestion, 100]);
    });   
    
    $('a[title="Nej"]').click(function () {
        var question = $(this).attr("href");
        $(this).parent().prev().html('Tack! Ditt svar hj&auml;lper oss att f&ouml;rb&auml;ttra v&aring;r webbplats.').text();
        $(this).parent().hide();
        $(this).removeAttr("href");
        var resQuestion = question.replace(/#/i,"");
        _gaq.push(['_trackEvent', 'FAQ', 'Nej', resQuestion, 0]);
    });     
});

//Script to track clicks in Flash to Google Analytics
function trackFlash(heading){
	var path = window.location.pathname + 'flash/' + heading + '/';
	_gaq.push(['_trackPageview', path]);
}

//Script to track feedback after purchase to Google Analytics
function GetRadioValue (radioControl) {
    var value = radioControl.value;
    if (value < 33)
    {
        $(".thankYouFeedbackValue").val("0");
        $(".thankYouFeedbackGrade").val("Mycket L&auml;tt");    
    }
    else if (value < 66)
    {
        $(".thankYouFeedbackValue").val("33");
        $(".thankYouFeedbackGrade").val("L&auml;tt");    
    }
    else if (value < 100)
    {
        $(".thankYouFeedbackValue").val("66");
        $(".thankYouFeedbackGrade").val("Sv&aring;rt");    
    }
    else
    {
        $(".thankYouFeedbackValue").val("100");
        $(".thankYouFeedbackGrade").val("Mycket sv&aring;rt");    
    }
}
