var SearchResultsLayoutOptions = {};

var SearchResultsLayout = {
	Horizontal : 0,
	Vertical : 1,
	ListOnly : 2
}

SearchResultsLayoutOptions.TurnButtonOff = function(button, src){
	
}

SearchResultsLayoutOptions.TurnButtonOn = function(button, src){
	
}

SearchResultsLayoutOptions.Button_MouseOver = function(button, type){
	if(button.src.indexOf('_Selected') == -1) { 
		button.src='Images/LayoutOptions_'+ type +'2.jpg'; 
	}else{ 
		button.src='Images/LayoutOptions_'+ type +'_Selected2.jpg'; 
	}
}

SearchResultsLayoutOptions.Button_MouseOut = function(button, type){
	if(button.src.indexOf('_Selected') == -1) { 
		button.src='Images/LayoutOptions_'+ type +'.jpg'; 
	}else{ 
		button.src='Images/LayoutOptions_'+ type +'_Selected.jpg'; 
	}
}

SearchResultsLayoutOptions.SwitchLayout = function(button, layout){
	var listCell = document.getElementById("SearchResultsListCell");
	var resizeCell = document.getElementById("SearchResultsResizeCell");
	var viewCell = document.getElementById("SearchResultsViewCell");
	var separatorCell = document.getElementById("SearchResultsHorizontalSeparatorCell");
	var viewHCell = document.getElementById("SearchResultsViewCell_H");
	
	var list = document.getElementById("ArticleList");
	var view = document.getElementById("ArticleView");
	var horizontalButton = document.getElementById("SearchResultsLayoutOptions_HorizontalLayoutButton");
	horizontalButton.src = "Images/LayoutOptions_Horizontal.jpg";
	var verticalButton = document.getElementById("SearchResultsLayoutOptions_VerticalLayoutButton");
	verticalButton.src = "Images/LayoutOptions_Vertical.jpg";
	var listOnlyButton = document.getElementById("SearchResultsLayoutOptions_ListOnlyButton");
	listOnlyButton.src = "Images/LayoutOptions_ListOnly.jpg";
	
	var listBLCorner = document.getElementById("ArticleListBlock_Corners_BL");
	var listBRCorner = document.getElementById("ArticleListBlock_Corners_BR");
	
	var currentSettingIsHorizontal = separatorCell.parentNode.style.display != "none";
	//alert(currentSettingIsHorizontal);
	switch(layout){
		case SearchResultsLayout.Horizontal:
			separatorCell.parentNode.style.display = "";
			viewHCell.parentNode.style.display = "";
			
			if(!currentSettingIsHorizontal){
				resizeCell.style.display = "none";
				viewCell.style.display = "none";
				horizontalButton.src = "Images/LayoutOptions_Horizontal2.jpg";
				listBRCorner.src = "Images/BlockCorners/ArticleListInnerBRFill.gif";
				listBLCorner.src = "Images/BlockCorners/ArticleListInnerBLFill.gif";
				Utilities.DOM.MoveChildren(viewCell, viewHCell);
				list.SetHeight(list.GetHeight() / 2 - 9);
				view.style.height = (parseInt(view.style.height) / 2) +"px";
			}
			
			SettingsManager.SaveSetting("SearchResults.Layout", "horizontal");
			break;
		case SearchResultsLayout.Vertical:
			separatorCell.parentNode.style.display = "none";
			viewHCell.parentNode.style.display = "none";
			
			resizeCell.style.display = "";
			viewCell.style.display = "";
			
			verticalButton.src = "Images/LayoutOptions_Vertical2.jpg";
			listBRCorner.src = "Images/BlockCorners/ArticleListInnerBRFill.gif";
			listBLCorner.src = "Images/BlockCorners/ArticleListInnerBL.gif";
			if(currentSettingIsHorizontal){
				Utilities.DOM.MoveChildren(viewHCell, viewCell);
				list.SetHeight((list.GetHeight() + 9) * 2);
				view.style.height = (parseInt(view.style.height) * 2) +"px";
			}else{
				if(viewCell.childNodes.length == 0){
					viewCell.appendChild(viewHCell.childNodes[0]);
				}
			}
			
			SettingsManager.SaveSetting("SearchResults.Layout", "vertical");
			break;
		case SearchResultsLayout.ListOnly:
			if(currentSettingIsHorizontal){
				Utilities.DOM.MoveChildren(viewHCell, viewCell);
				
				list.SetHeight((list.GetHeight() + 9) * 2);
				view.style.height = (parseInt(view.style.height) * 2 + 1) +"px";
			}
			resizeCell.style.display = "none";
			viewCell.style.display = "none";
			separatorCell.parentNode.style.display = "none";
			viewHCell.parentNode.style.display = "none";
			listOnlyButton.src = "Images/LayoutOptions_ListOnly2.jpg";
			listBRCorner.src = "Images/BlockCorners/ArticleListInnerBR.gif";
			listBLCorner.src = "Images/BlockCorners/ArticleListInnerBL.gif";
			SettingsManager.SaveSetting("SearchResults.Layout", "list");
			break;
	}
	list.ResizeHeaderScrollContainer();
}
