function show_brand(genreid, genrename, show) {
    var ob = $("brand_genre_" + genreid);
    var icheck = document.getElementById("genre_"+genreid);
    if (icheck.checked) {
        if (ob) {
                ob.style.display = 'block';
        } else {
            var x = new Ajax();
            x.get("do.php?ac=ajax&op=brand&genreid="+genreid+"&genrename="+encodeURIComponent(genrename), function(data,x){
                    var div = document.createElement("div");
                    div.innerHTML = data;
                    div.id = "brand_genre_" + genreid;
                    $('genre_brand').innerHTML = "<h3 class='eryiju_header'>请选择品牌</h3>";
                    $('genre_brand').appendChild(div);
                    div.style.display = '';
               });
        } 
    } else if (ob)
        ob.style.display = 'none';
}

function check_genre() {
    var genre = $("genrelist");
    if (genre) {
        var list = genre.getElementsByTagName("input");
        for (var i = 0; i < list.length; i++) {
            g = list[i];
            if (g.checked) {
                show_brand(g.getAttribute('genreid'), g.value, 1);
            }
        }
    }
}
check_genre();

//团购回帖 wxw 11-16
function tuangou_post_add(pid, result) {
	if(result) {
		var obj = $('post_ul');
		var newli = document.createElement("div");
		var x = new Ajax();
		x.get('do.php?ac=ajax&op=tuangou_post', function(s){
			newli.innerHTML = s;
		});
		obj.appendChild(newli);
		if($('message')) {
			$('message').value= '';
		}
		if($('post_replynum')) {
			var a = parseInt($('post_replynum').innerHTML);
			var b = a + 1;
			$('post_replynum').innerHTML = b + '';
		}
	}
}

function post_someone(formid, pid, tusername){
    //回复
    var tar = document.getElementById(formid);
    tar.innerHTML += '<input type="hidden" name="pid" value="'+pid+'" />';
    tar = document.getElementById('person_to_reply_'+formid);
    tar.innerHTML = '@'+tusername+':';
    var inputbox = document.getElementById('message');
    inputbox.focus();
}

function get_sub_post(pid,divid,tid){
		var obj = $(divid);
		var newli = document.createElement("ul");
		var x = new Ajax();
		x.get('space.php?do=event&id=2&post='+pid+'&tid='+tid, function(s){
			newli.innerHTML = s;
            newli.setAttribute('class','eryiju_reply_list');
            newli.setAttribute('id','sub_'+pid);
            //newli.setAttribute('style',"background:rgb(255,238,221)");
            newli.style.background='rgb(255,238,221)';
		    obj.appendChild(newli);
		});
            newli.className = 'eryiju_reply_list';
        if($('message')) {
			$('message').value= '';
		}
}

function showorfold(pid){
    var obj = $('showorfold_'+pid);
    obj.innerHTML = "<a href='javascript:void(0);' onclick='showorhide("+pid+")'>收起</a>";
}

function showorhide(pid){
    var obj=$('sub_'+pid);
    if(obj.style.display == 'none' ){
        obj.style.display = 'block';
        $('showorfold_'+pid).innerHTML = "<a href='javascript:void(0);' onclick='showorhide("+pid+")'>收起</a>";
    }
    else if(obj.style.display == 'block' || !obj.style.display){
        obj.style.display = 'none';
        $('showorfold_'+pid).innerHTML = "<a href='javascript:void(0);' onclick='showorhide("+pid+")'>查看</a>";
    }
}
function join_gevent(obj,eid){
    if(obj.checked){
        confirm('您确定要加入该团购吗？');
        ajaxget('cp.php?ac=event&op=join&eventid='+eid,'ajaxwaitid');
    }
    return false;
}
function get_ticket(obj,user,shopid,ticketid,eryijuid){
    if(!user){
        alert("对不起，您还没有登录。");
        return false;
    }else if(eryijuid != 3){
        alert("对不起，您不是业主。");
    }else if(!shopid){
        alert('发生未知错误');
    }else{
        curPos = fetchOffset(obj);
        $('tickettip').style.top = curPos.top + 'px';
        $('tickettip').style.left = 452 + 'px';
        $('tickettip').style.display = 'block';
        ajaxget('do.php?ac=ajax&op=getticket&username='+cnCode(user)+'&shopid='+shopid+'&ticketid='+ticketid ,'ticketcontent','ticketcontent');
    }
}

