﻿
/*
   fotky auta
*/

// otevre okno s originalni velikosti fotky
function foto_show_big(auto_id, act_id) {
	var f_arr = eval("foto_arr_" + auto_id);
	var f_act_id = act_id > -1 ? act_id : eval("foto_act_id_" + auto_id);
	var f_path = eval("foto_path_" + auto_id);
	var wf = window.open("", "car_foto", "resizable=1,width=640,height=480,top="+
			+ ((screen.height - 480) / 2) + ",left=" + ((screen.width - 640) / 2));
	wf.document.open();
	wf.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
		+ '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"><head>'
		+ '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Foto</title>'
		+ '<link rel="STYLESHEET" type="text/css" href="/i/css/screen.css"></head>'
		+ '<body style="background-color: #007757;"><img src="' + f_path + "big/" + f_arr[f_act_id] + '" border="0" width="640" '
		+ 'height="480" onClick="window.close()" style="cursor:pointer;" onclick="window.close()">');

	if (f_arr.length > 1 && f_act_id > 0)
		wf.document.write('<div style="position:absolute;right:45px;bottom:10px; background-color: #007757;"'
			+ '	class="button-right list-nav" onClick="document.body.style.cursor=\'wait\';'
			+ 'opener.foto_show_big('+auto_id+','+(f_act_id - 1)+')" title="předchozí fotografie">'
			+ '<div class="button-inner"><div class="buttontext" align=center>&lt;&lt;</div></div></div>');

	if (f_arr.length > 1 && f_act_id < f_arr.length - 1)
		wf.document.write('<div style="position:absolute;right:10px;bottom:10px; background-color: #007757;"'
			+ '	class="button-right list-nav" onClick="document.body.style.cursor=\'wait\';'
			+ 'opener.foto_show_big('+auto_id+','+(f_act_id + 1)+')" title="další fotografie">'
			+ '<div class="button-inner"><div class="buttontext" align=center>&gt;&gt;</div></div></div>');

	wf.document.write('</div></body></html>');
	wf.document.close();
	wf.focus();
	return void(0);
}


// event handler na nacteni fotky auta v dokumentu - zmeni kursor na normalni pointer
function foto_loaded() {
	document.body.style.cursor = 'auto';
}

// zabrazi v strance predchazejici fotku auta
function foto_next(auto_id) {
	var f_arr = eval("foto_arr_" + auto_id);
	var f_act_id = eval("foto_act_id_" + auto_id);
	var f_img = document.getElementById("foto_" + auto_id);
	var f_newxt_butt = document.getElementById("foto_next_" + auto_id);
	var f_path = eval("foto_path_" + auto_id);

	if (f_act_id < f_arr.length - 1) {
		document.body.style.cursor = 'wait';
		f_img.src = f_path + "small/" + f_arr[f_act_id + 1];
		document.getElementById("foto_number_" + auto_id + "_" + f_act_id).className = 'foto-number-off';
		document.getElementById("foto_number_" + auto_id + "_" + (f_act_id + 1)).className = 'foto-number-on';
		document.getElementById("foto_prev_" + auto_id).style.visibility = 'visible';
		if (f_act_id == f_arr.length - 2) {
			document.getElementById("foto_next_" + auto_id).style.visibility = 'hidden';
		}
		eval("foto_act_id_" + auto_id + "++");
	}
	return void(0);
}

// zabrazi v strance nasledujici fotku auta
function foto_prev(auto_id) {
	var f_arr = eval("foto_arr_" + auto_id);
	var f_act_id = eval("foto_act_id_" + auto_id);
	var f_img = document.getElementById("foto_" + auto_id);
	var f_newxt_butt = document.getElementById("foto_next_" + auto_id);
	var f_path = eval("foto_path_" + auto_id);

	if (f_act_id > 0) {
		document.body.style.cursor = 'wait';
		f_img.src = f_path + "small/" + f_arr[f_act_id - 1];

		document.getElementById("foto_number_" + auto_id + "_" + f_act_id).className = 'foto-number-off';
		document.getElementById("foto_number_" + auto_id + "_" + (f_act_id - 1)).className = 'foto-number-on';

		document.getElementById("foto_next_" + auto_id).style.visibility = 'visible';
		if (f_act_id == 1) {
			document.getElementById("foto_prev_" + auto_id).style.visibility = 'hidden';
		}
		eval("foto_act_id_" + auto_id + "--");
	}
	return void(0);
}

// zabrazi v strance konkretni fotku auta danou jejim poradovym cislem
function foto_switch(auto_id, new_foto_id) {
	var f_arr = eval("foto_arr_" + auto_id);
	var f_act_id = eval("foto_act_id_" + auto_id);
	var f_img = document.getElementById("foto_" + auto_id);
	var f_newxt_butt = document.getElementById("foto_next_" + auto_id);
	var f_path = eval("foto_path_" + auto_id);

	document.body.style.cursor = 'wait';
	f_img.src = f_path + "small/" + f_arr[new_foto_id];

	document.getElementById("foto_number_" + auto_id + "_" + f_act_id).className = 'foto-number-off';
	document.getElementById("foto_number_" + auto_id + "_" + new_foto_id).className = 'foto-number-on';

	document.getElementById("foto_next_" + auto_id).style.visibility = 'visible';
	if (new_foto_id == 0) {
		document.getElementById("foto_prev_" + auto_id).style.visibility = 'hidden';
	} else {
		document.getElementById("foto_prev_" + auto_id).style.visibility = 'visible';
	}
	if (new_foto_id == f_arr.length - 1) {
		document.getElementById("foto_next_" + auto_id).style.visibility = 'hidden';
	} else {
		document.getElementById("foto_next_" + auto_id).style.visibility = 'visible';
	}

	eval("foto_act_id_" + auto_id + "=" + new_foto_id);

	document.body.style.cursor = 'default';
	return void(0);
}



