﻿$(function(){
	AccessSortItemList();
});

var Button_SortItemList;
function AccessSortItemList(tmp_class){
	var tmp_path		= $("#SIL_block > div");
	var tmp_i				= 0;
	var tmp_sec			= 60*60*24*365;		//Cookie存活時間
	$("#SIL_block").attr({'class':tmp_class + '_block'});
	
	//取得搜尋建議開關值
	if(tmp_class==null && getCookie('Button_ShowCategoryItemStyle')){
		tmp_class			= getCookie('Button_ShowCategoryItemStyle');
		//AccessSortItemList(tmp_class);
	}
	switch(tmp_class){
		case 'literature':
			if(Button_SortItemList!='literature'){
				$("#SIL_bar").attr({'class':tmp_class + '_bar'});
				$("#SIL_bar").css({'display':''});
				for(tmp_i=1;tmp_i<tmp_path.length;tmp_i++){
					tmp_path.eq(tmp_i).attr({'class':tmp_class + '_item'});																//SIL_item
					
					tmp_path.eq(tmp_i).children("div").eq(1).after(tmp_path.eq(tmp_i).children("div").eq(0));
					tmp_path.eq(tmp_i).children("div").eq(0).attr({'class':tmp_class + '_title'});
					tmp_path.eq(tmp_i).children("div").eq(0).css({'display':''});				//SIL_title
					tmp_path.eq(tmp_i).children("div").eq(1).attr({'class':tmp_class + '_img'});					//SIL_img
					
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(0).css({'display':''});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(0).attr({'class':tmp_class + '_content_info'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(1).css({'display':''});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(1).attr({'class':tmp_class + '_content_nowcost'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(2).css({'display':''});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(2).attr({'class':tmp_class + '_content_buycost'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(3).css({'display':''});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(3).attr({'class':tmp_class + '_content_bids'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(4).css({'display':''});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(4).attr({'class':tmp_class + '_content_lasttime'});
					//tmp_path.eq(tmp_i).children("div").eq(1).attr({'class':tmp_class + '_content'});			//SIL_content
					//tmp_path.eq(tmp_i).children("div").eq(1).css({'display':''});												//SIL_content
					
					tmp_path.eq(tmp_i).children("div").eq(3).attr({'class':tmp_class + '_addtrack'});			//SIL_addtrack
					tmp_path.eq(tmp_i).children("div").eq(3).css({'display':''});	
				}
				Button_SortItemList	= tmp_class;
			}
			break;
		case 'show_photo':
		default:
			if(Button_SortItemList!='show_photo'){
				if(tmp_class==null) tmp_class	= 'show_photo';
				$("#SIL_bar").removeAttr('class');
				$("#SIL_bar").css({'display':'none'});
				for(tmp_i=1;tmp_i<tmp_path.length;tmp_i++){
					tmp_path.eq(tmp_i).attr({'class':tmp_class + '_item'});
					
					if(Button_SortItemList) tmp_path.eq(tmp_i).children("div").eq(1).after(tmp_path.eq(tmp_i).children("div").eq(0));
					tmp_path.eq(tmp_i).children("div").eq(0).attr({'class':tmp_class + '_img'});
					tmp_path.eq(tmp_i).children("div").eq(1).attr({'class':tmp_class + '_title'});
					tmp_path.eq(tmp_i).children("div").eq(1).css({'display':''});
					
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(0).css({'display':'none'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(0).attr({'class':tmp_class + '_content_info'});
					//tmp_path.eq(tmp_i).children("div").eq(1).children("div").eq(1).css({'display':'none'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(1).attr({'class':tmp_class + '_content_nowcost'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(2).css({'display':'none'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(2).attr({'class':tmp_class + '_content_buycost'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(3).css({'display':''});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(3).attr({'class':tmp_class + '_content_bids'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(4).css({'display':'none'});
					tmp_path.eq(tmp_i).children("div").eq(2).children("div").eq(4).attr({'class':tmp_class + '_content_lasttime'});
					//tmp_path.eq(tmp_i).children("div").eq(1).removeAttr('class');
					//tmp_path.eq(tmp_i).children("div").eq(1).css({'display':'none'});
					
					tmp_path.eq(tmp_i).children("div").eq(3).attr({'class':tmp_class + '_addtrack'});
					tmp_path.eq(tmp_i).children("div").eq(3).css({'display':''});
				}
				Button_SortItemList	= tmp_class;
			}
	}
	setCookie('Button_ShowCategoryItemStyle',tmp_class,tmp_sec);
}
//商品排列
function SortCategoryList(){
	if($("#choice option:selected").val()!=''){
		location.href= location.href + "&sort=" + $("#choice option:selected").val();
	}
}




