jQuery(document).ready(function() {
								
	// on the first time wait for 5 seconds before transitioning
	setTimeout(gallery_loop, 5000);
								
    /**
     * We show a simple loading indicator
     * using the jQuery ajax events
     */
    jQuery().ajaxStart(function() {
        jQuery(".jcarousel-clip-vertical").addClass('loading');
    });

    jQuery().ajaxStop(function() {
        jQuery(".jcarousel-clip-vertical").removeClass('loading');
    });

    jQuery('#mycarousel').jcarousel({
        vertical: true,
		scroll: 2,
		auto: 10,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
});

//Javascript for Index.html
function mycarousel_initCallback(carousel, state)
{
    // Lock until all items are loaded. That prevents jCarousel from
    // setup correctly and we have to do that in the ajax callback
    // function with carousel.setup().
    // We're doing that because we don't know the exact height of each
    // items until they are added to the list.
    carousel.lock();

    jQuery.get(
        'special_textscroller.php',
        {
            'feed': 'http://blog.gtradenet.com/?feed=rss2'
        },
        function(xml) {
            mycarousel_itemAddCallback(carousel, xml);
        },
        'xml'
    );
	
	 // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

	// Unlock and setup.
    carousel.unlock();
    carousel.setup();
	
};

function mycarousel_itemAddCallback(carousel, xml)
{
    var $items = jQuery('item', xml);

    $items.each(function(i) {
        carousel.add(i + 1, mycarousel_getItemHTML(this));
    });

    carousel.size($items.size());

};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return '<h3><a href="'+$('link', item).text()+'">'+$('title', item).text()+'</a></h3><p>'+mycarousel_truncate($('description', item).text(), 70)+'</p>';
};

/**
 * Utility function for truncating a string without breaking words.
 */
function mycarousel_truncate(str, length, suffix) {
    if (str.length <= length) {
        return str;
    }

    if (suffix == undefined) {
        suffix = '...';
    }

    return str.substr(0, length).replace(/\s+?(\S+)?$/g, '') + suffix;
};

//Thickbox
jQuery(function($){
$("#form_email_input").Watermark("Enter Email Address");
});

// Gallery Function
function gallery_loop()
{
	var cur = $("#index_feature_area_gallery_list li:visible");
	if (cur.is(":last-child") ) {
		cur.fadeOut('slow', function(){
		// run the loop function again when time is up, in this case 5seconds
			$("#index_feature_area_gallery_list li:first-child").fadeIn('slow', setTimeout(gallery_loop, 10000));
		});
	}
	else {
			cur.fadeOut('slow', function(){
			// run the loop function again when time is up, in this case 5seconds
			cur.next().fadeIn('slow', setTimeout(gallery_loop, 10000));
		});
	}
}