var pictures = new Array();

function swap_picture(what, where) {
	var x = document.getElementById(where);
	var key = where.split("_");


//	x.src = "/kwadrat/pictures/"+key[1]+"/small_c/"+what;
	alert(x.parentNode.title);
	pictures[key[1]] = what;
}

function spic(a_from) {
	//get target
	var a_to = document.getElementById('apicture_main');
	var img_to = (a_to.getElementsByTagName('img')[0]);
	
	//from img;	
	var img_from = (a_from.getElementsByTagName('img')[0]);

	var path_from = img_from.src.split('/');
	var picture_from = path_from[path_from.length-1];
	var path_to = img_to.src.slice(7);
	path_to = path_to.slice(path_to.indexOf('/'));
	//alert(path_to.slice(path_to.indexOf('/')));
	img_to.src = path_to.substr(0,  path_to.lastIndexOf('/')+1) + picture_from; //(img_to.src.substr(0,  img_to.src.lastIndexOf('/')+1) + picture_from);
	
	a_to.title = (a_from.title);

}

function mpic(a_from) {
	//get target
	var a_to = document.getElementById('apicture_main');

	var key = a_from.id.split("_")[1];
	
	//from img;	
	var img_from = (a_from.getElementsByTagName('img')[0]);

	var path_from = img_from.src.split('/');
	var picture_from = path_from[path_from.length-1];

	var div_resource = (document.getElementById('picr_'+key));
	var img_resource = (div_resource.getElementsByTagName('img')[0]);
	
	a_to.innerHTML = div_resource.innerHTML + "<br />"+ img_resource.alt;
	
//	var path_to = img_to.src.slice(7);
//	path_to = path_to.slice(path_to.indexOf('/'));
//	img_to.src = img_resource.src;
//	img_to.width = img_resource.width;
//	img_to.height = img_resource.height;
	
	
//	a_to.title = (a_from.title);

}

function show_picture(a_from) {
	var img_from = (a_from.getElementsByTagName('img')[0]);
	
	
	var path_from = img_from.src.split('/');
	path_from[path_from.length-2] = 'big';
	var picture_from = path_from[path_from.length-1];

	var big_pic = (path_from.join('/'));


	window_open ('picture.php?filename='+picture_from+'&id_offer='+(path_from[path_from.length-3]), "PICTURES", 800, 600);

/*      nw = window.open('', '','width=800,height=600,toolbar=no,directories=no,menubar=no,locations=no,status=no,scrollbars=yes,resizable=yes,fullscreen=no');
      nw.document.open();

		nw.document.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
      nw.document.writeln("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>");
      nw.document.writeln("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
      nw.document.writeln("<title>Kwadrat nieruchomosci</title>");
      nw.document.writeln("<style>html, body, table {background:#E4E8E8;	padding:  0;	margin:  0;	color: 		#3E3E3E;	font-family: 	Arial, Tahoma, Verdana, Helvetica, sans-serif;	font-size: 		16px;	vertical-align: top;} a {	color: #1D667D; text-decoration: none;}a:hover {	color: #3E3E3E; text-decoration: none;}</style>");
	  nw.document.writeln("<div style='display:none;'>"+document.getElementById('hidden_ones').innerHTML+"</div>");
      nw.document.writeln("</head><body>\n<div style='text-align: center'>\n<a href=\"#\" onclick=\"window.close()\">\n<img src=\""+big_pic+"\" border=\"0\" alt=\""+a_from.title+"\"/><br />"+a_from.title+"<br /><br /><br />Zamknij okno</a></div></body>");

      nw.document.writeln("</body>\n</html>\n");
      nw.document.close();
      nw.focus();
*/
      return;
	
}

function show_picture2(what) {
	var key = what.split("_");
	if (pictures[key[1]] == undefined) {
		var x = document.getElementById(what);
		path = x.src.split('/');
		pictures[key[1]] = path[path.length-1];
	}
	window_open ('picture.php?filename='+pictures[key[1]]+'&id_offer='+key[1], what, 700, 500);
}


function window_open(path, name, w, h) {
	window.open(path, name, 'width='+w+',height='+h+',resizable,scrollbars=yes,toolbar=no,status=yes,directories=no,menubar=no,location=no');
}


