﻿// JScript File
function Banner(host,lang,position,container,width,height){
    this.host = host;
    this.position = position;
    this.lang = lang;
    this.bdiv = document.getElementById(container);
    this.frmID = container+'_frm';
    if(this.bdiv!=null)
        this.bdiv.style.display = 'none';
    this.w = width;
    this.h = height;
}
Banner.prototype.host;
Banner.prototype.position;
Banner.prototype.lang;
Banner.prototype.bdiv;
Banner.prototype.frmID;
Banner.prototype.w;
Banner.prototype.h;



Banner.prototype.frame_resize = function ()
{
    var frmBanner =  this;//document.getElementById(this.frmID);//
    if(frmBanner!=null && frmBanner.readyState == "complete")
    {
        try{
        
        var hfWidth = frmBanner.contentWindow.document.getElementById("_width");
        var hfHeight = frmBanner.contentWindow.document.getElementById("_height");
        frmBanner.style.width = hfWidth.value;
        frmBanner.style.height = hfHeight.value;
        
        }catch(e){}
    }
}

Banner.prototype.Load = function()
{
    var frmBanner = document.getElementById(this.frmID);
    if(frmBanner==null)
    {
        frmBanner = document.createElement("iframe"); 
        frmBanner.marginWidth = 0;
	    frmBanner.marginHeight = 0;
	    frmBanner.id = this.frmID;
	    frmBanner.allowTransparency = true;
	    frmBanner.frameBorder = 0;
	    if(this.w!=null&&this.w>0)
	       frmBanner.width = this.w;
	    if(this.h!=null&&this.h>0)
	        frmBanner.height = this.h;
	    frmBanner.style.overflow = 'visible';
	    frmBanner.style.border = 'none';
	    frmBanner.style.borderStyle = 'none';
	    //frmBanner.style.position = 'absolute';
	    frmBanner.scrolling = "no";

        this.bdiv.appendChild(frmBanner);
        
        frmBanner.onreadystatechange = this.frame_resize;
        if(frmBanner.onreadystatechange==null)
        {
           frmBanner.onload = this.frame_resize;
        }
    }
    
    if(arguments[0]==null)
        frmBanner.src = "/CommonContent/Banners/Container.ashx?Host=" + this.host + "&Lang=" + this.lang + "&Position="+this.position;
    else
        frmBanner.src = "/CommonContent/Banners/Container.ashx?ID=" + arguments[0]+ "&Lang=" + this.lang;
	    
    this.bdiv.style.display = 'block';
}
