﻿
jQuery(document).ready(function() {
    var Play_list_a = "#play_list a";
    var Play_list_a_not = "#play_list a:not(:first-child)";
    var Play_list_a_first = "#play_list a:first-child";
    var Play_text_li_first = "#play_text li:first-child";
    var Play_text_li = "#play_text li";
    var Play_info = "#play_info";
    var Play = "#play";
    bcheck = false;

    if(window.location.href.indexOf("ProductMainPage")>-1)
    {
        //jQuery('div#play').css({'width':'959px'});
        jQuery('div#play, div#play_list, div#play_list img, div#play_list a').css({'width':'960px'});
        //jQuery('div#play_list img').css({'width':'959px'});
    }


    var _location = window.location.href;
    if (jQuery("#left") != null) {
        var a_href = jQuery("#left").find("a");
        jQuery(a_href).each(function() {
            if (_location.indexOf(jQuery(this).attr("href")) > -1) {
                jQuery(this).css({ "color": "#a205a2", "fontWeight": "bold" }); //ef8a13   a205a2
            }
        });
    }
    dynamicdisplay(Play_list_a, Play_list_a_not, Play_list_a_first, Play_text_li_first, Play_text_li, Play_info, Play);
});

function dynamicdisplay(Play_list_a, Play_list_a_not, Play_list_a_first, Play_text_li_first, Play_text_li, Play_info, Play) {
    var t = n = 0, count = 0;
    
    if(jQuery(Play_list_a) != null)
     count = jQuery(Play_list_a).size();    
    jQuery(function() {
        jQuery(Play_list_a_not).hide();
        jQuery(Play_info).html(jQuery(Play_list_a_first).find("img").attr('alt'));
        jQuery(Play_text_li_first).css({ "background": "#fff", 'color': '#000' });
        jQuery(Play_info).click(function() { document.location.href = jQuery(Play_list_a_first).attr('href') }); //window.open(jQuery(Play_list_a_first).attr('href'), "_parent")

        jQuery(Play_text_li).each(function(mm) {
            jQuery(this).click(function() {
                var i = mm;
                n = i;
                if (i >= count) return;
                jQuery(Play_info).html(jQuery(Play_list_a).eq(i).find("img").attr('alt'));
                jQuery(Play_info).unbind().click(function() { document.location.href = jQuery(Play_list_a).eq(i).attr('href') })
                jQuery(Play_list_a).filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
                jQuery(this).css({ "background": "#fff", 'color': '#000' }).siblings().css({ "background": "#000", 'color': '#fff' });
            });
        });
        t = setInterval(function() {
            n = n >= (count - 1) ? 0 : ++n;
            jQuery(Play_text_li).eq(n).trigger('click');

        }, 5000);
    })
}

function dynamicdisplay222(Play_list_a, Play_list_a_not, Play_list_a_first, Play_text_li_first, Play_text_li, Play_info, Play) {
    var t1 = n1 = 0, count1 = jQuery(Play_list_a).size();
    jQuery(function() {
        jQuery(Play_list_a_not).hide();
        jQuery(Play_info).html(jQuery(Play_list_a_first).find("img").attr('alt'));
        jQuery(Play_text_li_first).css({ "background": "#fff", 'color': '#000' });
        jQuery(Play_text_li).click(function() {
            var i1 = jQuery(this).text() - 1;
            n1 = i1;
            if (i1 >= count1) return;
            jQuery(Play_info).html(jQuery(Play_list_a).eq(i1).find("img").attr('alt'));
            jQuery(Play_list_a).filter(":visible").fadeOut(500).parent().children().eq(i1).fadeIn(1000);
            jQuery(this).css({ "background": "#fff", 'color': '#000' }).siblings().css({ "background": "#000", 'color': '#fff' });
        });
        t1 = setInterval(function() {
            n1 = n1 >= (count1 - 1) ? 0 : ++n1;
            jQuery(Play_text_li).eq(n1).trigger('click');

        }, 3000);
    })
}

function showAuto(Play_list_a1, Play_text_li1) {
    var count = jQuery(Play_list_a1).size();
    n = n >= (count - 1) ? 0 : ++n;
    jQuery(Play_text_li1).eq(n).trigger('click');
}

function SubCategoryImageDisplay() {
    var maxValue = 0;
    jQuery(".P_Image > .ProductsImageStyle").each(function(i) {
        if (jQuery(this).height() > maxValue)
            maxValue = jQuery(this).height();
    })

    jQuery(".P_Image > .ProductsImageStyle").each(function(i) {
        jQuery(".P_Image").height(maxValue);
        var values = (jQuery(".P_Image").height() - jQuery(this).height()) / 2;
        jQuery(this).css({ "padding-top": values });
    })
}

function TopCategoryImageDisplay() {
    var maxHeight = 0;
    jQuery(".content-txtbox-noshade .ProductsImageStyle").each(function() {
        if (jQuery(this).height() > maxHeight)
            maxHeight = jQuery(this).height();
    })

    jQuery("div[id=abc]").each(function(i) {
        jQuery(this).height(maxHeight + 80);
    })
}

function SelectAllCheckBox() {
    bcheck = !bcheck;
    if (bcheck == null)
        bcheck = true;

    jQuery("div[id=CheckBoxDiv] > :checkbox").each(function(i) {
        jQuery(this).attr("checked", bcheck);
    })
}

function SetWorldWidePartner() {
    var maxHeight = 0;
    jQuery("#play_list_1 img").each(function(i) {
        if (jQuery(this).height() > maxHeight)
            maxHeight = jQuery(this).height();
    })
    jQuery("#play_list_1").height(maxHeight);
    //    jQuery("#play_list_1 img").each(function(i) {
    //        var a = (maxHeight - jQuery(this).height()) / 2;
    //        jQuery(this).css({ "margin-top": a });
    //    })
}

function SetWorldWidePartner() {
    var maxHeight = 0;
    jQuery("#play_list_1 img").each(function(i) {
        if (jQuery(this).height() > maxHeight)
            maxHeight = jQuery(this).height();
    })
    jQuery("#play_list_1").height(maxHeight);
}

function QueryString(fieldName) {
    var urlString = document.location.search;
    if (urlString != null) {
        var typeQu = fieldName + "=";
        var urlEnd = urlString.indexOf(typeQu);
        if (urlEnd != -1) {
            var paramsUrl = urlString.substring(urlEnd + typeQu.length);
            var isEnd = paramsUrl.indexOf('&');
            if (isEnd != -1) {
                return paramsUrl.substring(0, isEnd);
            }
            else {
                return paramsUrl;
            }
        }
        else {
            return null;
        }
    }
    else {
        return null;
    }
}

// first version 
////function SetSelect() {
////    jQuery(".nav3 a").each(function(i) {
////        var c = jQuery(this).attr("href");
////        if (c.indexOf(QueryString("c")) < 0) {
////            if (jQuery(this).parent("li").hasClass("group")) {
////             
////            }
////            else {
////                jQuery(this).parent("li").css({ "border-left": "solid 7px rgb(255,255,255)" });
////            }
////        }
////        else {
////            jQuery(this).parent("li").css({ "border-left": "solid 7px rgb(156,186,214)" });
////        }
////    });

////    var value = ".nav3 a[href*='" + QueryString("c") + "']";
////    //  alert('c');
////    //   alert(value);
////    jQuery(value).each(function(i) {
////        jQuery(this).parent("li").css({ "border-left": "solid 7px rgb(156,186,214)" }); //, "text-decoration": "none"
////        // alert(value);
////    });
////}

//second version
function SetSelect() {
    ////    jQuery(".nav3 a").each(function(i) {
    ////        var c = jQuery(this).attr("href");
    ////        if (c.indexOf(QueryString("c")) < 0) {
    ////            if (jQuery(this).parent("td").hasClass("group")) {
    ////                //    jQuery(this).parent("li").css({ "border-left": "solid 7px rgb(156,186,214)" });
    ////            }
    ////            else {
    ////                //    jQuery(this).parent("li").css({ "border-left": "solid 7px rgb(255,255,255)" });
    ////            }
    ////        }
    ////        else {

    ////        }
    ////    });

    //////////////////    var value = ".nav3 a[href*='" + QueryString("c") + "']";
    //////////////////    jQuery(value).each(function(i) {
    //////////////////        if (jQuery(this).parent("td").hasClass("group")) {
    //////////////////            jQuery(this).parent("td").children("a").css({ "background-color": "rgb(156,186,214)" });
    //////////////////        }
    //////////////////        else if (jQuery(this).parent("td").hasClass("next")) {
    //////////////////        jQuery(this).parent("td").children("a").css({ "background-color": "rgb(219,230,241)" });

    //////////////////            jQuery(this).parent("td").parent("tr").prevAll().children("td.group:first").each(function(i) {
    //////////////////                    jQuery(this).children("a").css({ "background-color": "rgb(156,186,214)" });
    //////////////////            })
    //////////////////        }
    //////////////////    });

    var value = ".nav4 a[href*='" + QueryString("c") + "']";
    jQuery(value).each(function(i) {
        if (jQuery(this).parent("li").hasClass("first")) {
            jQuery(this).parent("li").children("a").addClass("selected");
            jQuery(this).parent("li").parent("ul").parent("div.slide").css({ "display": "block" });
            jQuery(this).parent("li").parent("ul").parent("div.slide").prev().each(function(i) {
                jQuery(this).addClass("expanded");
            })
        }
        else {
            if (jQuery(this).attr("id") == "firstlevel") {
                if (jQuery(this).parent("li").children("div.slide").children("ul").html() == "") {
                    jQuery(this).parent("li").children("div.slide").hide();
                    jQuery(this).parent("li").children("a").addClass("expanded");
                }
                else {
                    jQuery(this).parent("li").children("a").addClass("expanded");
                    jQuery(this).parent("li").children("div.slide").css({ "display": "block" });
                }
            } else {

            }
        }
    });
}

function MenuClick() {
    jQuery("a[id=firstlevel]").each(function(i) {
        jQuery(this).click(function() {
            jQuery("a[id=firstlevel]").each(function(i) {
                jQuery(this).parent("li").children("div.slide").css({ "display": "none" });
                jQuery(this).removeClass("expanded");
            });
            if (jQuery(this).parent("li").children("div.slide").children("ul").html() == "") {
            }
            else {
                jQuery(this).parent("li").children("div.slide").css({ "display": "block" });
                jQuery(this).addClass("expanded");
            }
        });
    });
}

function ChangeTitle(title) {
    document.title = title;
}






