/*
  $Id: common.js,v 1.0 2009/07/01  Samad Kushan Exp $
  
  @author 	Samad kushan (samad1983@gmail.com) 		
  @copyright 	Copyright 2009, Tavrizh	I.T	
  
  Virtu, Open Source E-Commerce
  http://www.e-virtu.com/  
  
  Copyright (c) 2007-2009 Virtu E-Commerce
  Released under the GNU General Public License
  powered by JQuery
*/


$(document).ready(function(){
		 
		
// compare 	

$(".add_compare_button").click(function(){	
$(".in_processing").show();

   $.get("compare_list_script.php", {product_id: $(this).attr("id"), Vsid: session_id}, function(data){
   		$(".in_processing").hide();																							
		if(data == 'too_many'){
			alert(text_too_many_products_added);
		}else if(data == 'exist'){
			
		}else if(data == 'not_found'){
			alert(text_not_found_products);
		}else{
			$("#compare_list_holder").replaceWith(data);
			$(".clear_compare_list_button").show();
			$(".button_compare").show();
		} 										 																		
	});	

 });

	$(".clear_compare_list_button").click(function(){	
   		$(".in_processing").show();
		$.get("compare_list_script.php", {clear_compare_list: true, Vsid: session_id }, function(data){	
				$(".in_processing").hide();		 
				if (data == 'empty') {
						$("#compare_list_holder").replaceWith('<div id="compare_list_holder" style="clear:both;"><span>' + text_no_compare_products_added + '</span></div>');
						$(".clear_compare_list_button").hide();
						$(".button_compare").hide();						
				}
				
		 });
	  })
})
/**************************************************************************************/

/*
  $Id: shopping_card.js,v 1.0 2009/07/26  Samad Kushan Exp $
  
  @author 	Samad kushan (samad1983@gmail.com) 		
  @copyright 	Copyright 2009, Tavrizh	I.T	
  
  Virtu, Open Source E-Commerce
  http://www.e-virtu.com/  
  
  Copyright (c) 2007-2009 Virtu E-Commerce
  Released under the GNU General Public License
  powered by JQuery
*/

function add_shopping_card(id, redirect_url){
					
$("#shopping_card_list_holder").hide();
$(".in_processing_add_shopping_card").show();
   $.get("add_to_shopping_card_script.php", {ajax: 'true', action: 'buy_now', products_id: id, Vsid: session_id}, function(data){
   $(".in_processing_add_shopping_card").hide();
   if(data == 'has_product_attributes'){
   	 window.location = redirect_url;   	 
   }else if(data == 'too_qty_in_cart'){
   	  $.modaldialog.error(text_too_many_qty_in_cart, { title:text_too_many_qty_in_cart_header, width:200, height:200 });
	  return false;   	
	}else{
   	 $("#ja_shopping_cart_content_holder").replaceWith(data);	
	 $.modaldialog.success(text_success_add_to_cart, {  title: text_success_add_to_cart_header, width:200,  height:200 }); 	 
   }		
   return false;	
});	
return false;
}

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
 // The index() method calculates the index from a
 // given index who is out of the actual item range.
 var idx = carousel.index(i, mycarousel_itemList.length);
 carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
 carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
 return '<div class="new_products_list_item">' + item.list_items + '</div>';
};
 
function mycarousel_initCallback(carousel)
{
        carousel.clip.hover(function() {		 		
                carousel.stopAuto();
        }, function() {
                carousel.startAuto();
        });
};



/* superfish */
$(document).ready(function(){ 

        $("ul.sf-menu").superfish({
			disableHI:     true,
			dropShadows:   false,    
			delay:       1000,                            // one second delay on mouseout 
            animation:   {height:'show'},  // fade-in and slide-down animation           
			speed:       300,            		
			autoArrows:  false                          // disable generation of arrow mark-up
		}); 
    }); 