
function $(obj)
{
    return document.getElementById(obj);
}

function onfs()
{
	var s = $("s_book_t");
	var c = s.style.color;
	if(s.value == "请输入书名或作者或出版社")
		s.value ="";
	if(c.toLowerCase() == "rgb(170, 170, 170)" || c.toLowerCase() == "#aaaaaa" )
		s.style.color = "#000000";

}

function tsb(e)
{
	if(e.keyCode == 13 )
	{
		sbook();
	}
}

function hid(o,s)
{
	if(s.src.indexOf("/images/buttonbg_4_1.jpg") != -1)
	{
		s.src = "../images/buttonbg_4.jpg";
		$(o).style.display = 'block';
	}
	else
	{
		s.src = "../images/buttonbg_4_1.jpg";
		$(o).style.display = 'none';
	}
}
function sbook()
{  
	var sv = $("s_book_t").value.replace(/^s*/,'');
	if(sv == '') return;
	if(self.location.href.indexOf('/shuku/') == -1 && self.location.href.indexOf('/shuxun/') == -1 && self.location.href.indexOf('/shuping/') == -1)
	self.location.href = "shuku/searchbook.php?t=top&v=" + encodeURI(sv);
	else
	self.location.href = "../shuku/searchbook.php?t=top&v=" + encodeURI(sv);
}

function favorite(id,na)
{
	if(isNaN(id) || na == '') return;
	var v = self.location.href;
	v = v.substring(0,v.indexOf('/searchbook.php'));
	v = v + "/content.php?id=" + id;
	window.external.addFavorite(v, na +' -- 所有网');
}
function selfurl(u,id)
{
	if(u =="" || !$(id)) return;
	var v = $(id).value.replace(/^\s*/,'');
	if(isNaN(v) || v == '') return;
	self.location.href=u + "&cpage=" + v;
}

function scheck(o)
{
	
	if(o.bname.value.replace(/^\s*/,'') == '' && o.bau.value.replace(/^\s*/,'') == '' && o.bpu.value.replace(/^\s*/,'') == '' && o.bdis.value.replace(/^\s*/,'') == ''  && o.syear.value.replace(/^\s*/,'') == ''  && o.smonth.value.replace(/^\s*/,'') == '' && o.eyear.value.replace(/^\s*/,'') == ''  && o.emonth.value.replace(/^\s*/,'') == '' && o.uptime.value.replace(/^\s*/,'') == '')
	{
		alert('请填写一个搜索内容');	
		o.bname.focus();
		return false;
	}
	if(o.bdis.value.replace(/^\s*/,'') != '' )
	{
		if(!o.bdis.value.replace(/^\s*/,'').match(/^[\d]{1,3}$/))
		{
		alert('折扣价填写不正确,请输入100以下的整数');	
		o.bdis.focus();
		return false;
		}
		else if(parseInt(o.bdis.value.replace(/^\s*/,''),10) > 100 )
		{
		alert('折扣价填写不正确,请输入100以下的整数');	
		o.bdis.focus();
		return false;
		}
	}
	
	if(o.uptime.value.replace(/^\s*/,'') != '' && !o.uptime.value.replace(/^\s*/,'').match(/^[\d]{4}\-[\d]{2}\-[\d]{2}$/))
	{
		alert('上价时间填写不正确，格式：[2008-01-01]');	
		o.uptime.focus();
		return false;
	}
	
	
}
function disyear(n,s)
{
	var D =   new Date();
	var y = D.getYear();
	y = (y < 1900) ? (1900 + y) : y;
	var str =" <select name='" + n + "' class='searchput3'> <option value=''></option>";
    
	for(var i=1970;i<=y;i++)
	{
		
		str += " <option value='" +  i + "'>" +  i + "</option>";
	}	
     str +="  </select>";
	 document.write(str);
}
function pagego(e,o,u)
{
	var v = o.value.replace(/^\s*/,'');
	if(e.keyCode == 13 && v != '' && !isNaN(v))
	{
		self.location.href=u + "&cpage=" + v;
	}
	
}
function subcom(o)
{
	if(o.content.value.replace(/^\s*/,'') =='')
	{
		o.content.focus();
		alert('评论内容还没有填写！');
		return false;
	}
	else if(o.content.value.replace(/^\s*/,'').length > 3000)
	{
		o.content.focus();
		alert('评论内容过长！');
		return false;
	}
	return true;
}
function openwin(o)
{
	if(!$(o)) return;
	if(o =='floatbg' && $('wint').value =='')
	{
		$('wint').value = self.location.href;
	}
	$(o).style.display = 'block';
}
function closewin(o)
{
	if(!$(o)) return;
	$(o).style.display = 'none';
}
function bigimg(o)
{
	if(!$(o)) return;
	$(o).style.display = 'block';
	if($('bimg').width >400)
		$('bimg').width =400;

}

function getfv()
{
	return pic;
}

function reimg()
{
	var imgs = document.images;
	for(var i=0;i<imgs.length;i++)
	{
		imgs[i].src = imgs[i].src.replace('book.suoyoo.com/book/up','book.suoyoo.com/up');
		imgs[i].src = imgs[i].src.replace('book.suoyoo.com/breeze/i','www.suoyoo.com/breeze/i');
	
	}
}
