
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function GetBrowserName(){
	if(navigator.userAgent.toLowerCase().indexOf("opera") != -1){
		return "Opera";
	}else if(navigator.userAgent.toLowerCase().indexOf("gecko") != -1){
		return "Mozilla";
	}else if(navigator.userAgent.toLowerCase().indexOf("msie") != -1){
		return "IE";
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function CBrowserWindow(sURL, nWidth, nHeight){
	var sBrowserName = GetBrowserName();
	
	if(sURL.length)
		this.sURL = sURL;
		
	this.nWidth = 480;
	if(nWidth)
		this.nWidth = nWidth;
		
	this.nHeight = 360;
	if(nHeight)
		this.nHeight = nHeight;
		
	var sTempName = Math.round(Math.random() * 999999999);
	this.sWindowName = 'Window'+ sTempName.toString();
	this.nTop = (screen.height - this.nHeight) / 2 - 40;
	this.nLeft = (screen.width - this.nWidth) / 2;
	
	this.nResizable = 0;
	this.nMenubar = 0;
	this.nStatusBar = 0;
	this.nScrollBars = 0;
	this.nLocationBar = 0;
	this.nToolBar = 0;
	this.nModal = 0;
	this.vWindowArguments = '';
	this.oWindow = null;
	
	this.Open = function(){
		var sAdditional = "";
		
		if(this.nStatusBar)
			sAdditional += "status = 1; ";
		else
			sAdditional += "status = 0; ";
		
		if(this.nStatusBar)
			sAdditional += "status: yes; ";
		else
			sAdditional += "status: no; ";
			
		if(this.nModal)
			sAdditional += "modal = yes; ";
		else
			sAdditional += "modal = no; ";
		
		if(this.nScrollBars)
			sAdditional += "scroll: yes; ";
		else
			sAdditional += "scroll: no; ";
				
		var sFeatures = sAdditional +"channelmode = 0, directories = 0, fullscreen = 0, location = "+ this.nLocationBar +", menubar = "+ this.nMenubar +", resizable = "+ this.nResizable +", scrollbars = "+ this.nScrollBars +", status = "+ this.nStatusBar +", toolbar = "+ this.nToolBar +", height = "+ this.nHeight +", width = "+ this.nWidth +", left = "+ this.nLeft +", top = "+ this.nTop +"";
		this.sURL = sLocation.replace(/(bg|en|ru|de)\/.*/, "") + this.sURL;
		if(sBrowserName == "IE" && this.nModal == 1){
		    this.oWindow = window.showModalDialog(this.sURL, this.vWindowArguments, sFeatures);
	    }else{	        
	        this.oWindow = window.open(this.sURL, this.sWindowName, sFeatures);
	    }			
	}
	
	this.Close = function(){
		this.oWindow.close();
	}
	
	this.GetWindow = function(){
		return this.oWindow;
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// C R E A T E   T E X T 
function CreateText(sString, bBold, bItalic){
	var pText = null;
	// replace all whitespaces with non-breaking spaces
	sString = sString.replace(/\&nbsp;/gi, String.fromCharCode(0xA0));
	if(bBold == true || bItalic == true){
		if(bBold == true){
			pText = document.createElement("strong");
			if(bItalic == true) pText = pText.appendChild(document.createElement("em"));
		}else if(bItalic == true){
			pText = document.createElement("em");
		}
		pText.appendChild(document.createTextNode(sString));
		return pText;
	}else{
		return document.createTextNode(sString);
	}	
}