/**
 * Created by Administrator on 2015/11/3.
 */
$(function(){
    //������
    $("div.like-selected").click(function(){
        var select = $(this).parent();
        var option = select.find(".like-option");
        if(option.css("display") == "block"){
            option.hide();
        }else{
        	 $("ul.like-option").hide();
            option.show();
        }
    });
    $("ul.like-option li").hover(function(){
        var option = $(this).parent();
        option.find("li").removeClass("current");
        $(this).addClass("current");
    },function(){

    });
    $("ul.like-option li").click(function(){
        var option = $(this).parent();
        var txt = $(this).attr("data-value");
        var select = option.parent();
        var text = select.find(".like-selected .text");
        text.html(txt);
        option.hide();
    });
    //ѡ�
    $("ul.tab-ul li").click(function(){
        var index = $(this).index();
        var ul_parent = $(this).parent();
        var div_parent = $(this).parent().parent();
        var content = div_parent.find(".tab-div");
        ul_parent.find("li").removeClass("current");
        $(this).addClass("current");
        content.hide();
        content.eq(index).show();
    });
    
    $('.check-icon').click(function () {
		var className = $('.check-icon i').attr('class');
		if(className.indexOf("icon-no-check-green")>=0){
			$('.check-icon i').attr('class','icon icon-checked-green');
		}else{
			$('.check-icon i').attr('class','icon icon-no-check-green');
		}
    });
    
    $("body").bind("click",function(e){
  		var target = $(e.target);
  		if(target.parents(".like-selected").length == 0 && target.closest(".like-option").length == 0){
  			$('.like-option').hide();
  		}
  	});
    
    $(".service-open").click(function(){
        var right = $(".service-quick-wrap").css("right");
        if(right == "-160px"){
            $(".service-quick-wrap").css("right","-2px");
        }
        if(right == "-2px"){
            $(".service-quick-wrap").css("right","-160px");
        }
    });
    
});

function showDialog(title,content,href){
	$(".dialog-title-wrap").html("");
    $(".dialog-content-wrap").html("");
    $(".dialog-title-wrap").html(title);
    $(".dialog-content-wrap").html(content);
    $(".dialog-bottom-wrap .default-btn").attr("onclick","closeDialog('"+href+"')");
    $(".shade").show();
}

function closeDialog(href){
	if(href==""){
		$(".shade").hide();
	}else{
		location.href = href;
	}
    
}
