/*
*
* Custom Javascript file requires the following: 
* Version:
* jQuery v 1.4+ 
* Plugins: 
* ScrollTo, BBQ, Galleria(modified), jQuery UI drop effect, jQuery UI
* jQuery UI progressbar widget, & some utilities noted in the 
* JQplugins.js file.  See the CMagriExtraJS.js file for a fully noted
* version of this script. 
*
* Script by John Stevens - iLightning.us 
*

jQuery.noConflict();function setCookie(c_name,value,expiredays){var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+"="+escape(value)+
((expiredays==null)?"":";expires="+exdate.toUTCString());}
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"";}
(function(){var CACHE_COOKIE='browser_cache_load';jQuery.loadedFromBrowserCache=getCookie(CACHE_COOKIE)=='true';setCookie(CACHE_COOKIE,'true');})();jQuery(function($){$('.content').wrapAll('<div id="footerPush"/>');var userHashChange=false;$('#groupP1').hide();$('#preLoader').detach().prependTo('#footerPush').show();$(document).ready(function(){$.loadedFromBrowserCache?$('#cacheText').show():$('#loadingText').show();$("#textScroller").jScrollPane({dragMaxHeight:50,scrollbarMargin:10});$("#loadingBar").progressbar({value:0});function GetPortImage(imageID,portNum){var ThumbIndex=0,thumbs=$("#groupP"+portNum+' ').find('.items li');$.each(thumbs,function(){var imgID=$(this).find('img').data('ImgHistID');if(imgID==imageID){var _p="#groupP"+portNum+' .items li';ThumbIndex=$(this).index(_p);}});return ThumbIndex;}
function ShowPortGroup(portNum,activate){var jShowPortDiv=$("#groupP"+portNum),jCurrPortDiv=$('.content:visible'),jCurrPortSubMenu=$('#portSubMenu .active'),jShowPortSubMenu=$("li a[href='#groupP"+portNum+"']"),jCurrActiveThumb=$('.items:visible .active'),jActivateThisLi=$('#groupP'+portNum+' .items li:eq('+activate+')'),activateAhref=jActivateThisLi.find('a').attr('href'),activateIMGrel=jActivateThisLi.find('img').attr('rel'),activateThis='default';if(activateAhref){activateThis=activateAhref;}
if(activateIMGrel){activateThis=activateIMGrel;}
jCurrPortDiv.hide();jCurrPortSubMenu.removeClass();jShowPortSubMenu.parent().addClass('active');jCurrActiveThumb.removeClass();jCurrActiveThumb.find('img').removeClass('selected');jActivateThisLi.addClass('active');jActivateThisLi.find('img').addClass('selected');jActivateThisLi.siblings().children('img').fadeTo('fast',0.3);$.galleria.activate(activateThis);$('#photoHolder').detach().appendTo('#groupP'+portNum+' .photoWrap');jShowPortDiv.fadeIn('fast');}
function cm_load_helper(portNum){var jCurrPortSubMenu=$('#portSubMenu .active'),jShowPortSubMenu=$("li a[href='#groupP"+portNum+"']");jCurrPortSubMenu.removeClass('active');jShowPortSubMenu.parent('li').addClass('active');$('#photoHolder').detach().appendTo('#groupP'+portNum+' .photoWrap');}
function cm_loader(showPort){var allImgs=$('.content img'),totImgs=allImgs.length,loaded=0,loaderVal=0,loadPercent=0,selText=null;intervalId=setInterval(function(){var loaded=jQuery.CMimgsLoaded;loadPercent=loaded/totImgs;loaderVal=Math.round(loadPercent*100);$("#loadingBar").progressbar("option","value",loaderVal);if(loaded===totImgs){clearInterval(intervalId);$.loadedFromBrowserCache?selText='#cacheText':selText='#loadingText';$('#loadingBar').find('.ui-widget-header').addClass('ui-corner-all');$(selText).fadeOut(1000,function(){$('#imgsLoaded').fadeIn(250,function(){$('#preLoader').delay(250).hide('drop',{direction:"right"},1000,function(){$('#icons').fadeIn(1000);$('#portSubMenu').fadeIn(1000);$('#groupP'+showPort+'').show('drop',{direction:"left"},1000);$('#preLoader').remove();});});});}},100);}
$('.items li').each(function(index){var imageID=$(this).children('span').attr('title');$(this).find('img').data('ImgHistID',imageID);$(this).children('span').remove();});$('.items').addClass('gallery_cm');$('.gallery_cm').galleria({history:false,clickNext:false,insert:'#photoHolder',onImage:function(image,caption,thumb){image.css('display','none').fadeIn(1000);var _p=thumb.parents('li');_p.siblings().children('img.selected').fadeTo(500,0.3);thumb.fadeTo('fast',1).addClass('selected');image.attr('title','');},onThumb:function(thumb){var _p=thumb.parents('li');var _fadeTo=_p.is('.active')?'1':'0.3';thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);thumb.hover(function(){thumb.fadeTo('fast',1);},function(){_p.not('.active').children('img').fadeTo('fast',0.3);})
thumb.click(function(){var ImgHistID=$(this).data('ImgHistID'),imgState={},imageHisKey="image";imgState[imageHisKey]=ImgHistID;userHashChange=true;$.bbq.pushState(imgState);});}});$(".wrap").scrollable({horizontal:true});$(window).bind('hashchange',function(e){var url=e.getState(),initLoad=$('html').hasClass('smoothInit'),thIndex=null,thisThumb=null;if(initLoad){if($.isEmptyObject(url)){$('#groupP1').find("li:eq(0)").addClass('active');cm_loader(1);return;}else if(!url.image){$('#groupP'+url.group+'').find("li:eq(0)").addClass('active');cm_load_helper(url.group);cm_loader(url.group);return;}else if(!url.group){thIndex=GetPortImage(url.image,1);thisThumb=$('#groupP1').find("li:eq("+thIndex+")");thisThumb.addClass('active');cm_load_helper(1);cm_loader(1);return;}else{thIndex=GetPortImage(url.image,url.group);$('#groupP'+url.group+'').find("li:eq("+thIndex+")").addClass('active');cm_load_helper(url.group);cm_loader(url.group);return;}}else if(userHashChange){userHashChange=false;return;}else if($.isEmptyObject(url)){ShowPortGroup(1,0);return;}else if(!url.image){ShowPortGroup(url.group,0);return;}else if(!url.group){var imageID=url.image,activate=GetPortImage(imageID,1);ShowPortGroup(1,activate);return;}else{var portNum=url.group,imageID=url.image,activate=GetPortImage(imageID,portNum);ShowPortGroup(portNum,activate);return;}});$(window).trigger('hashchange');$('#portSubMenu li').click(function(){var jThisMenuLink=$(this).children('a'),jAllMenuLi=$('#portSubMenu li'),jselectShowPort=jThisMenuLink.attr('href'),pushHeight=$('#footerPush').innerHeight(),currPortID=$('.content:visible').attr('id'),showPortID=jselectShowPort.replace(/^#/,''),splitID=[],splitID=showPortID.split('P'),portHistKey=splitID[0],portHistID=splitID[1],portState={};portState[portHistKey]=portHistID;$('#footerPush').css('min-height',pushHeight);if($(this).hasClass('active')){$.scrollTo(0,'slow');return false;}else{$.scrollTo(0,'slow',function(){userHashChange=true;$.bbq.removeState('image');$(jAllMenuLi).removeClass();$(jThisMenuLink).parent('li').addClass('active');$('.items:visible li').removeClass();$('.content:visible').hide("drop",{direction:"right"},1000,function(){var firstItem=$(jselectShowPort+' .items li:first').addClass('active').find('img').addClass('selected');$('#photoHolder').detach().appendTo(jselectShowPort+' .photoWrap');$.galleria.activate(firstItem.attr('rel'));userHashChange=true;$.bbq.pushState(portState);$(jselectShowPort).show("drop",{direction:"left"},1000);});});return false;}});$('html').removeClass('smoothInit');});}); 

*/
//jQuery.noConflict();  /*Makes for safe usage with Wordpress*/

/*
Utility function for using cookies

Params: name of the cookie, the value of the cookie, and (optional)the number of days until the cookie expires.
**********************************************/
function setCookie(c_name,value,expiredays) { 
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}	

/*
Utility function for using cookies

Retuns the value of the passed string (by name) or an empty string
*****************************/
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 "";
}

/*
Makes the CACHE_COOKIE true if the pages is laoded from the cache and saves to jquery object
- function calls itself
**************/	
(function() {
	var CACHE_COOKIE = 'browser_cache_load';
	jQuery.loadedFromBrowserCache = getCookie(CACHE_COOKIE) == 'true';
	setCookie(CACHE_COOKIE, 'true');
})();

jQuery(function($) { /*Makes safe use of the $ variable now that noConflict() has been called */
																																						
	$('.content').wrapAll('<div id="footerPush"/>');  //create wrapper to keep navigation pushed down during transition & pageload.

	var userHashChange = false; // a variable to track what caused the url to change (for history)	
		//pushHeight0 = $('#footerPush').innerHeight();
	
	//$('#footerPush').css('min-height',pushHeight0);	//keeps navigation down duringpage load (smoothInit class has already been added to <html>)
	
	$('#groupP1').hide();
	
	$('#preLoader').detach().prependTo('#footerPush').show();
				
	$(document).ready(function(){ 
							   
								
			$.loadedFromBrowserCache ? $('#cacheText').show() : $('#loadingText').show();	
				
			$("#textScroller").jScrollPane({
				dragMaxHeight:50,
				scrollbarMargin:10
			});	
	
			if( $('#loadingBar').length !== 0 ) { //if present
			
				$("#loadingBar").progressbar({
					value: 0
				});	
				
			}
					
									   		
			/*----------------- Helper functions for decoding hash (history) --------------------------------------------*/
			
		 	function GetPortImage(imageID,portNum){
				// Loop through visible thumbs looking for the thumb with data matching image id from hash
				var ThumbIndex = 0,
					thumbs = $("#groupP"+portNum+' ').find('.items li');
				
				$.each(thumbs,function(){			   
						var imgID = $(this).find('img').data('ImgHistID');	
						if(imgID==imageID){
							var _p = "#groupP"+portNum+' .items li'; 
							ThumbIndex = $(this).index(_p);
						}							  
				});
				
				return ThumbIndex;
			}	
			
		 	function ShowPortGroup(portNum,activate){
				//Used to show the correct portfolio & group when the back and forward buttons are hit
				var jShowPortDiv = $("#groupP"+portNum), // jQuery obj to show (portfolio div)
					jCurrPortDiv = $('.content:visible'), //jQuery obj to hide (portfolio div)
					jCurrPortSubMenu = $('#portSubMenu .active'), //Currenly active list item for porfolio nav menu
					jShowPortSubMenu = $("li a[href='#groupP"+portNum+"']"), //portfolio nav LI to activate
					jCurrActiveThumb = $('.items:visible .active'),
					jActivateThisLi = $('#groupP'+portNum+' .items li:eq('+activate+')'), //thumb to activate is in this li
					activateAhref = jActivateThisLi.find('a').attr('href'), //sometimes the full size image url is in the a.href	
					activateIMGrel = jActivateThisLi.find('img').attr('rel'), //sometimes the full size image url is in the img.rel
					activateThis = 'default';
					
				if(activateAhref){
					activateThis = activateAhref;
				}	
				if(activateIMGrel){
					activateThis = activateIMGrel;
				}	
				jCurrPortDiv.hide(); //hide the current portfolio 					 					
				jCurrPortSubMenu.removeClass();	//removes active class from current portfolio submenu item
				jShowPortSubMenu.parent().addClass('active'); //ads active class to the correct porfolio sub nav LI				
				jCurrActiveThumb.removeClass(); //removes active class from current active thumb
				jCurrActiveThumb.find('img').removeClass('selected');							
				jActivateThisLi.addClass('active');
				jActivateThisLi.find('img').addClass('selected');
				jActivateThisLi.siblings().children('img').fadeTo('fast',0.3); //keeps other thumbs faded
				$.galleria.activate(activateThis);
				$('#photoHolder').detach().appendTo('#groupP'+portNum+' .photoWrap'); //puts the #photHolder div into the correct visible div
				jShowPortDiv.fadeIn('fast');	
			} 
			
			function cm_load_helper(portNum){
				//called when the page is loaded to prep the DOM for the loading function.
				var	jCurrPortSubMenu = $('#portSubMenu .active'), //Currenly active list item for porfolio nav menu
					jShowPortSubMenu = $("li a[href='#groupP"+portNum+"']"); //portfolio nav LI to activate
						
				jCurrPortSubMenu.removeClass('active');
				jShowPortSubMenu.parent('li').addClass('active');
				$('#photoHolder').detach().appendTo('#groupP'+portNum+' .photoWrap');
				
			}
			
			function cm_loader(showPort, callback){
				
				var allImgs = $('.content img'), 
					totImgs = allImgs.length,  //selects just the thumbnails which is the same value as number of large images.
					loaded = 0,
					loaderVal = 0,
					loadPercent = 0,
					selText = null;
					
					intervalId = setInterval(function () {
					   
						var loaded = jQuery.CMimgsLoaded;
						
						loadPercent = loaded / totImgs;
						loaderVal = Math.round(loadPercent * 100);
						
						$( "#loadingBar" ).progressbar( "option", "value", loaderVal );
						
						if ( loaded === totImgs ) {
							
							clearInterval(intervalId);
							
							$.loadedFromBrowserCache ? selText = '#cacheText' : selText = '#loadingText';
							
							$('#loadingBar').find('.ui-widget-header').addClass('ui-corner-all');
							
							$(selText).fadeOut(1000, function(){
																 
								$('#imgsLoaded').fadeIn( 250 , function(){
																
									$('#preLoader').delay(250).hide('drop',{ direction: "right" }, 1000, function(){
										
										$('#icons').fadeIn(1000);
										$('#portSubMenu').fadeIn(1000);
										$('#groupP'+showPort+'').show('drop',{ direction: "left" }, 1000);
										$('#preLoader').remove();
										if ( callback ){ callback(); }										
									});
												
								});
							
							});	
							
						} 	  
					  //end setInterval, every 10th of a second
					} , 100);
					
				}
		
		
		    /*---------------------------------- Get DOM Ready for the rest of the script ----------------------------------------------*/
				
			$('.items li').each(function(index) { //for all thumbs
				 var imageID = $(this).children('span').attr('title'); //Get the image title (passed from WP backend into a span element)
				 $(this).find('img').data('ImgHistID', imageID); //Attach this id as data to the img for later use in history
				 $(this).children('span').remove();	//remove the span element that is just used to pass this info from WP backend
			});	
	
			$('.items').addClass('gallery_cm'); // adds new class name to maintain degradability (Galleria Plugin)	
			
			
			/*--------------------- Galleria  (plus url updates for image history)------------------------------*/
	
			$('.gallery_cm').galleria({
					history   : false, // de-activates the history object for bookmarking, back-button etc (used jquery bbq for this).
					clickNext : false, // helper for making the image clickable
					insert    : '#photoHolder', // the containing selector for our main image
					onImage   : function(image,caption,thumb) { 
						// fadein image
						image.css('display','none').fadeIn(1000); 						
						// fetch the thumbnail container
						var _p = thumb.parents('li');					
						// fade out inactive thumbnail
						_p.siblings().children('img.selected').fadeTo(500,0.3);					
						// fade in active thumbnail
						thumb.fadeTo('fast',1).addClass('selected');					
						// add a title for the clickable image
						image.attr('title','');	
					},
					onThumb : function(thumb) { // thumbnail effects goes here					
						// fetch the thumbnail container
						var _p = thumb.parents('li');					
						// if thumbnail is active, fade all the way.
						var _fadeTo = _p.is('.active') ? '1' : '0.3';					
						// fade in the thumbnail when finnished loading
						thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);										
						// hover effects
						thumb.hover(
							function() { thumb.fadeTo('fast',1); },
							function() { _p.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
						)
						//add history info to url when thumb is clicked
						thumb.click(function(){
							var ImgHistID = $(this).data('ImgHistID'), //get history data attached to this IMG
								imgState = {},
								imageHisKey = "image";
								//();
							imgState[ imageHisKey ] = ImgHistID; //populate image object with "image" and curr image id
							userHashChange = true; // change backButton to false right before the hashchange event is triggered
							$.bbq.pushState( imgState ); //add image info to the url.  Triggers hashchange event.
							
						});
					}				
			}); //End Galleria	
			
			
			if( $('#modal').length !== 0 ) { //if present
								
				$('#modal').dialog({
					
					autoOpen: false,
					modal: true,
					width: 570, 
					height: 500, 
					hide: 'blind',
					position: 'center'
					
				
				});
				
				
			}
				
		/*---------------------------- Scrollable -----------------------------------------*/			
		
		$(".wrap").scrollable({horizontal:true}); 
			
			
		/*--------------- Back button and bookmarking code -------------------------*/
		
		$(window).bind( 'hashchange', function(e) { //defines what to do when the url after # changes
	
			var url = e.getState(), //use jQuery BBQ to turn hash into JSON
				initLoad = $('html').hasClass('smoothInit'), //will be true when the page initially loads /*Higher in Code*/	
				thIndex = null, 
				thisThumb = null;
				
			if(initLoad){ // if the page is initially loading we need to run the loader function
				
				
				if($.isEmptyObject(url)){
					// this runs on default page load
					
					//actives proper thumb which triggers big image
					$('#groupP1').find("li:eq(0)").addClass('active');
					cm_loader( 1, function() {
										 
						$('#photoHolder img').attr('usemap','#flyer_map'); 
						
						$('area').click(function() { 
							var url = $(this).attr('href'); 
							var coords = $(this).attr('coords').split(','); 
						    console.log(url);
							if( url == 'http://www.charneymagri.com/women-of-the-uae-registration-form' ) {
								
								$('#modal').dialog('open');	
					 		    $("#modal_iframe").attr("src","http://www.charneymagri.com/women-of-the-uae-registration-form");								
								return false;
								
							} else {
								
								return true;	
							}
						   
						});
												
					});
				 
					return;
					
				} else if(!url.image) {
					// this runs on a bookmarking situation when no image info is given, it's the first image
					
					//actives proper thumb which triggers big image
					$('#groupP'+url.group+'').find("li:eq(0)").addClass('active');
					cm_load_helper(url.group);
					cm_loader(url.group);
					
					return;
					
				} else if(!url.group) {
					// if no group # then it's the first group
					thIndex = GetPortImage(url.image, 1);
					
					//actives proper thumb which triggers big image
					thisThumb = $('#groupP1').find("li:eq("+thIndex+")");						
					thisThumb.addClass('active');
					cm_load_helper(1);
					cm_loader(1);
					
					return;
					
				} else {
					// now need to decode hash completely
					thIndex = GetPortImage(url.image, url.group);
					
					//actives proper thumb which triggers big image
					$('#groupP'+url.group+'').find("li:eq("+thIndex+")").addClass('active'); 
					cm_load_helper(url.group);
					cm_loader(url.group);
					
					return;
				
				}
				// End initial page loading code
			
			} else if(userHashChange){ //if not back-forward button or there when window loads (exe bookmarked hash)
				userHashChange = false; //change this switch back to false
				return;	//do nothing. The hashchanged is due to onscreen change chosen by user. hash has been updated with $.bbq.pushState
				
			/* The rest are for the back & forward button */	
			} else if($.isEmptyObject(url)) { //if url is empty due to back button show portfolio one, image one (index 0).
				ShowPortGroup(1, 0); 
				return;
			} else if(!url.image) { //if no url image value it's the first in portfolio			 
				ShowPortGroup(url.group, 0);
				return;			 
			} else if(!url.group) { //if no url group value it's the first portfolio group
				var imageID = url.image,
					activate = GetPortImage(imageID, 1);		
				ShowPortGroup(1, activate);
				return;
			} else { //if none of the above decode hash to show the appropriate portfolio group and image
				var portNum = url.group,
					imageID = url.image,
					activate = GetPortImage(imageID, portNum);
						
				ShowPortGroup(portNum, activate);	
				return;
			}	
		});		
		
		$(window).trigger( 'hashchange' );
		
		/*--------------- Portfolio Transitions (plus url updates for Portfolio Group history) -------------------------*/

		$('#portSubMenu li').click(function(){	
			var	jThisMenuLink = $(this).children('a'),
				jAllMenuLi = $('#portSubMenu li'),
				jselectShowPort = jThisMenuLink.attr('href'), //has #
				pushHeight = $('#footerPush').innerHeight(),
				currPortID = $('.content:visible').attr('id'),
				showPortID = jselectShowPort.replace( /^#/, '' ),//strip hash
				splitID = [],
				splitID = showPortID.split('P'),
				portHistKey = splitID[0], //this will show in the url after the # symbol to represent which Porfolio group it's in 
				portHistID = splitID[1],  //also for portNum
				portState = {}; //create object for history purposes			
			portState[ portHistKey ] = portHistID; //populate state object with "group" and proper portfolio #					
			$('#footerPush').css('min-height',pushHeight); //Keeps footer pushed down during transition (FF fix)	

			if($(this).hasClass('active')){	//If this portfolio sub menu item is active scroll to the top slowly and do nothing else
				$.scrollTo( 0 , 'slow'); 
				return false;				
			} else {	

				$.scrollTo( 0 , 'slow' , function(){ // if top is out of view, scroll slowly to the top then do the following
					userHashChange = true; // change backButton to false right before the hashchange event is triggered
			   		$.bbq.removeState( 'image' ); //remove any image info from the url that may be there. Triggers hashchange event													
					$(jAllMenuLi).removeClass();	//remove active class from all portfolio menu sub-item												 
					$(jThisMenuLink).parent('li').addClass('active'); //add active class to the appropriate portfolio menu sub-item	
					$('.items:visible li').removeClass(); //removes active class from current thumbs
					$('.content:visible').hide("drop",{ direction: "right" },1000,function(){ //slide & fade curr port out then do the following
						var firstItem= $(jselectShowPort+' .items li:first').addClass('active').find('img').addClass('selected');  					
						$('#photoHolder').detach().appendTo(jselectShowPort+' .photoWrap'); //Move the photoholder DIV to the portfolio being shown
						$.galleria.activate(firstItem.attr('rel')); //activate the first thumb in the portfolio to be shown					
						userHashChange = true; // change backButton to false right before the hashchange event is triggered
						$.bbq.pushState( portState ); // put portfolio group info in url. Triggers hashchange event

						$(jselectShowPort).show("drop",{ direction: "left" },1000);	//slide & fade in the new port from the left
					});								
				});
				return false;
			}
							
		}); //End Click	
		
		/*------------------------------------------------ Misc stuff -----------------------------------------------------*/ 
		
		$('html').removeClass('smoothInit'); //removes the class from html that hides an unstyled flash of html before $.ready() fires.
		
		if( $('#Mktg_ID').length !== 0 ) { //if present.  This is form stuff		
		  
			$('#Mktg_ID').change( function() {
			
			   if( $(this).val() == 'other' ) { 
			   
				  $('#expl_oth').show();
			   
			   } else {
				   
				  $('#expl_oth').hide(); 
			   
			   }
			
			});
		  
		 } //if
		  
		  
		if( $('.date').length !== 0 ) {  //if present
		
		  $('.date').click( function(){							   
			  
			  //var val_spans = $('div.depend').next('span');
			  
			  //$('div.shown').hide().removeClass('shown');
			  
			  //if(val_spans){ val_spans.removeClass() }
			  
			  $(this).next('div').addClass('shown').fadeIn();
		  });
		  
		  $('.depend input').click( function() {
			  	  
			  
			  function check_radios(dom_radios) { 
			  
				var radio = dom_radios,
					output = true;
			  
				$.each(radio,function() {
		  
					  if ( $(this).is(':checked') ) { output = false; }
									  
				});
				
				return output;
			  
			  }
			  /*
			  pref_date = check_radios( $("input[name~=pref-date]") );
			   
			  morn_aft = check_radios( $("input[name~=morn-aft]") );
			  
			  if(!pref_date && !morn_aft){
			  */	  
				  $(this).closest('div').next('span').addClass('PASS');
					  
			 // }
											 
		  });
		  
		}// if present
		 
	
	}); // End Document Ready
	
}); //End no conflict wrapper