/**
 * File fixed.js.
 *
 * Theme Customizer enhancements for a better user experience.
 *
 * Contains handlers to make Theme Customizer preview reload changes asynchronously.
 * @package iweb-standard
 */


// page content below header (except Front Page)

jQuery( document ).ready(function($){
	if ( $( 'main' ).hasClass( 'itopmrg' ) ) {
		$( document ).ready(function(){
			$( ".site-header" ).css( {"position":"static"} );
		});
	}
});

jQuery( document ).ready(function($){
	var top_adbar_ht = $( ".top-add-bar-b" ).height() + 10;
		$( document ).ready(function(){
			$( ".top-add-bar-w" ).css( {"height":top_adbar_ht} );
			$( ".top-add-bar" ).css( {"height":top_adbar_ht} );
		});

	$( document ).ready(function() {
		$( window ).resize(function(){
			var top_adbar_ht = $( ".top-add-bar-b" ).height() + 10;
			$( document ).ready(function(){
				$( ".top-add-bar-w" ).css( {"height":top_adbar_ht} );
				$( ".top-add-bar" ).css( {"height":top_adbar_ht} );
			});
		});
	});
});

jQuery( document ).ready(function($){
	$( ".iwebstandard-slider-tit" ).html(function(){
		var text = $( this ).text().trim().split( " " );
		var last = text.pop();
		return ( text.join( " " ) + ( text.length > 0 ? " <span class='iwebstandard-lastWord'>" + last + "</span>" : last ) );
	});
});

// Slider

var myIndex = 0;
carousel();

function carousel() {
	var i;
	var x = document.querySelectorAll( '.iwebslides' );
	var iwebstandard_sld_dots = document.getElementsByClassName( "iwebstandard-sld-dot" );
	if ( x.length ) {
		for (i = 0; i < x.length; i++) {
			x[i].style.display = "none";
		}
		myIndex++; console.log( x.length );
		if (myIndex > x.length) {myIndex = 1}
		for (i = 0; i < iwebstandard_sld_dots.length; i++) {
			iwebstandard_sld_dots[i].className = iwebstandard_sld_dots[i].className.replace( " iwebstandard-sld-active", "" );
		}
		iwebstandard_sld_dots[myIndex - 1].className += " iwebstandard-sld-active";
		x[myIndex -1].style.display = "block";
		x[myIndex -1].style.animation = "iweb-fadeInRight 600ms";
		setTimeout( carousel, 5600 );
	}
}

// Testimonials

var iwebIndex = 0;
iwebstandard_tmonial();

function iwebstandard_tmonial() {
	var si;
	var sx = document.getElementsByClassName( "iwebstandard-tmonials-sld" );
	var iwebstandard_tmonials_dots = document.getElementsByClassName( "iwebstandard-tmonials-dot" );
	if ( sx.length ) {
		for (si = 0; si < sx.length; si++) {
			sx[si].style.display = "none";
		}
		iwebIndex++;
		if (iwebIndex > sx.length) {iwebIndex = 1}
		for (si = 0; si < iwebstandard_tmonials_dots.length; si++) {
			iwebstandard_tmonials_dots[si].className = iwebstandard_tmonials_dots[si].className.replace( " iwebstandard-tmonials-active", "" );
		}
			iwebstandard_tmonials_dots[iwebIndex - 1].className += " iwebstandard-tmonials-active";
			sx[iwebIndex - 1].style.display = "block";
			sx[iwebIndex - 1].style.animation = "iweb-fadeInLeft 0.3s";

		setTimeout( iwebstandard_tmonial, 4600 );
	}
}

//CSS Animation

jQuery( window ).scroll(function () {
	jQuery( '.iwebanim-fil' ).each(function (){
		var iwebstandard_imagePos = jQuery( this ).offset().top;
		var iwebstandard_topOfWindow = jQuery( window ).scrollTop();
		if (iwebstandard_imagePos < iwebstandard_topOfWindow + 500) {
			jQuery( this ).addClass( "iweb-fadeInLeft" );
			jQuery( this ).removeClass( "iwebanim-fil" );
		}
	});
});

jQuery( window ).scroll(function () {
	jQuery( '.iwebanim-fir' ).each(function (){
		var iwebstandard_imagePos = jQuery( this ).offset().top;
		var iwebstandard_topOfWindow = jQuery( window ).scrollTop();
		if (iwebstandard_imagePos < iwebstandard_topOfWindow + 500) {
			jQuery( this ).addClass( "iweb-fadeInRight" );
			jQuery( this ).removeClass( "iwebanim-fir" );
		}
	});
});

jQuery( window ).scroll(function () {
	jQuery( '.iwebanim-zin' ).each(function (){
		var iwebstandard_imagePos = jQuery( this ).offset().top;
		var iwebstandard_topOfWindow = jQuery( window ).scrollTop();
		if (iwebstandard_imagePos < iwebstandard_topOfWindow + 500) {
			jQuery( this ).addClass( "iweb-zoomin" );
			jQuery( this ).removeClass( "iwebanim-zin" );
		}
	});
});

jQuery( window ).scroll(function () {
	jQuery( '.iwebanim-fid' ).each(function (){
		var iwebstandard_imagePos = jQuery( this ).offset().top;
		var iwebstandard_topOfWindow = jQuery( window ).scrollTop();
		if (iwebstandard_imagePos < iwebstandard_topOfWindow + 500) {
			jQuery( this ).addClass( "iwebfadeInDown" );
			jQuery( this ).removeClass( "iwebanim-fid" );
		}
	});
});

// Our Team

function openTeam(evt, membName) {
	var i, istandardtm, istandardtab;
	istandardtm = document.getElementsByClassName( "istandardtm" );
	for (i = 0; i < istandardtm.length; i++) {
		istandardtm[i].style.display = "none";
	}
	istandardtab = document.getElementsByClassName( "istandardtab" );
	for (i = 0; i < istandardtab.length; i++) {
		istandardtab[i].className = istandardtab[i].className.replace( " active", "" );
	}
	document.getElementById( membName ).style.display = "block";
	evt.currentTarget.className += " active";

}

//$(this).removeClass('active');

// Get the element with id="defaultOpen" and click on it
document.getElementById( "defaultOpenstdtm" ).click();
