﻿$(document).ready(function() {
    function makeSublist(parent, child, isSubselectOptional, childVal, valBefore, valAfret) {
        $("body").append("<select style='display:none' id='" + parent + child + "'></select>");
        $('#' + parent + child).html($("#" + child + " option"));
        
        var parentValue = $('#' + parent).attr('value');
        $('#' + child).html($("#" + parent + child + " .sub_" + parentValue).clone());

        childVal = (typeof childVal == "undefined") ? "" : childVal;
        $("#" + child).val(childVal).attr('selected', 'selected');
        $('#' + child).prepend("<option value='0' selected='selected'>" + valBefore + "</option>");

        $('#' + parent).change(function() {
            var parentValue = $('#' + parent).attr('value');
            $('#' + child).html($("#" + parent + child + " .sub_" + parentValue).clone());
            if (isSubselectOptional) $('#' + child).prepend("<option value='0'>" + valAfret + "</option>");
			$('#' + child + ' option:first').attr("selected","selected");
            $('#' + child).trigger("change");
            $('#' + child).focus();

        });
    }

    $(document).ready(function() {
        makeSublist('ctl00_Top_ctl00_DropDownList1', 'ctl00_Top_ctl00_DropDownList2', true, '', 'הכל', 'הכל');
        makeSublist('ctl00_Top_ctl00_DropDownList2', 'ctl00_Top_ctl00_DropDownList3', true, '', 'הכל', 'הכל');
        makeSublist('ctl00_Top_ctl00_DropDownList4', 'ctl00_Top_ctl00_DropDownList5', true, '', 'הכל', 'הכל');
    });


    $(".NameValue").defaultValue("שם מלא");
    $(".EmailValue").defaultValue('דוא"ל');
    $(".PhoneValue").defaultValue("טלפון");
    $(".MobilValue").defaultValue("נייד");
    $(".StextValue").defaultValue("פרטים נוספים");
    //$("#aspnetForm").validate();

    $('.lastline ul li:last').css('backgound', 'none');

    $(".content").slideToggle(0);
    $(".link").click(function() {

        var id = $(this).attr("id");
        id = id.replace("l_", "");

        $("#c_" + id).slideToggle("slow");

        //alert(id);

        return false;
    });

});
