/**
 * @author Lic | lic@odiy.net
 */
$(function(){
      $(".city").bind("click", function(){$(".othercity").toggle()});$("span.close").click(function(){$(".othercity").toggle()});
	  if($.cookie('jiamy_loginuser')) $("#tbar > span").html($.cookie('jiamy_loginuser')+'[<a href="http://jiamy.com/member/logout.html">退出</a>] <a href="http://jiamy.com/space.php?do=home">我的家麦</a> 购物车');
});


function del() {
	var msg = "您真的确定要删除吗？\n\n请确认！";
	if (confirm(msg)==true){
	return true;
	}else{
	return false;
	}
	}


function show(ss){if (ss.style.display=="none"){ss.style.display="";}else{ss.style.display="none";}}
function fav($id){alert("收藏"+$id);}
function down($id){alert("下载"+$id);}
function isMail(_){var $=/^([a-zA-Z0-9]+[-_.])*[a-zA-Z0-9]+@\w+\.([a-zA-Z]{2,4}|\w+\.[a-zA-Z]{2,4})$/;return(_.search($)>=0)}

function fav(){
$.ajax({type: "POST",url: ajax_path+"fav.php",data: "bookid="+bookid,success: function(msg){$("#berr").html(msg);}}); return false;
}

function vote(){
$.ajax({type: "POST",url: ajax_path+"vote.php",data: "bookid="+bookid,success: function(msg){$("#berr").html(msg);}}); return false;
}
//搜索框处理
function cleanTip(){if($("#search-key").val()==$("#search-key").attr('title')){$("#search-key").val('');}else if($("#search-key").val()==""){$("#search-key").val($("#search-key").attr('title'));}}
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options = $.extend({}, options);
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); 
        }
        
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};