﻿jQuery.noConflict();
jQuery(document).ready(function() {
    /* showes the popup on img hover */
    jQuery('ul.mainNavigation li').bind("mouseenter", function() {
        jQuery(this).children('span').addClass('hover');
    }).bind("mouseleave", function() {
        jQuery(this).children('span').removeClass('hover');
    });

    //Link Arrow    
    jQuery('.readmore').arrowBefore();
    jQuery('.paging-buttons .prev').pagingArrowBefore();
    jQuery('.paging-buttons .next').pagingArrowAfter();

    //Empty searchfield
    jQuery('#quickSearch .textfield').click(function() {
        jQuery(this).val("");
    });

    //Tabel rows
    jQuery('table tr:even').addClass('even');

    //startpage leftarea portlets
    jQuery('.startPage #leftContentPortlets .x-portlet').addClass('noBottom');
    jQuery('.startPage #leftContentPortlets .last-portlet').removeClass('noBottom');

    //Put class on first "normal" news
    if (jQuery('.startPage .newslist div:first').hasClass('normal')) {
        jQuery('.startPage .newslist div:first').addClass('firstNormal');
    }

    jQuery('ul.headerLinks li:first').addClass('first');

    //Quick search clearer
    var searchText = jQuery('.quickSearch input.textfield').val().length;
    if (searchText == "0") {
        jQuery('.quickSearch .textfield').val("Sök");
    }
    jQuery('.quickSearch input.textfield').focus(function() {
        var searchOrd = jQuery('.quickSearch input.textfield').val();
        if (searchOrd == "Sök") {
            jQuery('.quickSearch input.textfield').val("");
        } 
    });
});

jQuery.fn.arrowBefore = function(){
    if(this.size() > 0) {
        this.each(function(){
            jQuery(this).prepend("<span class='arrow'>&rsaquo;&nbsp;</span>");
        });
    }
};
jQuery.fn.arrowAfter = function(){
    if(this.size() > 0) {
        this.each(function(){
            jQuery(this).append("<span class='arrow'>&nbsp;&lsaquo;</span>");
        });
    }
};

jQuery.fn.pagingArrowBefore = function(){
    if(this.size() > 0) {
        this.each(function(){
            jQuery(this).prepend("<span class='arrow'>&lsaquo;&nbsp;</span>");
        });
    }
};
jQuery.fn.pagingArrowAfter = function(){
    if(this.size() > 0) {
        this.each(function(){
            jQuery(this).append("<span class='arrow'>&nbsp;&rsaquo;</span>");
        });
    }
};

