
/**

  Simon Willison's awesome load event function, for multiple onload events

  More information:
  http://simon.incutio.com/archive/2004/05/26/addLoadEvent

**/

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


var ajaxSelectList;
var countyListCache = new Array();
function getCountyList(countryId, root)
{
	var obj = document.getElementById('countyId')
	obj.options.length = 0;	// Empty counties select box
	obj.options[obj.options.length] = new Option("Please Wait...","");
	
	if(countyListCache[countryId])
	{		
		obj.options.length = 0;
		eval(countyListCache[countryId]);
		return;		
	}

	ajaxSelectList = new sack();		
	ajaxSelectList.requestFile = root + '/ajax/get-county-list.asp?countryId=' + countryId;	// Specifying which file to get
	ajaxSelectList.onCompletion = function(){ createCountyList(countryId, root); };	// Specify function that will be executed after file has been found
	ajaxSelectList.runAJAX();		// Execute AJAX function
}
function createCountyList(countryId, root)
{
	var obj = document.getElementById('countyId');
	obj.options.length = 0;
	countyListCache[countryId] = ajaxSelectList.response;
	eval(ajaxSelectList.response);	// Executing the response from Ajax as Javascript code	
}

function showProgressAudio(url)
	{
	  strAppVersion = navigator.appVersion;
		
		w = 400
		h = 160
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		
		fileName = document.uploadAudio.eventAudio.value;
		imageCaption = document.uploadAudio.audioCaption;
		
		if(fileName == "")
		{	
			alert('You must specify a name and a file for the audio');
			return false;
		}	
		if(fileName.toLowerCase().lastIndexOf(".mp3")==-1)
		{
			alert('You can only upload MP3 audio files (files with a .mp3 extension)');
			return false;	
		}
		if(imageCaption.value == "")
		{
			alert("Before uploading, please enter a caption/title for this audio file");
			imageCaption.focus();
			return false;
		}
	
		if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
		{
		  window.open(url + '&b=IE','','width=' + w + ',height=' + h + ',top='+TopPosition+',left='+LeftPosition+',scrollbars=no', true);
		}
		else
		{
		  window.open(url + '&b=NN','','width=' + w + ',height=' + h + ',top='+TopPosition+',left='+LeftPosition+',scrollbars=no', true);
		}
		return true;
	}

function showProgress(url)
	{
	  strAppVersion = navigator.appVersion;
		
		w = 400
		h = 160
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		
		fileName = document.uploadImage.eventImage.value;
		imageCaption = document.uploadImage.imageCaption;
		
		if(fileName == "")
		{	
			alert('You must specify a name and a file for the image');
			return false;
		}	
		if(fileName.toLowerCase().lastIndexOf(".jpg")==-1)
		{
			alert('You can only upload JPEG images (files with a .jpg extension)');
			return false;	
		}
		if(imageCaption.value == "")
		{
			alert("Before uploading, please enter a caption/title for this image");
			imageCaption.focus();
			return false;
		}
	
		if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
		{
		  window.open(url + '&b=IE','','width=' + w + ',height=' + h + ',top='+TopPosition+',left='+LeftPosition+',scrollbars=no', true);
		}
		else
		{
		  window.open(url + '&b=NN','','width=' + w + ',height=' + h + ',top='+TopPosition+',left='+LeftPosition+',scrollbars=no', true);
		}
		return true;
	}