<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	// Save Calendar Prefs
	// ========================================================================================
	
	$PageTitle = $MsgText[1][3];
	$BrowserTitle = $MsgText[1][3];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[1][3];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[101] == 'y') {
	
	
			ReadFormArguments();
			Global $FormArguments;
			
			if (count($FormArguments) > 0) {
																		
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['PageTitle']."' where Name='PageTitle' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['TitleAlignment']."' where Name='TitleAlignment' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['TopText']."' where Name='TopText' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['TopTextAlignment']."' where Name='TopTextAlignment' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['BottomText']."' where Name='BottomText' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['BottomTextAlignment']."' where Name='BottomTextAlignment' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['NumberLocation']."' where Name='NumberLocation' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['DetailsDisplay']."' where Name='DetailsDisplay' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['ConvertReturns']."' where Name='ConvertReturns' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['ShowPoster']."' where Name='ShowPoster' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['BorderStyle']."' where Name='BorderStyle' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['GridPrefix']."' where Name='GridPrefix' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['DetailsAlignment']."' where Name='DetailsAlignment' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['DatesToShow']."' where Name='DatesToShow' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['ReversePeriod']."' where Name='ReversePeriod' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['ForwardPeriod']."' where Name='ForwardPeriod' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['ItemFontFace']."' where Name='ItemFontFace' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['ItemFontSize']."' where Name='ItemFontSize' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['PopWidth']."' where Name='PopWidth' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['PopHeight']."' where Name='PopHeight' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['CenterPop']."' where Name='CenterPop' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['DayViewDescriptionLength']."' where Name='DayViewDescriptionLength' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['DetailsPopDescriptionLength']."' where Name='DetailsPopDescriptionLength' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['SortOrder']."' where Name='SortOrder' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['DayNamesStyle']."' where Name='DayNamesStyle' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "select * from `".$Settings['DBPrefix']."cl-Settings` where Name='TitleImage' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$query = "update `".$Settings['DBPrefix']."cl-Settings` set Value='".$FormArguments['TitleImage']."' where Name='TitleImage' limit 1";
					$result = mysql_query($query) or die (mysql_error());
				}
				else {
					$query = "insert into `".$Settings['DBPrefix']."cl-Settings` (Name, Value) values ('TitleImage','".$FormArguments['TitleImage']."')";
					$result = mysql_query($query) or die (mysql_error());
				}
	
			
			
				header('Location: ' . $MainURL . '/options.html');
				
			}
			else {
				$PageContents = $MsgText[0][98];
			}
			
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}
	
	

	// ========================================================================================




?>
