/**
 * @author Leon Janzen <leon@novgroup.com>
 * 
 * @requires jQuery framework
 */

/**
 * Constructor
 * @param {Object} objSettings Banner rotator settings
 * objSettings={
 * 		id:String The id of the container element for the banner rotator. It can can be styled, but the dimensions may be overwritten (if given in the settings), and it will be set to display:relative, and overflow:hidden
 * 		width:Integer The desired width of the banner rotator
 * 		height:Integer The desired height of the banner rotator
 * 		defaultDisplayTime:Integer The default display time for banners, if they don't have their own display time given in the settings
 * 		stretch:Boolean If true (default), the images and flash objects will be stretched to fit the container (not proportionally), if false, the images will retain their original dimensions, and flash will be resized to fit inside the container, but sized proportionally
 * 		random:Boolean If true, the banners will be rotated in a controlled random order, if false (default), they will be displayed in the order that they were added
 * 		rotateSingle:Boolean If there is only a single banner in the rotator, and this is true (default), it will still be rotated (restarted), which is useful for animated gif images, and flash objects; if false it will not be rotated
 * }
 */
function TNGBannerRotator(objSettings)
{
	//properties
	this.strElementId=null;
	this.eleElement=null;
	this.strWidth=null;
	this.strHeight=null;
	this.intDefaultDisplayTime=4000; //default display time if no default is given in the settings
	this.intTransitionTime=800; //transition time
	this.blnStretch=true; //if true, the images and flash objects will be stretched to fit the container (not proportionally), if false, the images will retain their original dimensions, and flash will be resized to fit inside the container, but sized proportionally
	this.blnRandom=false; //if true, the banners will be rotated in a controlled random order, if false, they will be displayed in the order that they were added
	this.blnRotateSingle=true; //if there is only a single banner in the rotator, and this is true, it will still be rotated (restarted), which is useful for animated gif images, and flash objects; if false it will not be rotated
	
	this.arrBanners=new Array();
	this.intCurrentBannerIndex=-1;
	this.blnInitialized=false;
	this.objTimeout=null;
	this.blnRunning=false;
	this.objOutgoingBanner=null;
	this.objIncomingBanner=null;
	this.arrAvailable=new Array(); //an array of banner indices that are available for random selection
	
	//update properties based on values in the given settings object
	if(objSettings)
	{
		if(objSettings.id!=undefined) //check if element id exists in settings
			this.strElementId=objSettings.id;
		if(objSettings.width!=undefined)
			this.strWidth=objSettings.width;
		if(objSettings.height!=undefined)
			this.strHeight=objSettings.height;
		if(objSettings.defaultDisplayTime!=undefined)
			this.intDefaultDisplayTime=objSettings.defaultDisplayTime;
		if(objSettings.stretch!=undefined)
			this.blnStretch=objSettings.stretch;
		if(objSettings.random!=undefined)
			this.blnRandom=objSettings.random;
		if(objSettings.rotateSingle!=undefined)
			this.blnRotateSingle=objSettings.rotateSingle;
	}
	
	//getters and setters
	this.getElementId=function()
	{
		return this.strElementId;
	};
	this.getElement=function()
	{
		if(!this.eleElement) //check if element pointer has not been set
			if(document.getElementById(this.getElementId())) //check if element exists
				this.eleElement=document.getElementById(this.getElementId()); //set element pointer
		
		return this.eleElement;
	};
	this.getWidth=function()
	{
		return this.strWidth;
	};
	this.setWidth=function(strWidth)
	{
		this.strWidth=strWidth;
		this.getElement().style.width=this.getWidth(); //set width
	};
	this.getHeight=function()
	{
		return this.strHeight;
	};
	this.setHeight=function(strHeight)
	{
		this.strHeight=strHeight;
		this.getElement().style.height=this.getHeight(); //set width
	};
	this.isStretched=function()
	{
		return this.blnStretch;
	};
	this.setStretched=function(blnStretch)
	{
		this.blnStretch=blnStretch;
	};
	this.isRandom=function()
	{
		return this.blnRandom;
	};
	this.setRandom=function(blnRandom)
	{
		this.blnRandom=blnRandom;
	};
	this.isRotateSingle=function()
	{
		return this.blnRotateSingle;
	};
	this.setRotateSingle=function(blnRotateSingle)
	{
		this.blnRotateSingle=blnRotateSingle;
	};
	
	this.isRunning=function()
	{
		return this.blnRunning;
	};
	this.setRunning=function(blnRunning)
	{
		this.blnRunning=blnRunning;
	};
	
	/**
	 * Adds a banner item to the banner rotator
	 * @param {Object} objBannerSettings Banner item settings
	 * objBannerSettings={
	 * 		src:String The href of the banner file
	 * 		,id:String the id of the html element (only used for TNGBannerRotator.TYPE_HTML)
	 * 		,displayTime:Number The time that the banner should be displayed, in millseconds
	 * 		,type:The type of banner (image, animated gif, or flash), can use one the following class contants:
	 * 			TNGBannerRotator.TYPE_IMAGE
	 * 			TNGBannerRotator.TYPE_ANIMATED_GIF
	 * 			TNGBannerRotator.TYPE_FLASH
	 * 			TNGBannerRotator.TYPE_HTML (banners of this type will ignore the url and newWindow properties; any links should be built into the html element instead)
	 * 		,url:The the URL that the banner links to
	 * 		,newWindow:If true, the link will open in a new window (default is true)
	 * }
	 * @return {void}
	 */
	this.addBanner=function(objBannerSettings)
	{
		if(objBannerSettings) //check if a settings object has been given
		{
			//the id property in the settings will be used to find the html element for TNGBannerRotator.TYPE_HTML, and then appropriated for internal use
			if(objBannerSettings.id!=undefined) //check if id property exists
				if(jQuery("#"+objBannerSettings.id).size()) //check if element exists
				{
					objBannerSettings.element=jQuery("#"+objBannerSettings.id); //store element object (instead of just an id to reference the object)
					
					objBannerSettings.element.remove(); //remove element from DOM
					
					if(objBannerSettings.element.css("display")=="none") //check if element display is set to "none" (it may be set to none to prevent flicker while loading page)
						objBannerSettings.element.css("display","block"); //change element display to "block"
				}
			
			objBannerSettings.id=this.strElementId+"-banner-"+this.arrBanners.length; //create an element id for the banner item
			
			if(!objBannerSettings.displayTime) //check if a display time has not been given for the banner
				objBannerSettings.displayTime=this.intDefaultDisplayTime; //set to default value
			
			this.arrBanners.push(new TNGBanner(objBannerSettings)); //create a new banner item based on the given settings, and add to array
		}
	};
	
	/**
	 * Initializes the banner rotator
	 * Checks if the required elements exist, and the required scripts (jQuery), and if they exist it stores 
	 * a reference to the element as an object property, sets the dimensions of the element, and sets the 
	 * styles of the element required for the banner rotator.
	 * 
	 * @return {boolean} True on success, false on error
	 */
	this.initialize=function()
	{
		if(!this.blnInitialized) //check if rotator has not already been initialized
		{
			if(this.getElement()) //check if element exists in DOM
			{
				if(this.arrBanners.length>0) //check if there are banners
				{
					if(jQuery) //check if jQuery exists
					{
						//set element styles
						this.getElement().style.position="relative"; //set position
						this.getElement().style.overflow="hidden"; //set overflow
						if(this.getWidth())
							this.getElement().style.width=this.getWidth(); //set width
						if(this.getHeight())
							this.getElement().style.height=this.getHeight(); //set height
						
						this.blnInitialized=true;
					}
				}
			}
		}
		
		return this.blnInitialized;
	};
	
	/**
	 * Initializes and starts the banner rotation if it is not already running
	 * @uses initialize
	 * @return {void}
	 */
	this.start=function()
	{
		if(this.initialize() && !this.isRunning()) //make sure the rotator has been initialized, and is not currently running
		{
			this.setRunning(true);
			this.next();
		}
	};
	
	/**
	 * Displays the next banner item in the rotator
	 * @return {void}
	 */
	this.next=function()
	{
		//select the next banner index
		if(this.isRandom())
		{
			var intLastBannerIndex=this.intCurrentBannerIndex; //store last used banner index
			var blnNewRotation=(this.arrAvailable==undefined || this.arrAvailable.length==0); //start a new rotation if the array of available banners indices has not been set or is empty
			
			if(blnNewRotation) //check if this is a new rotation
				for(var i=0;i<this.arrBanners.length;i++)
					if(i!=this.intCurrentBannerIndex) //don't add the index of the most recently used banner, so that the new rotation will not start with the same banner as the last rotation ended with, causing a repeating banner
						this.arrAvailable.push(i); //populate array of available banner indices

			if(this.arrAvailable.length>0) //check if there are available indices to select from (i.e. there is more than one banner in the rotator)
			{
				var intAvailableIndex=Math.floor(Math.random()*this.arrAvailable.length); //randomly select an index from the array of available indices
				this.intCurrentBannerIndex=this.arrAvailable[intAvailableIndex]; //use the random index
				this.arrAvailable.splice(intAvailableIndex,1); //remove used index from array
				
				if(blnNewRotation && intLastBannerIndex!=-1) //check if this is a new rotation, and a last banner index exists
					this.arrAvailable.push(intLastBannerIndex);
			}
			//if there are no available indices to select from (i.e. there is only one banner in the rotation), then the current banner index remains unchanged, and is reused
		}
		else
		{
			this.intCurrentBannerIndex++; //increment the current banner index
			
			if(!this.arrBanners[this.intCurrentBannerIndex]) //check if a banner does not exist at the new index
				this.intCurrentBannerIndex=0; //reset to the beginning of the array
		}
		
		this.objOutgoingBanner=this.objIncomingBanner; //replace old outgoing banner with last incoming banner
		this.objIncomingBanner=this.arrBanners[this.intCurrentBannerIndex]; //replace incoming banner with new banner
		
		//define a function that set the dimensions of the banner element within the rotator element
		var setBannerDimensions=function(objEvent)
		{
			var objRotator=objEvent.data.objRotator;
			
			if(objRotator.isStretched())
			{
				//set banner dimensions to match rotator element
				jQuery(this).css("width",jQuery(objRotator.getElement()).css("width"));
				jQuery(this).css("height",jQuery(objRotator.getElement()).css("height"));
			}
			else
			{
				//set dimensions to match image element that it is displaying (if image dimensions exist and are greater than 0)
				if(this.width)
					jQuery(this).css("width",this.width);
				if(this.height)
					jQuery(this).css("height",this.height);
				
				//test - set the banner height to the height of the rotator
				jQuery(this).css("height",objRotator.getHeight());
				jQuery(this).css("width","");
			}
		};
		
		//define a function that inserts the banner element into the rotator (which is called when the image has loaded) 
		var insertBanner=function(objEvent)
		{
			var blnRotate=true;
			var objRotator=objEvent.data.objRotator;
			var eleBanner=objEvent.data.eleBanner;
			
			if(objRotator.objOutgoingBanner) //check if an outgoing banner exists
			{
				var strOutgoingBannerElementId=objRotator.objOutgoingBanner.getElementId(); //store the outgoing banner id
				
				if(objRotator.objIncomingBanner==objRotator.objOutgoingBanner) //check if the incoming banner and the outgoing banner are the same (when there is only one element in the rotator)
				{
					if(objRotator.isRotateSingle())
					{
						//update the id of the outgoing banner element (and the stored id) so it is different than the incoming banner id
						strOutgoingBannerElementId=objRotator.objOutgoingBanner.getElementId()+"-outgoing";
						jQuery("#"+objRotator.objOutgoingBanner.getElementId()).attr("id",strOutgoingBannerElementId);
					}
					else
						blnRotate=false; //cancel rotation
				}
			}
			
			if(blnRotate)
			{
				if(jQuery("#"+objRotator.objIncomingBanner.getElementId()).size()) //check if an item with the incoming banner element id already exists in the DOM
					jQuery("#"+objRotator.objIncomingBanner.getElementId()).remove(); //remove it
				
				jQuery("#"+objRotator.getElementId()).prepend(eleBanner); //prepend the incoming banner element to the rotator element, so that it is behind the outgoing banner element if an outgoing banner element exists
				
				if(objRotator.objOutgoingBanner) //check if an outgoing banner exists
					jQuery("#"+strOutgoingBannerElementId).fadeOut(objRotator.intTransitionTime,function(){jQuery(this).remove();}); //fade out the outgoing banner element, and remove the element from the DOM when the fade is complete
			}
		};

		//create banner element
		var eleBanner=document.createElement("div");
		eleBanner.id=this.objIncomingBanner.getElementId();
		eleBanner.style.position="absolute";

		if(this.objIncomingBanner.getUrl().length>0) //check if banner has a URL
		{
			//create anchor element (link)
			var eleA=document.createElement("a");
			jQuery(eleA).attr("href",this.objIncomingBanner.getUrl());
			if(this.objIncomingBanner.isNewWindow())
				jQuery(eleA).attr("target","_blank");
			
			//set anchor styles
			jQuery(eleA).css("margin","0px");
			jQuery(eleA).css("padding","0px");
			jQuery(eleA).css("border-width","0px");
		}

		switch(this.objIncomingBanner.getType())
		{
			case(TNGBannerRotator.TYPE_FLASH):
				//insert object and embed elements as an html string, rather than DOM objects (below), which causes an error in IE
				var strHtml="<object id=\""+this.objIncomingBanner.getElementId()+"-flash\" width=\""+jQuery(this.getElement()).css("width")+"\" height=\""+jQuery(this.getElement()).css("height")+"\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.adobe.com/pub/shockwave/cabs/flash/\">" +
					"<param name=\"movie\" value=\""+this.objIncomingBanner.getSrc()+"\" />" +
					"<param name=\"wmode\" value=\"transparent\" />" +
					"<param name=\"play\" value=\"true\" />" +
					"<param name=\"loop\" value=\"true\" />" +
					"<param name=\"quality\" value=\"high\" />" +
					(this.isStretched() ? "<param name=\"scale\" value=\"exactfit\" />" : "") +
					"<embed " +
						" name=\""+this.objIncomingBanner.getElementId()+"-flash\"" +
						" width=\""+jQuery(this.getElement()).css("width")+"\" height=\""+jQuery(this.getElement()).css("height")+"\"" +
						" src=\""+this.objIncomingBanner.getSrc()+"\"" +
						" type=\"application/x-shockwave-flash\"" +
						" pluginspage=\"http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"" +
						" wmode=\"transparent\"" +
						" play=\"true\"" +
						" loop=\"true\"" +
						" quality=\"high\"" +
						(this.isStretched() ? " scale=\"exactfit\"" : "") +
					" />" +
				"</object>";
				
				/*
				var eleObject=document.createElement("object");
				jQuery(eleObject).attr("id",this.objIncomingBanner.getElementId()+"-flash");
				jQuery(eleObject).attr("width",jQuery(this.getElement()).css("width"));
				jQuery(eleObject).attr("height",jQuery(this.getElement()).css("height"));
				jQuery(eleObject).attr("classid","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
				jQuery(eleObject).attr("codebase","http://fpdownload.adobe.com/pub/shockwave/cabs/flash/");
				jQuery(eleBanner).append(eleObject); //append object element to banner element
				
				var eleParam=document.createElement("param");
				jQuery(eleParam).attr("name","movie");
				jQuery(eleParam).attr("value",this.objIncomingBanner.getSrc());
				jQuery(eleObject).append(eleParam); //append param element to object element
				
				var eleParam=document.createElement("param");
				jQuery(eleParam).attr("name","wmode");
				jQuery(eleParam).attr("value","transparent"); //this allows CSS fading of the flash element
				jQuery(eleObject).append(eleParam); //append param element to object element
				
				var eleParam=document.createElement("param");
				jQuery(eleParam).attr("name","play");
				jQuery(eleParam).attr("value","true");
				jQuery(eleObject).append(eleParam); //append param element to object element
				
				var eleParam=document.createElement("param");
				jQuery(eleParam).attr("name","loop");
				jQuery(eleParam).attr("value","true");
				jQuery(eleObject).append(eleParam); //append param element to object element
				
				var eleParam=document.createElement("param");
				jQuery(eleParam).attr("name","quality");
				jQuery(eleParam).attr("value","high");
				jQuery(eleObject).append(eleParam); //append param element to object element
				
				if(this.isStretched())
				{
					var eleParam=document.createElement("param");
					jQuery(eleParam).attr("name","scale");
					jQuery(eleParam).attr("value","exactfit");
					jQuery(eleObject).append(eleParam); //append param element to object element
				}
				
				var eleEmbed=document.createElement("embed");
				jQuery(eleEmbed).attr("name",this.objIncomingBanner.getElementId()+"-flash");
				jQuery(eleEmbed).attr("width",jQuery(this.getElement()).css("width"));
				jQuery(eleEmbed).attr("height",jQuery(this.getElement()).css("height"));
				jQuery(eleEmbed).attr("src",this.objIncomingBanner.getSrc());
				jQuery(eleEmbed).attr("type","application/x-shockwave-flash");
				jQuery(eleEmbed).attr("wmode","transparent"); //this allows CSS fading of the flash element
				jQuery(eleEmbed).attr("pluginspage","http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash");
				jQuery(eleEmbed).attr("play","true");
				jQuery(eleEmbed).attr("loop","true");
				jQuery(eleEmbed).attr("quality","high");
				if(this.isStretched())
					jQuery(eleEmbed).attr("scale","exactfit");
				jQuery(eleObject).append(eleEmbed); //append embed element to object element
				
				jQuery(eleBanner).append(eleObject); //append object element to banner element
				*/
			
				jQuery(eleBanner).html(strHtml); //append html to banner element
				
				if(eleA!=undefined) //check if banner has a URL
				{
					//set required anchor styles
					jQuery(eleA).css("width",jQuery(this.getElement()).css("width"));
					jQuery(eleA).css("height",jQuery(this.getElement()).css("height"));
					jQuery(eleA).css("position","absolute");
					
					jQuery(eleBanner).prepend(eleA); //prepend anchor to the banner element so it becomes an overlay over the flash object
				}

				var objEvent=new Object();
				objEvent.data=new Object();
				objEvent.data.objRotator=this;
				objEvent.data.eleBanner=eleBanner;
				jQuery(eleBanner).bind("load",{objRotator:this},setBannerDimensions);
				insertBanner.call(eleBanner,objEvent); //call insertBanner(), which is normally called on the "load" event, but doesn't work with flash movies
				
				break;
				
			case(TNGBannerRotator.TYPE_HTML):
				
				jQuery(eleBanner).append(this.objIncomingBanner.getElement());
				
				var objEvent=new Object();
				objEvent.data=new Object();
				objEvent.data.objRotator=this;
				objEvent.data.eleBanner=eleBanner;
				//jQuery(eleBanner).bind("load",{objRotator:this},setBannerDimensions);
				insertBanner.call(eleBanner,objEvent); //call insertBanner(), which is normally called on the "load" event, but doesn't work with flash movies
				
				break;
			
			case(TNGBannerRotator.TYPE_ANIMATED_GIF):
				//create image element
				var eleImage=document.createElement("img"); //new Image()
				jQuery(eleImage).attr("alt","");
				
				//set required image styles
				jQuery(eleImage).css("margin","0px");
				jQuery(eleImage).css("padding","0px");
				jQuery(eleImage).css("border-width","0px");
				
				if(eleA!=undefined) //check if banner has a URL
				{
					jQuery(eleA).append(eleImage); //append image to anchor
					jQuery(eleBanner).append(eleA); //append anchor to banner
				}
				else
				{
					jQuery(eleBanner).append(eleImage); //append image to banner
				}
				
				jQuery(eleImage).bind("load",{objRotator:this,eleBanner:eleBanner},setBannerDimensions);
				jQuery(eleImage).bind("load",{objRotator:this,eleBanner:eleBanner},insertBanner);
				var strConnector="?";
				if(eleImage.src.indexOf("?")!=-1) //check if the src URL already contains a ?
					strConnector="&";
				eleImage.src=this.objIncomingBanner.getSrc()+strConnector+"TNGBannerRotator="+Math.round(Math.random()*1000000); //add a random URL parameter to make sure the image is not loaded from the cache, so that the animation is restarted each time the image loads
				break;
			
			default: //includes TNGBannerRotator.TYPE_IMAGE
				//create image element
				var eleImage=document.createElement("img"); //new Image()
				jQuery(eleImage).attr("alt","");
				
				//set required image styles
				jQuery(eleImage).css("margin","0px");
				jQuery(eleImage).css("padding","0px");
				jQuery(eleImage).css("border-width","0px");
				
				if(eleA!=undefined) //check if banner has a URL
				{
					jQuery(eleA).append(eleImage); //append image to anchor
					jQuery(eleBanner).append(eleA); //append anchor to banner
				}
				else
				{
					jQuery(eleBanner).append(eleImage); //append image to banner
				}
				
				jQuery(eleImage).bind("load",{objRotator:this,eleBanner:eleBanner},setBannerDimensions);
				jQuery(eleImage).bind("load",{objRotator:this,eleBanner:eleBanner},insertBanner);
				eleImage.src=this.objIncomingBanner.getSrc();
				break;
		}
		
		var objRotator=this; //create new reference to 'this'
		this.objTimeout=window.setTimeout(function(){objRotator.next()},this.objIncomingBanner.getDisplayTime());
		
		return eleBanner;
	}
	
	/**
	 * Stops the banner rotation
	 * @return {void}
	 */
	this.stop=function()
	{
		this.setRunning(false);
		window.clearTimeout(this.objTimeout);
	};
}

TNGBannerRotator.TYPE_IMAGE=1;
TNGBannerRotator.TYPE_ANIMATED_GIF=2;
TNGBannerRotator.TYPE_FLASH=3;
TNGBannerRotator.TYPE_HTML=4;


/**
 * Constructor
 * @param {Object} objSettings Banner item settings
 * objSettings={
 * 		id:The id of the banner element, for internal use only
 * 		,src:String The href of the banner file
 * 		,element:Object The html element to be used as a banner
 * 		,displayTime:Number The time that the banner should be displayed, in millseconds
 * 		,type:The type of banner (image, animated gif, or flash), can use one the following class contants:
 * 			TNGBannerRotator.TYPE_IMAGE
 * 			TNGBannerRotator.TYPE_ANIMATED_GIF
 * 			TNGBannerRotator.TYPE_FLASH
 * 			TNGBannerRotator.TYPE_HTML (banners of this type will ignore the url and newWindow properties; any links should be built into the html element instead)
 * 		,url:The the URL that the banner links to
 * 		,newWindow:If true, the link will open in a new window (default is true)
 * }
 */
function TNGBanner(objSettings)
{
	//properties
	this.strElementId=null;
	this.strSrc="";
	this.objElement=null; //only used for TNGBannerRotator.TYPE_HTML
	this.intType=TNGBannerRotator.TYPE_IMAGE; //default to regular image
	this.intDisplayTime=null;
	this.strUrl="";
	this.blnNewWindow=true; //open URL in new window
	
	//update properties based on values in the given settings object
	if(objSettings)
	{
		if(objSettings.id!=undefined)
			this.strElementId=objSettings.id;
		if(objSettings.src!=undefined)
			this.strSrc=objSettings.src;
		if(objSettings.element!=undefined)
			this.objElement=objSettings.element;
		if(objSettings.displayTime!=undefined)
			this.intDisplayTime=objSettings.displayTime;
		if(objSettings.type!=undefined)
			this.intType=objSettings.type;
		if(objSettings.url!=undefined)
			this.strUrl=objSettings.url;
		if(objSettings.newWindow!=undefined)
			this.blnNewWindow=objSettings.newWindow;
	}
	
	//getters and setters
	this.getElementId=function()
	{
		return this.strElementId;
	};
	this.setElementId=function(strElementId)
	{
		this.strElementId=strElementId;
	};
	this.getSrc=function()
	{
		return this.strSrc;
	};
	this.setSrc=function(strSrc)
	{
		this.strSrc=strSrc;
	};
	this.getElement=function()
	{
		return this.objElement;
	};
	this.setElement=function(objElement)
	{
		this.objElement=objElement;
	};
	this.getType=function()
	{
		return this.intType;
	};
	this.setType=function(intType)
	{
		this.intType=intType;
	};
	this.getDisplayTime=function()
	{
		return this.intDisplayTime;
	};
	this.setDisplayTime=function(intDisplayTime)
	{
		this.intDisplayTime=intDisplayTime;
	};
	this.getUrl=function()
	{
		return this.strUrl;
	};
	this.setUrl=function(strUrl)
	{
		this.strUrl=strUrl;
	};
	this.isNewWindow=function()
	{
		return this.blnNewWindow;
	};
	this.setNewWindow=function(blnNewWindow)
	{
		this.blnNewWindow=blnNewWindow;
	};
}
