/*----------------------------------------
---------------Common-Features-JQuery---*/
$(function(){
/*
var menuContent = '';
//Build Responsive Nav
menuContent = $('#header-nav-ul').html();
$('#responsive-header-nav-ul').html(menuContent);
//Mark Expandable Links
var expandableIconContent = '';
expandableIconContent = '';
$('#responsive-header-nav-ul').children('li').each(function(){
if($(this).children('ul').length > 0){
$(this).addClass('expandable');
$(this).prepend(expandableIconContent);
}
});
//Handle Toggle Navigation Sub Menu
//var busy = false;
$('#header-nav-ul li').on('mouseenter', function(){
if(!$(this).children('ul').hasClass('open') && !$(this).children('ul').is(':animated') && $(this).children('ul').length > 0){
$(this).children('ul').slideDown(500, 'easeInOutCubic', function(){
$(this).addClass('open');
});
$(this).on('mouseleave',function(){
$(this).unbind('mouseleave');
$(this).children('ul').stop(true).slideUp(500, 'easeInOutCubic', function(){
$(this).removeClass('open');
});
});
}
});
//Handle Toggle Responsive Navigation
var busy = false;
$('#header-nav-toggle').click(function(){
if(!busy){
if($('#responsive-header-nav-ul').hasClass('open')){
busy = true;
$('#responsive-header-nav-ul').slideUp(1000, 'easeInOutCubic', function(){
$(this).removeClass('open');
busy = false;
});
}else{
busy = true;
$('#responsive-header-nav-ul').slideDown(1000, 'easeInOutCubic', function(){
$(this).addClass('open');
busy = false;
});
}
}
});
//Handle Toggle Responsive Sub Menu
$('#responsive-header-nav-ul li.expandable').children('a').click(function(e){
e.preventDefault();
if(!busy){
if($(this).siblings('ul').hasClass('open')){
busy = true;
$(this).siblings('ul').removeClass('open').slideUp('800', function(){
busy = false;
});
$(this).siblings('span.glyphicon').removeClass('glyphicon-minus-sign').addClass('glyphicon-plus-sign');
}else{
busy = true;
$(this).siblings('ul').addClass('open').slideDown('800', function(){
busy = false;
});
$(this).siblings('span.glyphicon').removeClass('glyphicon-plus-sign').addClass('glyphicon-minus-sign');
}
}
});
*/
var breakingNewsBusy = false;
var breakingNewsTimer = false;
var hSize = '40%';
var bnCursor = false;
$('#breaking-news-nav #nav-prev').click(function(){
var newCurrentItem = $('.breaking-news-item').last();
if(breakingNewsBusy == false){
breakingNewsBusy = true;
$('.breaking-news-item.active').removeClass('active');
newCurrentItem.addClass('active').css('margin-left','-'+hSize).parent().prepend(newCurrentItem);
$('.breaking-news-item.active').animate({
marginLeft: "+="+hSize
}, 1000, function(){
breakingNewsBusy = false;
if(bnCursor == false){
tickerTimerBreakingNews();
}
});
}
});
$('#breaking-news-nav #nav-next').click(function(){
var currentItem = $('.breaking-news-item.active');
if(breakingNewsBusy == false){
breakingNewsBusy = true;
$('.breaking-news-item.active').animate({
marginLeft: "-="+hSize
}, 1000, function(){
$('.breaking-news-item.active').next().addClass('active');
currentItem.removeClass('active').css('margin-left','0').parent().append(currentItem);
breakingNewsBusy = false;
if(bnCursor == false){
tickerTimerBreakingNews();
}
});
}
});
$('#breaking-news-div').mouseenter(function(){
bnCursor = true;
if(breakingNewsTimer != false){
clearTimeout(breakingNewsTimer);
}
}).mouseleave(function(){
bnCursor = false;
tickerTimerBreakingNews();
});
if(bnCursor == false){
tickerTimerBreakingNews();
}
function tickerTimerBreakingNews(){
breakingNewsTimer = setTimeout(function(){
if(bnCursor == false){
$('#breaking-news-nav #nav-next').trigger('click');
}
}, 5000);
}
$('#breaking-news-button').click(function(){
$('#genModalLabel').html('BREAKING NEWS');
var bnContent = '';
bnContent += '
';
bnContent += '
';
bnContent += '';
$('.breaking-news-item').each(function(){
var textValue = $(this).find('p').html();
bnContent += '';
bnContent += ''+textValue+' | ';
bnContent += ' |
';
});
bnContent += '';
bnContent += '
';
bnContent += '
';
$('#gen-modal .modal-header').css('background-color','#C1272D');
$('#gen-modal .modal-title').css('color','#FFFFFF');
$('#gen-modal .modal-body').html(bnContent);
$('#gen-modal').modal('toggle');
});
//Click on Subscribe
$(".subscribe").click(function(e){
//$('#header').on('click', '#subscribe-open', function(e){
e.preventDefault();
var returnHTML = "";
$("#subscribe_modal_detail").remove();
$("#modal_subscribe_body").html(returnHTML);
returnHTML = '';
returnHTML += '
';
returnHTML += '
';
$("#modal_subscribe_header").html('Subscribe to Our Newsletter');
$("#modal_subscribe_body").html(returnHTML);
$("#modal_subscribe").modal('show');
$('#frmSubscribe').submit(function(e){
//e.preventDefault();
thisForm = $(this);
autoscroll = false;
if ($.validateForm()){
return true;
/*returnHTML = '';
returnHTML = '';
returnHTML += '
';
returnHTML += '
';
returnHTML += '
You have been added.
';
returnHTML += '
';
returnHTML += '
';
returnHTML += '
';
$("#modal_upload_body").html(returnHTML);*/
}else{
returnHTML = '';
returnHTML = '';
returnHTML += '
';
returnHTML += '
';
returnHTML += '
There was a problem.
';
returnHTML += '
';
returnHTML += '
';
returnHTML += '
';
return false;
}
})
});
//Select input text on click
$('input.select-on-click-input').on('click',function(){
$(this).select();
});
/* denoteScrollableTables();
var winX = $(window).width();
//Set Screensize changes listener
$(window).resize(function(){
var newWinX = $(window).width();
var winDifference = newWinX - winX;
if(winDifference > 20 || winDifference < -20){
winX = newWinX;
denoteScrollableTables();
}
});
//Generate Fixed Menu
$('#fixed_menu').html($('#top_menu').html());
//Fixed Menu on/off
var count = 0;
var top_menu_offset = $('#top_menu').offset();
var menu_timer;
var window_width = $(window).width();
$(window).scroll(function(){
if(window_width>=992){
var scrollPos = $(window).scrollTop();
clearTimeout(menu_timer);
if($('#fixed-menu-div').hasClass('open') && scrollPos<=(top_menu_offset.top +100)){
$('#fixed-menu-div').stop(true).removeClass('open').slideUp('100');
}else if(!$('#fixed-menu-div').is(':visible') && scrollPos>(top_menu_offset.top +100)){
$('#fixed-menu-div').stop(true).addClass('open');
menu_timer = setTimeout(function(){
$('#fixed-menu-div').slideDown('100');
}, 250);
}
}
});
//Top Nav dropdowns - Open
if(window_width>=992){
var dropmenu_timer = [];
$('.navbar-nav>li').each(function(i){
var thisLi = $(this);
if($(this).children('ul').length == 1){
thisLi.mouseenter(function(){
clearTimeout(dropmenu_timer[i]);
$(this).children('ul').css('z-index',6);
$(this).addClass('submenu_open');
var thisUl = $(this).find('ul');
thisUl.stop(true).slideDown(200);
});
thisLi.mouseleave(function(){
if($(this).hasClass('submenu_open')){
$(this).children('ul').css('z-index',5);
var thisUl = $(this).find('ul');
dropmenu_timer[i] = setTimeout(function(){
thisUl.slideUp(200,function(){
thisLi.removeClass('submenu_open');
});
}, 300);
}
});
}
});
}
//Toggle Menu
$('#navbar').on('click', '#toggle-menu-btn-span', function(){
if(!$(this).hasClass('animating')){
var thisElem = $(this);
$(this).addClass('animating');
if($('#navbar .navbar-collapse').is(':visible')){
$('#navbar .navbar-collapse').slideUp('300', "easeInOutCubic", function(){
thisElem.removeClass('animating');
});
}else{
$('#navbar .navbar-collapse').slideDown('300', "easeInOutCubic", function(){
thisElem.removeClass('animating');
});
}
}
});
//Top Nav dropdowns - Toggle (on click - responsive)
$('.navbar-nav').on('click', 'a', function(e){
if(window_width<992){
var child_ul_count = $(this).closest('li').find('ul').length;
if($(this).closest('ul').hasClass('navbar-nav') && child_ul_count == 1){
e.preventDefault();
var thisUl = $(this).closest('li').find('ul');
if(thisUl.hasClass('submenu_open')){
thisUl.slideUp(200,function(){
$(this).removeClass('submenu_open');
});
}else{
thisUl.slideDown(200,function(){
$(this).addClass('submenu_open');
});
}
}
}
});
//Set Video Sizes
$('.popular-video-div').each(function(){
var video_width = $('.home-popular').width();
var video_height = $('.home-popular').height();
$(this).find('iframe').attr({width:video_width,height:video_height});
});
*/
});
/*
function denoteScrollableTables() {
//Denote scrollable tables
var t = $('body .scrollable-label-div').length;
var c = 0;
$('.scrollable-label-div').each(function(){
$(this).remove();
c++;
});
if(c == 0 || c == t){
$('.table-container').each(function(){
var divWidth = $(this).width();
var tableWidth = $(this).children('table').width();
if(tableWidth > divWidth){
$(' SWIPE BELOW TO SCROLL
').insertBefore($(this));
}
});
}
}
function closeOtherMenus() {
$('.navbar-nav li').each(function(){
if($(this).hasClass('submenu_open')){
$(this).find('ul').slideUp(200);
$(this).removeClass('submenu_open');
}
});
}*/