// JavaScript Document

$(document).ready(function(){
						   
	$('.add_to').click(function() {
		if ($('#viewer').css('height') != '200px')
		{
		$('#show_inter_items').click();
		}
	});
	
	$('#hide_inter_items').click(function() {
		$('#inter_items').css('display','none');
		$('#viewer').animate({
			height: '0',
		}, "fast", function() {
			// Animation complete.
			$('#viewer_summary').css('display','block');
			$('#viewer_summary').animate({height: '41px'}, "fast");
			$('#viewer_summary_text').css('display','block');	
			
			$.post(dotdotpath+'_include/module/baskettotal.cfm',{}, function(data) {
				document.getElementById("baskettotal").innerHTML = data;
			});
			
		});
	});
	
	$('#show_inter_items').click(function() {
		$('#viewer_summary').animate({height: '0'}, "fast");
		$('#viewer_summary_text').css('display','none');		
			
		$('#viewer').animate({
			height: '160',
		}, "fast", function() {
			// Animation complete.
			$('#inter_items').css('display','block');
		});
	});

	$(".view_item").colorbox({width:"800px", height:"400px", iframe:true,onClosed:function(){ $('#hide_inter_items').click() } });
	
	
	var $winwidth = $(window).width();
	$("img.source-image").attr({
			width: $winwidth
	});
	$(window).bind("resize", function(){
			var $winwidth = $(window).width();
			$("img.source-image").attr({
					width: $winwidth
			});
	 });
});


function changerows()
{
	document.rows.submit();
}

function addtobasket(ProductID)
{
	$.post(dotdotpath+'_include/module/addtobasket.cfm',{ProductID: ProductID}, function(data) {
		document.getElementById("basketcontents").innerHTML = data;
	});
	$.post(dotdotpath+'_include/module/baskettotal.cfm',{}, function(data) {
		document.getElementById("baskettotal").innerHTML = data;
	});
	
	return false;
}

function removefrombasket(ProductID)
{
	$.post(dotdotpath+'_include/module/removefrombasket.cfm',{ProductID: ProductID}, function(data) {
		document.getElementById("basketcontents").innerHTML = data;
	});
	$.post(dotdotpath+'_include/module/baskettotal.cfm',{}, function(data) {
		document.getElementById("baskettotal").innerHTML = data;
	});
	
	return false;
}

function removefrombasketreload(ProductID)
{
	$.post(dotdotpath+'_include/module/removefrombasket.cfm',{ProductID: ProductID}, function(data) {
		location.href="";																						  
	});	
	
	return false;
}

function deletemessage(id)
{
	if (confirm("Are you sure you want to delete this message?"))
	{
		location.href="delete.cfm?messageid=" + id;
	}
}
