function slideSwitch() 
{
    
	var $numbers = $('#slideshow blockquote');	
	if($numbers.length<2) return false;
	
	var $active = $('#slideshow blockquote.active');

    if ( $active.length == 0 ) $active = $('#slideshow blockquote:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $('#slideshow blockquote:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');	

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

function slideSwitch1() 
{ 
	if(!$('#slideshow1'))
		return false;
	
	var $numbers = $('#slideshow1 img');	
	if($numbers.length<2) return false;
	
	var $active = $('#slideshow1 img.active');

    if ( $active.length == 0 ) $active = $('#slideshow1 img:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $('#slideshow1 img:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');	

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch1()", 5000 );
});


function changeTabs(id,tab_name,tab_class,total) 
{
	for(var i=1;i<total;i++) 
	{		
		document.getElementById(tab_class+'_'+i).className = '';
		document.getElementById(tab_name+'_'+i).style.display = 'none';
		
	}
	
	document.getElementById(tab_class+'_'+id).className = 'selected';	
	document.getElementById(tab_name+'_'+id).style.display = 'block';
	
	
}

function header_list(id)
{	
	if(id=='newsletter') {
		document.getElementById('top-feedback').style.display = 'none';
		document.getElementById('feedback_btn').style.color = '#FFF';
	}
	else{
			document.getElementById('top-newsletter').style.display = 'none';
			document.getElementById('newsletter_btn').style.color = '#FFF';
		}
	
	
	document.getElementById(id+'_btn').style.color = '#000000';	
	document.getElementById('top-'+id).style.display = 'block';
	
}

function ajaxMsg(text) 
{
	$("#ajax_msg").css('display','block');
	$("#ajax_msg").html(text);
	
	setTimeout(function () {$("#ajax_msg").css('display','none');}, 2000);
}

function add_to_cart(product_id) 
{
	var loadUrl = self_location+'add_to_cart.php?product_id='+product_id;	
   
	$.get(loadUrl,function(data){
		
		ajaxMsg(data);
		
		updateTotal('1');
		
	});    
}

function updateTotal(show)
{
	var loadUrl1 = self_location+'add_to_cart.php?total=1';	
	$.get(loadUrl1,function(text1){
		if(!parseInt(text1))
			tot = 'Total 0 RON';
		else
			tot = 'Total '+ parseInt(text1) + ' RON';
		if(show)
			$("#bascket").css('display','block');
		
		$("#total_cart").html(tot);
	});
}

function delFromCart(product_id) 
{
	var loadUrl = self_location+'add_to_cart.php?del_id='+product_id;	
   
	$.get(loadUrl,function(data){
		$("#cart_item_"+product_id).remove();
		ajaxMsg(data);
	}); 

	updateTotal();
}

function delivery_cart(type) 
{
	
	if(type==0)
		urls = 'add_to_cart.php?delivery=0';
	
	if(type==1)
		urls = 'add_to_cart.php?delivery=1';
	
	if(type==2)
		urls = 'add_to_cart.php?delivery=2';
	
	var loadUrl = self_location+urls;	
   
	
	$.get(loadUrl,function(data){		
		broken=data.split("--");		
		tot = 'Total '+ parseInt(broken[0]) + ' RON';
		$("#total_cart").html(tot);

		if(broken[1]=='0')
			$("#explanation").html('');
		if(broken[1]=='1')
			$("#explanation").html('* 10 RON reprezentand costul pentru transport prin posta');
		if(broken[1]=='2')
			$("#explanation").html('* 20 RON reprezentand costul pentru transport prin curierat rapid');
			
	});   
}

function verify(results)
{
	alert(results[0])
}
