/*
  $Id: common.js,v 1.0 2009/07/01 $
  
  @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(){		 
	$(".language_flag").css("opacity","0.5");
	$(".language_flag").hover(function(){
	  $(this).css("opacity","1.0");
	},function(){
	  $(this).css("opacity","0.5");
	})
// 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;">' + text_no_compare_products_added + '</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'){
   	$("#shopping_card_list_holder").show();
   	  $.modaldialog.error(text_too_many_qty_in_cart, { title:text_too_many_qty_in_cart_header, width:200, height:200 });	  
	  return false;   	
	}else{
   	 var contents = data.split('//==//');
	 $("#shopping_card_list_holder").replaceWith('<div id="shopping_card_list_holder">'+ contents[0] + '</div>');
	 $("#shopping_card_total_holder").replaceWith('<div id="shopping_card_total_holder">'+ contents[1] + '</div>');
	 $.modaldialog.success(text_success_add_to_cart, {  title: text_success_add_to_cart_header, width:200,  height:200 });	 
   }		
   return false;	
});	
return false;
}



/* Linux Template event handlers 2009/10/13  
  
  @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(){
    maxWidth = 235;
    minWidth = 0;	

    $("#login_box_button").click(
      function(){
        if($("#loginbox_holder").attr("alt") == "opened"){		  		
  		  $("#loginbox_holder").animate({right: maxWidth+"px"}, { queue:false, duration:800 });
		  $("#loginbox_holder").attr("alt","closed");
		  $(this).addClass("login_box_closed_button_" + language_name); 
        }else{
		  $("#loginbox_holder").animate({right: minWidth+"px"}, { queue:false, duration:800 });
		  $("#loginbox_holder").attr("alt","opened");
		  $(this).removeClass("login_box_closed_button_" + language_name);
		}	
		return false;
      }
    );
	$("#search_box_button").click(
      function(){
        if($("#searchbox_holder").attr("alt") == "opened"){
		  $(this).addClass("search_box_closed_button_" + language_name);    
  		  $("#searchbox_holder").animate({left: maxWidth+"px"}, { queue:false, duration:800 });
		  $("#searchbox_holder").attr("alt","closed");
		  //$(this).attr("class")
        }else{
		  $(this).removeClass("search_box_closed_button_" + language_name);
		  $("#searchbox_holder").animate({left: minWidth+"px"}, { queue:false, duration:800 });
		  $("#searchbox_holder").attr("alt","opened");
		}		
		return false; 	
      });
	$("#account_box_button").click(
      function(){
        if($("#loginbox_holder").attr("alt") == "opened"){
		  $(this).addClass("account_box_closed_button_" + language_name);    
  		  $("#loginbox_holder").animate({right: maxWidth+"px"}, { queue:false, duration:800 });
		  $("#loginbox_holder").attr("alt","closed");
		  //$(this).attr("class")
        }else{
		  $(this).removeClass("account_box_closed_button_" + language_name);
		  $("#loginbox_holder").animate({right: minWidth+"px"}, { queue:false, duration:800 });
		  $("#loginbox_holder").attr("alt","opened");
		}		
		return false; 	
      });
});
