function VisulandBrowserDetect(){
	this.isFirefox= function(){
		if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 
		  var ffversion=new Number(RegExp.$1) 
		  if (ffversion>=2) return true;
		}
	    return false;
	}

	this.isGoogleChrome=function(){
		return (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent));
	}

	this.isInternetExplorer=function(){
		return (/MSIE[\/\s](\d+\.\d+)/.test(navigator.userAgent));
	}
}
var visulandBrowserDetect=new VisulandBrowserDetect();



function Visuland(){
	
	this.currentPluginVersion="1.7"; 
	this.skin="default.skin"; // real5d.skin
	this.clientLanguage="eng"; // hun eng pol
	this.encodedLoginAndPassword=false;
	this.enterByLocationName=false; //If true then use location name instead of id
	this.domainName="visuland.com"; // the user can see the rooms in this tomain only
	this.loginDomain="visuland.com"; //usable for user autentication only 
	
	this.enter = function(login, password, locationId){
		
	    if (this.installed()){
	       var plugin=document.getElementById('vlPlugin');
	       if (plugin.valid){
		       if (this.encodedLoginAndPassword){	
			     plugin.startVisuland(" -enc_user=\""+login+"\" -enc_pass=\""+password+"\" -domain=\""+this.domainName+"\" -login_domain=\""+this.loginDomain+"\" -autojoinloc="+locationId+" -language="+this.clientLanguage+" -skin="+this.skin);
		       }else{
				 plugin.startVisuland(" -user=\""+login+"\" -pass=\""+password+"\" -domain=\""+this.domainName+"\" -login_domain=\""+this.loginDomain+"\" -autojoinloc="+locationId+" -language="+this.clientLanguage+" -skin="+this.skin);  
		       }
	       }
	    }else{
		  var locStr=this.enterByLocationName?("&locname="+locationId):("&locid="+locationId);	
		  var passwd=this.encodedLoginAndPassword?("&enc_password="+escape(password)):("&password="+escape(password));
		  var loginStr=this.encodedLoginAndPassword?("&enc_login="+escape(login)):("&login="+escape(login));
		  document.location="http://visuland.com/servlet/launcherdownload2?skin="+this.skin+locStr+loginStr+passwd+"&domain="+this.domainName;
	    }
	}
	
	this.enterEmpty = function(locationId){
		var plugin=document.getElementById('vlPlugin');
	    if (plugin.valid){
	    	var locIdParam=(locationId==0?"":("-autojoinloc="+locationId));
		   plugin.startVisuland(" -domain=\""+this.domainName+"\" -login_domain=\""+this.loginDomain+"\" "+locIdParam+" -language="+this.clientLanguage+" -skin="+this.skin);
	    }else{
	     
		  var locStr=locationId==this.enterByLocationName?("&locname="+locationId):("&locid="+locationId);	
		  if (locationId==0){
		    locStr="";
		  }
		  var passwd="";
		  var loginStr="";
		  document.location="http://visuland.com/servlet/launcherdownload2?skin="+this.skin+locStr+loginStr+passwd+"&domain="+this.domainName;+"&login_domain="+this.loginDomain;
	    }
	}
	

	this.enterGuest = function (nick, gender,locationId){
		var plugin=document.getElementById('vlPlugin');
	    if (plugin.valid){
		  plugin.startVisuland(" -gender=\""+gender+"\" -nick=\""+nick+"\" -login_domain=\""+this.loginDomain+"\" -autojoinloc="+locationId+" -language="+this.clientLanguage+" -skin="+this.skin);  
		}else{
		  var locStr=this.enterByLocationName?("&locname="+locationId):("&locid="+locationId);
	  	  document.location="http://visuland.com/servlet/launcherdownload2?skin="+this.skin+locStr+"&gender="+gender+"&nick="+escape(nick)+"&login_domain="+this.loginDomain;
		}
	}
	
	this.installed = function(){
		//return document.getElementById('vlPlugin').valid;
	   if (window.ActiveXObject) { // IE
		    var plugin=false;
		    try {
		     plugin=new ActiveXObject("Weblords.vlplugin");
		    } catch (e) {
		    // alert("plugin not installed");
		     return false;
		    }
		    var version=false;
		    if(plugin) {
		     try {
		      version = plugin.version;
		      //alert("IE plugin installed - no version");
		     } catch (e) {
		      version=true;
		       return true;
		     }
		    }
		    return version;
		   } else
		   if (navigator.plugins) { // !IE
		    var mimeType="application/x-vlobject";
		    var name="VLPlugin";
		    if (typeof(navigator.plugins[name])!="undefined") {
		     var re=/([0-9.]+)\.dll/; // look for the version at the end of the filename, before dll     
		     // Get the filename
		     var filename=navigator.plugins[name].filename;
		     // Search for the version
		     var fnd=re.exec(filename);
		     if (fnd===null) { // no version found
		      return true; // plugin installed, unknown version
		     } else {
		    	 return true;
		      return fnd[1]; // plugin installed, returning version
		      return true;
		     }
		    }
		    return false;
		
		 }
	}
	
	
}

var visuland= new Visuland();






