/**
*
 * Only using with AT_LiveShop
 *@author: Ahmet Topal <ahmet-topal.com>
 *
 */
jQuery.noConflict();

jQuery( document ).ready(function() {
	jQuery( 'div#at_liveshop').hide();
	
/*	at_hide_product_on_hover( '#at_ls_1' );
	at_hide_product_on_hover( '#at_ls_2' );
	at_hide_product_on_hover( '#at_ls_3' );
	at_hide_product_on_hover( '#at_ls_4' );
	at_hide_product_on_hover( '#at_ls_5' );
	at_hide_product_on_hover( '#at_ls_6' );
	at_hide_product_on_hover( '#at_ls_7' );
	at_hide_product_on_hover( '#at_ls_8' );
	at_hide_product_on_hover( '#at_ls_9' );
	at_hide_product_on_hover( '#at_ls_10' );
*/
	
	at_show_product_on_hover( '#at_ls_2' );
	at_show_product_on_hover( '#at_ls_4' );
	at_show_product_on_hover( '#at_ls_6' );
});

function at_show_product_on_hover( divid )
{
	jQuery( 'div#at_liveshop' ).hover(function() {
		jQuery( 'div#at_liveshop').stop().fadeOut( 0 ).fadeIn( 0 );
	}, function() {
		at_hide_product();
	});
	
	jQuery( divid ).hover(function() {
		at_show_product( divid );
		jQuery( 'div#at_liveshop').stop().fadeIn( 500 );
	}, function() {
		at_hide_product();
	});
}

function at_hide_product_on_hover( divid )
{
	jQuery( divid ).hover(function() {
		at_hide_product();
	});
}

function at_show_product( id )
{
	jQuery.ajax({
 		type: 'GET',
		url: 'http://livebuzz.ch/wp-content/themes/livebuzz_v1/at_liveshop/at_liveshop.php?id='+id.replace( '#at_ls_', '' ),
		dataType: 'xml',
		success: at_load_xml
	});
}

function at_load_xml( xml )
{
	jQuery( xml ).find( 'produkt' ).each(function()
	{
		jQuery( 'div#at_liveshop' ).html( '' );
		jQuery( 'div#at_liveshop' ).append( '\
			<div class="left">\
				<div class="titel">'+ jQuery(this).find( "titel" ).text() + '</div>\
				<div class="beschreibung">'+ jQuery(this).find( "beschreibung" ).text() + '</div>\
			</div>\
			<div class="right">\
				<div class="foto"><img src="'+ jQuery(this).find( "foto" ).text() + '" alt="'+ jQuery(this).find( "web" ).text() + '" /></div>\
				<div class="preis_chf">Preis: '+ jQuery(this).find( "preis_chf" ).text() + ' CHF</div>\
				<div class="versand_chf">Versand: '+ jQuery(this).find( "versand_chf" ).text() + ' CHF</div>\
				<div class="verfuegbar">Verfügbar: '+ jQuery(this).find( "verfuegbar" ).text().replace("%", "") + '% <span><img src="http://livebuzz.ch/wp-content/themes/livebuzz_v1/at_liveshop/verfuegbar.png" height="20" width="'+ jQuery(this).find( "verfuegbar" ).text().replace( "%", "") + '" /></span></div>\
				<div class="web"><img src="http://livebuzz.ch/wp-content/themes/livebuzz_v1/logos/'+ jQuery(this).find( "web" ).text() + '.png" alt="'+ jQuery(this).find( "web" ).text() + '" /></div>\
			</div>\
		' );
	});
}

function at_hide_product()
{
	jQuery( 'div#at_liveshop').stop().fadeOut( 500, function() {
		jQuery( this ).html( '' );
	});
}