$(document).ready(function () {

    //submitknapper
    $('.btnSubmit').click(function (event) {
        event.preventDefault();
        $(this).closest('form').submit();
    });

    prepareFormFieldsLabelInside();
    $('link[href="/umbraco/plugins/umbracoContour/css/defaultform.css"]').remove();

    if ($('#gallerySlider').length > 0) {
        $('#gallerySlider').after('<div id="slidenav" class="slidenav">').cycle({
            fx: 'fade',
            speed: 1000,
            timeout: 6000,
            pager: '#slidenav'
        });
    }

    /*
    $("div#gallerySlider").slideViewerPro({
        NovicellthumbsWidth: 63,
        NovicellthumbsHeight: 41,
        thumbs: 6,
        NovicellButtonsHeight: -8
    });
    */
    $(".colLeft .nav a.selected").parents(".colLeft .nav ul").show();
    $(".colLeft .nav a.selected").parent().children("ul").show();
});

function prepareFormFieldsLabelInside() {
    $('textarea[title]').focus(function () {
        showHideInputValue($(this), 'focus');
    }).blur(function () {
        showHideInputValue($(this), 'blur');
    }).each(function () {
        showHideInputValue($(this), 'blur');
    });
    $('input[type=text][title]').focus(function () {
        showHideInputValue($(this), 'focus');
    }).blur(function () {
        showHideInputValue($(this), 'blur');
    }).each(function () {
        showHideInputValue($(this), 'blur');
    });
}
function showHideInputValue(argObj, argStrType) {
    if (argStrType == 'focus' && $(argObj).val() == $(argObj).attr('title'))
        $(argObj).val('')
    else if ($(argObj).val() == "")
        $(argObj).val($(argObj).attr('title'))
}

function say(txt) {
    $('body').prepend('<span style="color:#fff">' + txt + '</span><hr />');
}
