
function createPlayerAdmin(theVideo, width, height) {

	var flashMovie = new SWFObject("../inc/flash/player.swf", "player", width, height, "8.0.15", "#000000", true);
	flashMovie.addParam("allowScriptAccess", "always");
	flashMovie.addParam("allowFullScreen", "true");

	flashMovie.addVariable("file", theVideo);
	flashMovie.addVariable("autostart", "true");
	flashMovie.addVariable("bufferlength", "10");
	flashMovie.addVariable("buffer", "10");
	flashMovie.addVariable("backcolor", "#FFFFFF");
	flashMovie.addVariable("wmode", "transparent");
	flashMovie.addVariable("frontcolor", "#000000");
	flashMovie.addVariable("stretching","fill");
	flashMovie.addVariable("displayclick","none");
	flashMovie.write("videoDisplay");

	jQuery("#videoDisplay").append('<p align="center"><a href="#" id=\"closeVideo\"><b>close video</b></a></p>').click(function() {		
		jQuery("#videoDisplay").html('');
		return false;		
	}).css('margin-top', '20px').css('font-size', '15pt').css('font-weight', 'bold');


}



/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
function createPlayer(video, elementId, width, height) {

	if(width===undefined)		width = 400;
	if(height===undefined)		height = 300;

	var flashMovie = new SWFObject("inc/videos/player.swf", "player1", width, height, "8.0.15", '#000000', true);
	flashMovie.addParam("allowScriptAccess", "always");
	flashMovie.addParam("allowFullScreen", "true");

	flashMovie.addVariable("file", video);
	flashMovie.addVariable("autostart", 'true');
	flashMovie.addVariable("bufferlength", "5");
	flashMovie.addVariable("buffer", "10");

	flashMovie.addVariable("backcolor", '#000000');
	flashMovie.addVariable("wmode", "opaque");
	flashMovie.addVariable("frontcolor", '#FFFFFF');
	flashMovie.addVariable("stretching","fill");
	flashMovie.addVariable("displayclick","none");
	flashMovie.write(elementId);

}



function createFlashObject(parentId, flashMovie, bgColor, width, height, params) {

	var MM_contentVersion = 6;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		for (var i = 0; i < words.length; ++i) {
			if (isNaN(parseInt(words[i])))
				continue;
			var MM_PluginVersion = words[i]; 
		}
		var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;

	} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {

		try {
			// Try 7 first, since we know we can use GetVariable with it
			var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
			flashVersion = getFlashVersion(ax.GetVariable('$version'));
		} catch (e) {
		      // Try 6 next, some versions are known to crash with GetVariable calls
		    try {
		      var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
		      MM_FlashCanPlay = '6.0.21';  // First public version of Flash 6
		    } catch (e) {
			  try {
		        // Try the default activeX
				var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
				MM_FlashCanPlay = getFlashVersion(ax.GetVariable('$version'));
		      } catch (e) {
				 // No flash
		      }
		    }
		}
	}
	if ( MM_FlashCanPlay ) {
		var flashMovie = new SWFObject(flashMovie, parentId+"flash", width, height, "8.0.15", "#000000", true);
		flashMovie.addParam("allowScriptAccess", "always");
		flashMovie.addParam("allowFullScreen", "false");
		if(params!==false) 
			flashMovie.addParam("FlashVars", params);
		flashMovie.write(parentId);
	} else if(width>150 && height>60)
		jQuery(('#'+parentId)).html('<p align="center"><b>Some parts of this site require the adobe flash player,'
							   + '<br> please click the image below to install the flash player.</b></p>'
							   + '<p align="center"><a href="http://get.adobe.com/flashplayer/" target="_blank">'
							   + '<img src="images/get_flash_player.gif" alt="Get Adobe Flash Player" border="0" /></a></p>');

}


function setCookie(name, value) {

	document.cookie = name + '=' + escape(value);

}



function arrayKeyExists(array, key) {

	if(array[key]==undefined) 
		return false;
	return true;

}


function resetMenuItems() {

	jQuery("img[class=menu]").each(function() {
		if(arrayKeyExists(menuButtons, jQuery(this).attr('id'))) {
			if($.cookie('currentMenuItem')!=jQuery(this).attr('id'))
				jQuery(this).attr('src', menuButtons[jQuery(this).attr('id')]['buttonOff']);
			else	jQuery(this).attr('src', menuButtons[jQuery(this).attr('id')]['buttonOn']);
		}
	});

}


/**
@description				get the value from the cookie with the name c_name
@param string c_name		name of the value in the cookie
@return boolean, string		false when the name was not found, the value when it was
*/
function getCookie(c_name) {

	if (document.cookie.length>0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)  {
			c_start = c_start + c_name.length+1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end==-1) 
				c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return false;
}



/**
@description				gets tge flash movie object for javascript to control
							flash movies
@param string movieName		name of the flash movie				
*/
function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}


/*		Admin area		*/

function moveRow(headingId, reference, direction) {
	
	switch(direction) {

		case 'up':

		   var $thisRow = jQuery(reference).parents('tr:first');
		   $thisRow.insertBefore( $thisRow.prev() );

		   jQuery('#'+headingId).insertBefore( jQuery('#'+headingId).prev() );
		   break;

		case 'down':
		   var $thisRow = jQuery(reference).parents('tr:first');
		   $thisRow.insertAfter( $thisRow.next() );
			break;

	}
} 


/**
@description						hides all html elements in allElements and show only the currentElement
@param string currentElement		the current element		
@param array allElements			an array with all the elements inside including the current
*/
function swapElements(currentElement, allElements, prefix) {

	if(prefix==undefined)		prefix = '';
	jQuery(prefix+currentElement).css('display', 'block');	

	for(var i in allElements) {
		if(allElements[i]!=currentElement)
			jQuery(prefix+allElements[i]).css('display', 'none');
	}
}




function addDatePickerToElements(elements, options) {

	for(var i in elements) {

		options['onChange'] = function(formated, dates){
								jQuery(elements[i]).val(formated);
								jQuery(elements[i]).DatePickerHide();
							  };
							  alert(options['onChange']);
		jQuery(elements[i]).DatePicker(options);

	}
}


function searchArray(array, value) {
	
	for(var i =0; i<array.length; i++) {
		if(array[i]==value)		return i;
	}
	return false;
}


function searchKeyArray(array, key) {
	
	for(var arrayKey in array) {
		if(key==arrayKey)		return true;
	}
	return false;

}