//---------------------------------------------------------------------------------------------
//---- GLOBAL JAVASCRIPT
//---------------------------------------------------------------------------------------------

// TRUNCATE TEXT   |  add "class='truncateXXX'" to any html text element
//---------------------------------------------------------------------------------------------
jQuery(document).ready(function(){ 
	jQuery('.truncate500').truncate( {  
	  length: 500,  
	  minTrail: 10,  
	  moreText: 'show more',  
	  lessText: 'show less',  
	  ellipsisText: "..."  
	 });
	jQuery('.truncate300').truncate( {  
	  length: 300,  
	  minTrail: 10,  
	  moreText: 'show more',  
	  lessText: 'show less',  
	  ellipsisText: "..."  
	 });
	jQuery('.truncate100').truncate( {  
	  length: 100,  
	  minTrail: 10,  
	  moreText: 'show more',  
	  lessText: 'show less',  
	  ellipsisText: "..."  
	 });
});
// ONHOVER EVENTS |  add new line below: jQuery().{ONHOVERFUNCTION}('{SELECTOR}');
//---------------------------------------------------------------------------------------------
jQuery(document).ready(function(){
	jQuery().siblingFade('.rd .rd-lightboxInfo .repeater li');
	jQuery().siblingFade('.rd .rd-caseStudy .repeater-block li');
	jQuery().siblingFade('.rd .rd-article .repeater-block li');
	jQuery().siblingFade('.rd .rd-upsell .repeater li');
	jQuery().siblingFade('.rd .rd-photoAlbum .repeater li');
	jQuery().siblingFade('.rd .subNav ul li');
});
// SIBLING FADE FUNCTION
jQuery.fn.siblingFade = function(listItem){
	jQuery(listItem).each(function(){
		jQuery(this).hover(
			function(){
				jQuery(this).stop().animate({opacity:'1'},150)
				jQuery(this).siblings().stop().animate({opacity:'.6'},400);
			},
			function(){
				jQuery(this).siblings().stop().animate({opacity:'1'},600);
			}
		);
	});
}
// BUMP UP FUNCTION
jQuery.fn.bumpUp = function(listItem){
	jQuery(listItem).each(function(){
		jQuery(this).hover(
			function(){
				jQuery(this).css({'position':'relative'});
				jQuery(this).stop().animate({'top':'-10px'},250);
			},
			function(){
				jQuery(this).stop().animate({'top':'0px'},250);
			}
		);
	});
}

//---------------------------------------------------------------------------------------------
//---- RD MODULES
//---------------------------------------------------------------------------------------------

// ARTICLE SPLIT COLUMN TEXT
//---------------------------------------------------------------------------------------------
jQuery(document).ready(function(){
	var textObj = jQuery('.rd-article .detail .body .text').html() + "&diams;&diams;&diams;";
	var safeSplit = textObj.indexOf('>',textObj.indexOf('</',Math.round(textObj.length/1.5))) + 1;	
	var textLeft = textObj.substring(0,safeSplit);
	var textRight = textObj.substring(safeSplit,textObj.length);
	jQuery('.rd-article .detail .body  .left .text').html(textLeft);
	jQuery('.rd-article .detail .body  .right .text').html(textRight);
});

// PHOTO ALBUM, CASE STUDY & SCREESHOT LIGHTBOXS
//---------------------------------------------------------------------------------------------
jQuery(function() {
	jQuery('#Images a').lightBox();

});

// SLIDER
//---------------------------------------------------------------------------------------------

jQuery(document).ready(function(){
	jQuery("#slider").easySlider({
		prevId: 		'prevBtn',
		prevText: 		'',
		nextId: 		'nextBtn',	
		nextText: 		'',
		controlsShow:	true,
		controlsBefore:	'',
		controlsAfter:	'',	
		controlsFade:	true,
		firstId: 		'firstBtn',
		firstText: 		'First',
		firstShow:		false,
		lastId: 		'lastBtn',	
		lastText: 		'Last',
		lastShow:		false,				
		vertical:		false,
		speed: 			1000,
		auto:			true,
		pause:			4000,
		continuous:		true,
		initialDelay:	0
	});
});


//---------------------------------------------------------------------------------------------
//---- RD FORMS
//---------------------------------------------------------------------------------------------

//IMPOSE LENGTH LIMIT 
//---------------------------------------------------------------------------------------------
function limitText(limitField, limitNum) {
	if (limitField.value.length > limitNum) {
	limitField.value = limitField.value.substring(0, limitNum);
	}
}


