Index: pageear.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pageear/pageear.info,v
retrieving revision 1.1
diff -u -r1.1 pageear.info
--- pageear.info	18 Mar 2008 13:47:38 -0000	1.1
+++ pageear.info	21 May 2009 10:42:12 -0000
@@ -1,4 +1,4 @@
-; $Id: pageear.info,v 1.1 2008/03/18 13:47:38 fokke Exp $
+; $Id: pageear.info $
 name = PageEar
-description = Add a peel away ad (magic corner, peelad) to your website.
-core = 6.x
\ No newline at end of file
+description = "Add a peel away ad (magic corner, peelad) to your website."
+core = 5.x
Index: pageear.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pageear/pageear.module,v
retrieving revision 1.4
diff -u -r1.4 pageear.module
--- pageear.module	23 May 2008 12:25:10 -0000	1.4
+++ pageear.module	21 May 2009 10:42:13 -0000
@@ -1,294 +1,606 @@
 <?php
+// $Id$
+
+/**
+ * @file
+ * Pageear module file.
+ *
+ * Pagear module allows you to add a peel away ad (magic corner, peelad)
+ * to your website.
+ */
+
+/**
+ * Implementation of hook_menu().
+ */
+function pageear_menu($may_cache) {
 
-function pageear_menu() {
   $items = array();
   
-  $items['admin/settings/pageear'] = array(
-		'title'								=> t('PageEar'),
-		'description'					=> t('Add a peel away ad (magic corner, peelad) to your website.'),
-		'page callback'				=> 'drupal_get_form',
-		'page arguments'			=> array('pageear_settings'),
-		'access arguments'		=> array('administer site configuration'),
-	);
+  if ($may_cache) {
+    $items[] = array(
+      'path' => 'admin/settings/pageear',
+      'title' => t('PageEar'),
+      'description' => t('Add a peel away ad (magic corner, peelad) to your website.'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('pageear_settings'),
+      'access' => user_access('administer site configuration'),
+    );
+  }
 
   return $items;
+
 }
 
+
+/**
+ * Implementation of hook_init().
+ */
 function pageear_init() {
-	$settings = variable_get('pageear_settings', array());
-	
-	if (variable_get('pageear_state', FALSE) && count($settings)) {
-
-		if (module_exists('condition')) {
-			$conditions = variable_get('pageear_conditions', array());
-
-			if (!condition_selection_validate($conditions)) {
-				variable_set('pageear_init', FALSE);
-				return;
-			}
-		}
-		
-		variable_set('pageear_init', TRUE);
-		drupal_add_js(drupal_get_path('module', 'pageear').'/pageear/AC_OETags.js');
-		drupal_add_js(drupal_get_path('module', 'pageear').'/pageear/pageear.js');
-		
-	} else {
-		variable_set('pageear_init', FALSE);
-	}
+
+  $settings = variable_get('pageear_settings', array());
+
+  if (variable_get('pageear_state', FALSE) && count($settings)) {
+
+    $conditions = variable_get('pageear_conditions', array());
+
+    if (module_exists('condition') && count($conditions)) {
+
+      if (!condition_selection_validate($conditions)) {
+
+        variable_set('pageear_init', FALSE);
+        return;
+
+      }
+
+    }
+
+    variable_set('pageear_init', TRUE);
+    drupal_add_js(drupal_get_path('module', 'pageear') .'/pageear/AC_OETags.js');
+    drupal_add_js(drupal_get_path('module', 'pageear') .'/pageear/pageear.js');
+
+  }
+  else {
+
+    variable_set('pageear_init', FALSE);
+
+  }
+
 }
 
+
+/**
+ * Implementation of hook_footer().
+ */
 function pageear_footer($main = 0) {
-	
-	if (variable_get('pageear_init', FALSE)) {
-		$settings = variable_get('pageear_settings', array());
-		
-		$js = "<script type=\"text/javascript\">\n";
-		
-		foreach ($settings as $name => $setting) {		
-			$js .= "var ".$name." = ".drupal_to_js(is_numeric($setting) ? (float) $setting : $setting).";\n";
-		}
-		
-		$js .= "var pagearSmallSwf = '".base_path().drupal_get_path('module', 'pageear')."/pageear/pageear_s.swf';\n";
-		$js .= "var pagearBigSwf = '".base_path().drupal_get_path('module', 'pageear')."/pageear/pageear_b.swf';\n";
-		$js .= "var queryParams = 'pagearSmallImg='+escape(pagearSmallImg);\n";
-		$js .= "queryParams += '&pagearBigImg='+escape(pagearBigImg);\n";
-		$js .= "queryParams += '&pageearColor='+pageearColor;\n";
-		$js .= "queryParams += '&jumpTo='+escape(jumpTo);\n";
-		$js .= "queryParams += '&openLink='+escape(openLink);\n"; 
-		$js .= "queryParams += '&mirror='+escape(mirror);\n";
-		$js .= "queryParams += '&copyright='+escape(copyright);\n";
-		$js .= "queryParams += '&speedSmall='+escape(speedSmall);\n";
-		$js .= "queryParams += '&openOnLoad='+escape(openOnLoad);\n";
-		$js .= "queryParams += '&closeOnLoad='+escape(closeOnLoad);\n";
-		$js .= "queryParams += '&setDirection='+escape(setDirection);\n";
-		$js .= "queryParams += '&softFadeIn='+escape(softFadeIn);\n";
-		$js .= "writeObjects();\n";
-		$js .= "</script>\n";
-		
-		return $js;
-	}
+
+  if (variable_get('pageear_init', FALSE)) {
+
+    $settings             = variable_get('pageear_settings', array());
+    $image_settings       = $settings['image_settings'];
+    $sound_settings       = $settings['sound_settings'];
+    $url_settings         = $settings['url_settings'];
+    $closebutton_settings = $settings['closebutton_settings'];
+    $position_settings    = $settings['position_settings'];
+    $motion_settings      = $settings['motion_settings'];
+
+    $js = "<script type=\"text/javascript\">\n";
+
+    foreach ($image_settings as $name => $setting) {
+      $js .= "var ". $name ." = ". drupal_to_js(is_numeric($setting) ? (float) $setting : $setting) .";\n";
+    }
+
+    foreach ($sound_settings as $name => $setting) {
+      $js .= "var ". $name ." = ". drupal_to_js(is_numeric($setting) ? (float) $setting : $setting) .";\n";
+    }
+
+    foreach ($url_settings as $name => $setting) {
+      $js .= "var ". $name ." = ". drupal_to_js(is_numeric($setting) ? (float) $setting : $setting) .";\n";
+    }
+
+    foreach ($closebutton_settings as $name => $setting) {
+      $js .= "var ". $name ." = ". drupal_to_js(is_numeric($setting) ? (float) $setting : $setting) .";\n";
+    }
+
+    foreach ($position_settings as $name => $setting) {
+      $js .= "var ". $name ." = ". drupal_to_js(is_numeric($setting) ? (float) $setting : $setting) .";\n";
+    }
+
+    foreach ($motion_settings as $name => $setting) {
+      $js .= "var ". $name ." = ". drupal_to_js(is_numeric($setting) ? (float) $setting : $setting) .";\n";
+    }
+
+    $js .= "var pagearSmallSwf = '". base_path() . drupal_get_path('module', 'pageear') ."/pageear/pageear_s.swf';\n";
+    $js .= "var pagearBigSwf = '". base_path() . drupal_get_path('module', 'pageear') ."/pageear/pageear_b.swf';\n";
+    $js .= "var queryParams = 'pagearSmallImg='+escape(pagearSmallImg);\n";
+    $js .= "queryParams += '&pagearBigImg='+escape(pagearBigImg);\n";
+    $js .= "queryParams += '&pageearColor='+pageearColor;\n";
+    $js .= "queryParams += '&jumpTo='+escape(jumpTo);\n";
+    $js .= "queryParams += '&openLink='+escape(openLink);\n"; 
+    $js .= "queryParams += '&mirror='+escape(mirror);\n";
+    $js .= "queryParams += '&copyright='+escape(copyright);\n";
+    $js .= "queryParams += '&speedSmall='+escape(speedSmall);\n";
+    $js .= "queryParams += '&openOnLoad='+escape(openOnLoad);\n";
+    $js .= "queryParams += '&closeOnLoad='+escape(closeOnLoad);\n";
+    $js .= "queryParams += '&setDirection='+escape(setDirection);\n";
+    $js .= "queryParams += '&softFadeIn='+escape(softFadeIn);\n";
+    $js .= "queryParams += '&playSound='+escape(playSound);\n";
+    $js .= "queryParams += '&playOpenSound='+escape(playOpenSound);\n";
+    $js .= "queryParams += '&playCloseSound='+escape(playCloseSound);\n";
+    $js .= "queryParams += '&closeOnClick='+escape(closeOnClick);\n";
+    $js .= "queryParams += '&closeOnClickText='+escape(closeOnClickText);\n";
+    $js .= "writeObjects();\n";
+    $js .= "</script>\n";
+
+    return $js;
+  }
 }
 
-function pageear_help($path, $arg) {
-  switch ($path) {
+
+/**
+ * Implementation of hook_help().
+ */
+function pageear_help($section) {
+  switch ($section) {
     case 'admin/settings/pageear':
-      return '<p>'. t('Install the !condition module to add additional conditions for displaying the PageEar. On this page you can set all PageEar variables. For a test-drive, just submit the default values. This module is a Drupal implementation of the excellent !pageear by WebPicasso Media.', array('!pageear' => l(t('PageEar'), 'http://www.webpicasso.de/blog/kostenloses-pagepeel/'), '!condition' => l(t('Condition'), 'http://drupal.org/project/condition'))).'</p>';
+      return '<p>'. t('Install the !condition module to add additional conditions for displaying the PageEar. On this page you can set all PageEar variables. For a test-drive, just submit the default values. This module is a Drupal implementation of the excellent !pageear by WebPicasso Media.', array('!pageear' => l(t('PageEar'), 'http://www.webpicasso.de/blog/kostenloses-pagepeel/'), '!condition' => l(t('Condition'), 'http://drupal.org/project/condition'))) .'</p>';
   }
 }
 
+
+/**
+ * Admin pageear module configuration form.
+ */
 function pageear_settings() {
-	$settings = variable_get('pageear_settings', array());
-	
-	$form['#attributes'] = array('enctype' => "multipart/form-data");	
-	
-	// On / Off
-	$form['pageear_state'] = array(
-		'#type' => 'checkbox',
-		'#title' => t('Enable PageEar'),
-		'#default_value' => variable_get('pageear_state', FALSE),
-	);
-	
-	// Conditions
-	if (module_exists('condition')) {
-		$form_conditions = module_invoke('condition', 'selection_form', variable_get('pageear_conditions', array()));
-		$form['pageear_conditions'] = $form_conditions['conditions'];
-	}
-	
-	$form['pageear_settings'] = array(
-		'#type' => 'fieldset',
-		'#title' => t('Settings'),
-		'#tree' => TRUE,
-		'#collapsible' => TRUE,
-		'#collapsed' => FALSE,
-	);
-	
-	// URL to small image 
-	$form['pageear_settings']['pagearSmallImg'] = array(
-		'#type' => 'textfield',
-		'#title' => t('Unpeeled image'),
-		'#description' => t('URL of image to show when the ad is not peeled (JPEG, 100x100 pixels).'),
-		'#required' => TRUE,
-		'#default_value' => $settings['pagearSmallImg'] ? $settings['pagearSmallImg'] : base_path().drupal_get_path('module', 'pageear').'/pageear/pageear_s.jpg',
-	);
-  $form['pageear_settings']['pagearSmallImg_upload'] = array(
+  $settings = variable_get('pageear_settings', array());
+
+  $form['#attributes'] = array('enctype' => "multipart/form-data");
+
+  // On / Off.
+  $form['pageear_state'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable PageEar'),
+    '#default_value' => variable_get('pageear_state', FALSE),
+  );
+
+  // Conditions.
+  if (module_exists('condition')) {
+    $form_conditions = module_invoke('condition', 'selection_form', variable_get('pageear_conditions', array()));
+    $form['pageear_conditions'] = $form_conditions['conditions'];
+  }
+
+  // Pageear settings.
+  $form['pageear_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Settings'),
+    '#tree' => TRUE,
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+
+  // Start of fieldset for position settings.
+
+  // Position settings fieldset.
+  $form['pageear_settings']['position_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Position Settings'),
+    '#tree' => TRUE,
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+  // Set direction of pageear in left or right top browser corner ( lt: left | rt: right ).
+  $form['pageear_settings']['position_settings']['setDirection'] = array(
+    '#type' => 'radios',
+    '#title' => t('Corner'),
+    '#description' => t('In what corner the ad will be displayed.'),
+    '#options' => array(
+      'rt' => t('Top right'),
+      'lt' => t('Top left'),
+    ),
+    '#default_value' => $settings['position_settings']['setDirection'] ? $settings['position_settings']['setDirection'] : 'rt',
+    '#required' => TRUE,
+  );
+
+
+  // Start of fieldset for image settings.
+
+  // Image Settings Fieldset.
+  $form['pageear_settings']['image_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Image Settings'),
+    '#tree' => TRUE,
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+  // URL to small image.
+  $form['pageear_settings']['image_settings']['pagearSmallImg'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Unpeeled image'),
+    '#description' => t('URL of image to show when the ad is not peeled (JPEG, 100x100 pixels).'),
+    '#required' => TRUE,
+    '#default_value' => $settings['image_settings']['pagearSmallImg'] ? $settings['image_settings']['pagearSmallImg'] : base_path() . drupal_get_path('module', 'pageear') .'/pageear/pageear_s.jpg',
+  );
+
+  $form['pageear_settings']['image_settings']['pagearSmallImg_upload'] = array(
     '#type' => 'file',
     '#description' => t('Upload an image to show when the ad is not peeled.'),
     '#tree' => FALSE,
   );
-	
-	// URL to big image
-	$form['pageear_settings']['pagearBigImg'] = array(
-		'#type' => 'textfield',
-		'#title' => t('Peeled image'),
-		'#description' => t('URL of the image to show when the ad is peeled (JPEG, 500x500 pixels).'),
-		'#required' => TRUE,
-		'#default_value' => $settings['pagearBigImg'] ? $settings['pagearBigImg'] : base_path().drupal_get_path('module', 'pageear').'/pageear/pageear_b.jpg',
-	);
-  $form['pageear_settings']['pagearBigImg_upload'] = array(
+
+  // URL to big image.
+  $form['pageear_settings']['image_settings']['pagearBigImg'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Peeled image'),
+    '#description' => t('URL of the image to show when the ad is peeled (JPEG, 500x500 pixels).'),
+    '#required' => TRUE,
+    '#default_value' => $settings['image_settings']['pagearBigImg'] ? $settings['image_settings']['pagearBigImg'] : base_path() . drupal_get_path('module', 'pageear') .'/pageear/pageear_b.jpg',
+  );
+
+  $form['pageear_settings']['image_settings']['pagearBigImg_upload'] = array(
     '#type' => 'file',
     '#description' => t('Upload an image to show when the ad is peeled.'),
     '#tree' => FALSE,
   );
-	
-	// Movement speed of small pageear 1-4 (2=Standard)
-	$form['pageear_settings']['speedSmall'] = array(
-		'#type' => 'select',
-		'#title' => t('Motion speed'),
-		'#description' => t('Speed for the motion in the unpeeled state.'),
-		'#options' => array(
-			1 => t('1 (slow)'),
-			2 => t('2 (default)'),
-			3 => t('3 (faster)'),
-			4 => t('4 (fastest)'),
-		),
-		'#default_value' => $settings['speedSmall'] ? $settings['speedSmall'] : 2,
-		'#required' => TRUE,
-	);
-	
-	// Mirror image ( true | false )
-	$form['pageear_settings']['mirror'] = array(
-		'#type' => 'select',
-		'#title' => t('Back mirror'),
-		'#description' => t('Mirror the ad on the back of the peeled page.'),
-		'#options' => array(
-			'true' => t('Enabled'),
-			'false' => t('Disabled'),
-		),
-		'#default_value' => $settings['mirror'] ? $settings['mirror'] : 'true',
-		'#required' => TRUE,
-	);
-	
-	// Color of pagecorner if mirror is false
-	$form['pageear_settings']['pageearColor'] = array(
-		'#type' => 'textfield',
-		'#title' => t('Back color'),
-		'#description' => t('If the mirror effect is disabled, this color will be used on the back.'),
-		'#required' => TRUE,
-		'#default_value' => $settings['pageearColor'] ? $settings['pageearColor'] : 'FFFFFF',
-	);
-	
-	// URL to open on pageear click
-	$form['pageear_settings']['jumpTo'] = array(
-		'#type' => 'textfield',
-		'#title' => t('URL'),
-		'#description' => t('URL to go to when clicked on the ad.'),
-		'#required' => TRUE,
-		'#default_value' => $settings['jumpTo'] ? $settings['jumpTo'] : 'http://www.webpicasso.de/blog/',
-	);
-	
-	// Browser target  (new) or self (self)
-	$form['pageear_settings']['openLink'] = array(
-		'#type' => 'select',
-		'#title' => t('URL target'),
-		'#description' => t('How to open the URL.'),
-		'#options' => array(
-			'self' => t('Same window'),
-			'new' => t('New window'),
-		),
-		'#default_value' => $settings['openLink'] ? $settings['openLink'] : 'self',
-		'#required' => TRUE,
-	);
-	
-	// Opens pageear automaticly (false:deactivated | 0.1 - X seconds to open) 
-	$form['pageear_settings']['openOnLoad'] = array(
-		'#type' => 'select',
-		'#title' => t('Automaticly peel on load'),
-		'#description' => t('Unpeel automaticly when the page loads.'),
-		'#options' => array(
-			'' => t('(disabled)'),
-			0.1 => t('After 0.1 second'),
-			1 => t('After 1 second'),
-			3 => t('After 3 seconds'),
-			5 => t('After 5 seconds'),
-			10 => t('After 10 seconds'),
-		),
-		'#default_value' => $settings['openOnLoad'] ? $settings['openOnLoad'] : '',
-	);
-	
-	// Second until pageear close after openOnLoad
-	$form['pageear_settings']['closeOnLoad'] = array(
-		'#type' => 'select',
-		'#title' => t('Automaticly unpeel'),
-		'#description' => t('Automaticly close after unpeeling.'),
-		'#options' => array(
-			'' => t('(disabled)'),
-			0.1 => t('After 0.1 second'),
-			1 => t('After 1 second'),
-			3 => t('After 3 seconds'),
-			5 => t('After 5 seconds'),
-			10 => t('After 10 seconds'),
-		),
-		'#default_value' => $settings['closeOnLoad'] ? $settings['closeOnLoad'] : '',
-	);
-	
-	// Set direction of pageear in left or right top browser corner (lt: left | rt: right )
-	$form['pageear_settings']['setDirection'] = array(
-		'#type' => 'select',
-		'#title' => t('Corner'),
-		'#description' => t('In what corner the ad will be displayed.'),
-		'#options' => array(
-			'rt' => t('Top right'),
-			'lt' => t('Top left'),
-		),
-		'#default_value' => $settings['setDirection'] ? $settings['setDirection'] : 'rt',
-		'#required' => TRUE,
-	);
-	
-	// Fade in pageear if image completly loaded (0-5: 0=off, 1=slow, 5=fast )
-	$form['pageear_settings']['softFadeIn'] = array(
-		'#type' => 'select',
-		'#title' => t('Fade in'),
-		'#description' => t('Fade in the peel ad once the image is loaded.'),
-		'#options' => array(
-			0 => t('(disabled)'),
-			1 => t('Slow'),
-			5 => t('Fast'),
-		),
-		'#default_value' => $settings['softFadeIn'] ? $settings['softFadeIn'] : 5,
-		'#required' => TRUE,
-	);
-	
-	$form['#submit'][] = 'pageear_settings_submit';
-	
-	return system_settings_form($form);
+
+  // Mirror image ( true | false ).
+  $form['pageear_settings']['image_settings']['mirror'] = array(
+    '#type' => 'radios',
+    '#title' => t('Back mirror'),
+    '#description' => t('Mirror the ad on the back of the peeled page.'),
+    '#options' => array(
+      'true' => t('Enabled'),
+      'false' => t('Disabled'),
+    ),
+    '#default_value' => $settings['image_settings']['mirror'] ? $settings['image_settings']['mirror'] : 'true',
+    '#required' => TRUE,
+  );
+
+  // Color of pagecorner if mirror is false.
+  $form['pageear_settings']['image_settings']['pageearColor'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Back color'),
+    '#description' => t('If the mirror effect is disabled, this color will be used on the back.'),
+    '#required' => TRUE,
+    '#default_value' => $settings['image_settings']['pageearColor'] ? $settings['image_settings']['pageearColor'] : 'FFFFFF',
+  );
+
+  // Fade in pageear if image completly loaded ( 0-5: 0=off, 1=slow, 5=fast ).
+  $form['pageear_settings']['image_settings']['softFadeIn'] = array(
+    '#type' => 'select',
+    '#title' => t('Fade in'),
+    '#description' => t('Fade in the peel ad once the image is loaded.'),
+    '#options' => array(
+      0 => t('(disabled)'),
+      1 => t('Slow'),
+      5 => t('Fast'),
+    ),
+    '#default_value' => $settings['image_settings']['softFadeIn'] ? $settings['image_settings']['softFadeIn'] : 5,
+    '#required' => TRUE,
+  );
+
+
+  // Start of fielset for sound settings.
+
+  // Sound settings fieldset.
+  $form['pageear_settings']['sound_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Sound Settings'),
+    '#tree' => TRUE,
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+  // URL to background sound.
+  $form['pageear_settings']['sound_settings']['playSound'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Background Sound'),
+    '#description' => t('URL of mp3 file to play when the ad is loaded. false for no background sound.'),
+    '#required' => TRUE,
+    '#default_value' => $settings['sound_settings']['playSound'] ? $settings['sound_settings']['playSound'] : 'false',
+  );
+
+  $form['pageear_settings']['sound_settings']['playSound_upload'] = array(
+    '#type' => 'file',
+    '#description' => t('Upload an mp3 file to play when the ad is loaded.'),
+    '#tree' => FALSE,
+  );
+
+  // URL to open peel sound.
+  $form['pageear_settings']['sound_settings']['playOpenSound'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Open Peel Sound'),
+    '#description' => t('URL of mp3 file to play when the peel is opened. false for no open sound.'),
+    '#required' => TRUE,
+    '#default_value' => $settings['sound_settings']['playOpenSound'] ? $settings['sound_settings']['playOpenSound'] : 'false',
+  );
+
+  $form['pageear_settings']['sound_settings']['playOpenSound_upload'] = array(
+    '#type' => 'file',
+    '#description' => t('Upload an mp3 file to play when the peel is opened.'),
+    '#tree' => FALSE,
+  );
+
+  // URL to close peel sound.
+  $form['pageear_settings']['sound_settings']['playCloseSound'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Close Peel Sound'),
+    '#description' => t('URL of mp3 file to play when the peel is closed. false for no close sound.'),
+    '#required' => TRUE,
+    '#default_value' => $settings['sound_settings']['playCloseSound'] ? $settings['sound_settings']['playCloseSound'] : 'false',
+  );
+
+  $form['pageear_settings']['sound_settings']['playCloseSound_upload'] = array(
+    '#type' => 'file',
+    '#description' => t('Upload an mp3 file to play when the peel is closed.'),
+    '#tree' => FALSE,
+  );
+
+
+  // Start of fielset for URL settings.
+
+  // URL settings fieldset.
+  $form['pageear_settings']['url_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('URL Settings'),
+    '#tree' => TRUE,
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+  // URL to open on pageear click.
+  $form['pageear_settings']['url_settings']['jumpTo'] = array(
+    '#type' => 'textfield',
+    '#title' => t('URL'),
+    '#description' => t('URL to go to when clicked on the ad.'),
+    '#required' => TRUE,
+    '#default_value' => $settings['url_settings']['jumpTo'] ? $settings['url_settings']['jumpTo'] : 'http://www.webpicasso.de/blog/',
+  );
+
+  // Browser target (new) or self (self).
+  $form['pageear_settings']['url_settings']['openLink'] = array(
+    '#type' => 'radios',
+    '#title' => t('URL target'),
+    '#description' => t('How to open the URL.'),
+    '#options' => array(
+      'self' => t('Same window'),
+      'new' => t('New window'),
+    ),
+    '#default_value' => $settings['url_settings']['openLink'] ? $settings['url_settings']['openLink'] : 'self',
+    '#required' => TRUE,
+  );
+
+
+  // Start of fieldset for motion settings.
+
+  // Motion settings fieldset.
+  $form['pageear_settings']['motion_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Motion Settings'),
+    '#tree' => TRUE,
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+  // Movement speed of small pageear 1-4 (2=Standard).
+  $form['pageear_settings']['motion_settings']['speedSmall'] = array(
+    '#type' => 'select',
+    '#title' => t('Motion speed'),
+    '#description' => t('Speed for the motion in the unpeeled state.'),
+    '#options' => array(
+      1 => t('1 (slow)'),
+      2 => t('2 (default)'),
+      3 => t('3 (faster)'),
+      4 => t('4 (fastest)'),
+    ),
+    '#default_value' => $settings['motion_settings']['speedSmall'] ? $settings['motion_settings']['speedSmall'] : 2,
+    '#required' => TRUE,
+  );
+
+  // Opens pageear automaticly (false:deactivated | 0.1 - X seconds to open).
+  $form['pageear_settings']['motion_settings']['openOnLoad'] = array(
+    '#type' => 'select',
+    '#title' => t('Automatically peel on load'),
+    '#description' => t('Unpeel automatically when the page loads.'),
+    '#options' => array(
+      '' => t('(disabled)'),
+      '0.1' => t('After 0.1 second'),
+      1 => t('After 1 second'),
+      3 => t('After 3 seconds'),
+      5 => t('After 5 seconds'),
+      10 => t('After 10 seconds'),
+    ),
+    '#default_value' => $settings['motion_settings']['openOnLoad'] ? $settings['motion_settings']['openOnLoad'] : '',
+  );
+
+  // Second until pageear close after openOnLoad.
+  $form['pageear_settings']['motion_settings']['closeOnLoad'] = array(
+    '#type' => 'select',
+    '#title' => t('Automatically unpeel'),
+    '#description' => t('Automatically close after unpeeling.'),
+    '#options' => array(
+      '' => t('(disabled)'),
+      '0.1' => t('After 0.1 second'),
+      1 => t('After 1 second'),
+      3 => t('After 3 seconds'),
+      5 => t('After 5 seconds'),
+      10 => t('After 10 seconds'),
+    ),
+    '#default_value' => $settings['motion_settings']['closeOnLoad'] ? $settings['motion_settings']['closeOnLoad'] : '',
+  );
+
+
+  // Start of fieldset for close button settings.
+
+  // Close button settings fieldset.
+  $form['pageear_settings']['closebutton_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Close Button Settings'),
+    '#tree' => TRUE,
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+  // Clickable button on open peel ( true | false ).
+  $form['pageear_settings']['closebutton_settings']['closeOnClick'] = array(
+    '#type' => 'radios',
+    '#title' => t('Close Button'),
+    '#description' => t('Show a close button on open peel. If this is enabled the peel will not close on mouse out. Users must click button to close peel.'),
+    '#options' => array(
+      'true' => t('Enabled'),
+      'false' => t('Disabled'),
+    ),
+    '#default_value' => $settings['closebutton_settings']['closeOnClick'] ? $settings['closebutton_settings']['closeOnClick'] : 'false',
+    '#required' => TRUE,
+  );
+
+  // Text on close button.
+  $form['pageear_settings']['closebutton_settings']['closeOnClickText'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Close Button Text'),
+    '#description' => t('Text on clickable close button.'),
+    '#required' => TRUE,
+    '#default_value' => $settings['closebutton_settings']['closeOnClickText'] ? $settings['closebutton_settings']['closeOnClickText'] : 'Close',
+  );
+
+  return system_settings_form($form);
+
 }
 
-function pageear_settings_validate($form, &$form_state) {
 
-	$directory_path = file_directory_path().'/pageear';
+/**
+ * Admin pageear module configuration form validation.
+ */
+function pageear_settings_validate($form_id, $form_values, $form) {
+
+  $directory_path = file_directory_path() .'/pageear';
+
   file_check_directory($directory_path, FILE_CREATE_DIRECTORY, 'file_directory_path');
-	
-	foreach(array('pagearBigImg', 'pagearSmallImg') as $image) {
 
-	  if ($file = file_save_upload($image.'_upload', array('file_validate_is_image' => array()))) {
-		  $parts		= pathinfo($file->filename);
-		  
-		  if ($parts['extension'] != 'jpeg' && $parts['extension'] != 'jpg') {
-			  form_set_error($image, t('Uploaded image must be a JPEG file.'));
-			  
-		  } else {
-		    $filename	= $directory_path.'/'.$image.'.'.$parts['extension'];
-		
-		    if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
-		      $form_state['values']['pageear_settings'][$image] = $file->filepath;
-		    }
-	    }
-	  }
-	}
+  foreach (array('pagearBigImg', 'pagearSmallImg') as $image) {
+
+    if ($file = file_save_upload($image .'_upload')) {
+
+      $parts = pathinfo($file->filename);
+  
+      if ($parts['extension'] != 'jpeg' && $parts['extension'] != 'jpg') {
+
+        form_set_error($image, t('Uploaded image must be a JPEG file.'));
+  
+      }
+      else {
+
+        $filename = $directory_path .'/'. $image .'.'. $parts['extension'];
+
+        if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
+
+          form_set_value($form['pageear_settings']['image_settings'][$image], $file->filepath);
+
+        }
+      }
+    }
+  }
+
+  foreach (array('playSound', 'playOpenSound', 'playCloseSound') as $sound) {
+
+    if ($file = file_save_upload($sound .'_upload')) {
+
+      $parts = pathinfo($file->filename);
+  
+      if ($parts['extension'] != 'mp3') {
+
+        form_set_error($sound, t('Uploaded sound must be a MP3 file.'));
+  
+      }
+      else {
+
+        $filename = $directory_path .'/'. $sound .'.'. $parts['extension'];
+
+        if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
+
+          form_set_value($form['pageear_settings']['sound_settings'][$sound], $file->filepath);
+
+        }
+      }
+    }
+  }
+
 }
 
-function pageear_settings_submit($form, &$form_state) {
-	
-	if (!is_numeric($form_state['values']['pageear_settings']['openOnLoad'])) {
-		$form_state['values']['pageear_settings']['openOnLoad'] = FALSE;
-	}
-	
-	if (!is_numeric($form_state['values']['pageear_settings']['closeOnLoad'])) {
-		$form_state['values']['pageear_settings']['closeOnLoad'] = FALSE;
-	}
-	
-	$form_state['values']['pageear_settings']['pagearSmallImg'] = url($form_state['values']['pageear_settings']['pagearSmallImg'], array('absolute' => TRUE));
-	$form_state['values']['pageear_settings']['pagearBigImg'] = url($form_state['values']['pageear_settings']['pagearBigImg'], array('absolute' => TRUE));
+
+/**
+ * Admin pageear module configuration form submition.
+ */
+function pageear_settings_submit($form_id, $form_values) {
+
+  if (!is_numeric($form_values['pageear_settings']['motion_settings']['openOnLoad'])) {
+    if ($form_values['pageear_settings']['motion_settings']['openOnLoad'] == '0.1') {
+      $form_values['pageear_settings']['motion_settings']['openOnLoad'] = 0.1;
+    }
+    else {
+      $form_values['pageear_settings']['motion_settings']['openOnLoad'] = FALSE;
+    }
+  }
+
+  if (!is_numeric($form_values['pageear_settings']['motion_settings']['closeOnLoad'])) {
+    if ($form_values['pageear_settings']['motion_settings']['closeOnLoad'] == '0.1') {
+      $form_values['pageear_settings']['motion_settings']['closeOnLoad'] = 0.1;
+    }
+    else {
+      $form_values['pageear_settings']['motion_settings']['closeOnLoad'] = FALSE;
+    }
+  }
+
+  if ($form_values['pageear_settings']['image_settings']['pagearSmallImg'] != base_path() . drupal_get_path('module', 'pageear') .'/pageear/pageear_s.jpg') {
+    $form_values['pageear_settings']['image_settings']['pagearSmallImg'] = url($form_values['pageear_settings']['image_settings']['pagearSmallImg'], NULL, NULL, TRUE);
+  }
+
+  if ($form_values['pageear_settings']['image_settings']['pagearBigImg'] != base_path() . drupal_get_path('module', 'pageear') .'/pageear/pageear_b.jpg') {
+    $form_values['pageear_settings']['image_settings']['pagearBigImg'] = url($form_values['pageear_settings']['image_settings']['pagearBigImg'], NULL, NULL, TRUE);
+  }
+
+  if ($form_values['pageear_settings']['sound_settings']['playSound'] != 'false') {
+    $form_values['pageear_settings']['sound_settings']['playSound'] = url($form_values['pageear_settings']['sound_settings']['playSound'], NULL, NULL, TRUE);
+  }
+
+  if ($form_values['pageear_settings']['sound_settings']['playOpenSound'] != 'false') {
+    $form_values['pageear_settings']['sound_settings']['playOpenSound'] = url($form_values['pageear_settings']['sound_settings']['playOpenSound'], NULL, NULL, TRUE);
+  }
+
+  if ($form_values['pageear_settings']['sound_settings']['playCloseSound'] != 'false') {
+    $form_values['pageear_settings']['sound_settings']['playCloseSound'] = url($form_values['pageear_settings']['sound_settings']['playCloseSound'], NULL, NULL, TRUE);
+  }
+
+  pageear_reset_session_uploads();
+
+  system_settings_form_submit($form_id, $form_values);
+
 }
 
-?>
\ No newline at end of file
+/**
+ * Resets the value of uploads in the $_SESSION variable.
+ */
+function pageear_reset_session_uploads() {
+
+  if ($_SESSION['file_uploads']['pagearSmallImg_upload']) {
+    $_SESSION['file_uploads']['pagearSmallImg_upload'] = NULL;
+  }
+
+  if ($_SESSION['file_uploads']['pagearBigImg_upload']) {
+    $_SESSION['file_uploads']['pagearBigImg_upload'] = NULL;
+  }
+
+  if ($_SESSION['file_uploads']['playSound_upload']) {
+    $_SESSION['file_uploads']['playSound_upload'] = NULL;
+  }
+
+  if ($_SESSION['file_uploads']['playOpenSound_upload']) {
+    $_SESSION['file_uploads']['playOpenSound_upload'] = NULL;
+  }
+
+  if ($_SESSION['file_uploads']['playCloseSound_upload']) {
+    $_SESSION['file_uploads']['playCloseSound_upload'] = NULL;
+  }
+
+}
