// JavaScript Document
/*
	Author   shahid iqbal	
	email    shahid.iqbal.pk@gmail.com
	created on 12 Sep 2011
*/
  
  //$('#addcartbtn').delegate('a.lnkclass2', 'click', function() { alert("That tickles!") });
		//$('#addcartbtn2').live('click', function() { alert("That tickles!"); });
		
		//$("#addcartbtn2").on( 'click','a', function() { alert("That tickles!"); });
	
 
  
			$(document).ready(function(){
									   
				$("area[rel^='prettyPhoto']").prettyPhoto();
				
				$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'light_square',slideshow:3000, autoplay_slideshow: false});
				$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});
		
				$("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
					custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
					changepicturecallback: function(){ initialize(); }
				});

				$("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
					custom_markup: '<div id="bsap_1259344" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div><div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
					changepicturecallback: function(){ _bsap.exec(); }
				});
					 			   
									   
									   
				 // Use the each() method to gain access to each of the elements attributes
				//$(".lnkReply").live("each",function () { 	 
			  //	 
			  // $('div.product_box').live("each",function ()
															
			 /* $('div.product_box').each(function()  
				{
				   var cart_quantity = '<div class="gallery clearfix">'+$(this).parent().find("#product_detail_link").html()+'</div>';				   
				  $(this).qtip(
				  {    
					 content: cart_quantity , // Give it some content
					 position: 'center', // Set its position
					 hide: {
						fixed: true // Make it fixed so it can be hovered over
					 },
					 style: {  
						  width: 150, 
						  background: '#A2D959',
						  color: 'black',
						  textAlign: 'center',
						  border: {
							 width: 7,
							 radius: 5,
							 color: '#A2D959'},
						  padding: '15px 15px', // Give it some extra padding
						  name: 'dark' // And style it with the preset dark theme
					 }
				  });
			   }); 				*/	   
									    
		
		$(".viewcart").live('click', function() { 	
		
					//alert("Hello hide");
					$('#cartbox').toggle('slow'); 
			  });
		
		
		/*$('#addcartbtn2').live('click', function() {     
		 
			//$(this).parent().css('background-color', 'red');
			
			//$(this).parent().css('background-color', 'red');
			// alert($(this).parent().attr('id'));
			//divid="#"+$(this).parent().attr('id')+" cart_quantity" ;
			//alert(divid); 
			
			$('#cartbox').show('slow'); 
			var cart_quantity = $(this).parent().find(".txtcart_quantity").val();
			var products_id = $(this).parent().find(".txtproducts_id").val();
			var attribute_id = $(this).parent().find(".txtattribute_id").val();	
			var option_id = $(this).parent().find(".txtattribute_id").attr('name'); 
			option_id = option_id.replace("]", "").replace("id[", ""); 	
			
			$.ajax({
			type: 'POST',
			url: 'ajax_add_to_cart.php?action=add_product'+'&cart_quantity=' + cart_quantity+'&products_id='+products_id+'&id='+attribute_id+'&option_id='+option_id,
			data: '&cart_quantity=' + cart_quantity+'&products_id='+products_id+'&id='+attribute_id+'&option_id='+option_id+'&action=add_product',
			dataType: 'html',
			beforeSend: function() {				 
				$('#cartbox').html('<img src="images/ajax-loader.gif" alt="loading..." />'); 
			},
			success: function(response) {
				
				$('#cartbox').html(response);
				alert("Product Added to Cart");  
			}
		});
			
														   
		});
		*/
		 
		$("#addcartbtn.lnkclass").live('click', function() { 										 
			//alert("Hello shahid.......*********");	
			//$(this).parent().css('background-color', 'red');
			
			//$(this).parent().css('background-color', 'red');
			// alert($(this).parent().attr('id'));
			//divid="#"+$(this).parent().attr('id')+" cart_quantity" ;
			//alert(divid); 
			
			$('#cartbox').show('slow'); 
			var cart_quantity = $(this).parent().find(".txtcart_quantity").val();
			var products_id = $(this).parent().find(".txtproducts_id").val();
			var attribute_id = $(this).parent().find(".txtattribute_id").val();	
			var option_id = $(this).parent().find(".txtattribute_id").attr('name'); 
			option_id = option_id.replace("]", "").replace("id[", ""); 
		
		$.ajax({
			type: 'POST',
			url: 'ajax_add_to_cart.php?action=add_product'+'&cart_quantity=' + cart_quantity+'&products_id='+products_id+'&id='+attribute_id+'&option_id='+option_id,
			data: '&cart_quantity=' + cart_quantity+'&products_id='+products_id+'&id='+attribute_id+'&option_id='+option_id+'&action=add_product',
			dataType: 'html',
			beforeSend: function() {				 
				$('#cartbox').html('<img src="images/ajax-loader.gif" alt="loading..." />'); 
			},
			success: function(response) {
				
				$('#cartbox').html(response);
				alert("Product Added to Cart");  
			}
		});
			 
	});
	
function update_notes_welcome(){
	 
	//just for the fade effect
	content.hide();
	loading.fadeIn();
	//send the post to shoutbox.php
	 
	/*
	$.ajax({
	type: "POST",
	url: "ajax_user_chat.php",
	// data: "action=update",
	complete: function(data){
	
	loading.fadeOut();
	list.html(data.responseText);
	 
	list.fadeIn(500);
	//completedList.fadeIn(2000);
	}
	
	
	});
	*/
	
}
					   
						   
});


	 
