$(document).ready(function(){  

	
	$("a.zoomin").css("display","block");
	$("div.zoomout").hide();
   
	$("div.ctntimg a.zoomin").click(function(event){			   
		
		//hide small image
		$(this).parent().prev("img").hide();
		
		//get image url
		var bigimage = $(this).attr("href");	
		
		
		if ($(this).parent().parent().hasClass("halfwidth")) {
		
			//insert big image
			$(this).parent().before("<img class='bigimg' src="+bigimage+" />");
			
			$(this).parent().parent().removeClass("halfwidth");
			$(this).parent().parent().addClass("fullwidth");
			
			if ($(this).parent().parent().hasClass("halffloat_left")) {
				$(this).parent().parent().removeClass("halffloat_left");
				$(this).parent().parent().addClass("halffloat_left_full");
			}
			
			if ($(this).parent().parent().hasClass("halffloat_right")) {
				$(this).parent().parent().removeClass("halffloat_right");
				$(this).parent().parent().addClass("halffloat_right_full");
			}
		}
		
		
		if ($(this).parent().parent().hasClass("q1width")) {
			//insert big image
			$(this).parent().before("<img class='bigimg' src="+bigimage+" />");
			
			$(this).parent().parent().removeClass("q1width");
			$(this).parent().parent().addClass("fullwidth");
			$(this).parent().parent().addClass("q1full");
			
		}
		
		
		if ($(this).parent().parent().hasClass("q3width")) {
			//insert big image
			$(this).parent().before("<img class='bigimg' src="+bigimage+" />");
			
			$(this).parent().parent().removeClass("q3width");
			$(this).parent().parent().addClass("fullwidth");
			$(this).parent().parent().addClass("q3full");
			
			if ($(this).parent().parent().hasClass("q3float_left")) {
				$(this).parent().parent().removeClass("q3float_left");
				$(this).parent().parent().addClass("q3float_left_full");
			}
			
			if ($(this).parent().parent().hasClass("q3float_right")) {
				$(this).parent().parent().removeClass("q3float_right");
				$(this).parent().parent().addClass("q3float_right_full");
			}
			
		}
		
		
		
		
		
		
		
		// toggle functions
		
		$(this).hide();
		$(this).next("div.zoomout").show();
		
		event.preventDefault();
    });
	
	$("div.ctntimg div.zoomout").mouseover(function(event){	});
	
	$("div.ctntimg div.zoomout").click(function(event){		
		
		
		//remove big image
		$(this).parent().prev("img.bigimg").remove();
		
		//show small image
		$(this).parent().prev("img").show();
		
		if ($(this).parent().parent().hasClass("q1full")) {
			
			$(this).parent().parent().removeClass("fullwidth");
			$(this).parent().parent().removeClass("q1full");
			$(this).parent().parent().addClass("q1width");
		}
		
		else if ($(this).parent().parent().hasClass("q3full")) {
			
			$(this).parent().parent().removeClass("fullwidth");
			$(this).parent().parent().removeClass("q3full");
			$(this).parent().parent().addClass("q3width");
			$(this).parent().parent().addClass("q3float");
			
			if ($(this).parent().parent().hasClass("q3float_left_full")) {
				$(this).parent().parent().removeClass("q3float_left_full");
				$(this).parent().parent().addClass("q3float_left");
				$(this).parent().parent().addClass("q3left");
			}
			
			if ($(this).parent().parent().hasClass("q3float_right_full")) {
				$(this).parent().parent().removeClass("q3float_right_full");
				$(this).parent().parent().addClass("q3float_right");
				$(this).parent().parent().addClass("q3right");
			}
			
		}
		
		else {
			
			$(this).parent().parent().removeClass("fullwidth");
			$(this).parent().parent().addClass("halfwidth");
			
			if ($(this).parent().parent().hasClass("halffloat_left_full")) {
				$(this).parent().parent().removeClass("halffloat_left_full");
				$(this).parent().parent().addClass("halffloat_left");
			}
			
			if ($(this).parent().parent().hasClass("halffloat_right_full")) {
				$(this).parent().parent().removeClass("halffloat_right_full");
				$(this).parent().parent().addClass("halffloat_right");
			}
		}
		
		// toggle functions
		
		$(this).hide();
		$(this).prev("a.zoomin").show();
		
		event.preventDefault();


    });
	
	
	
});