/**
 * This javascript is for the frontpage.
 * GUL Copyright Mediaman
 * This javascript effect use jQuery prototype
 * Author Billy Song <billy.song@mediaman.com.cn>
 */




$("document").ready(function(){
	
	$("#fl1").click(function(){
		//alert("风险等级0");
		$("#selected").hide();
		$("#unselected").show();
	});

	$("#fl2").click(function(){
		//alert("风险等级1");
		$("#unselected").hide();
		//alert($("select[@name='fxLevel'][@selected]").val());
		//$("#speed option[@selected]").removeAttr("selected");
		//$("#value").attr("selected","selected");
		//alert($("#speed option[@selected]").val());
		$("#selected").show();
		//alert($("select[@name='fxLevel']").val()+"df");
		
		
	});
	
	//调整首页上单只基金查询的边框样式
	//alert("class="+$("form[@name=search_quick]").attr("class"));
	$("form[@name=search_quick]").attr("class","search1a");
	//alert("class="+$("form[@name=search_quick]").attr("class"));
	
	//基金查询
	/*筛选时在提交之前要做的事*/
	jQuery("form[@name='search_filter']").submit(function () {
		//筛选时，两个类型选框的协同变化情况
		//alert("in submit");
		jQuery("input[@name='fundtype'][@checked]").removeAttr("checked");
		var ty=jQuery("input[@name='fundtype.type'][@checked]").val();
		jQuery("input[@name='fundtype'][@value='"+ty+"']").attr("checked","checked");
		
		//筛选时是否是选择风险等级条件的处理
		if(jQuery("input[@name='fund_degree_type'][@checked]").val()=='0')
		{
			jQuery("input[@name='fundtype.fxLevel']").val("");
		}
		if(jQuery("input[@name='fund_degree_type'][@checked]").val()=='1')
		{
	
			jQuery("input[@name='fundtype.fxLevel']").val(jQuery("select[@name='fxLevel']").val());
		}

		
		//筛选时范围条件的处理
		var scal=jQuery("select[@name='scale']").val();
		   //alert("ppp"+jQuery("select[@name='scale']").val());
		   var ss=new Array();
		   ss=scal.split("-");
		 
		   if(ss[0]=="")
		   {
			   //alert("null1");
			   jQuery("input[@name='fundtype.begin']").val(ss[0]);
		   }
		 
		   else
		   {
			   //alert("!=null");
			   jQuery("input[@name='fundtype.begin']").val(Math.pow(10,8)*ss[0]);
		   }
		   
	
		   //alert(jQuery("input[@name='fundtype.begin']").val());
		  
		  if(ss[1]=="")
		  {
			  //alert("end==null");
			  jQuery("#max").val(ss[1]);
		  }
		  else
		  {
			  jQuery("#max").val(Math.pow(10, 8)*ss[1]);
		  }
		  
		   //alert("max="+jQuery("input[@name='fundtype.end']").val());
		   

		   var value=jQuery("select[@name='value']").val();
		   var vv=new Array();
		   vv=value.split("-");
		
		   if(vv[0]=="")
		   {
			
			   jQuery("#min2").val(vv[0]);
		   }
		   else
		   {
			   jQuery("#min2").val(Math.pow(10, -2)*vv[0]);
		   }
		   if(vv[1]=="")
		   {
			  
			   jQuery("#max2").val(vv[1]);
		   }
		   else
		   {
			   jQuery("#max2").val(Math.pow(10, -2)*vv[1]);
		   }
		   
		   
		  
		//货币基金的筛选条件处理
		   if(ty==05)
		   {
		   var scale2=jQuery("select[@name='scale2']").val();
		   //alert("ppp2"+jQuery("select[@name='scale2']").val());
		   var ss=new Array();
		   ss=scale2.split("-");
	
		   if(ss[0]=="")
		   {
			  
			   jQuery("input[@name='coinfund.begin']").val(ss[0]);
		   }
		   else
		   {
			   
			   jQuery("input[@name='coinfund.begin']").val(Math.pow(10, -2)*ss[0]);
		   }
		   if(ss[1]=="")
		   {
			  //alert("3==null");
			   jQuery("#max3").val(ss[1]);
		   }
		   else
		   {
			   end3=ss[1];
			   jQuery("#max3").val(end3=Math.pow(10, -2)*ss[1]);
		   }
		   
	
		   //alert(jQuery("input[@name='fundtype.begin']").val());
		   
		   //alert("max="+jQuery("input[@name='fundtype.end']").val());
		   

		   var value=jQuery("select[@name='value2']").val();
		   var vv=new Array();
		   vv=value.split("-");

		   if(vv[0]=="")
		   {
			
			   jQuery("#min4").val(vv[0]);
		   }
		   else
		   {
			   jQuery("#min4").val(Math.pow(10, -2)*vv[0]);
		   }
		   if(vv[1]=="")
		   {
			  
			   jQuery("#max4").val(vv[1]);
		   }
		   else
		   {

			   jQuery("#max4").val(Math.pow(10, -2)*vv[1]);
		   }

		   //jQuery("form[@name='search_filter']").attr("action","/fund/pai/searchCoinNetValue.gsp"); 
		   //alert(jQuery("form[@name='search_filter']").attr("action"));
		   }
		  
	
	});
	
	
});	

