var CIP_curNumb = null;

function photosShow ( numb ) {

	var tmp_params = CIP_arr[ numb ];
	if( tmp_params ) {
		var tmp_img = getElement( "CIP_popupImg" );
		//var tmp_img = window.CIP_popupImg;
		if( tmp_img ) {
			var img_preview = getElement( "galleryImg" + numb );
			if( img_preview ) {
				img_preview.onmouseover();
				img_preview.setAttribute( "hard_lock" , "yes" );
				}
			
			//tmp_img.src = tmp_params[ 0 ];
			//tmp_img.location.href = "/scripts/picture_preload.php?img=" + tmp_params[ 0 ];
			//if( ie5 && tmp_img.filters[0] ) {
			//	tmp_img.filters[0].Apply();
			//	}
			
			tmp_img.style.backgroundImage = "url(" + tmp_params[ 0 ] + ")";
			tmp_img.src = tmp_params[ 0 ];
			
			//tmp_img.src = tmp_params[ 0 ];
			if (getElement( "CIP_popupImgName" )) getElement( "CIP_popupImgName" ).innerHTML = tmp_params[ 1 ];
			CIP_curNumb = numb;
			photosNavInit( "CIP_popupPrev" , "CIP_popupNext" );
			
			var tmp_img_preload = new Image();
			tmp_img_preload.src = tmp_params[ 0 ];
			if( tmp_img_preload.width > 0 ) {
				photosShowSetBorder( tmp_img_preload );
				}
			else {
				tmp_img_preload.onload = function(){ photosShowSetBorder( tmp_img_preload , 'CIP_popupImgName' ) };
				}
				
			if( CIP_arr[ numb + 1] ) {
				var tmp_img_preload_next = new Image();
				tmp_img_preload_next.src = CIP_arr[ numb + 1][ 0 ];
				if( CIP_arr[ numb + 2] ) {
					var tmp_img_preload_next_next = new Image();
					tmp_img_preload_next_next.src = CIP_arr[ numb + 2][ 0 ];
					}
				}	
			}
		}
	}

function photosShowBig ( numb ) {

	var tmp_params = CIP_arr_big[ numb ];
	getElement( "BigImageContainer" ).style.display = 'block';
	if( tmp_params ) {
		var tmp_img = getElement( "CIP_popupBigImg" );
		//var tmp_img = window.CIP_popupImg;
		if( tmp_img ) {
			var img_preview = getElement( "galleryImg" + numb );
			if( img_preview ) {
				img_preview.onmouseover();
				img_preview.setAttribute( "hard_lock" , "yes" );
				}
			
			//tmp_img.src = tmp_params[ 0 ];
			//tmp_img.location.href = "/scripts/picture_preload.php?img=" + tmp_params[ 0 ];
			if( ie5 && tmp_img.filters[0] ) {
				tmp_img.filters[0].Apply();
				}
			
			tmp_img.style.backgroundImage = "url(" + tmp_params[ 0 ] + ")";
			tmp_img.src = tmp_params[ 0 ];
			
			//tmp_img.src = tmp_params[ 0 ];
			if (getElement( "CIP_popupBigImgName" )) { 
				getElement( "CIP_popupBigImgName" ).innerHTML = tmp_params[ 1 ];
				}
			CIP_curNumb = numb;
			photosNavInit( "CIP_popupBigPrev" , "CIP_popupBigNext" );
			
			var tmp_img_preload = new Image();
			tmp_img_preload.src = tmp_params[ 0 ];
			if( tmp_img_preload.width > 0 ) {
				photosShowSetBorder( tmp_img_preload );
				}
			else {
				tmp_img_preload.onload = function(){ photosShowSetBorder( tmp_img_preload , 'CIP_popupBigImgName' ) };
				}
				
			if( CIP_arr_big[ numb + 1] ) {
				var tmp_img_preload_next = new Image();
				tmp_img_preload_next.src = CIP_arr_big[ numb + 1][ 0 ];
				if( CIP_arr_big[ numb + 2] ) {
					var tmp_img_preload_next_next = new Image();
					tmp_img_preload_next_next.src = CIP_arr_big[ numb + 2][ 0 ];
					}
				}	
			}
		}
	}
	
function photosShowSetBorder( tmp_img_preload , el ) {
	var tmp_img = el;	
	if( tmp_img ) {
		tmp_img.width = tmp_img_preload.width;
		tmp_img.height = tmp_img_preload.height;		
		if( ie5 ) {
			if( tmp_img.filters[0] ) {
				tmp_img.filters[0].Play(duration=0.5);
				}
			}
		}
	}
	
function photosNavInit( prev_arrow , next_arrow ) {
	var tmp_prev = getElement( prev_arrow );
	var tmp_next = getElement( next_arrow );
	if( tmp_prev && tmp_next ) {

		tmp_prev.firstChild.src = "";
		tmp_next.firstChild.src = "";
		tmp_prev.firstChild.src = adress_short + ( CIP_curNumb > 0 ? "img/buttons/search_double_arrow_back.gif" : "img/s.gif" );
		tmp_next.firstChild.src = adress_short + ( CIP_curNumb < ( CIP_arr.length - 1 ) ? "img/buttons/search_double_arrow.gif" : "img/s.gif" );	
		}
	}

