function updatechannel(id,rid) {
    for(i=0;i<=14;i++)
	{
	    var clear = 'search'+i;
		if(document.getElementById(clear) == null)
			continue;

		if(i == id)
			document.getElementById(clear).className = "tag now";
		else
			document.getElementById(clear).className = "tag";
	}
    document.getElementById('channel').value = rid;
    if(id == 0){
    	document.getElementById('searchform').action = 'http://search.mamasgoodbaby.com/search.shtml';
    }else{
    	document.getElementById('searchform').action = 'http://search.goodbaby.com/search.shtml';
    }
}

//search change
function search_morechange(obj,hid,changedid)
{
	var changetext = document.getElementById('search'+changedid).innerHTML;
	document.getElementById('search'+changedid).innerHTML = obj.innerHTML;
	obj.innerHTML = changetext;
	document.getElementById('search_more0').style.display = 'none';
	var changevalue = document.getElementById(hid).value;
	document.getElementById(hid).value = document.getElementById('hid'+changedid).value;
	document.getElementById('hid'+changedid).value = changevalue;	
	updatechannel(changedid,changevalue);
}

//obj show or unshow
function obj_show(obj)
{
	var showobj =  document.getElementById(obj);
	if(showobj.style.display == '') 
		showobj.style.display = 'none';
	else 
		showobj.style.display = '';
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	window.open(selObj.options[selObj.selectedIndex].value,targ,"")
  if (restore) selObj.selectedIndex=0;
}
//main_menu change
function indexmenu_display(obj,num,menu_baby)
{
		if(menu_baby == '')
		{
			document.getElementById('yuerbaike').style.display = 'none';
			document.getElementById('yuershequ').style.display = 'none';
		}
		else if(menu_baby == 'yuerbaike')
		{
			document.getElementById(menu_baby).style.display = '';
			document.getElementById('yuershequ').style.display = 'none';
		}
		else
		{
			document.getElementById('yuerbaike').style.display = 'none';
			document.getElementById(menu_baby).style.display = '';	
		}
}

//xmlhttp object
function initxmlhttp()
{
	var xmlhttp;
	if(window.XMLHttpRequest){ 
		xmlhttp= new XMLHttpRequest(); 
	}else if(window.ActiveXObject){ 
		try{ 
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
		}catch(e){ 
			try{ 
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
			}catch(e){ 
				xmlhttp=false; 
			} 
		}
	}
  return xmlhttp;
}

var host_name = window.location.hostname;

//list param to htmlcode
function readcontent(catid,secid,count,contentstr,action,url,mid)
{  
  var xmlhttp=initxmlhttp();
  var showcontent=document.getElementById(contentstr);
  var url="http://" + host_name + "/common/lib/ajax_cms_content.php?catid="+catid+"&secid="+secid+"&count="+count+"&action="+action+"&url="+encodeURI(url)+"&mid="+mid;
  xmlhttp.open("GET",url,true);
  xmlhttp.setRequestHeader("Cache-Control","no-cache,must-revalidate");
  xmlhttp.setRequestHeader("If-Modified-Since","0");
  xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			showcontent.innerHTML=xmlhttp.responseText;
		}		
	}
  xmlhttp.send(null);
}

function loadcommon()
{
	window.setTimeout('',10);
	if(document.cookie.indexOf("goodbabyuumsid=") != -1)
	{
		if(document.getElementById('logindiv') != null)
			readcontent('','','','logindiv','login','','');
		//if(document.getElementById('yershequ') != null)
			//readcontent('','','','yuershequ','yuershequ','','');
		if(document.getElementById('myspace') != null)
			readcontent('','','','myspace','myspace','','');
		if(document.getElementById('mybbs') != null)
			readcontent('','','','mybbs','mybbs','','');
		if(document.getElementById('my2hand') != null)
			readcontent('','','','my2hand','my2hand','','');
		if(document.getElementById('myask') != null)
			readcontent('','','','myask','myask','','');
		if(document.getElementById('combbs') != null)
			readcontent('','','','combbs','combbs','','');
		if(document.getElementById('comblog') != null)
			readcontent('','','','comblog','comblog','','');
		if(document.getElementById('comqinzi') != null )
			readcontent('','','','comqinzi','comqinzi','','');
		if(document.getElementById('comershou') != null)
			readcontent('','','','comershou','comershou','','');
		if(document.getElementById('comask') != null)
			readcontent('','','','comask','comask','','');
	}

	if(document.getElementById('left_adv1') != null && document.getElementById('left_adv2') != null && document.getElementById('left_adv3') != null && host_name == 'www.goodbaby.com')
		window.setInterval(changeImg,3000);
}

function blog_searchchk(obj) {
	obj.keyword.value = encodeURIComponent(obj.keyword_gbk.value);
	return true;
}
