function logoutFunction() {
    if ( $('stopWidget')){
        	stopClick();
     }
     if (navigator.userAgent.indexOf("Firefox") == -1 && navigator.userAgent.indexOf("Safari") == -1) {
		g_isPostBack = true;
	}
  	document.logout.submit();
}

function esLoginValido() {
    var userID = document.getElementById('userID').value;
    var password = document.getElementById('password').value;
    var esValido = true;

    if (userID=='' || password=='') {
        esValido = false;
    }
    return esValido;
}

function userIDTBW_onFocus(){
    if ($('userID').value == "Rogomo ID")
        $('userID').value="";
}
function userIDTBW_onClick(){
    if ($('userID').value == "Rogomo ID")
        $('userID').value="";
}
function userIDTBW_onBlur(){
    if ($('userID').value == "")
        $('userID').value="Rogomo ID";
}

function passwordTBW_onFocus(){
    $('password').value="";
}
function passwordTBW_onClick(){
    $('password').value="";
}
function passwordTBW_onBlur(){
    if ($('password').value == "")
        $('password').value="******";
}

function quickView(){
    $('quickViewForm').submit();
}



function view(name){
    $('studentInput').value = name;
}


function startSelling(){
    var elem = $('startSelling');
    if ($('sessionStatus')) {
        if($F('sessionStatus') == ""){
            return true;
        }
        else{
                if ($F('sessionStatus') == "Negotiation")             {
                    new Ajax.Request("/private/readyToClean.htm" + paramString,{
                        asynchronous:false
                    });
                    elem.setAttribute("href","/private/selling.htm");
                }
                else if ($F('sessionStatus') == "Live Session") {
                    if (getTimerPE != null)
                            getTimerPE.stop();
                    new Ajax.Request("/private/stopTimer.htm" + paramString + "&forceStop=true",{
                        asynchronous:false
                    });
                }

        }
    }
    else{
        return true;
    }
}

function filterBookmarks(child){ 
	changeDisplay();
    new Ajax.Request("/child/bookmarkFilter.htm",{
    	parameters: {idChild:child, visible: $('submenu').style.visibility},
        evalScripts: true,
        onComplete: function(transport) {        	
        	$('tutorMenu').update(transport.responseText);        	        	
        	//buildsubmenus_horizontal();        	                	
        }
    });    
}

function refreshMenu(child){
    new Ajax.Request("/child/refreshMenu.htm",{
    	parameters: {idChild:child},
        evalScripts: true,
        
        onComplete: function(transport) {
        	//Pongo la inversa, para ocultar el submenu con la funcion changeDisplay de filterBookmarks
    		document.getElementById('submenu').style.visibility="visible";
    		$('studentMenu').update(transport.responseText);
    		filterBookmarks(child);
    		buildsubmenus_horizontal();    		
        }
    });    
}

function changeDisplay(){
		var o = document.getElementById('submenu');
      	var state = o.style.visibility;
		if (state == "visible")
			o.style.visibility="hidden";
		else
			o.style.visibility="visible";
}

/*SlideShow*/
function Slideshow(slideshow, timeout) {
 this.slides = [];
 var nl = $(slideshow).getElementsByTagName('div');
 for (var i = 0; i < nl.length; i++) {
   if (Element.hasClassName(nl[i], 'slide')) {
     this.slides.push(nl[i]);
   }
 }
 this.timeout = timeout;
 this.current = 0;

 for (var i = 0; i < this.slides.length; i++) {
   this.slides[i].style.zIndex = this.slides.length - i;
 }

 Element.show(slideshow);
 setTimeout((function(){this.next();}).bind(this), this.timeout + 850);
}

Slideshow.prototype = {
 next: function() {
   for (var i = 0; i < this.slides.length; i++) {
     var slide = this.slides[(this.current + i) % this.slides.length];
     slide.style.zIndex = this.slides.length - i;
   }

   Effect.Fade(this.slides[this.current], {
     afterFinish: function(effect) {
       effect.element.style.zIndex = 0;
       Element.show(effect.element);
       Element.setOpacity(effect.element, 1);
     }
   });
      this.current = (this.current + 1) % this.slides.length;
   setTimeout((function(){this.next();}).bind(this), this.timeout + 850);
 }
} 