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 popup_whatsnew(){
	if(tutorial_win)tutorial_win.close();
    tutorial_win = new Window('whatsnew', {maximizable: false, resizable: false, minimizable: false, className: "tutorial_simplify", width: 700, height: 525, destroyOnClose: true});
    tutorial_win.setContent('inner_img_whatsnew');	
	tutorial_win.setZIndex(88);
    $('inner_img_whatsnew').show();
	tutorial_win.showCenter(true);
}

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.showCenter(true);
}
myObserver = {
	onDestroy: function(eventName, win) {
		try{
	  var file_prefix = "";
	  if( win.getId() == "whatsnew"){
		file_prefix = "whats_new_";
	  }
		
	  var img_id = win.getContent().firstChild.id;
	  $('root').appendChild($(img_id));
	  $(img_id).hide();
	  tutorial_index = 1;
	  $('tutorial_next'+file_prefix).show();
	  try{$('account').hide();}catch(err){}
	  $('tutorial_previous'+file_prefix).style.visibility = "hidden";
	  $("tutorial_image"+file_prefix).src = "/images/slideshow/simplify/" + file_prefix + tutorial_index + ".jpg";}catch(err){}
	}
}
Windows.addObserver(myObserver);
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");
		}
	});
});