var changePhoto = function (id) {
	$('img_preview_'+id).className='active';
	$('img_preview_link_'+id).onclick=function(){return false;};
	if($('img_preview_link_'+$('pid').value)) {
		$('img_preview_link_'+$('pid').value).pid=$('pid').value;
		$('img_preview_link_'+$('pid').value).onclick=function(){return changePhoto(this.pid)};
		$('img_preview_'+$('pid').value).className='nonactive';
	}
	$('big_photo_'+id).style.display = 'block';
	$('big_photo_'+$('pid').value).style.display = 'none';
	$('photo_title_'+id).style.display = 'block';
	$('photo_title_'+$('pid').value).style.display = 'none';
	$('photo_view_count_'+id).style.display = 'block';
	$('photo_view_count_'+$('pid').value).style.display = 'none';
	$('photo_vote_'+id).style.display = 'block';
	$('photo_vote_'+$('pid').value).style.display = 'none';
	if($('photo_author_'+id)) {
		$('photo_author_'+id).style.display = 'block';
		$('photo_author_'+$('pid').value).style.display = 'none';
	}	
	if($('insert_code')) {
		$('links').removeChild($('insert_code'));
	}
	if($('org_img')) {
		$('originalimageinner').innerHTML = '';
	}
	$('item_id').value = id;
	$('pid').value = id;
	writeCookie('pid', id);
	aid = document.URL.substr(document.URL.lastIndexOf('/')+1, document.URL.lastIndexOf('.') - document.URL.lastIndexOf('/') - 1);
	writeCookie('aid', aid);
	sendRequest('POST', 'ajax/changePhoto.php', 'pid=' + id, function (req) {
		var jSonObj = getJSon(req);
		if(jSonObj.photo_rights == 0) {
			$('del_photo_link').style.display = 'none';
			$('change_p_title').style.display = 'none';
			$('ch_p_title_cont').style.display = 'none';
		} else if(jSonObj.photo_rights == 1) {
			$('del_photo_link').style.display = 'block';
			if($('change_p_title')) {
				$('change_p_title').style.display = 'block';
				$('ch_p_title_cont').style.display = 'none';
				$('change_title_input').value = $('photo_title_'+id).innerHTML.replace(/^\s+|\s+$/g, '');
			}			
		}
		$('comments_list').innerHTML = jSonObj.comments_text;
	});
	return false;
}