﻿function slideshow(){
    var cur_pic=Math.floor(Math.random()*5)+1;
	if ( document.getElementById('img'+1) != null){
		document.getElementById('img'+1).style.display='none';
	}    
	if ( document.getElementById('img'+2) != null){
		document.getElementById('img'+2).style.display='none';
	}
	if ( document.getElementById('img'+3) != null){
		document.getElementById('img'+3).style.display='none';
	}
	if ( document.getElementById('img'+4) != null){
		document.getElementById('img'+4).style.display='none';
	}
	if ( document.getElementById('img'+5) != null){
		document.getElementById('img'+5).style.display='none';
	}
	if ( document.getElementById('img'+cur_pic)){
		document.getElementById('img'+cur_pic).style.display='block';
		document.getElementById('border_for_frame').style.display = 'block';
	}  
	if ( document.getElementById('swf'+1) != null){
		document.getElementById('swf'+1).style.display='none';
	}    
	if ( document.getElementById('swf'+2) != null){
		document.getElementById('swf'+2).style.display='none';
	}
	if ( document.getElementById('swf'+3) != null){
		document.getElementById('swf'+3).style.display='none';
	}
	if ( document.getElementById('swf'+4) != null){
		document.getElementById('swf'+4).style.display='none';
	}
	if ( document.getElementById('swf'+5) != null){
		document.getElementById('swf'+5).style.display='none';
	}
	if ( document.getElementById('swf'+cur_pic)){
		document.getElementById('swf'+cur_pic).style.display='block';
		document.getElementById('border_for_frame').style.display = 'none';
	}	
}

//function random_id(){
//		var cur_pic=Math.floor(Math.random()*5)+1;
//    	document.getElementById('img'+cur_pic).style.display='block';
//	    document.getElementById('img'+cur_pic).style.cssText='filter:alpha(opacity=100);-moz-opacity:1;opacity:1';
//		return cur_pic;
//}

//function slideshow(){
//	var picture_delay = 4000; // in msec
//    var opacity_delay = 2; // in msec
//    var min_opacity_step = 0;
//    var max_opacity_step = 50;
//    // pictures array
//    var arr_div_pic = new Array();
//    var arr_slides = document.getElementsByTagName('DIV');
//	var div_cnt = 0;
//    for (var i = 0; i < arr_slides.length; i++){
// 		try{
// 			// take only div, which contain slideshow pictures
// 			if(arr_slides[i].getAttribute('type') == 'slideshow'){
// 		                arr_div_pic[div_cnt] = arr_slides[i];
// 				div_cnt++;
// 			}
// 		}catch(e){}
//     }
//     // array of start image style
//     var arr_startStyle = new Array();
//     var count_pic = arr_div_pic.length;
//     
//     //var cur_pic=Math.floor(Math.random()*5);
//     //alert(cur_pic);
//     for (var i = 0; i < count_pic; i++){
//     		for(var j = 0; j < arr_div_pic[i].childNodes.length; j++){
//            	
//            	if (arr_div_pic[i].childNodes[j].nodeType==1 && arr_div_pic[i].childNodes[j].nodeName.toUpperCase()=='IMG'){
//            	    arr_div_pic[i]=arr_div_pic[i].childNodes[j];
//                	break;
//                }
//                
//            }
//			arr_startStyle[i] = arr_div_pic[i].style.cssText;
//			
//		}
//		
//    //var cur_pic=Math.floor(Math.random()*5);
//    
//    function show_img(step, next_pic) {
//		try{
//        	arr_startStyle[next_pic] = arr_startStyle[next_pic].replace(/none/,'block');
//            var trans1 = parseFloat(step)/max_opacity_step;
//            var trans2 = 1-(parseFloat(step)/max_opacity_step);
//            var transPattern1 = "; filter:alpha(opacity="+Math.round(100*trans1)+");-moz-opacity:"+trans1+";opacity:"+trans1+";";
//            var transPattern2 = "; filter:alpha(opacity="+Math.round(100*trans2)+");-moz-opacity:"+trans2+";opacity:"+trans2+";";
//            arr_div_pic[cur_pic].style.cssText = arr_startStyle[cur_pic] + transPattern1;
//            arr_div_pic[next_pic].style.cssText = arr_startStyle[next_pic] + transPattern2;
//            if(step > min_opacity_step){
// 			  // while opacity is not 0
//             	step--;
// 			  	delay = opacity_delay;
//			}else{
// 			  // if opacity is 0 - change pictures pair
// 				arr_div_pic[cur_pic].style.cssText = arr_startStyle[cur_pic].replace(/block/,'none');
// 				arr_startStyle[cur_pic] = arr_startStyle[cur_pic].replace(/block/,'none');
// 				cur_pic = next_pic;
//             	if ((next_pic+1) < count_pic)
//                	next_pic++;
//				else
//                	next_pic = 0;
//				step = max_opacity_step;
// 				delay = picture_delay;
//             }
//             setTimeout(function(){show_img(step, next_pic)}, delay);
//         }catch(e){}
//    }
//    
//    var cur_pic = random_id()-1;
//	
//	setTimeout(function(){show_img(max_opacity_step, (cur_pic+1))}, picture_delay);
//}