$(document).ready(function() {
 	
        $("a.swapImage").live("click",function(){
      	var newSrc=$(this).attr("href");
      	var resizeSrc='image.php?width=450&height=450&sq=450&image='+newSrc;
      	$("a#imageLink").attr("href",newSrc);
      	
      	$("img#imageSrc").attr("src",resizeSrc);
		
        
		return false;	
      });
      
        
//	  $("a.simple_popup").live("click",function(){
//	  	$("#backgroundPopup").css({
//			"opacity": "0.7"
//		});
//	  	$("#backgroundPopup").fadeIn("slow");
//	  	var href=$(this).attr("href");
//	  	// parse query into array
//	  		temp=href.split("?");
//	  		temp2=temp[0].split("-");
//	  		temp2=temp2[temp2.length-1].split(".");
//        
//	
//	  		$("#popupContent").load("product_info_ajax.php?"+temp[1]+"&products_id="+temp2[0], {}, function(){
//	  				centerPopup();  		
//	  				loadPopup();
//	  		});
//
//	  	
//	  	return false;
//	  })	
	 
	 
	   
	  	//CLOSING POPUP
	//Click the x event!
	
	$("#popupDivClose").click(function(){
		disablePopup();
		return false;
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
	
	 // end $(document).ready
})


/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		
		$("#popupContainer").fadeIn("fast");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popupContainer").fadeOut("fast");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	
	var top=( $(window).height() - $("#popupContainer").height() ) / 2+$(window).scrollTop();
	var left=( $(window).width() - $("#popupContainer").width() ) / 2+$(window).scrollLeft();
	//centering
	
	if(top<40){top=40;}
    
	$("#popupContainer").css({
		"position": "absolute",
		"top": top,
		"left": left
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": $(document).height()
	});
	
}

/**
 * scaleImage 0.1
 * 
 * Rendez vos sites glissant !
 *
 * Copyright (c) 2008 Benoit G (http://www.tim-burton.net) based upon
 * Licensed under the Creative Commons License:
 * http://creativecommons.org/licenses/by/3.0/
 *
 * Date: 2008-08-25
 */
 
	(function($){
		$.fn.scaleImage = function(options) {

			var defaults = {
			maxwidth: 200,
			linkclass:'',
			icon:true,
			thickbox:true
			};
			var options = $.extend(defaults, options);

			return this.each(function() {
				obj = $(this);

				var width = obj.width();
				var height = obj.height();
				if (width > options.maxwidth) {
					//Set variables	for manipulation
					var ratio = (height / width );
					var new_width = options.maxwidth;
					var new_height = (new_width * ratio);
					var classes = options.linkclass+' scaleImage';

					//thickbox
					if (options.thickbox == true) {
						var img_full_link = obj.attr('src');
						obj.wrap('<a class="thickbox" title="'+obj.attr('alt')+'" href="'+img_full_link+'"></a>');
						tb_init(obj.parent('a'));
					}
					
					//Shrink the image and add link to full-sized image
					obj.height(new_height).width(new_width);
					obj.addClass(classes);
					
					//zoom icon
					if (options.icon == true) {
						obj.after('<div class="thumb-zoom"> </div>');
						obj.hover(function(){
							$(this).next('.thumb-zoom').addClass("hover");
						},function(){
							$(this).next('.thumb-zoom').removeClass("hover");
						});
					}
				
				}
			});
		};
	})(jQuery);




		
		
		

