/*******************/
/* piczapper.js    */
/* streeck.com     */
/*******************/
/* copyright       */
/* www.streeck.com */
/*******************/
/* Ver 5.2.2       */ /* depends on browsersniff.js */
/*   20050420.2300 */
/*******************/

document.writeln('<script type="text/javascript" src="piczapper.pz_list.js"><'+'/script>');

var pz_cur = 0;
var pz_min = 0;
var pz_max = 0;
var pz_img_cur = new Image();
var pz_img_next = new Image();
var pz_img_prev = new Image();
var ext_pic = ".jpg";
var ext_tn = ".tn.jpg";
var pz_max_width;
var pz_max_height;
var pz_mode = 1;

function pz_max_size_get()
{
	if (bs_ie)
	{
		areawidth  = document.body.offsetWidth;
		areaheight = document.body.offsetHeight;
	}
	else
	{
		areawidth = window.innerWidth;
		areaheight = window.innerHeight;
	}

	pz_max_width = areawidth - 24;
	pz_max_height = areaheight - 80;
}	

function pz_setheight(mode)
{
	imgwidth = pz_img_cur.width;
	imgheight = pz_img_cur.height;

	if (!mode)
		mode = pz_mode;

	switch (mode)
	{
		case 3: // ORIGINAL size
			document.images.picture.height = imgheight;
		break;
		case 2: // ENLARGE if it's too small (and shrink if it's too big)
			if ((imgwidth / imgheight) < (pz_max_width / pz_max_height)) 
				document.images.picture.height = pz_max_height // resising because of height
			else
				document.images.picture.height = imgheight * pz_max_width / imgwidth; // 'cause of width
		break;
		default: // SHRINK (case 1)
			if ((imgheight > pz_max_height) || (imgwidth > pz_max_width)) // only if it's too big
			{
				if ((imgwidth / imgheight) < (pz_max_width / pz_max_height)) 
					document.images.picture.height = pz_max_height // resising because of height
				else 
					document.images.picture.height = imgheight * pz_max_width / imgwidth; // 'cause of width
			}
			else
				document.images.picture.height = imgheight; // not too big
		break;
	}
}

function pz_prev_status(flag)
{
	if (flag == 1)
		document.getElementById("prev").className = "visible"
	else
		document.getElementById("prev").className = "hidden";
}

function pz_next_status(flag)
{
	if (flag == 1)
		document.getElementById("next").className = "visible"
	else
		document.getElementById("next").className = "hidden";
}

function pz_handle_resize()
{
	pz_max_size_get();
	pz_setheight();
}

function pz_handle_prev_enable()
{
	pz_prev_status(1);
}

function pz_handle_next_enable()
{
	pz_next_status(1);
}

function pz_handle_firstload()
{
	if (pz_list[pz_cur].mode)
		pz_setheight(pz_list[pz_cur].mode)
	else
		pz_setheight();
	document.images.picture.onload = null;
}

function pz_next()
{
	if (pz_cur < pz_max)
	{
		pz_img_prev.src = pz_img_cur.src;
		pz_img_cur.src = pz_img_next.src;
		pz_cur++;
		
		if (pz_list[pz_cur].mode)
			pz_setheight(pz_list[pz_cur].mode)
		else
			pz_setheight();

		document.images.picture.src = pz_img_cur.src;
		document.getElementById("text").firstChild.nodeValue = pz_list[pz_cur].text;

		if ((bs_opera) && (bs_vermajor < 8)) // makes opera <=7.5 work, don't know why
			pz_setheight();

		if (!(bs_opera) || ((bs_opera) && (bs_vermajor >= 8)))
			pz_next_status(0);
		if ((pz_cur+1) <= pz_max)
			pz_img_next.src = pz_list[(pz_cur+1)].file + ext_pic;
	}
}

function pz_prev()
{
	if (pz_cur > pz_min)
	{
		pz_img_next.src = pz_img_cur.src;
		pz_img_cur.src = pz_img_prev.src;
		pz_cur--;

		if (pz_list[pz_cur].mode)
			pz_setheight(pz_list[pz_cur].mode)
		else
			pz_setheight();

		document.images.picture.src = pz_img_cur.src;
		document.getElementById("text").firstChild.nodeValue = pz_list[pz_cur].text;

		if ((bs_opera) && (bs_vermajor < 8)) // makes opera <=7.5 work, don't know why
			pz_setheight();

		if (!(bs_opera) || ((bs_opera) && (bs_vermajor >= 8)))
			pz_prev_status(0);
		if ((pz_cur-1) >= pz_min)
			pz_img_prev.src = pz_list[(pz_cur-1)].file + ext_pic;
	}
}

function pz_mode_change()
{
	if (pz_mode < 3)
		pz_mode++
	else
		pz_mode = 1;
	switch (pz_mode)
	{
		case 1:
			document.getElementById("mode").src = document.getElementById("mode").src.replace(/original/, "shrink");
		break;
		case 2:
			document.getElementById("mode").src = document.getElementById("mode").src.replace(/shrink/, "enlarge");
		break;
		case 3:
			document.getElementById("mode").src = document.getElementById("mode").src.replace(/enlarge/, "original");
		break;
	}
	pz_setheight();
}

function pz_init()
{
	pz_max = pz_list.length - 1;
	pz_max_size_get();

	window.onresize = pz_handle_resize;
	if (!(bs_opera) || ((bs_opera) && (bs_vermajor >= 8)))
	{
		pz_img_prev.onload = pz_handle_prev_enable;
		pz_img_next.onload = pz_handle_next_enable;
		pz_prev_status(0);
		pz_next_status(0);
	}
	
	if (parent.window.location.search != "")
	{
		start = window.location.search;
		start = start.substr(1,start.length-1);
		pz_cur = parseInt(start);
	}

	pz_img_cur.src = pz_list[pz_cur].file + ext_pic;
	document.images.picture.onload = pz_handle_firstload;
	document.images.picture.src = pz_img_cur.src;
	document.getElementById("text").firstChild.nodeValue = pz_list[pz_cur].text;

	if ((pz_cur+1) <= pz_max)
		pz_img_next.src = pz_list[(pz_cur+1)].file + ext_pic;
	if ((pz_cur-1) >= pz_min)
		pz_img_prev.src = pz_list[(pz_cur-1)].file + ext_pic;
}

function pz_writecontrols(path)
{
	jspath = "'"+path+"'";
	document.writeln('<a href="javascript:pz_mode_change()"><img src="'+path+'piczapper.mode.shrink.png" width="30" height="30" title="Change mode (shrink/enlarge/original)" id="mode" class="left"/></a>');
	document.writeln('<a href="javascript:pz_info('+jspath+');"><img src="'+path+'piczapper.pz.png" width="30" height="30" class="right"/></a>');
	document.writeln('<a href="javascript:pz_prev();" id="prev"><img src="'+path+'piczapper.previous.png" width="30" height="30" title="Previous picture"/></a>');
	document.writeln('<a href="javascript:history.back();"><img src="'+path+'piczapper.up.png" width="30" height="30" title="Back to overview"/></a>');
	document.writeln('<a href="javascript:pz_next();" id="next"><img src="'+path+'piczapper.next.png" width="30" height="30" title="Next picture"/></a>');
}

function pz_tn()
{
	pz_max = pz_list.length - 1;

	for (pz_cur = 0; pz_cur <= pz_max; pz_cur++)
	{
		document.writeln('<a href="piczapper.html?'+pz_cur+'" title="'+pz_list[pz_cur].text+'"><img src="'+pz_list[pz_cur].file+ext_tn+'" alt="'+pz_list[pz_cur].text+'"/></a>');
	}
}

function pz_tn_part(start, end)
{
	pz_max = pz_list.length - 1;

	for (pz_cur = start; ((pz_cur<=end)&&(pz_cur<=pz_max)); pz_cur++)
	{
		document.writeln('<a href="piczapper.html?'+pz_cur+'" title="'+pz_list[pz_cur].text+'"><img src="'+pz_list[pz_cur].file+ext_tn+'" alt="'+pz_list[pz_cur].text+'"/></a>');
	}
	document.writeln('<br/>');
}

function pz_info(path)
{
	window.open(path+"piczapper.png","pzinfo","height=276,innerHeight=270,width=276;innerWidth=270");
}
