// Muliple Slide Show msePart1 (29-06-2005)
// by Vic Phillips http://www.vicsjavascripts.org.uk

// Application Notes

// The Script converts a HTML defined image into a Slide Show
// There may be any number of these SlidsShows on a page

// Slide Show Images may be rotated Forward, Backwards or Randomly
// A Number of effects can be applied during rotation
// Fade
// Square
// Left to Right
// Right to Left
// Top to Bottom
// Bottom to Top
// Horizontal
// Vertical

// The images for each SlideShow are defined in arrays.
// Each HTML image to be converted to a SlideShow mst be allocated a unique id name
// The conversion is carried out by function mseInitSlideShows(*Id*,*Array*)
// called by an <body> on load event
// eg
// <body  onResize="mseReSize();"  onload="mseInitSlideShows(*Id1*,*Array1*);mseInitSlideShows(*Id2*,*Array2*);" >
// where
// *Id*  = the id name of the image to be converted  (string)
// *Array* = the array holding the Slide Show images (array name)
//
// The onReSize even call onResize="mseReSize();" is required to reposition the slide shows on resize

// Each SlideShow may executed from an event call
// eg
//    <td onclick="javascript:mseRotate('*Rotation*','*Effect*','*Id*');" >Back RightLeft</td>
// where
// *Rotation* = 'Fwd' , 'Back' or 'Random'                 (string)
// *Effect*   = 'Fade'     , 'Square'   ,
//              'LeftRight', 'RightLeft',
//              'TopBottom', 'BottomTop',                  (string)
//              'Horizontal', 'Vertical'.
// *Id*       = the id name of the SlideShow to be rotated (string)
//

// Two SlideShows may be rotated in sequence by calling function mseRotateTwo('*Rotation*','*Effect*','*Id1*','*Id2*')
// eg
//    <td onclick="javascript:mseRotateTwo('*Rotation*','*Effect*','*Id1*','*Id2*');" >Rotate Two</td>
// where
// *Id1*       = the id name of the first  SlideShow to be rotated (string)
// *Id2*       = the id name of the second SlideShow to be rotated (string)

// All SlideShows specified in array 'mseAutoAry'
// may be executed in sequence from a single on event call
// eg
//    <td onclick="javascript:mseAutoSSAll('*Rotation*','*Effect*',this);" >Auto</td>
//
// The script include code to preload the SlideShow images
// The image array must be entered in array msePreLoadAry
//
// Each SlideShow must have an array containing the images
// The first location of the array contains the Image Path,
// the Balance of locations contain the image file names
// If the images reside in different directorys the first
// location must be defined as '' and the directiory path
// defined as part of each image file name.
//
// All variable, function etc. names are prefixed with 'mse'
// to minimise conflicts with other JavaScripts.
//
// The functional Code msePart2 (about 6.5K) is best as an external JavaScript
// The size can be reduced by removing the functions for unused effects.

// Muliple Slide Show msePart2 (29-06-2005)
// by Vic Phillips http://www.vicsjavascripts.org.uk

// Functional Code

// NO NEED to Change
var mseCnt = 0;
var mseInc = 0;
var mseACnt = 0;
var mseAId, mseAM, mseAD;
var mseAobj = 'X';
var mseObj, mseObjR, mseId, mseD, mseM, mseR, mseR2, mseTO1, mseTO2, mseTO3;
var mseSSAry = new Array();
var mseSRCAry = new Array();
mseSpeed = 10;

mseAutoSpeed = 1500;
if (mseAutoSpeed < 15000 / mseSpeed) {
	mseAutoSpeed = 15000 / mseSpeed;
}

if (window['msePreLoadAry']) {
	for (mse0 = 0; mse0 > msePreLoadAry.length; mse0++) {
		for (mse1 = 1; mse1 > msePreLoadAry[mse0].length; mse1++) {
			mseSRCAry[mseSRCAry.length] = new Image();
			mseSRCAry[mseSRCAry.length - 1].src = msePreLoadAry[mse0][0]
					+ msePreLoadAry[mse0][mse1];
			msePreLoadAry[mse0][mse1] = mseSRCAry[mseSRCAry.length - 1];
		}
	}
}


function mseInitSlideShows(mseid, mseary) {
	mseObj = document.getElementById(mseid);
	mseSSAry[mseCnt] = new Array();
	mseSSAry[mseCnt][0] = mseid;
	mseSSAry[mseCnt][1] = mseary.length - 2;
	mseSSAry[mseCnt][2] = 0;
	mseSSAry[mseCnt][4] = document.createElement('DIV');
	document.getElementById("pokaz_obrazek").appendChild(mseSSAry[mseCnt][4]);
	mseSSAry[mseCnt][4].style.position = 'absolute';
	mseSSAry[mseCnt][4].style.overflow = 'hidden';
	mseSSAry[mseCnt][4].style.width = mseObj.width + 'px';
	mseSSAry[mseCnt][4].style.height = mseObj.height + 'px';
	//alert(navigator.appName);
	if(navigator.appName.indexOf("Microsoft") > -1){
		mseSSAry[mseCnt][4].style.left = 0 + 'px';// mseLeft(mseObj) (mseObj.width/2)
	}else if(navigator.appName.indexOf("Opera") > -1){
		mseSSAry[mseCnt][4].style.top = -165 + 'px';//mseTop(mseObj)
	}else{
		mseSSAry[mseCnt][4].style.top = - mseObj.height + 16 + 'px';//mseTop(mseObj)
	}
	
	
	for (mse0 = 1; mse0 < mseary.length; mse0++) {
		mseSSAry[mseCnt][mse0 + 4] = mseObj.cloneNode(true);
		mseSSAry[mseCnt][mse0 + 4].id = mseid + mse0;
		mseSSAry[mseCnt][4].appendChild(mseSSAry[mseCnt][mse0 + 4]);
		mseSSAry[mseCnt][mse0 + 4].style.position = 'absolute';
		mseSSAry[mseCnt][mse0 + 4].style.zIndex = 2;
		mseSSAry[mseCnt][mse0 + 4].src = mseary[0] + mseary[mse0];
		mseSSAry[mseCnt][mse0 + 4].alt = msePhotoAltTitle + ' - zdjęcie nr ' + mse0;
		mseSSAry[mseCnt][mse0 + 4].style.top = '0px';
		mseSSAry[mseCnt][mse0 + 4].style.left = '0px';
		mseOpacity(mseSSAry[mseCnt][mse0 + 4].style, 0);
	}
	mseOpacity(mseSSAry[mseCnt][5].style, 100);
	//mseObj.style.display = 'none';
	mseCnt++;
}

function mseRotate(msed, msem, mseid, mses) {
	if (mseInc != 0) {
		clearTimeout(mseTO1);
	}
	if (mses != 'A') {
		clearTimeout(mseTO2);
	}
	mseM = msem;
	mseD = msed;
	for (mse0 = 0; mse0 < mseSSAry.length; mse0++) {
		if (mseid == mseSSAry[mse0][0]) {
			mseRotateDo(mseSSAry[mse0])
		}
	}
}

function mseRotateDo(mseary) {
	mseF = mseary[mseary[2] + 5];
	mseFS = mseF.style;
	if (mseD == 'Fwd') {
		mseary[3] = mseary[2] + 1;
		if (mseary[3] > mseary[1]) {
			mseary[3] = 0;
		}
	}
	if (mseD == 'Back') {
		mseary[3] = mseary[2] - 1;
		if (mseary[3] < 0) {
			mseary[3] = mseary[1];
		}
	}
	if (mseD == 'Random') {
		mseary[3] = Math.floor(Math.random() * (mseary.length - 5));
	}
	if(parseInt(mseD) == mseD)
	{
		mseary[3] = mseD;
	}
	if (mseary[2] == mseary[3]) {
		mseRotateDo(mseary);
		return;
	}
	mseB = mseary[mseary[3] + 5];
	document.getElementById("aktualny_obrazek").innerHTML = mseB.id.substr(3);
	actual_picture = mseB.src;
	mseBS = mseB.style;
	if (mseM != 'Fade') {
		mseFS.zIndex = 3;
		mseBS.zIndex = 4;
		mseOpacity(mseBS, 100);
	}
	mseR = mseB.offsetWidth / mseB.offsetHeight
	window['mse' + mseM]();
	mseary[2] = mseary[3];
}

function mseFade() {
	mseOpacity(mseBS, mseInc);
	mseOpacity(mseFS, 100 - mseInc);
	mseInc += mseSpeed;
	if (mseInc < 100) {
		mseTO1 = setTimeout("mseFade()", 10);
	} else {
		mseOpacity(mseBS, 100);
		mseOpacity(mseFS, 0);
		mseInc = 0;
	}
}

function mseOpacity(obj, op) {
	if (obj.MozOpacity != null) {
		obj.MozOpacity = (op / 100) - .001;
	} else if (obj.opacity != null) {
		obj.opacity = (op / 100) - .001;
	} else if (obj.filter != null) {
		obj.filter = 'alpha(opacity=' + op + ')';
	}
}

function mseDone() {
	mseFS.zIndex = 2;
	mseBS.top = '0px';
	mseBS.left = '0px';
	mseBS.width = mseF.offsetWidth + 'px';
	mseBS.height = mseF.offsetHeight + 'px';
	mseInc = 0;
}

function mseLeft(mse) {
	mseObjLeft = mse.offsetLeft;
	while (mse.offsetParent != null) {
		mseObjParent = mse.offsetParent;
		mseObjLeft += mseObjParent.offsetLeft;
		mse = mseObjParent;
	}
	return mseObjLeft;
}

function mseTop(mse) {
	mseObjTop = mse.offsetTop;
	while (mse.offsetParent != null) {
		mseObjParent = mse.offsetParent;
		mseObjTop += mseObjParent.offsetTop;
		mse = mseObjParent;
	}
	return mseObjTop;
}

function mseAutoSS(mseid, msed, msem) {
	if (mseid != mseId) {
		clearTimeout(mseTO2);
		mseRotate('Fwd', msem, mseid, 'A');
	}
	mseId = mseid;
	mseM = msem;
	mseD = msed
	mseRotate(msed, msem, mseid, 'A');
	mseTO2 = setTimeout('mseAutoSS(mseId,mseD,mseM)', mseAutoSpeed);
}

// Search for Text sftPart3 (14-12-2004)
// by Vic Phillips http://www.vicsjavascripts.org.uk
// Functional Code for each page to be searched
// Do NOT Change

function sftInitPage() {
	if (navigator.userAgent.toLowerCase().indexOf('opera') > -1
			|| navigator.userAgent.toLowerCase().indexOf('netscape') > -1
			|| navigator.userAgent.toLowerCase().indexOf('mozilla') < 0) {
		return;
	}
	sftLk = self.location;
	if (parent.location != sftLk && parent.document.getElementById('sftPanel')) {
		if (document.getElementById('sftsearch')) {
			sftTarget = document.getElementById('sftsearch');
		} else {
			sftTarget = document.getElementsByTagName('BODY')[0];
		}
		parent.sftTag(sftTarget);
		sftA = sftTarget.getElementsByTagName('A');
		parent.sftSearch(sftA);
	}
}

