var tutorial_win = null;
var tutorial_index=1;


function tutorial_next(prefix, max_num) {
	if(typeof max_num == "undefined"){
		max_num = 8;
	}
	if(typeof prefix == "undefined"){
		prefix = "";
	}
   ++tutorial_index;

   $('tutorial_previous'+prefix).style.visibility = "visible";
   $("tutorial_image"+prefix).src = "/images/slideshow/simplify/" + prefix + tutorial_index + ".jpg";
    if(tutorial_index==max_num){
	  //try{$('account').style.display='block';}catch(err){}
	  $('tutorial_next'+prefix).hide();
	  return;
	}
}

function tutorial_prev(prefix) {
	if(typeof prefix == "undefined"){
		prefix = "";
	}
   --tutorial_index;
	document.getElementById('tutorial_next'+prefix).style.display='inline';
   $("tutorial_image"+prefix).src = "/images/slideshow/simplify/" +prefix+ tutorial_index + ".jpg";
   try{$('account').hide();}catch(err){}
   $('tutorial_next'+prefix).show();
   if(tutorial_index==1){
	  $('tutorial_previous'+prefix).style.visibility = "hidden";
	  return;
   }
}


function simplify_em_tutorial_popup(){
	if(tutorial_win)tutorial_win.close();
    tutorial_win = new Window('tutorial', {maximizable: false, resizable: false, draggable: false, minimizable: false, className: "tutorial_simplify", width: 700, height: 525, left:0, top:0, destroyOnClose: true});
    tutorial_win.setContent('inner_img_simplify');	
	tutorial_win.setZIndex(88);
    $('inner_img_simplify').show();
  
  tutorial_win.setCloseCallback(function() {
	  var img_id = tutorial_win.getContent().firstChild.id;
	  
	  document.body.appendChild($(img_id));
	  $(img_id).hide();
	  tutorial_index = 1;
	  
	  try{$('account').hide();}catch(err){}
	  
	  $('tutorial_next').show();
	  $('tutorial_previous').style.visibility = "hidden";
	  $("tutorial_image").src = "/images/slideshow/simplify/" + tutorial_index + ".jpg";
	  
	  return true;
	});
	  
	tutorial_win.showCenter(true);
}

Event.observe(window, "load", function(){
	$$(".tutorial_nav_btn").each(function(button) {
		button.onmouseover = function(){
			this.addClassName("tutorial_nav_btn_hover");
		}
		button.onmouseout = function(){
			this.removeClassName("tutorial_nav_btn_hover");
		}
	});
});
