
function setarea(){
	ui.box.load('js/area.html',{title:'选择小区'});
	resize2();
	document.getElementById("boxy-modal-blackout").style.opacity=1;
	//document.getElementById("boxy-modal-blackout").style.backgroundColor="#fff";
}
function default_yaoqing(){
	ui.box.load('js/default_yaoqing.php',{title:'邀请注册有奖'});
	resize2();
}
function mtv(){
	ui.box.load('api/mtv.html',{title:'MTV'});
	resize2();
}
function baike(qu_id){
	ui.box.load('info_baike_more.php?qu_id='+qu_id,{title:'小区介绍'});
	resize2();
}


//电台
function diantai(){
	document.getElementById("diantai").innerHTML="<iframe src='http://www.911pop.com/qmoonplayer/apply/viewradio2.aspx?id=f70b0e57-4aab-44c2-8cfa-e3d0d6d17d1c' marginwidth='0' marginheight='0' frameborder='0' scrolling='no' width='110px' height='178px'></iframe>";
}
function diantai_close(){
	document.getElementById("diantai").innerHTML='';
}

/*PPTV*/
function pptv(){
	document.getElementById("pptv_main").style.display="";
	document.getElementById("pptv").innerHTML='<iframe id="tv_url" frameborder="no" scrolling="no" width="100%" height="470" src="http://app.baidu.com/100050/main"> </iframe>';
}
function pptv_close(){
	document.getElementById("pptv_main").style.display="none";
	document.getElementById("pptv").innerHTML='';
}
function tv_menu(num, all, url) {
	/*for (var i = 1; i <=all ; i++) {
		if (num == i) {
			document.getElementById('tv_menu_'+num).className = 'btn cur btn_'+num+'';
		} else {
			document.getElementById('tv_menu_'+i).className = 'btn btn_'+num+'';
		}
	}*/
	if (num == 1) {
		document.getElementById('tv_menu_1').className = 'btn btn_1 cur';
		document.getElementById('tv_menu_2').className = 'btn btn_2';
	} else if (num == 2) {
		document.getElementById('tv_menu_1').className = 'btn btn_1';
		document.getElementById('tv_menu_2').className = 'btn btn_2 cur';
	}
		
	
	document.getElementById("tv_url").src=url;
}




/*音乐API*/
function music(){
	document.getElementById("music_main").style.display="";
	document.getElementById("music").innerHTML='<iframe id="music_url" width="750" height="516" src="http://player.kuwo.cn/webmusic/play?src=top" frameborder="0" scrolling="no"></iframe>';
}
function music_close(){
	document.getElementById("music").innerHTML="";	
	document.getElementById("music_main").style.display="none";
}

	
function fnChgTab(num, all, url) {
	for (var i = 1; i <=all ; i++) {
		if (num == i) {
			document.getElementById('k_'+num).className = 'cur';
		} else {
			document.getElementById('k_'+i).className = '';
		}
	}
	document.getElementById("music_url").src=url;
}


/**/
function my_guanzhu(page){
	document.getElementById("guanZhuxiaoqu").innerHTML="正在加载中...";
	xmlHttp.sendReq('get',"xiaoqu_guanzhu_admin.php?page="+page,'',Rq);
	
	function Rq(str){
		var response = str.responseText;
		document.getElementById("guanZhuxiaoqu").innerHTML=response;
	}
}


function haoyou_home(haoyou_number){
	window.location.href="/?wo="+haoyou_number;
}
function openAds(id,title){
	ui.box.load('/info_bianmin_right_more.php?id='+id,{title:''+title+''});
}
/*function photo_zoomimg(path,photoTitle){
	ui.box.load('js/photo_zoomimg.html?path='+path,{title:photoTitle+'-相册'});
}*/

/*function s_xiaoqu(id){
	if(GetCookie("JM_SelectXiaoqu") && GetCookie("JM_SelectXiaoqu")!=""){
		window.location.href="/"+GetCookie("JM_SelectXiaoqu");
	}
}*/

//下拉面板
//关闭下拉
function box_main_content_close(){
	menu_re();//恢复菜单，
	document.getElementById("topmenu_0").className="nav_00_on";
	document.getElementById("box_main").style.display="none";
	//document.getElementById("box_main_content_left").innerHTML="";
	//document.getElementById("box_main_content_right").innerHTML="";
	document.getElementById("gonggao").style.display="";
	
}
//关闭身份证
var usernumber=GetCookie("JM_LOGGED_usernumber");
if(usernumber && usernumber!=""){
	usernumber=utf8to16(base64decode(usernumber));
}
function sfz_box_close(){
	document.getElementById("login").style.display="none";
	document.getElementById("sfz_ico").className="sfz_ico";
}




//控制导航菜单
//重置菜单状态
function menu_re(){
	document.getElementById("gonggao").style.display="none";
	//清除加载内容
	document.getElementById("box_main_content_left").innerHTML="";
	document.getElementById("box_main_content_right").innerHTML="";
	for(var i=0;i<=7;i++){
		document.getElementById("topmenu_"+i).className="nav_0"+i;
	}	
}
//返回居民广场
function guangchang(){
	sfz_box_close();////关闭身份证
	menu_re();
	box_main_content_close();
	document.getElementById("gonggao").style.display="block";
	writeFlash("main.swf?qu_id="+qu_id);
}
//切换其它模块

function type(id,name){
	//关闭虾米音乐
	music_close();
	sfz_box_close();
	
	if(qu_id==0){
		setarea();
	}else{
		menu_re();
		document.getElementById("topmenu_"+id).className="nav_0"+id+"_on";
		
		if(name=="weibo"){
			weibo(1);
		}else if(name=="zhaoren"){
			zhaoren(1);
		}else if(name=="baike"){	
			baike(1);
		}else if(name=="huodong"){	
			huodong_all(1);
			huodong_my(1);
		}else if(name=="yingji"){	
			yingji(1);	
		}else if(name=="bianmin"){
			bianmin(1);	
		}else if(name=="map"){
			window.location.href="http://map.jumin.com/"+qu_id;
			//getmap();
		}
	}
}



/*function closeBox(){
	for(var i=1;i<=4;i++){
		document.getElementById("btn_"+i).className="";
	}
	reSize();
}*/

//安全退出/////////////////////////
function loginOut(){
	var url="/login_out.php?action=sfz";
	xmlHttp.sendReq('get',url,null,loginOutType);
}
function loginOutType(str){
	var response = str.responseText;
	//alert(response)
	if (response == "logout_ok") {
		//退出成功，加载登录框
		//showLogin();
		window.location.href="/";
	} else {
		alert(response);
	}
}
//关注/////////////////////////
function dofollow(id){
	if (GetCookie("JM_LOGGED_uname") && GetCookie("JM_LOGGED_uname")!=""){
		var url="/info_zhaoren_dofollow.php";
		var info="&fid="+id;
		xmlHttp.sendReq('post',url,info,followok);
	}else{
		dologin();
	}
}
function followok(str){
	var response = str.responseText;
	//alert(response)
	if (response == "1") {
		alert("添加成功！");
		haoyou_my(1)
	} else if (response == "13") {
		alert("已添加！");
	} else if (response == "11") {
		alert("此用户不存在！");
	} else if (response == "0") {
		alert("不能添加自己！");
	} else if (response == "00") {
		alert("禁止添加(位于黑名单中)！");
	}else {
		alert(response);
	}
}

function guanzhu_del(id){
		var url = "xiaoqu_guanzhu.php?action=del&id="+id;
		xmlHttp.sendReq("GET", url,null,guanzh_del_save);
		
		function guanzh_del_save(str){
				var response = str.responseText;
				if(response=="del_ok"){
					var t=document.getElementById("id_"+id);
					//var l=window.document.getElementById('leftIfr').contentWindow.document.getElementById(id)
					t.parentNode.removeChild(t);
					//l.parentNode.removeChild(l);
				}else{
					alert(response)
				}
		}
}

//微薄广场
function weibo(page){
	
	loadinfo("weibo",page,null,"box_main_content_left");
	if(page==1){loadinfo("weibo_right",null,null,"box_main_content_right")};
	
}
//找人
function zhaoren(page){
	haoyou_my(1);
	haoyou_all(1);
	
}
//活动
function huodong_all(page){
	loadinfo("event",page,null,"box_main_content_left");
}
function huodong_my(page){
	loadinfo("event2",page,null,"box_main_content_right");
}

//群组
/*function qunzu(page){
	loadinfo("qunzu",page,null,"box_main_content_left");
}*/
//影集
function yingji(page){
	loadinfo("yingji",page,null,"box_main_content_left")
}
//便民
function bianmin(page){
	loadinfo("bianmin",page,null,"box_main_content_left")
	if(page==1){
		loadinfo("bianmin_right",null,null,"box_main_content_right")
	};
}

//便民搜索
function bianminSearch1(typeid,obj){
	var pid=document.getElementById("pid");
	var btn_search_pid=document.getElementById("btn_search_pid");
	btn_search_pid.style.display="";//显示小类搜索按钮
	btn_search_pid.disabled=false //可以点击///
	pid.value=typeid;
	bianminSearch(1,obj);
}
function bianminSearch2(typeid,obj){
	var stid=document.getElementById("stid");
	var btn_search_pid=document.getElementById("btn_search_pid");
	btn_search_pid.style.display="";//显示小类搜索按钮
	btn_search_pid.disabled=false; //可以点击
	stid.value=typeid;
	bianminSearch(1,obj);
}
function bianminSearchClass(){
	var keyword=document.getElementById("bianmin_keyword");
	var pid=document.getElementById("pid");
	var stid=document.getElementById("stid");
	var btn_search_pid=document.getElementById("btn_search_pid");
	
	if(!keyword || keyword.value=="" || keyword.value==keyword.defaultValue){
		keyword.focus();
		return false;
	}
	
	pid.value="";
	stid.value="";
	btn_search_pid.style.display="none";//显示小类搜索按钮
	btn_search_pid.disabled=true; //可以点击
	bianminSearch(1,null)	
	return false;
}
function bianminSearchAll(){
	var keyword=document.getElementById("bianmin_keyword");
	var pid=document.getElementById("pid");
	var stid=document.getElementById("stid");
	if(!keyword || keyword.value=="" || keyword.value==keyword.defaultValue){
		keyword.focus();
		return false;
	}
	
	bianminSearch(1,null)
	return false;
}


function bianminSearch(page,sbtn){
	var keyword=document.getElementById("bianmin_keyword");
	var pid=document.getElementById("pid");
	var stid=document.getElementById("stid");
	var selectedid=document.getElementsByName("btn_list");
	var bianmin_keyword=document.getElementById("bianmin_keyword");
	//alert("|"+selectedid.length)
	
	//复位菜单
	if (typeof(selectedid.length)!= "undefined") {
		for (var i = 0; i<selectedid.length; i++) {
			//alert(selectedid[0].className)
			//selectedid[0].className="";
			document.getElementById("btn_"+i).className="";
		}
	}
	if(sbtn){sbtn.className="on"};

	//读取查询数据///////
	var url="";
	
	if(keyword && keyword.value!="" && keyword.value!=keyword.defaultValue){
		url+="&keyword="+encodeURIComponent(keyword.value);
		//if(pid.value==""){pid.value=0;}
		//if(stid.value==""){stid.value=0;}
	}
	
	if(pid && pid.value!="" && pid.value>0){
		url+="&pid="+pid.value;
	}
	
	if(stid && stid.value!="" && stid.value>0){
		url+="&stid="+stid.value;
	}
	if(page && page!=""){
		url+="&page="+page;						
	}
	//alert(document.getElementById("bianmin")+"|"+url)
	loadinfo("bianmin_info",page,url,"bianmin");
}


//地图
function getmap(){
	
	var map=false;
	box_main_content_close();
	document.getElementById("topmenu_0").className="nav_00";
	if(qu_id==1){
		map=true;
	}else if(qu_id==63){
		map=true;
	}else if(qu_id==43){
		map=true;
	}
		
	if(map){
		writeFlash("flash_earth/"+qu_id+"/map.swf?qu_id="+qu_id);
	}else { 
		//alert(GetCookie("JM_x")+"-"+GetCookie("JM_y"));
		
		if(GetCookie("JM_city_id")>0 && GetCookie("JM_x") && GetCookie("JM_x")!="" && GetCookie("JM_y") && GetCookie("JM_y")!=""){
			loadgoogleMap();
			GUnload();
		}else{
			alert("地图加载失败！");
		}
	}
}




//百科/////////////////////////////////////
function baike(page){
	loadinfo("tieba",page,null,"box_main_content_left");
	loadinfo("baike",page,null,"box_main_content_right");
}

//加载信息内容
function loadinfo(path,page,action,obj){
	//alert(obj+"|"+document.getElementById(obj))
	//显示加载进度
	if(obj){document.getElementById(obj).className="loader_bg";}	
	//显示面板
	document.getElementById("box_main").style.display="";
	
	//加载数据
	var url = "info_"+path+".php?qu_id="+qu_id+"&action=";
	
	if(page && page!=""){
		url+="&page="+page;						
	}
	if(action && action!=""){
		url+=action;
	}
	//xmlHttp.sendReq('get',url,'',function(Rq) {alert(Rq.responseText);});
	
	xmlHttp.sendReq('get',url,'',Rq);
	
	
	function Rq(str){
		var response = str.responseText;
			if(obj){document.getElementById(obj).className="";}	
			if(obj){document.getElementById(obj).innerHTML=response;}
			
			//window.clearInterval(scrtime);
			//$("#weibo").innerHTML="";
				
			//滚动代码
			if(path=="weibo"){
					 var scrtime;
					 
					 $("#btn_close").click(function(){
						clearInterval(scrtime);
					 })
					 for(var i=0;i<=7;i++){
						 $("#topmenu_"+i).click(function(){
							clearInterval(scrtime);
					 	})
					 }
					 
					
					/* scrtime = setInterval(function(){
					  var $ul = $("#weibo ul");
					  var liHeight = $ul.find("li:last").height();
					  $ul.animate({marginTop : liHeight+"px"},500,function(){
					  $ul.find("li:last").prependTo($ul)
					  $ul.find("li:first").hide();
					  $ul.css({marginTop:0});
					  $ul.find("li:first").fadeIn(500);
					  });
					 },2000);*/
					 
					var speed=25;
					var tabTop=document.getElementById("weibo");
					var tab3=document.getElementById("demo3");
					var tab4=document.getElementById("demo4");
					tab4.innerHTML=tab3.innerHTML;
					
					function Marquee2(){
						if(tabTop.scrollTop>=tab4.offsetHeight)
							tabTop.scrollTop-=tab3.offsetHeight;
						else{
							tabTop.scrollTop++;
						}
					}
					var MyMar2=setInterval(Marquee2,speed);
					tabTop.onmouseover=function() {clearInterval(MyMar2)};
					tabTop.onmouseout=function() {MyMar2=setInterval(Marquee2,speed)};
					
			}
			
			//end if
	}

}


function xiaoquguano(page) {
	//var url = "xiaoqu_guanzhu_admin.php";
	var url="Default.php";
	if(page && page!=""){
		url+="&page="+page;
	}
	document.getElementById("guanZhuxiaoqu").innerHTML = '正在加载...';
	xmlHttp.sendReq('get',url,null,loadxiaoquguano);
}
function loadxiaoquguano(str) {
	document.getElementById("guanZhuxiaoqu").innerHTML = str.responseText;
}
//调查投票部分
function diaocha(id,type){
	var url="diaocha_save.php?action=chk&qu_id="+qu_id+"&diaocha_id="+id+"&type="+type;
	xmlHttp.sendReq('get',url,null,Rq);
	
	function Rq(str){
		var response = str.responseText;
		if(response=="ok"){
			if(type==1){
				var num=Math.floor(document.getElementById("diaocha_num_1").innerHTML);
				document.getElementById("diaocha_num_1").innerHTML=Math.floor(num+1);
			}else{
				var num=Math.floor(document.getElementById("diaocha_num_2").innerHTML);
				document.getElementById("diaocha_num_2").innerHTML=Math.floor(num+1);	
			}
			document.getElementById("diaocha_num_1").disabled=true;
			document.getElementById("diaocha_num_2").disabled=true;
			document.getElementById("diaocha_num_1").style.cursor="default";
			document.getElementById("diaocha_num_2").style.cursor="default";
		}else if(response=="msg=请先登录！"){
			showLogin();
		}else{
			alert(response);	
		}
	}
}

//全部友邻///////////////////////////////////
function haoyou_all(page){
	document.getElementById("box_main_content_left").innerHTML='<div class="title"><div class="left"><strong>小区居民</strong></div><div class="left" style="margin-left:180px;"><input name="q" id="q" value="输入名称或居民号" style="color:#999;"  type="text" maxlength="10" /> <input type="submit"  onclick="zhaoren_search(1)" id="button" value="搜索" /></div></div> <div id="zhaorenList"></div>';
	var q=document.getElementById("q");
	
	q.onfocus=function(){
		if (q.value==q.defaultValue) {
			q.value='';
			q.style.color='#666';
		}
	}
	q.onblur=function (){
		if(!q.value){
			q.value=q.defaultValue;
			q.style.color='#999';
		}
	}
	zhaoren_search(1);
	
	q.attachEvent('onpropertychange',function(){ 
		//alert(arguments.length);    
		zhaoren_search(1);
	});
	
	
}
//我的友邻///////////////////////////////////
function haoyou_my(page){
	loadinfo("zhaoren2",page,null,"box_main_content_right");
}

//找人搜索部分
function zhaoren_search(page) {
	var q=document.getElementById("q");

	var url="";
	//输入关键字
	if(q.value!="" && q.value!=q.defaultValue){
		url+="&q="+encodeURIComponent(q.value);
	}

	if(page && page!=""){
		url+="&page="+page;
	}
	
	loadinfo("zhaoren",page,url,"zhaorenList");
}


