﻿function setTab(name,cursel,n){
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById("dsTitle_"+name+"_"+i);
		if(menu){
			menu.className=((i==cursel)?"on":"");
		}
		if(con){
			con.style.display=((i==cursel)?"block":"none");
		}
		var tmp=document.getElementById("storydiv"+i);
		if(tmp){
			tmp.className="no"+i;
		}
		
	}
	var storydiv=document.getElementById("storydiv"+cursel);
		if(storydiv!=null){
			storydiv.className="on";
		}
}

//é¡µé¢å±•ç¤ºçš„åˆ‡æ¢(æ˜¯é‚£ä¸ªæ–¹æ³•çš„æ‰©å±•é€šç”¨æ–¹æ³•,å¯ä»¥ä¼ å…¥æ ‡ç­¾éƒ¨åˆ†Idå€¼,ä¸å¿…ä¸€å®šä¸º"dsTitle")
function setCommonTab(name,cursel,n,className){
	if(!className){
		className="on";
	}
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById(name+"_"+i);
		if(menu){
			menu.className=((i==cursel)?className:"");
		}
		if(con){
			con.style.display=((i==cursel)?"block":"none");
		}
	}
}

//é¡µé¢å±•ç¤ºçš„åˆ‡æ¢(æ˜¯é‚£ä¸ªæ–¹æ³•çš„æ‰©å±•é€šç”¨æ–¹æ³•,å¯ä»¥ä¼ å…¥æ ‡ç­¾éƒ¨åˆ†Idå€¼,ä¸”å¯ä»¥ç”¨äºŽæŽ§åˆ¶ä¸¤å—æ•°æ®çš„å±•ç¤º)
function setCommonTabForTwo(name,cursel,n,className){
	if(!className){
		className="on";
	}
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById(name+"_"+i);
		var con2=document.getElementById(name+"2_"+i);
		if(menu){
			menu.className=((i==cursel)?className:"");
		}
		if(con){
			con.style.display=((i==cursel)?"block":"none");
		}
		if(con2){
			con2.style.display=((i==cursel)?"block":"none");
		}
	}
}

//ç›®å‰ç”¨äºŽå¥åº·æ‰‹å†Œï¼ˆæ‚å¿—ï¼‰é¦–é¡µçš„4ç¯‡æŽ¨èä¸“é¢˜é¡µé¢å±•ç¤ºçš„åˆ‡æ¢
function setTabToggle(name,cursel,n){
	for(i=1;i<=n;i++){
		var id = name+i;
		var con=document.getElementById(id);
		if(con){
			con.style.display=((i==cursel)?"block":"none");
		}
	}
}
function search_dsDt1() {
	advSearchStatus();
	$("#search_more img").attr("src","http://image.djjk.cn/styles/images/frontend/public/search_more_up.gif");
	$("#search_dsDetail").show();
	//$("#search_cond").show();
	$('#search_more img').toggle(
		function() {$(this).attr("src","http://image.djjk.cn/styles/images/frontend/public/search_more.gif"); $("#search_dsDetail").hide();$("#search_cond").hide();advSearchStatus();},
		function() {$(this).attr("src","http://image.djjk.cn/styles/images/frontend/public/search_more_up.gif"); $("#search_dsDetail").show();advSearchStatus();}
	);	
	
}

function advSearchStatus(){
	var advSearch=$("#advSearch").val();
	if(advSearch==0){
		$("#advSearch").val(1);
	}else{
		$("#advSearch").val(0);
	}
}


function intval(v)
{
	v = parseInt(v);
	return isNaN(v) ? 0 : v;
}

function getPos(e)
{
	var l = 0;
	var t  = 0;
	var w = intval(e.style.width);
	var h = intval(e.style.height);
	var wb = e.offsetWidth;
	var hb = e.offsetHeight;
	while (e.offsetParent){
		l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
		t += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
		e = e.offsetParent;
	}
	l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
	t  += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
	return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
}

function getScroll()
{
	var t, l, w, h;
	if (document.documentElement && document.documentElement.scrollTop) {
		t = document.documentElement.scrollTop;
		l = document.documentElement.scrollLeft;
		w = document.documentElement.scrollWidth;
		h = document.documentElement.scrollHeight;
	}else if(document.body){
		t = document.body.scrollTop;
		l = document.body.scrollLeft;
		w = document.body.scrollWidth;
		h = document.body.scrollHeight;
	}
	return { t: t, l: l, w: w, h: h };
}

function scroller(el, duration)
{
	if(typeof el != 'object') { el = document.getElementById(el); }
	if(!el) return;
	var z = this;
	z.el = el;
	z.p = getPos(el);
	z.s = getScroll();
	z.clear = function(){window.clearInterval(z.timer);z.timer=null};
	z.t=(new Date).getTime();
	z.step = function(){
		var t = (new Date).getTime();
		var p = (t - z.t) / duration;
		if (t >= duration + z.t) {
			z.clear();
			window.setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
		} else {
			st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
			sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
			z.scroll(st, sl);
		}
	};
	z.scroll = function (t, l){window.scrollTo(l, t)};
	z.timer = window.setInterval(function(){z.step();},13);
}



function person_down(n) {
	$("#personIco_img"+n).attr("src","http://image.djjk.cn/styles/images/frontend/public/per_up.gif");
	$("#personIco"+n).show();
	$('#personIco_img'+n).toggle(
		function() {$(this).attr("src","http://image.djjk.cn/styles/images/frontend/public/per_down.gif"); $("#personIco"+n).hide();},
		function() {$(this).attr("src","http://image.djjk.cn/styles/images/frontend/public/per_up.gif"); $("#personIco"+n).show();}
	);	
}







