/////////////////////////////////////////////
// Options /////
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 12/2/2013	ELL
// Revised: 2/3/2015	ELL
// Converted list selection with images from post and re-write page to selecting image from JS multi-dim array.
// Converted save operation to work as AJAX form post using JQuery.
// 
//
var browser = BrowserDetect.browser;
var browser_version = BrowserDetect.version;

var param_array = {'popup_msg_type' : 1, 'status_msg' : '', 'popup_timeout' : -1};
var popup_msg = new PopupMsg(param_array);

window.parent.document.title = document.title;

function dropdown(sel){
	var opt_val = sel.options[sel.selectedIndex].value;
	var opt_name = sel.name;
	var opt_img = option_image[opt_name][opt_val];
	document.getElementById(opt_name).src = "images/" + opt_img;
}

function OpenHelpWindow()
{
	window.open("http://breezewebsitebuilder.com/docs/cms/help.html#options", "Help", "scrollbars=1,resizable=1,status=0,toolbar=0,menubar=0,location=0,height=700,width=800");
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function SaveOptions()
{
	$.ajax({type:'POST', url: 'save_options.php', data:$('#frmChangeOptions').serialize(), success: function(response) {
		CompleteSaveOptions(response);
	}});
}
function CompleteSaveOptions(response)
{
	var resp_arr = response.split(":");
	var options_saved = resp_arr[0].split("=");
	var refresh_main = resp_arr[1].split("=");
	
	popup_msg.top_offset = 0;
	popup_msg.left_offset = 320;
	popup_msg.popup_msg_type = 1;
	popup_msg.popup_timeout = 3000;
	if (options_saved[1] == 1)
		popup_msg.status_msg = MANAGE_SITE_OPTIONS_OPTIONS_SAVED_MSG;
	else
		popup_msg.status_msg = MANAGE_SITE_OPTIONS_ERROR_SAVING_OPTIONS_ERR;
	popup_msg.ShowPopupMsg();
	
	
	if (refresh_main[1] == 1)
		var timer = setTimeout(function() { RefreshMainMenu(); }, 3000);
}
function RefreshMainMenu()
{
	window.parent.location = "main.php";
}