// Gets the config settings from HTML page
// Writes an <iframe...> tag into the requesting page putting the user settings into the src querystring url
// Optional settings:
//{
    // An array of values that go in the iframe source querystring
    // the key/value params are classname/color
    //"stylesConfig"          : ["dpGreenSaperator=green","dpDayHighlightTD=#790f11"],
    
    // Width and Height that will be set to the iframe and the calendar as well
    //"width"                 : 300,
    //"height"                : 300,
    
    // Controls wether the event pages (triggered by clicking the calendar days) will open in a new window or not.
    // Optional. Default = true.
    //"openEventsInNewWindow" : true
//}
function initCalendarWidget(config, mouseUrl){
    var string = "",
        // Iframe source URL. Should be changed in every environment I presume. 
        iframeSrc = mouseUrl + "/widgets/calendarwidget.aspx",
        
        // Iframe style params (later on may be added by width and height)
        iframeParams = "allowTransparency=\"true\" frameborder=\"0\" scrolling=\"no\" ";
        
        // User settings sent to the calendar. MAy be width, height, classnames and colors, openEventsInNewWindow
        iframeQueryString = "?Widget=true";
    
    // If a width setting was sent - add it to the iframe params and the querystring as well
    if (config.width)
    {
        iframeParams+= "width=\""+config.width+"\" ";
        iframeQueryString+= "&width="+config.width;
    }
    else
    {
        string+= "width=\"100%\" ";
    }
    
    // If a height setting was sent - add it to the iframe params and the querystring as well
    if (config.height)
    {
        iframeParams+= "height=\""+config.height+"\" ";
        iframeQueryString+= "&height="+config.height;
    }
    
    // If a openEventsInNewWindow setting was sent - add it to the querystring
    if (typeof config.openEventsInNewWindow != "undefined")
    {
        iframeQueryString+= "&openEventsInNewWindow="+config.openEventsInNewWindow;
    }
    
    if(config.clientSiteHref)
    {
		 iframeQueryString+= "&clientSiteHref="+config.clientSiteHref;
    }
    
    if(config.css)
    {
		 iframeQueryString+= "&css="+config.css;
    }
    
    // Joining the classname=color array to the final querystring
    if (config.stylesConfig)
    {
        for (var i = 0; i < config.stylesConfig.length; i++)
        {
            iframeQueryString+= "&"+config.stylesConfig[i];
        }        
    }
    
    // if area id specified - add it to query
    if(config.areaid)
    {
		 iframeQueryString+= "&areaid="+config.areaid;
    }
    
    // if target css specified - add it to query
    if(config.targetcss)
    {
		 iframeQueryString+= "&targetcss="+config.targetcss;
    }
    
   
    
    
    // Put it all together
    string+= "<iframe ";
    string+= "src=\""+iframeSrc+iframeQueryString+"\"";
    string+= iframeParams;
    string+= "></iframe>";
    
    //Write it to the page!
    document.write(string);
}

	

