var $ = function(id){
   return document.getElementById(id);
}

function otherOffice(city){
	if(city != ""){
		if(city == "bj"){
			window.open("http://office.soufun.com");
		}else{
			window.open("http://office." + city + ".soufun.com");
		}
	}
}

function show_menu1(id1, id2, index, count, classcurrent, classname){
	for(var i = 0; i < count; i++){
		$(id2.toString() + i).style.display = "none";
		$(id1.toString() + i).className = classname;
	}
	$(id2.toString() + index).style.display = "block";
	$(id1.toString() + index).className = classcurrent;
}

function show_menu2(id1, id2, index, count, classcurrent, classname, anchor_point){
	for(var i = 0; i < count; i++){
		$(id2.toString() + i).style.display = "none";
		$(id1.toString() + i).className = classname;
	}
	$(id2.toString() + index).style.display = "block";
	$(id1.toString() + index).className = classcurrent;
	if(anchor_point != ""){
		document.location.href = anchor_point;
	}
}

function changePriceList(opt){
	if(opt == '3'){
		$('priceList3').style.display = "block";
		$('priceList3Button').style.display = "block";
		$('priceList').style.display = "none";
		$('priceListButton').style.display = "none";
	}else if(opt == 'all'){
		$('priceList3').style.display = "none";
		$('priceList3Button').style.display = "none";
		$('priceList').style.display = "block";
		$('priceListButton').style.display = "block";
	}
}

/*口碑榜 begin*/
function gradeStar(stars, commenttype, newcode, city){
    Xml.Request("/officenet/newhouse_info/propertyComment.aspx", "stars=" + stars + "&commenttype=" + commenttype + "&newcode=" + newcode + "&city=" + city, gradeInform, stars);
}
function gradeInform(ss){
    var rsphtml = this.responseText;

    var allCount = rsphtml.substr(rsphtml.lastIndexOf("<allCount>") + 10, rsphtml.lastIndexOf("</allCount>") - rsphtml.lastIndexOf("<allCount>") - 10);
    var allBar = rsphtml.substr(rsphtml.lastIndexOf("<allBar>") + 8, rsphtml.lastIndexOf("</allBar>") - rsphtml.lastIndexOf("<allBar>") - 8);

	var purpleCount = rsphtml.substr(rsphtml.lastIndexOf("<purpleCount>") + 13, rsphtml.lastIndexOf("</purpleCount>") - rsphtml.lastIndexOf("<purpleCount>") - 13);
    var purpleBar = rsphtml.substr(rsphtml.lastIndexOf("<purpleBar>") + 11, rsphtml.lastIndexOf("</purpleBar>") - rsphtml.lastIndexOf("<purpleBar>") - 11);

    var redCount = rsphtml.substr(rsphtml.lastIndexOf("<redCount>") + 10, rsphtml.lastIndexOf("</redCount>") - rsphtml.lastIndexOf("<redCount>") - 10);
    var redBar = rsphtml.substr(rsphtml.lastIndexOf("<redBar>") + 8, rsphtml.lastIndexOf("</redBar>") - rsphtml.lastIndexOf("<redBar>") - 8);

    var yellowCount = rsphtml.substr(rsphtml.lastIndexOf("<yellowCount>") + 13, rsphtml.lastIndexOf("</yellowCount>") - rsphtml.lastIndexOf("<yellowCount>") - 13);
    var yellowBar = rsphtml.substr(rsphtml.lastIndexOf("<yellowBar>") + 11, rsphtml.lastIndexOf("</yellowBar>") - rsphtml.lastIndexOf("<yellowBar>") - 11);

    var greenCount = rsphtml.substr(rsphtml.lastIndexOf("<greenCount>") + 12, rsphtml.lastIndexOf("</greenCount>") - rsphtml.lastIndexOf("<greenCount>") - 12);
    var greenBar = rsphtml.substr(rsphtml.lastIndexOf("<greenBar>") + 10, rsphtml.lastIndexOf("</greenBar>") - rsphtml.lastIndexOf("<greenBar>") - 10);

    var blueCount = rsphtml.substr(rsphtml.lastIndexOf("<blueCount>") + 11, rsphtml.lastIndexOf("</blueCount>") - rsphtml.lastIndexOf("<blueCount>") - 11);
    var blueBar = rsphtml.substr(rsphtml.lastIndexOf("<blueBar>") + 9, rsphtml.lastIndexOf("</blueBar>") - rsphtml.lastIndexOf("<blueBar>") - 9);

	//改写页面投票信息
	document.getElementById('all_count').innerHTML = allCount;
	document.getElementById('all_bar').innerHTML = allBar;
	document.getElementById('purple_count').innerHTML = "&nbsp;共<em>" + purpleCount + "</em>人";
	document.getElementById('purple_bar').style.width = purpleBar + "%";
	document.getElementById('purple_bar').alt = purpleBar + "%";
	document.getElementById('red_count').innerHTML = "&nbsp;共<em>" + redCount + "</em>人";
	document.getElementById('red_bar').style.width = redBar + "%";
	document.getElementById('red_bar').alt = redBar + "%";
	document.getElementById('yellow_count').innerHTML = "&nbsp;共<em>" + yellowCount + "</em>人";
	document.getElementById('yellow_bar').style.width = yellowBar + "%";
	document.getElementById('yellow_bar').alt = yellowBar + "%";
	document.getElementById('green_count').innerHTML = "&nbsp;共<em>" + greenCount + "</em>人";
	document.getElementById('green_bar').style.width = greenBar + "%";
	document.getElementById('green_bar').alt = greenBar + "%";
	document.getElementById('blue_count').innerHTML = "&nbsp;共<em>" + blueCount + "</em>人";
	document.getElementById('blue_bar').style.width = blueBar + "%";
	document.getElementById('blue_bar').alt = blueBar + "%";
}
function gradeHover(obj, score){
	for(i = 1; i <= score; i++){
		$(obj + i).style.background = "url(http://img.soufun.com/house/detail_new/images/newstar.gif) 0 -14px no-repeat";
	}
	for(i = score + 1; i <= 5; i++){
		$(obj + i).style.background = "url(http://img.soufun.com/house/detail_new/images/newstar.gif) 0 0 no-repeat";
	}
	var obj = $("fen_" + obj);
	if(obj){
		if(score == 1){
			obj.innerHTML = "很差";
		}else if(score == 2){
			obj.innerHTML = "一般";
		}else if(score == 3){
			obj.innerHTML = "还行";
		}else if(score == 4){
			obj.innerHTML = "不错";
		}else if(score == 5){
			obj.innerHTML = "很好";
		}
	}
}
function gradeOut(obj){
	for(i = 1; i <= 5; i++){
		if($(obj + i)){
			$(obj + i).style.background = "url(http://img.soufun.com/house/detail_new/images/newstar.gif) 0 0 no-repeat";
		}
	}
	var obj = $("fen_" + obj);
	if(obj){
		obj.innerHTML = "打分";
	}
}
/*口碑榜 end*/
