/*********************************************
  CPGNuCalendar
  ********************************************
  Copyright ©2005 by Kris Henneman
  
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  CPGNuCalendar is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  $Revision: 1.1 $
  $Author: Phoenix $
  $Date: 2007/10/21 13:04:08 $
**********************************************/

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
W3C = (document.getElementById) ? 1 : 0;	

var choices = new Array();
choices[0] = "daily";
choices[1] = "weekly";
choices[2] = "monthly";
choices[3] = "yearly";
choices[4] = "recurrencerange";
choices[5] = "recurring";

function toggle ( name ) {
  var ele;

  if ( W3C ) {
    ele = document.getElementById(name);
  } else if ( NS4 ) {
    ele = document.layers[name];
  } else { // IE4
    ele = document.all[name];
  }

  if ( NS4 ) {
    if (ele.display == "inline")
		hideRecurProperties(name);
    else 
		showRecurProperties(name);
  } else {  // IE4 & W3C & Mozilla
    if (ele.style.display == "inline")
		hideRecurProperties(name);
    else 
		showRecurProperties(name);
  }

  
}
function showRecurProperties ( name ) {
  var ele;
  var count = 5;
  
  if ( W3C ) {
    ele = document.getElementById(name);
  } else if ( NS4 ) {
    ele = document.layers[name];
  } else { // IE4
    ele = document.all[name];
  }

  if ( NS4 ) {
    ele.display = "inline";
  } else {  // IE4 & W3C & Mozilla
    ele.style.display = "inline";
  }
  
  if (name != choices[4])
  {
	  for (i=0; i<4; i++)
	  {
		  if (choices[i] != name)
			  hideRecurProperties(choices[i]);
		  else
			  count = i;
	  }
	  if (count < 4)
		  showRecurProperties(choices[4]);
  }
}

function hideRecurProperties ( name ) {
  if (W3C) {
    document.getElementById(name).style.display = "none";
  } else if (NS4) {
    document.layers[name].display = "none";
  } else {
    document.all[name].style.display = "none";
  }
}

function makeSuggestions( dir, id ) {
	if ( W3C ) {
		ele = document.getElementById(id);
	} else if ( NS4 ) {
		ele = document.layers[id];
	} else { // IE4
		ele = document.all[id];
	}
	image = ele.getAttribute('image');
	priority = ele.getAttribute('priority');
	document.editeventform.priority.selectedIndex = priority - 1;
	for (var i=0; i<document.editeventform.evt_img.options.length; i++) {
		if (document.editeventform.evt_img.options[i].value == image) {
			document.editeventform.evt_img.options.selectedIndex = i;
			changeImage(dir, image);
			break;
		}
	}
}

function changeImage (dir, image) {
	document.images.sample.src = dir + image;
}

