jQuery(document).ready(function($) {
$('.bgimg-main').each(function() {
var imgSrc = $(this).find('.bg-img img').attr('src');
$(this).css('background-image', 'url(' + imgSrc + ')');
});
$(".menulink").click(function() {
$(this).next('ul').slideToggle(250);
$(this).toggleClass('active');
$('span.childlink').removeClass('active');
$('.mainmenu ul li.parent ul').slideUp(250);
return false;
});
$('.mainmenu .wrapper ul li.menu-item-has-children > a').after('');
if ($(window).width() <= 767){
$('.landing-row .row-fluid .left').insertAfter('.landing-row .row-fluid .right');
}
$( "ol li" ).wrapInner( "" );
$('span.childlink').click(function() {
$(this).parent().siblings('li.menu-item-has-children').find('span.childlink').removeClass('active');
$(this).parent().siblings('li.menu-item-has-children').find('ul').slideUp(250);
$(this).next('ul').slideToggle(250);
$(this).next('ul').children('li').find('ul').slideUp(250);
$(this).next('ul').children('li').find('span.childlink').removeClass('active');
$(this).toggleClass('active');
return false;
});
$('li.search-icon-raw a .fa').click(function() {
$('.header-search-raw').slideToggle(250);
});
/* Google Search */
$('.top .googleCse').after('');
$('.top .googleCse').hide();
$('.top .hs-input').attr('placeholder', 'Type and hit enter...');
$('.search-button').click(function(){
$('.top .googleCse').slideToggle();
});
/* Blog post item load more */
/*var i = 4;
var totalRes = $('.post-itemblog').length;
$('.post-itemblog:gt(3)').hide();
if(totalRes > i){
$('.post-listing').after(' + NÄYTÄ LISÄÄ ');
}
$('.load-more').click(function(){
i = (i + 3 <= totalRes) ? i + 3 : totalRes;
$('.post-itemblog:lt('+i+')').fadeIn('slow');
//equalheight('.sameheight1');
//equalheight('.spot-contentbox .post-header h2');
setTimeout(function(){
$(window).trigger('resize');
}, 1000);
if(totalRes <= i){
$(this).hide();
}
});
*/
$('.post-listing .feature-postiem').appendTo($('.feature-post-main'));
});
jQuery(window).load(function() {
if ($('.sameheight').length > 0) {
equalheight('.sameheight');
}
setTimeout(function(){
$('.innerPost-form3 form .hs_submit').insertAfter('.innerPost-form3 form .hs_phone');
$('.innerPost-form3 form .hs_submit').addClass('hs-form-field');
$('.innerPost-form3 form .form-columns-2').addClass('form-columns-3');
}, 100);
if($(window).width() < 900) {
$('.menu-bar-raw').click(function() {
$(this).next('ul').slideToggle(250);
$(this).toggleClass('open');
});
$('li.search-icon-raw').insertBefore('.menu-bar-raw');
$('.blog-top .topic-menu ul li').each(function() {
if($(this).children("ul").length) {
$(this).addClass('has-children');
}
});
$('.blog-top .topic-menu ul li.has-children').each(function() {
$(this).append('');
});
$('.menu-dropdown-raw').click(function() {
$(this).next('ul').slideToggle();
});
}
if($(window).width() < 768) {
$('.form-bottomtext').insertAfter( $('.blog-rightbox .box1 .widget-type-form h3').next('div').find('form') );
$('.blog-rightbox .box1 .widget-type-form h3').next('div').css('display','none');
$('.blog-rightbox .box1 .widget-type-form h3').click(function() {
$(this).next('div').slideToggle(250);
$(this).toggleClass('open');
});
$('.form4-raw h3.form-title').next('div').css('display','none');
$('.blog-rightbox .box3 .form-toptitle h4').click(function() {
$('.form4-raw h3.form-title').next('div').slideToggle(250);
$(this).toggleClass('open');
});
$('.intrested-formsec h3.form-title').next('div').css('display','none');
$('.intrested-formsec .box h4').click(function() {
$('.intrested-formsec h3.form-title').next('div').slideToggle(250);
$(this).toggleClass('open');
});
$('.bloginner-subformsec h3.form-title').next('div').css('display','none');
$('.bloginner-subformsec .widget-type-header h3').click(function() {
$('.bloginner-subformsec h3.form-title').next('div').slideToggle(250);
$(this).toggleClass('open');
});
setTimeout(function(){
$('p.form2-text-raw').insertBefore( $('.form4-raw h3.form-title').next('div').find('form') );
$('p.form2-text-raw').insertBefore( $('.intrested-formsec h3.form-title').next('div').find('form') );
$('.move-into-form').insertBefore( $('.bloginner-subformsec h3.form-title').next('div').find('form') );
}, 10);
$('.blog-rightbox').insertBefore('.blog-leftbox');
$('.slider-raw3').slick({
dots: true,
arrows: false,
infinite: true,
speed: 900,
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true
});
}
});
jQuery(window).resize(function(){
if ($('.sameheight').length > 0) {
equalheight('.sameheight');
}
});
$(window).scroll(function () {
if ($(this).scrollTop() > 0 ) {
$('.top').addClass('fixed');
} else {
$('.top').removeClass('fixed');
}
if ($(this).scrollTop() > 600 && $(this).scrollTop() < 2100 ) {
$('.row-fluid .cta-inner').addClass('show');
} else {
$('.row-fluid .cta-inner').removeClass('show');
}
});
equalheight = function(container){
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$(container).each(function() {
$el = $(this);
$($el).height('auto')
topPostion = $el.position().top;
if (currentRowStart != topPostion) {
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].outerHeight(currentTallest);
}
rowDivs.length = 0; // empty the array
currentRowStart = topPostion;
currentTallest = $el.outerHeight();
rowDivs.push($el);
} else {
rowDivs.push($el);
currentTallest = (currentTallest < $el.outerHeight()) ? ($el.outerHeight()) : (currentTallest);
}
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
});
}