/***********************************************************/
/*                  Begin image preloading class           */
/***********************************************************/
//used to preload images 
//reload the page after all images are loaded or the timeout expires
function ImagePreloading(){
    this.initImages();
}

ImagePreloading.prototype.initImages = function(){
	this.yourImages = new Array();
	this.maxTimeout = 1001; //timpul dupa care daca una dintre poze daca nu se incarca sa treaca la urmatoarea
	this.passTimeout = 150; //timpul de timeout la fiecare pass de verificare
	//if (document.images) {
	this.preImages = new Array();
	this.loaded = new Array();
	this.i;
	this.timerID;
	this.currCount = 0;
	this.currImage = 0;
	this.currTimeout = 0; 
}

ImagePreloading.prototype.loadImagesAsync = function(images_names, callback){
 window.yourImages = images_names;
 var dt=new Date().getTime();
 for (this.i = 0; this.i < window.yourImages.length; this.i++) { 
  this.preImages[this.i] = new Image();
  this.preImages[this.i].src = window.yourImages[this.i]+"&d="+dt;
 }
 for (this.i = 0; this.i < this.preImages.length; this.i++) { 
  this.loaded[this.i] = false;
 }
 this.checkLoad(callback);
};

ImagePreloading.prototype.loadImages = function(images_names){
	this.loadImagesAsync(images_names, null);
}

ImagePreloading.prototype.checkLoad = function(callback) {
 if (this.currCount >= this.preImages.length) {
  this.initImages();
  if(callback)
	callback();
  else  window.location.reload();
  return;
 }
 for (this.i = 0; this.i < this.preImages.length; this.i++) {
  if (this.loaded[this.i] === false && this.preImages[this.i].complete) {
   this.loaded[this.i] = true;
   this.currCount++;
  }
 }
 
 if(this.currImage < this.currCount){
  this.currImage = this.currCount; 
  this.currTimeout = this.passTimeout;
 }else{
  this.currTimeout = this.currTimeout + this.passTimeout;
 }
 if( (this.currTimeout - this.passTimeout) >= this.maxTimeout){
  this.loaded[this.currCount] = true;
  this.currCount++;
 }
 var self = this;
 this.timerID = window.setTimeout(function(){self.checkLoad(callback);},this.passTimeout);
};
/***********************************************************/
/*                  End image preloading class             */
/***********************************************************/


EvolverSSOHandle.strSSOWebServiceUrl			= "/SSOWebservice/Service.asmx";
EvolverSSOHandle.strSSOWebServiceAuthMethod		= "EVOSSOLoginUser";
EvolverSSOHandle.strSSOWebServiceLogoutMethod	= "EVOSSOLogout";			
EvolverSSOHandle.strSSOWebServiceGetDataMethod	= "EVOSSOGetAllUserDataSpecCookie";
function EvolverSSOHandle(){
    
}

EvolverSSOHandle.prototype.getUserInformation = function(cookieVal){ 
    var UseSoap = true;
    var Params = new SOAPClientParameters();
	Params.add('cookieVal',cookieVal);
    var r = SOAPClient.invoke (UseSoap, EvolverSSOHandle.strSSOWebServiceUrl, EvolverSSOHandle.strSSOWebServiceGetDataMethod, Params, false, null );
    return r;
}

EvolverSSOHandle.prototype.authentificateUser = function(user, pass, boolKeepLoggedIn){
    var UseSoap = true;
    var Params = new SOAPClientParameters();
    Params.add("login", user);
	Params.add("pass", pass);
	if(boolKeepLoggedIn==true)
	    Params.add("permLogin","1");
	else Params.add("permLogin","0");
	
	var r = SOAPClient.invoke (UseSoap, EvolverSSOHandle.strSSOWebServiceUrl, EvolverSSOHandle.strSSOWebServiceAuthMethod, Params, false, null );
	return r;
}

EvolverSSOHandle.prototype.logoutUser = function(){
    var UseSoap = true;
    var Params = new SOAPClientParameters();
    var r = SOAPClient.invoke (UseSoap, EvolverSSOHandle.strSSOWebServiceUrl, EvolverSSOHandle.strSSOWebServiceLogoutMethod, Params, false, null );
    return r;
}

var UseEvolverSSOSwitch = true;