
function closePreview() { 
	
	try {
   	setprevalues();
	}
	catch (e) {
   
	}
	
	$("div.matpreview_abs").hide(); 
}

function setMapPreview() { 
	//add googles point by getting map and calling addLocation
	try {
   	setprevalues();
	}
	catch (e) {
   
	}
	
	$("div.matpreview_abs").hide(); 
}

function chgImage() { 
	// this viittaa siihen elementtiin, jonka onclik-eventti suoritetaan
	$("img.matimg").attr('src', 'components/com_dpmaterial/images/matloader.gif');
	jqmat = $(this);
	$("div.thumbmat_cont").attr('style', '');
	var thumb_img = jqmat.attr('dpimg');
	var file = jqmat.attr('file');
	var info = jqmat.attr('matinfo');
	var name = jqmat.attr('matname');
	var matowner = jqmat.attr('matowner');
	var mathits_txt_start = jqmat.attr('mathits_txt_start');
	var mathits_txt_end = jqmat.attr('mathits_txt_end');
	var mathits = jqmat.attr('mathits');
	var full_size_file = jqmat.attr('full_size_file');
	var mid = jqmat.attr('mid');
	
	
	

	$("input#mat_send_comment").attr('mid', mid);
	$("div#mat_comments_list").html('<img src="components/com_dpmaterial/images/matloader.gif" alt="" />');
	
	
	$("div.matpreview_abs").css("top", ($(document).scrollTop() + 10) + "px");
	
	
	info = (info) ? info : '';
	$("p.matinfo").html(info);
	$("div.matname").html(name);
	

	$("div.matpreview_abs").show();
	$("div.mat_thumbcont").attr('style', '');
	$(".borders").attr('style', '');
	$("#"+thumb_img).attr('style', 'border: 1px solid #993300');
	
	$("div#matdetails_holder").show();
	$("div#mat_commentsholder").hide();
}

$(function () {
	
	$("div.thumbmat_cont").bind( 'click', chgImage );
	
	
	$("div.mat_closeimg").bind( 'click', closePreview );
	$("div.mat_closetxt").bind( 'click', closePreview );
	$("div.mat_set").bind( 'click', setMapPreview );

	$("div#dpmatperview").draggable(
		{handle:'#maptreview_handle', opacity: 0.8}
	);

});
