/*---------------------------------------------------------------------*/
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
;(function($){
	$(document).ready( function(){
		ww = document.body.clientWidth;
		/*Navigation */
		if( $(".mainMenu").length) {
			$(".toggleMenu").click(function(e) {
				e.preventDefault();
				$(this).toggleClass("active");
				$(".mainMenu").slideToggle();
				$(".mainMenu li").removeClass("resHover")
				$(".resIcon").removeClass("active")
				return false;
			});
			$(".mainMenu li a").each(function() {
				if ($(this).next().length) {
					$(this).parent().addClass("parent");
				};
			})
			$(".mainMenu li.parent").each(function () {
				if ($(this).has(".menuIcon").length <= 0) $(this).append('<i class="menuIcon">&nbsp;</i>')
			});
			dropdown('menu-main', 'hover', 1);
			adjustMenu();
		}
		// Index Banner Slider
		if( $(".indexBanner").length) {
			var owl = $(".sliderBanner");
			owl.owlCarousel({
				loop:true,
				//autoplay:true,
				autoplayTimeout:3000,
				smartSpeed:1200,
				nav:true,
				items : 1,
				dots : false		
			});
		}
		if( $(".carouselBlock").length) {
			$('.carouselBlock').owlCarousel({
				loop:true,
				//autoplay:true,
				autoplayTimeout:3000,
				smartSpeed:1200,
				margin:25,
				nav:true,
				dots : false,
				responsive:{
					0:{
						items:1
					},
					600:{
						items:2
					},
					900:{
						items:4
					}
				}
			})
		}
		if( $(".ticker").length){
			$('.ticker').each(function(i){
				$(this).addClass('tickerDiv'+i).attr('id', 'ticker'+i);
				$('#ticker'+i).find('.tickerDivBlock').first().addClass('newsTikker'+i).attr('id', 'newsTikker'+i);
				$('#ticker'+i).find('a').first().attr('id', 'stopNews'+i)
				$('#newsTikker'+i).vTicker({ speed: 1E3, pause: 4E3, animation: "fade", mousePause: false, showItems: 3, height: 165, direction: 'up' })
				$("#stopNews"+i).attr("href", "#").toggle(function () {
					$(this).removeClass("stop").addClass("play").text("Play").attr('title', 'Play');
					}, function () {
					$(this).removeClass("play").addClass("stop").text("Pause").attr('title', 'pause');
				}); 
			});
		}
		// Responsive Tabing Script
		if( $(".resTab").length) {
			$('.resTab').responsiveTabs({
				rotate: false,
				startCollapsed: 'tab', //accordion
				collapsible: 'tab', //accordion
			});
		}
		if( $(".accordion").length){
		   $('.accordion .accordDetail').hide();
		   $(".accordion .accordDetail:first").show(); 
		   $(".accordion .accTrigger:first").addClass("active");	
		   $('.accordion .accTrigger').click(function(){
			  if ($(this).hasClass('active')) {
				   $(this).removeClass('active');
				   $(this).next().slideUp();
			  } else {
				   $('.accordion .accTrigger').removeClass('active');
				   $(this).addClass('active');
				   $('.accordion .accordDetail').slideUp();
				   $(this).next().slideDown();
			  }
			  return false;
		   });
		};
		// Responsive Table
		if( $(".responsiveTable").length){
			$(".responsiveTable").each(function(){
			$(this).wrap('<div class="tableOut"></div>');
			$(this).find('td').removeAttr('width');$(this).find('td').removeAttr('align');
			var head_col_count =  $(this).find('tr th').size();
			// loop which replaces td
			for ( i=0; i <= head_col_count; i++ )  {
				// head column label extraction
				var head_col_label = $(this).find('tr th:nth-child('+ i +')').text();
				// replaces td with <div class="column" data-label="label">
				$(this).find('tr td:nth-child('+ i +')').attr("data-label", head_col_label);
			}
			});
		}
		// Back to Top function
		if( $("#backtotop").length){
			$(window).scroll(function(){
				if ($(window).scrollTop()>120){
				$('#backtotop').fadeIn('250').css('display','block');}
				else {
				$('#backtotop').fadeOut('250');}
			});
			$('#backtotop').click(function(){
				$('html, body').animate({scrollTop:0}, '200');
				return false;
			});
		};
		// Message block close script
		if( $(".btnMClose").length) {
			$(".btnMClose").click(function(e) {
				e.preventDefault();
				$(this).parent().fadeOut('slow');
				return false;
			});
		}
		if( $("#gmap").length){
			google.maps.event.addDomListener(window, 'load', function() {
			var map = new google.maps.Map(document.getElementById('gmap'), {
			zoom: 15,
			center: new google.maps.LatLng(23.021666 , 72.55464),
			mapTypeId: google.maps.MapTypeId.ROADMAP
			});
			var infoWindow = new google.maps.InfoWindow;
			var onMarkerClick = function() {
			  var marker = this;
			  var latLng = marker.getPosition();
			  infoWindow.setContent('<strong>Silver Touch Technologies Limited</strong><br>2nd Floor, Saffron Towers,<br>Near Panchwati Circle,<br>Ahmedabad, Gujarat 380006');
			  infoWindow.open(map, marker);
			};
			google.maps.event.addListener(map, 'click', function() {
			  infoWindow.close();
			});
			var marker = new google.maps.Marker({
			  map: map,
			  position: new google.maps.LatLng(23.021666 , 72.55464)
			});
			google.maps.event.addListener(marker, 'click', onMarkerClick);
		  });
		}
	});
$(window).bind('resize orientationchange', function() {
	ww = document.body.clientWidth;
	adjustMenu();
});
$(window).load(function() {
  // When the page has loaded
  //$("#preLoader").fadeOut(1000);
  //$("#wrapper").fadeIn(1000);
});
})(jQuery);

