﻿	var img;
	var currentPicSize=2;
	var sBtnCaption1='<img src="images/look-small.gif" align="top" vspace="3" width="10" height="10"> גודל מקורי';
	var sBtnCaption2='<img src="images/look-small.gif" align="top" vspace="3" width="10" height="10"> גודל חלון';
	var sBtnCaption3='<img src="images/x-small.gif" align="top" vspace="3" width="10" height="9"> סגור'

	if (document.images){
		pic1= new Image(158,26); 
		pic1.src="images/pleasewait.gif"; 
		pic2= new Image(10,10);
		pic2.src="images/look-small.gif";
		pic3= new Image(10,9);
		pic3.src="images/x-small.gif";
		pic4= new Image(78,20);
		pic4.src="images/button1.gif";
		pic5= new Image(32,32); 
		pic5.src="images/pleasewait2.gif"; 

	}


	function SwitchPic(){
		if (currentPicSize==2){
			currentPicSize=1;
			document.getElementById('btnSwitch').innerHTML=sBtnCaption1;
			waitToLoad(document.frmPic.picBig.value);}
		else{
			currentPicSize=2;
			document.getElementById('btnSwitch').innerHTML=sBtnCaption2;
			waitToLoad(document.frmPic.picOriginal.value);}
	}

	function enlarge(e,filename,forceUpdate){
		if (filename=='') {return}
		document.getElementById('btnClose').innerHTML=sBtnCaption3;
		document.frmPic.picBig.value='images/data/Thumb450x350/' + filename + (forceUpdate?'?' + (new Date()).getTime():'');
		document.frmPic.picOriginal.value='images/data/Originals/'+filename + (forceUpdate?'?' + (new Date()).getTime():'');
		currentPicSize=2;
		box.style.left=e.clientX-465+document.body.scrollLeft;;
		box.style.top=e.clientY-10+document.body.scrollTop;
		box.style.display='block';
		SwitchPic();	


	}

	function waitToLoad(sSrc){ 
		document.getElementById('picSrc').src="images/pleaseWait.gif"
		img=new Image(); 
		img.errored=false; 
		img.onerror=new Function("img.errored=true"); 
		img.src=sSrc;
		wait();
	} 

	function wait(){
		if (img.complete || img.errored){ 			
			document.all.picSrc.src=img.src}
		else {
			setTimeout("wait()",200); }
	}


