﻿String.prototype.asCurrency = function() {
	var f1 = this;
	var f2 = (Math.round((f1-0) * 100)) / 100;
	f2 = Math.floor(f2) == f2 ? f2 + ".00" : (Math.floor(f2 * 10) == f2 * 10) ? f2 + '0' : f2;
	f2 = String(f2);
	r = /(\d+)(\d{3})/;
	fs = String(f2);
	while (r.test(f2)) {
	      f2 = f2.replace(r, '$1' + ',' + '$2');
	}
	return (f2);
}
$(document).ready(function(){
    // png fixed
    $("body").pngFix();
    //国家下拉选择框
    $(".selector").click(function(){
        $(this).addClass("selector-hover");
        $(this).children(".selector-items").show();
    });
    $(".selector").hover(function(){
        }, function(){
            $(this).removeClass("selector-hover");
            $(this).children(".selector-items").hide();
        }
    );
    
    $(".info-menu-link").hover(function(index){
        $(this).parent("td").addClass("hover");
        $(this).children("span").addClass("hover");
    }, function(){
        $(this).parent("td").removeClass("hover");
        $(this).children("span").removeClass("hover");
    });
    //搜索框
    $(".txt-search").focus(function(){
        if($(this).val() == "搜索...")
        {
            !$(this).val("");
        }
    });
    $(".txt-search").focusout(function(){
        if($(this).val() == "")
        {
            !$(this).val("搜索...");
        }
    });
    //Newsletter
    $(".txt-newsletter").focus(function(){
        if($(this).val() == "Email...")
        {
            !$(this).val("");
        }
    });
    $(".txt-newsletter").focusout(function(){
        if($(this).val() == "")
        {
            !$(this).val("Email...");
        }
    });
    
    //顶部下拉导航
    $(".category-items li").each(function(index){
         $(this).hover(function(){
            $(this).children(".subitems").show();
         }, function(){
            $(this).children(".subitems").hide();
         });
    });
    
    // block-1 More
    $(".trans").hover(function(){
        $(this).children("span").addClass("hover");
    }, function(){
        $(this).children("span").removeClass("hover");
    });
    
    //货币转换
    $(".price").each(function(index){
        $(this).html($(this).html().asCurrency());
    });
    
});

