function OMQ(accountName, apiKey, language, version, calledFromSC)
{
	
	this.accountName	= accountName;
	this.version		= version;
	this.apiKey			= apiKey;
	this.language		= language;
	this.isOpen			= false;
	this.clientWidth	= 300;
	this.calledFromSC	= calledFromSC;
	this.OMQWidget		= null;

	// Major version of Flash required
	var requiredMajorVersion = 9;
	// Minor version of Flash required
	var requiredMinorVersion = 0;
	// Minor version of Flash required
	var requiredRevision = 124;
	
	this.init = function(imageUrl)
	{
		var container = document.createElement("div");
		container.id = "omqMainDiv";
		container.style.cssText = "right:0px; bottom:0px; position:fixed; width:55px; height:500px; z-index:99;";
		
		var image = document.createElement("img");
		image.id = "omqClickImage";
		image.style.cssText = "width:50px; margin-top:100px; cursor:pointer; margin-right:-10px; z-index:99;";
		image.src = imageUrl;
		
		var customerClient = document.createElement("div");
		customerClient.id = "omqCustomerClientBox";
		customerClient.style.cssText = "width:5px; height:500px; float:right; background-image:url('shadow-left.png'); background-repeat:repeat-y;";
		if(image.addEventListener)
		{
      		image.addEventListener("click", this.slideWidget, false);
   		}
   		else if(image.attachEvent)
   		{
      		image.attachEvent("onclick", this.slideWidget);
   		}
		
		container.appendChild(customerClient);
		container.appendChild(image);
				
		document.body.appendChild(container);
	}
		
	this.popUpWidget = function()
	{
		if(this.OMQWidget != null && this.OMQWidget.closed)
		{
			this.OMQWidget = null;
		}
		
		if(this.OMQWidget == null)
		{
			this.OMQWidget = window.open
			(
				"about:blank", 
				"OMQWidget", 
				"dependent=yes,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=310,height=700,left=100,top=200"
			);
						
			var title 	= this.accountName.substr(0, 1).toUpperCase() + this.accountName.substr(1) + " Client";
			var content = this.generateClientHTML(title);
			
			this.OMQWidget.document.write(content);
			this.OMQWidget.focus();
		}else
		{
			this.OMQWidget.focus();
		}
	}
	
	this.slideWidget = function(evt)
	{
		if(!this.isOpen)
		{
			doWidthChangeMem(document.getElementById("omqMainDiv"), 55, 360, 10, 50, 0.5);
			
			var movie = document.createElement("div");
			movie.id = "omqMovie";
			movie.style.cssText = "width:300px; height:500px; padding-left:5px;";
			movie.innerHTML = omq.loadClient();
			document.getElementById("omqCustomerClientBox").appendChild(movie);

			doWidthChangeMem(document.getElementById("omqCustomerClientBox"), 5, 305, 10, 50, 0.5);
			
			setTimeout(function(){document.getElementById("omqClickImage").style.marginRight = "-15px";}, 10*50, "JavaScript");
			
			this.isOpen = true;
			return;
		}
		
		doWidthChangeMem(document.getElementById("omqMainDiv"), 360, 55, 10, 50, 0.5);
		doWidthChangeMem(document.getElementById("omqCustomerClientBox"), 305, 5, 10, 50, 0.5);
		
		setTimeout(function(){document.getElementById("omqCustomerClientBox").removeChild(document.getElementById("omqMovie"))}, 10*50);
		setTimeout(function(){document.getElementById("omqClickImage").style.marginRight = "-10px";}, 10*50);
		this.isOpen = false;
	}
	
	this.inlineWindow = function(name)
	{
		if(!this.isOpen)
		{	
			// clean box
			var parentBox = document.getElementById(name); 
			
			parentBox.style.cssText = "padding: 0 0 0 0;"
			parentBox.innerHTML 	= "";
					
			// load customer client
			var movie = document.createElement("div");
			movie.id = "omqMovie";
			movie.style.cssText = "width:300px; height:500px;";
			movie.innerHTML = omq.loadClient();
			
			parentBox.appendChild(movie);

			this.isOpen = true;
			return;
		}
				
		setTimeout(function(){document.getElementById(name).removeChild(document.getElementById("omqMovie"))}, 10*50);
		this.isOpen = false;
	}
		
	this.loadClient = function()
	{
		var hasProductInstall = DetectFlashVer(6, 0, 65);

		// Version check based upon the values defined in globals
		var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

		if ( hasProductInstall && !hasRequestedVersion )
		{
			// DO NOT MODIFY THE FOLLOWING FOUR LINES
			// Location visited after installation is complete if installation is required
			var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
			var MMredirectURL = window.location;
    		document.title = document.title.slice(0, 47) + " - Flash Player Installation";
    		var MMdoctitle = document.title;
			
			var client = OMQ_AC_FL_RunContent(
				"src", "OMQ_customer_client/playerProductInstall.swf",
				"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
				"width", "100%",
				"height", "100%",
				"align", "middle",
				"id", "OMQ_customer_client",
				"quality", "high",
				"bgcolor", "#869ca7",
				"name", "OMQ_customer_client",
				"allowScriptAccess","sameDomain",
				"type", "application/x-shockwave-flash",
				"pluginspage", "http://www.adobe.com/go/getflashplayer"
			);
			
			return client;				
		} else if (hasRequestedVersion)
		{
			var clientURL = "https://" + this.accountName + "-client.omq-diagnostic.de/OMQ_customer_client/OMQ_customer_client.swf"
			//var clientURL = "https://192.168.140.108:8443/OMQ_customer_client/OMQ_customer_client.swf"
			
			// if we've detected an acceptable version
			// embed the Flash Content SWF when all tests are passed
			var client = OMQ_AC_FL_RunContent(
				"src", clientURL,
				"FlashVars", "accountName="+this.accountName+"&lang="+this.language+"&apiKey="+this.apiKey+"&version="+this.version+"&calledFromSC="+this.calledFromSC,
				"width", "100%",
				"height", "100%",
				"align", "middle",
				"id", "OMQ_customer_client",
				"quality", "high",
				"bgcolor", "#869ca7",
				"name", "OMQ_customer_client",
				"allowScriptAccess","always",
				"type", "application/x-shockwave-flash",
				"pluginspage", "http://www.adobe.com/go/getflashplayer"
			);

			return client;
  		} else
  		{  // flash is too old or we can't detect the plugin
    		var alternateContent = 'Alternate HTML content should be placed here. '
  									+ 'This content requires the Adobe Flash Player. '
   									+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
    		return alternateContent;  // insert non-flash content
  		}
	}
	
	this.sendInformationToClient = function(name, value)
	{
		if(this.OMQWidget == null) return false;
		
		this.OMQWidget["OMQ_customer_client"].sendInformationToClient(name, value);
	}
	
	this.generateClientHTML = function(title)
	{
		var htmlClient = 	"<html>" + 
								"<head>" + 
									"<title>" + title + "</title>" + 
			 						"<style>body{margin:0px 0px 0px 0px;}</style>" + 
			 					"</head>" + 
								"<body>" + this.loadClient() + "</body>" + 
							"</html>";
		return htmlClient;
	}
		
	//elem: element that we're going to animate
	//startWidth: starting width of animation
	//endWidth: target width of animation
	//steps: total steps of animation
	//intervals: intervals the animation will be done in miliseconds
	//powr: value used for determining ease-in and out.
	//----
	//elem.widthChangeMemInt: The interval animation value for self inhibition.
	//elem.currenWidth: The objects 'memory' of its last set width.
	//actstep: actual step of the animation, increased 1 per every execution.
	
	function doWidthChangeMem(elem,startWidth,endWidth,steps,intervals,powr)
	{
	    if(elem.widthChangeMemInt) window.clearInterval(elem.widthChangeMemInt);
	    var actStep = 0;
	   
	    elem.widthChangeMemInt = window.setInterval(
													function()
													{ 
		 	 											elem.currentWidth = easeInOut(startWidth,endWidth,steps,actStep,powr);
		  												elem.style.width = elem.currentWidth + "px"; 
		  												actStep++;
		  												if (actStep > steps) window.clearInterval(elem.widthChangeMemInt);
													} 
													,intervals)
	}
	
	function easeInOut(minValue,maxValue,totalSteps,actualStep,powr)
	{ 
	    var delta = maxValue - minValue; 
	    var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
	    return Math.ceil(stepp) 
	}
	
	function OMQ_AC_Generateobj(objAttrs, params, embedAttrs) 
	{ 
	    var str = '';
	    if (isIE && isWin && !isOpera)
	    {
	  		str += '<object ';
	  		for (var i in objAttrs)
	  			str += i + '="' + objAttrs[i] + '" ';
	  		str += '>';
	  		for (var i in params)
	  			str += '<param name="' + i + '" value="' + params[i] + '" /> ';
	  		str += '</object>';
	    } else {
	  		str += '<embed ';
	  		for (var i in embedAttrs)
	  			str += i + '="' + embedAttrs[i] + '" ';
	  		str += '> </embed>';
	    }

	    //document.write(str);
	    return str;
	}

	function OMQ_AC_FL_RunContent(){
	  var ret = 
	    AC_GetArgs
	    (  arguments, "", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
	     , "application/x-shockwave-flash"
	    );
	  //AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
	  return OMQ_AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
	}
}