﻿
$(document).ready(function() {
    //    $(".addToFavoriteBtn12212").click(function() {
    //        var currentId = null;
    //        currentId = $(".prpIdNo").text().match(/([0-9]+)/ig);
    //        alert("read current:" + currentId);
    //        var ids = $.cookie("favlist").split(",");
    //        alert("read all" + ids);
    //        $.cookie("favlist", $.cookie("favlist") + "," + currentId + ",");
    //        var idsnew = $.cookie("favlist").split(",");
    //        alert("new " + idsnew);
    //    });
    //    $(".addToFavoriteBtn111").click(function() {

    //        $(this).hide();
    //        $(".Load").show();
    //        //  var current = $(".RemFromFavoriteBtn100");
    //        // var currentId2 = null;
    //        //currentId2 = $(this).parent().parent().parent().parent().parent().children(".prpIdNo").text().match(/([0-9]+)/ig);
    //        // var current = $(this).next(".HHH");
    //        // alert(current.id);
    //        // current.style.display = "block";
    //       // $(".toggleFavBtn").hide(); $(".favs-show").hide();

    //    });
    //    $(".addToFavoriteBtn222").click(function() {

    //        $(this).hide();
    //         $(".Load").show();
    //        $(".RemFromFavoriteBtn222").show();
    //        $(".toggleFavBtn").hide();
    //        $(".favs-show").hide();
    //    });

    //    $(".addToFavoriteBtn333").click(function() {

    //        $(this).hide(); $(".Load").show();
    //        $(".RemFromFavoriteBtn333").show();
    //        $(".toggleFavBtn").hide();
    //        $(".favs-show").hide();
    //    });
    //    $(".RemFromFavoriteBtn111").click(function() {

    //       
    //        $(this).hide(); $(".Load").show();
    //        $(".addToFavoriteBtn111").show();
    //        $(".toggleFavBtn").hide();
    //        $(".favs-show").hide();
    //    });

    //    $(".RemFromFavoriteBtn222").click(function() {

    //   
    //        $(this).hide();
    //        $(".addToFavoriteBtn222").show();
    //        $(".toggleFavBtn").hide();
    //        $(".favs-show").hide();
    //    });

    //    $(".RemFromFavoriteBtn333").click(function() {

    //   
    //        $(this).hide();
    //        $(".addToFavoriteBtn333").show();
    //        $(".toggleFavBtn").hide();
    //        $(".favs-show").hide();
    //    });

    $(".dropContainer select").each(function() {
        var optionSize = $(this).children("option").size();
        for (i = 0; i < optionSize; i++) {
            var currentText = "";
            var currentValue = "";
            currentText = $(this).children("option:eq(" + i + ")").text();
            currentValue = $(this).children("option:eq(" + i + ")").attr("value");
            $(this).parent(".dropContainer").children(".dropSimulator").children("ul").append("<li val=\"" + currentValue + "\">" + currentText + '</li>');
            //alert(currentText +"  -  "+ currentValue);
        }
    });
    $(".dropSimulator").click(function() {
        $(this).next("ul").toggle();
    });
    $(".dropSimulator").next("ul").click(function() {
        $(this).hide();
    });
    $(".dropSimulator ul li").click(function() {
        var thisIndex = $(this).parent("ul").children("li").index(this);
        $(this).parent().parent().parent().children("select").children("option:eq(" + thisIndex + ")").attr("selected", "true");
        var selectedValue = $(this).text();
        $(this).parent().parent().children("span").text(selectedValue);
    });
}); 
