var search_action_array=['http://bbs.ifeng.com/search.php','http://sou.ifeng.com/hlftiweb/search.action?q=&c=5','http://sou.ifeng.com/hlftiweb/search.action?q=&c=1','http://sou.ifeng.com/bsearch/bsearch.do?q=','http://app.finance.ifeng.com/hq/search.php?q='];
var search_array=['ra', 'ra0','ra1','ra2','ra3'];
var search_index=0;
function switch_search(index)
{
	document.getElementById('c').value = index==0?5:1;
	document.getElementById('searchForm').action=search_action_array[index];
}
function init_search()
{
	switch_search(search_index);
	V.addListener(search_array,'click',
		function(e,obj)
		{
			var tmp=0;
			for(var i=0;i!=search_array.length;i++)
			{
				if(obj.id==search_array[i])
				{
					tmp=i;break;
				}
			}
			switch_search(tmp);
		}
	)
	/*
	V.addListener('searchbutton','click',function(e,obj){
	document.getElementById('searchForm').submit();});*/
	document.getElementById('searchForm').q.focus();
	document.getElementById('searchForm').q.value=PH_HOTWORDS[0];
}


function clickLoginSelect(){
	if(document.getElementById("loginFldselectop").style.display == "block"){
		document.getElementById("loginFldselectop").style.display = "none";
	}else{
		document.getElementById("loginFldselectop").style.display = "block";
		selectlist();
	}
}

function myclick(obj)
{
	document.getElementById("loginUl").innerHTML = obj.innerHTML;
	document.getElementById("loginFldselectop").style.display = "none";
}
function selectlist(){
	var liObj = document.getElementById("loginFldselectop").getElementsByTagName("li");
	for (var j=0;j<liObj.length;j++){
	liObj[j].onmouseover=function(){
		this.style.background="#B4777A";
		this.getElementsByTagName("a")[0].style.color="white";
		
	}
	liObj[j].onmouseout=function(){
		this.style.background="white";
		this.getElementsByTagName("a")[0].style.color="black";
	}
	liObj[j].onclick=function(){
		document.getElementById("loginFldselectop").style.display == "none";
	}
	}
}
function getHotwords()
{
	var PH_HOTWORDS_TRAGET='http://sou.ifeng.com/hlftiweb/search.action?c=1&q=', __s='';
	for(var i=1;i<5;i++){__s+='<a href="'+PH_HOTWORDS_TRAGET+encodeURIComponent(PH_HOTWORDS[i])+'" target="_blank">'+PH_HOTWORDS[i]+'</a>&nbsp;&nbsp;';}
	return __s;
}
function clear_text(){
	var t = document.getElementById("q");
	t.value="";
}

/*ifeng_viewthread_albums*/
var j = jQuery.noConflict();
var imageOnmousemove = function(e, id, photoid) {
	if(e) {
		var cursorper = (parseInt(e.clientX)-j(id).offset().left)/j(id).width();
		if(cursorper > 0.5 || photoid == 0) {
			j(id).css('cursor', "url(http://img.ifeng.com/tres/TemplateRes/right.cur),auto");
		} else {
			j(id).css('cursor', "url(http://img.ifeng.com/tres/TemplateRes/left.cur),auto");	
		}
	} else {
		return false;
	} 
}

var imageOnclick = function(e, id, preid, nextid) {
	if(e) {
		var cursorper = (parseInt(e.clientX)-j(id).offset().left)/j(id).width();
		if(cursorper > 0.5) {
			window.location.href = j(nextid).attr('href');	
		} else {
			window.location.href = j(preid).attr('href');	
		}
	} else {
		return false;
	}
}

