

	//-------------------------------------------------------------------------------------------------
	//--- EMBED MOVIES - flv/flash ---
	
	function fcn_embed_flash(useimg){		
		//alert("dfsd");
		
		//replace all html editor inserted movies with swfobject
		//needed for accessibility options
		var cnt = 1;
		var next_img = null;
		//find all embed objects
		$('div.flash-movie').each(function()
		{		
			var next_img = $(this).siblings('img');
			//alert(useimg);
			if (useimg==1){
				//alert("df");
				//var next_img = $(this).siblings('img');
				var next_img = $(this).children("img");
			}
			var flash_preview_img = null;
			var flash_div = $(this).children("a");
			var flash_href = flash_div.attr('href');
			var flash_extension = flash_div.attr('href').substring(flash_div.attr('href').lastIndexOf(".")+1,flash_div.attr('href').length);
			//var flash_preview_img = '/content/images/flash-default.gif';
			var flash_preview_img = '/content/images/flash-default.gif';
			//alert(flash_extension);

			//
			switch (flash_extension)
			{
				case "flv":
				//case "swf":
					if (next_img.length > 0 && next_img.attr('src').length > 0)
					{	
						flash_preview_img = next_img.attr('src');
						//remove the image from the page
						next_img.remove();
						//alert("next_img");
					}
					flash_href = flash_href + '&image=' + flash_preview_img;
					flash_div.attr('href',flash_href);	
					//alert(flash_href);
					//alert(next_img.attr('src').length);
				break;
			}
			
			//flash_div.media();
			//using jquery media to run the videos
			flash_div.media({  
				attrs:     {'margin':   '0 auto', 'allowfullscreen':   'true', 'allowscripaccess':   'always'}  // object/embed attrs 
			}); 

			//if there is an img next to the flash video then use that image as the image preview			
			/*if(next_img.length > 0 && next_img.attr('src').length > 0){
				flash_preview_img = next_img.attr('src');
				//remove the image from the page
				next_img.remove();
			}*/
			
								
			//set default player location
			//$.fn.media.defaults.flvPlayer = '/css/skins/default/flash/player.swf';
			//run media plugin on all a links with media class
			//$('#'+flash_div+' a').media();
		});
		
	
		//replace all fck inserted movies with swfobject
		//needed for accessibility options
		var cnt = 1;
		//find all embed objects
		$('embed').each(function(){
				//if they are flash movies
				if ($(this).attr('type') == 'application/x-shockwave-flash')
				{				
					//get the source fo the flash movie
					if ($(this).attr('src'))
					{	
						//get width and height of movie to use for replacement below
						flash_width = $(this).attr('width');
						flash_height = $(this).attr('height');
						//alert(flash_width+":"+flash_height);
						
						embed_type = $(this).attr('type');
						flash_src = $(this).attr('src');
						flash_div = 'flash-'+cnt;
						flash_extension = $(this).attr('src').substring($(this).attr('src').lastIndexOf(".")+1,$(this).attr('src').length);
						flash_preview_img = '/content/images/flash-default.gif';
						//alert("type:"+embed_type+"ext:"+flash_extension+"flash_src:"+flash_src);
		
						//give the element an id
						$(this).attr('id','embed-'+cnt);
	
						switch (flash_extension)
						{						
							/*case "flv":
								alert(flash_height);
								
								if (jQuery.fn.media)
								{	
									//replace the embed obect with a holding div
									$(this).replaceWith('<div id="'+flash_div+'"></div>');
	
									//use swfobject to embded the flash movie
									$('#'+flash_div).flash({ 
										// test.swf is the flash document 
										swf: flash_src,
										play: false,
										width : flash_width,
										height : flash_height
										//width : 425,
										//height : 344
									});
									
									//alert(flash_height);
									
									//set default player location
									$.fn.media.defaults.flvPlayer = '/css/skins/default/flash/mediaplayer.swf';
									//run media plugin on all a links with media class
									//$('#'+flash_div+' a').media();
								}
								else
								{
									alert('You need to have the media and meta plugins installed.');
								}
							break;*/
							case "swf":
								if (jQuery.fn.flash)
								{
									//alert("swf");	
										
									//replace the embed obect with a holding div
									$(this).replaceWith('<div class="flash-movie"><div id="'+flash_div+'"></div></div>');
									//use swfobject to embded the flash movie
									$('#'+flash_div).flash({ 
										// test.swf is the flash document 
										swf: flash_src,
										width : flash_width,
										height : flash_height									
										//width : 425,
										//height : 344
									}); 
								}
								else
								{
									alert('You need to have the swfobject plugins installed.');
								}
							break;
							default:
							break;
						}
					}
				}
			cnt++;
		});
		
	}//fcn_embed_flash
	
	//--- EMBED MOVIES - flv/flash ---
	//-------------------------------------------------------------------------------------------------




$(document).ready(function(){	
	
	//-------------------------------------------------------------------------------------------------
	//--- EMBED MOVIES - flv/flash ---	
	fcn_embed_flash(0);
	//--- EMBED MOVIES - flv/flash ---
	//-------------------------------------------------------------------------------------------------
	
	//-------------------------------------------------------------------------------------------------
	/* EMBED MEDIA */
	if (jQuery.fn.media){
		//set default player location
		$.fn.media.defaults.flvPlayer = '/css/skins/default/flash/mediaplayer.swf';
		//run media plugin on all a links with media class
		$('a.media').media();
	}
	//-------------------------------------------------------------------------------------------------	
	
	
	//-------------------------------------------------------------------------------------------------
	/* SHOW/HIDE */	
	if(jQuery.fn.showhide){
		//apply show hide plugin for use in gallery
		if($('a.showhide').length > 0 ){
			$('a.showhide').showhide({
				animate:true,
				event:'click',
				target:'#large_img',
				animate_type:'custom'
			});
		}
	}
	/* SHOW/HIDE */		
	//-------------------------------------------------------------------------------------------------
		

	/*
	//-------------------------------------------------------------------------------------------------
	//--- LINKS - NEW WINDOW ---						   
	//xhtml work around to open all EXTERNAL links (with re=new-window) as new tab or window
	$(function(){	
		//check all hrefs, if external, open in blank window
		$('a').filter(function(){
			pattern = /http|ftp(s)?/i;			//basic regex patterm case insensitive
			result = pattern.test($(this).attr('href'));	//rung using test method
					
			if(result == true){
				$(this).attr({
					target: "_blank", 
					title: "Opens in a new window"
				});
			}
		});
	});	
	//--- LINKS - NEW WINDOW ---		
	//-------------------------------------------------------------------------------------------------
	*/

	
	/* -------------------------------------------------------------------------------------------- */
	/* CONTACT US - CONTACT FORM */
	if ($('#form-contact').length > 0 ){ // check if element is on page	
		//contact form
		$("#form-contact").livequery(function(){
			$(this).validate({
				rules: {
					txt_firstname: "required",
					txt_lastname: "required",
					txt_email: {
						required: true,
						email: true
					},
					txt_telephone: "required",
					txa_message: "required"
					//txt_contact_preference: "required",						
				},
				messages: {
					txt_firstname: "Please complete your first name.",
					txt_lastname: "Please complete your last name.",
					txt_email: "Please enter a valid email address.",
					txt_telephone: "Please complete your main telephone number.",
					txa_message: "Please complete your message."
					//txt_contact_preference: "How would you prefer we contact you?",				
				}
			});
		});
	 }//check
	/* CONTACT US - CONTACT FORM */
	/* -------------------------------------------------------------------------------------------- */
	
	
	/* -------------------------------------------------------------------------------------------- */
	/* JQUERY - LIGHTBOX */	
    /*$(function() {
        $('#inner .home #banner-outer-wrapper #banner #video-list ul li a').lightBox();
    });	*/
	/* JQUERY - LIGHTBOX */		
	/* -------------------------------------------------------------------------------------------- */
	
	/* -------------------------------------------------------------------------------------------- */
	/* JQUERY - NYROMODAL */		
	if ($('#inner .home #banner-outer-wrapper #banner #video-list ul li a').length > 0){ // check if element is on page
		$('#inner .home #banner-outer-wrapper #banner #video-list ul li a').nyroModal({
			width: 428,
			height: 270//,
			//closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="close">Close</a>' // Adding automaticly as the first child of #nyroModalWrapper
		});		
	}//check
	/* JQUERY - NYROMODAL */		
	/* -------------------------------------------------------------------------------------------- */		


	/* -------------------------------------------------------------------------------------------- */
	/* HOME FLASH BANNER */
	if ($('#flash-element').length > 0 ){ // check if element is on page	
		$('#flash-element').flash({
			swf: '/content/flash/hca_people_matter_interface.swf',
			width: 449,
			height: 334,
			flashvars: {
				url_of_videos_page: "/what-people-say"
			}
		});
	}//check
	/* HOME FLASH BANNER */
	/* -------------------------------------------------------------------------------------------- */
	
	
	/* -------------------------------------------------------------------------------------------- */
	/* GALLERIFIC EXTRAS */	
	if($('div.caption-container').length > 0 ){
		$('.caption-close').click(function(){
			//alert("gffrove");
			$('div.caption-container').hide();
		});

		/*$('div.caption-container').click(function(){
			alert("grove");
		});*/
	}//check

	/* GALLERIFIC EXTRAS */
	/* -------------------------------------------------------------------------------------------- */
	
	
	
});


//********************************************************************************************************

/*
window.onload = function () {

}*/
