function InitChatButton()
{   
	if(!window.ChatButtonIndex) 
		window.ChatButtonIndex=0;
	
	
	eval("window.ChatButton"+ChatButtonIndex+"=new  ChatButton();");
	eval("var tmp=window.ChatButton"+ChatButtonIndex+";");  
	tmp.index=ChatButtonIndex;
	ChatButtonIndex=ChatButtonIndex+1;   
	
	return tmp; 
	  
}

function ChatButton()
{
	this.isClosed=true;
	this.redirectPath='';
	this.wasRedirected=false;
	this.hasImage=false;
	this.buttonText='';
	this.buttonPath='';
	this.errorMessage='';
	this.errorShown=false;
	this.buttonClass='';
	this.buttonStyle='';
	this.buttonHoveredPath='';	
	this.index=0;
}

ChatButton.prototype.Load=function() 
 {  
	if(this.errorMessage.length>0&&!this.errorShown)
	{
		alert(this.errorMessage);
		return false;
	}
	  
	if(this.isClosed)
	{
		document.write(this.getLinkedObject());
	}
	else
	{
		document.write("<a href='#' onclick='ChatButton"+this.index+".openregform()' "+this.buttonClass+this.buttonStyle+">"+this.getLinkedObject()+"</a>");
	} 
 }

ChatButton.prototype.openregform=function() 
{
	if(this.errorMessage.length>0)
	{
		alert(this.errorMessage);
		return false;
	}
	if(!this.isClosed)
	{
		if(this.wasRedirected)
		{
			if (this.redirectInNewWindow)
			{
				window.open(this.redirectPath, '_blank');
			}
			else
			{
				window.location.replace(this.redirectPath);
			}
		}
		else
			window.open(this.redirectPath, '_blank', 'width=600, height=600, resizable=0, scrollbars=1, toolbar=0, status=0');
	}
}

ChatButton.prototype.getLinkedObject=function() 
{
	if(this.hasImage)
	   {
	   var prop='';
	   if(!this.isClosed)
			prop=prop+" style='CURSOR:pointer'";
		
		prop=prop+" alt='"+this.buttonText+"'";
		prop=prop+" src='"+this.buttonPath+"'"; 
		
		if(this.buttonHoveredPath&&this.buttonHoveredPath.length>0) 
			  prop=prop+" onmouseover='ChatButton"+this.index+".mouseOver()' onmouseout='ChatButton"+this.index+".mouseOut()'";		 
			
		return "<img id='iButton"+this.index+"' border=0 "+prop+"/>";
	   }
	
	return  this.buttonText;	
}

ChatButton.prototype.mouseOver=function() 
{
	var button=document.getElementById('iButton'+this.index);
	button.src=this.buttonHoveredPath;
}

ChatButton.prototype.mouseOut=function() 
{
	  var button=document.getElementById('iButton'+this.index);
	button.src=this.buttonPath;
}
chatBt=InitChatButton();
chatBt.isClosed=true;
chatBt.wasRedirected=false;
chatBt.redirectInNewWindow=true;
chatBt.hasImage=true;
chatBt.redirectPath='http://www.dotnetlivehelp.com/livehelp/RegistrationForm.aspx?depId=0';
chatBt.buttonText='Closed chat';
chatBt.buttonPath='http://www.dotnetlivehelp.com/livehelp/UploadedFiles/i_id_2_helpclosed.gif';
chatBt.errorShown=false;
chatBt.errorMessage='';
chatBt.buttonClass="";
chatBt.buttonStyle="";
chatBt.buttonHoveredPath="";
chatBt.Load();
