//
$j('#nav_1386815').addClass('nav');


function setcolH(){
	$j.get(document.location.href,function(){
		var colHg_1 = parseInt( $j('#nav_1386815').height() + $j('.side-logo').height() );
		var colHg_2 = parseInt( $j('.columns:last').height() );
		
		if( colHg_1 > colHg_2 ){
			console.log(colHg_1);
			$j('.columns').height(colHg_1+60);
		}
		else if( colHg_1 < colHg_2 ){
			console.log(colHg_2);
			$j('.columns').height(colHg_2);
		}
	});
}

// JoNGsKiE777 Scripts
var engine = {
		utils : {
			callback : function(callback){
				if(typeof(callback) == "function"){
					callback()
				}
			}
		},
		globalScripts : {
			mainMenuSeparator : function(){
				$j('#main-menu-image-separator span').unwrap('a');
			},
			mainMenu : function(){
				// $j('#nav_1386815').addClass('nav');
			},
			overrideBCLightbox : function(){
				if($j('.faq-question').length > 0){
					$j('.faq-question').each(function(){
					    var $this = $j(this);
					    $this.find('a').click(function(){
					        var a = setInterval(function(){
					            // remove each rel and onclick attr
					            $this.find('.photogalleryItem a').each(function(){
					                var $subThis = $j(this);
					                $subThis.removeAttr('onclick').removeAttr('rel').attr('rel','colorbox');
					            });
					            if($this.find('.photogalleryItem a[rel]').length === 0 && $this.find('.photogalleryItem a[onclick]').length === 0){
					                clearInterval(a);
					            }
								$this.find('a[rel=colorbox]').colorbox();
					        });
					    });
					});
				}else if($j('.photogalleryItem a').length > 0){
					var a = setInterval(function(){
			            // remove each rel and onclick attr
			            $j('.photogalleryItem a').each(function(){
			                var $subThis = $j(this);
			                $subThis.removeAttr('onclick').removeAttr('rel').attr('rel','colorbox');
			            });
			            if($j('.photogalleryItem a[rel]').length === 0 && $j('.photogalleryItem a[onclick]').length === 0){
			                clearInterval(a);
			            }
						$j('a[rel=colorbox]').colorbox();
			        });
				}
			},
			init : function(){
				engine.globalScripts.mainMenu();
				engine.globalScripts.mainMenuSeparator();
				engine.globalScripts.overrideBCLightbox();
			}
		},
		innerTemplate : {
			resizeColumns : function(){
				if($j('.innerTemplate').length > 0){
					/*
					$j.get(document.location.href,function(){
						var colHg_1 = parseInt( $j('#nav_1386815').height() + $j('.side-logo').height() );
						var colHg_2 = parseInt( $j('.columns:last').height() );
						
						if( colHg_1 > colHg_2 ){
							console.log(colHg_1);
							$j('.columns').height(colHg_1+60);
						}
						else if( colHg_1 < colHg_2 ){
							console.log(colHg_2);
							$j('.columns').height(colHg_2);
						}
					});
					*/
					// setcolH();
				}	
			},
			init : function(){
				engine.innerTemplate.resizeColumns();
			}
		
		},
		homeTemplate : {
			bannerRotator : function(callback){
				/*
				$j('#homeSlider').anythingSlider({
				   delay           : 6000,
					width           : 965,   // Override the default CSS width
				   height   : 319,   // Override the default CSS height 
				   pauseOnHover        : false, 
				   hashTags            : false, 
				   easing          : 'easeInOutBack',  // slider effects
				   autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
				   resumeDelay     : 6000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
				   onSlideComplete : function(slider){
					// event after slide load complete
				   },
				   stopAtEnd : false,  // true if slider will stop at the end of the slide, false if slider is continuous
				   onShowStop : function(e, slider){
					setTimeout(function(){
					 if (slider.currentPage === slider.pages) { slider.gotoPage(1); }
					}, 6000);
				   }
				  });
				  
				$j('.slider-cont').anythingFader({
					easing: "linear",
					autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
					delay: 5000,                    // How long between slide transitions in AutoPlay mode
					startStopped: false,            // If autoPlay is on, this can force it to start stopped
					animationTime: 500,             // How long the slide transition takes
					hashTags: true,                 // Should links change the hashtag in the URL?
					buildNavigation: true,	
					pauseOnHover: false,
					stopAtEnd : false,
					hashTags  : false,
					autoPlayLocked  : true,
					onShowStop : function(e, slider){
						setTimeout(function(){
					 		if (slider.currentPage === slider.pages) { slider.gotoPage(1); }
						}, 6000);
				   	}
				});
				  */
				$j('#homeSlider').fader({ 
					'animationtype': 'fade',
				  	'speed': 800, 
					'timeout':6000, 
					'containerHeight':322, 
					'play' : true
				});
				
				$j('.fader-nav').insertAfter('.homeBanner').wrap('<div class="fader-menu"></div>');
				
				$j('.fader-nav .fader-jumpNav a').click(function(){
						$j('.fader-nav .fader-jumpNav a').removeClass('active');
						$j(this).addClass('active');
				});
				
				engine.utils.callback(callback)
				  
			},
			servicesWebAppList : function(){
				$j('.our-services-list-layout').each(function(){
					$j(this).find('.learn-more-link').attr('href',$j(this).find('.tag-name-with-link a').attr('href'));
				});
			},
			init : function(){
				engine.homeTemplate.servicesWebAppList();
				engine.homeTemplate.bannerRotator(function(){
					 /* var a = $j('.banner-image.homeBanner');
					 a.after('<div class="anythingControls">'+$j('.anythingControls').html()+'</div>').find('.anythingControls').remove(); */
				});
			}
		
		},
		init : function(){
			this.homeTemplate.init();
			this.innerTemplate.init();
			this.globalScripts.init();
		}
}

// CSS DEPT JAVASCRIPTS
jQuery(function($j){
				
	engine.init();
	
	$j('#nav_1386815 li.selected').attr('id','active').find('ul').slideDown(500);
	
	$j('#nav_1386815 li a').click(function(){
		$j('#nav_1386815 li#active a').css('color','#000000 !important');
		if($j(this).parent('li').attr('id') == 'active'){
			$j('#nav_1386815 li').removeAttr('id').find('ul').slideUp(500);
		}
		else{
			if($j(this).parent('li').find('ul').length > 0){
				$j('#nav_1386815 li').removeAttr('id').find('ul').slideUp(500);
				$j(this).parent('li').attr('id','active').find('ul').slideDown(500);	
			}
		}
			
		
	});
	
	
	
});

