﻿function checkUncheckAll(theElement) {
    var theForm = theElement.form, z = 0;
    for (z = 0; z < theForm.length; z++) {
        if (theForm[z].type == 'checkbox' && theForm[z].name == 'checkbox4process') {
            theForm[z].checked = theElement.checked;
        }
    }
}

$(document).ready(function() {
    $(".lUser").val('E-Posta');

    $('.lUser').focus(function() {
        var newValue = $(this).val();
        if ($(this).val() == 'E-Posta') {
            $(this).attr('value', '');
        } else {
            $(this).val(newValue);
        }
    });

    $('.lUser').blur(function() {
        var newValue = $(this).val();
        if ($(this).val() == '') {
            $(this).attr('value', 'E-Posta');
        } else {
            $(this).val(newValue);
        }
    });

    $(".lPass").val('Şifre');

    $('.lPass').focus(function() {
        var newValue = $(this).val();
        if ($(this).val() == 'Şifre') {
            $(this).attr('value', '');
        } else {
            $(this).val(newValue);
        }
    });

    $('.lPass').blur(function() {
        var newValue = $(this).val();
        if ($(this).val() == '') {
            $(this).attr('value', 'Şifre');
        } else {
            $(this).val(newValue);
        }
    });

    $('.tSearch').focus(function() {
        var newValue = $(this).val();
        if ($(this).val() == 'Site içi arama') {
            $(this).attr('value', '');
        } else {
            $(this).val(newValue);
        }
    });

    $('.tSearch').blur(function() {
        var newValue = $(this).val();
        if ($(this).val() == '') {
            $(this).attr('value', 'Site içi arama');
        } else {
            $(this).val(newValue);
        }
    });

});


/*--------------------------------*/
function js_dropdownbuilderParams(dropdownID, targetClass, className, targetClassID) {

    //Parametre Açıklamaları
    //dropdownID : style değiştirilecek ddl in client ID si, örnek : '#ctl00_header1_cmbCategory' ya da '#cmbCategory' gönderilir.
    //targetClass : yaratılan ddl in hanigi nesne içine yerleşeceğini belirtmek için, mesela <div class="cmb-style"></div> içine yerleşmesi için ".cmb-style" gönderilir.
    //className : yaratılan ddl in css kodlarını çağırması için kullanacağı class adı, örnek : 'yeniddlclassı'
    //targetClassID : her ddl için farklı olması gereken hizalama IDsi, örnek : 'ddlTargetClass_01'  ,02,03....

    js_createDropDown(dropdownID, targetClass, className, targetClassID);

    $("." + className + " dt a").click(function() {
        $("." + className + " dd ul").toggle();
    });

    $(document).bind('click', function(e) {
        var $clicked = $(e.target);
        if (!$clicked.parents().hasClass(className))
            $("." + className + " dd ul").hide();
    });

    $("." + className + " dd ul li a").click(function() {
        var text = $(this).html();
        $("." + className + " dt a").html(text);
        $("." + className + " dd ul").hide();

        var ddl_search = $(dropdownID);
        ddl_search.val($(this).find("span.value").html())
    });
}

function js_createDropDown(dropdownID, targetClass, className, targetClassID) {
    var ddl_search = $(dropdownID);
    var selected = ddl_search.find("option[selected]");
    var options = $("option", ddl_search);

    $(targetClass).append('<dl id="' + targetClassID + '" class="' + className + '"></dl>')
    $("#" + targetClassID).append('<dt><a href="#">' + selected.text() +
    '<span class="value">' + selected.val() +
    '</span></a></dt>')
    $("#" + targetClassID).append('<dd><ul></ul></dd>')

    options.each(function() {
        $("#" + targetClassID + ' dd ul').append('<li><a href="#">' +
        $(this).text() + '<span class="value">' +
        $(this).val() + '</span></a></li>');
    });
}
/*--------------------------------*/

