/**
*	File: common.js
*	Author: Deepak Balani.
*	Description: JavaScript written for Ascent Web Technology(http://www.ascentwebtechnology.com) Website.
*/


var def_text='Search...';	
jQuery(function () {
    jQuery('input#search-box').focus(function () {
        if (jQuery(this).val() == def_text) {
            jQuery(this).attr('value', '');
        }
    }).blur(function () {
        if (jQuery(this).val() == '') {
            jQuery(this).attr('value', def_text);
        }
    });
});

/*****************************************************************************************************************/

// Function to initlize jQuery Sliding Gallery Widget when DOM ready.
var trigger_banner = false; 	// Banner is not shown on inner pages.
jQuery(function() {
	if(trigger_banner) {	
		//jQuery('div.slides img').addClass('start');
		jQuery('div.slides img').slidingGallery({
			container   : jQuery('div#slides'),
			gutterWidth : 7,
			Lheight	    : 250,
			Lwidth		: 200,
			useCaptions : false,
		});
	}
});
// End.

/*****************************************************************************************************************/

var is_tab_set = false;
jQuery(function () {
    jQuery('input.page-ids').each(function () {
        if (jQuery(this).val() == current_page_id) {
            jQuery(this).prev().addClass('js-hover'); // Add class similar to hyperlink hover.
            is_tab_set = true;
        }
    });
    if (!is_tab_set && !window.location.search) {
        jQuery('#home-link').addClass('js-hover');
    }
});

/*****************************************************************************************************************/

// Deepak 19-11-2010
// Function to search content on WordPress.
// Use closure function() & callback function().

jQuery(function () {
    jQuery('#s-form').submit(function () {
        var action = jQuery(this).attr('action');
        var keyword = jQuery(this).children('input[type="text"]').val();
        if (keyword == "Search..." || keyword == '') {
            alert( 'Please enter a search keyword' );
		} else {
            window.location = action + '?s=' + keyword;
        }
        return false;
    });
});
/*****************************************************************************************************************/

// Deepak 19-11-2010
// Function to void all the unwanted links.

jQuery(function () {
    jQuery('a').each(function () {
        if (jQuery(this).attr('href') == '#') {
            jQuery(this).attr('href', 'javascript:void(0)');
        }
    });
	
	jQuery('.footer-icon-links a').each(function() {
		this.target = '_blank';						// Service links in new tab.
	});
	
});
/*****************************************************************************************************************/

// News Scroller 
jQuery(function() {
	jQuery("#news-section").jCarouselLite({
		vertical: true,
		hoverPause:true,
		visible: 2,
		auto:  500,
		speed: 3000
	});
});

/*****************************************************************************************************************/

jQuery(function() {
	jQuery('.preview').jcarousel({
		vertical : false,						 
		scroll	 : 1,
		buttonNextHTML : "<a href='javascript:void(0)'></a>",
		buttonPrevHTML : "<a href='javascript:void(0)'></a>",
		easing		    : 'easeOutBounce',
		animation		: 2000,
		wrap			: 'circular',
		buttonNextCallBack : carousel_next_callback,
		buttonPrevCallBack : carousel_prev_callback
	});				
});

function carousel_next_callback(instance) {

}

function carousel_prev_callback(instance) {
	
}

/*****************************************************************************************************************/


jQuery(function() {
	jQuery('.top-menu').hover(function() {
		//jQuery('.children').slideUp();
		jQuery('.level-3-menu').hide();
		jQuery(this).children('.submenu-wrapper').css('display','block');										 
	},function() {
		jQuery('.level-3-menu').hide();
		jQuery(this).children('.submenu-wrapper').css('display','none');
	});
});

jQuery(function() {
	jQuery('.have-submenu').mouseover(function() {
		jQuery('.level-3-menu').hide();
		id = jQuery(this).attr('id');
		$sel = '#menu-' + id;
		jQuery($sel).css('display','block');
	});
});

