﻿var time = 3000;
var default_time = time;
var timeout;
var timeout2;


function addOnloadEvent(){

  if ( typeof window.addEventListener != "undefined" ) {
    window.addEventListener( "load", initTO, false );
  }
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", initTO );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[initTO]();
      };
    }
    else {
      window.onload = initTO;
	}
}
}

// properties timeout (product_desc)

function initTO() {
	if(document.getElementById("md_ind_changeimg")) {
		var classname = document.getElementById("md_ind_changeimg").className;
		//alert(classname);
		var id = Number(classname.replace('fi',''));
		//alert(id);
		var imgli = document.getElementById("md_ind_changeimg").getElementsByTagName("img");
		for(var i=1; i<=imgli.length; i++) {
			document.getElementById('flash'+i).style.display = 'none';	
		}
		if (id == '') {
			var id = 1;
		}
		var idN = id + 1;
		if (imgli.length <= id) {
			var idN = 1;
		}
		//alert(idN);
		
		document.getElementById("md_ind_changeimg").className = "fi" + idN;
		document.getElementById('flash'+id).style.display = 'none';
		document.getElementById('flash'+idN).style.display = '';
		
		timeout = setTimeout("initTO()", time);
		
	}
}

//
addOnloadEvent();
