function JuzWychodzeForm(){

this.scroll='auto';
this.width='517';
this.height='500';
this.tuneVersion='1';

this.bgColor='';
this.queryBgColor='';
this.queryBorderColor='';
this.queryColumnColor='';
this.outsideFontColor='';
this.outsideHoverFontColor='';

this.initialize=function(params){
    for(key in params){
        this[key]=params[key];
    }
    this.hostDomain=document.domain;
    //this.hostDomain=this.hostDomain.replace(".", "");
    this.frameUrl=this.generateFrameUrl();
    
},

this.generateFrameUrl=function() {
    var domain = 'www.juzwychodze.pl';
    //var domain = 'localhost/frontend';
    
    var url='http://'+domain+'/index.php?'+this.generateTuneParams();
    url+='&utm_source='+this.hostDomain+'&utm_medium=query&utm_content=tune_'+this.tuneVersion+'&utm_campaign=organizacje_publiczne';
    return url;
},

this.generateTuneParams=function() {
    var params='tune='+this.tuneVersion;
    
    var jsonParams='';
    if (this.bgColor!='') {
        if (jsonParams!='')
            jsonParams+=',';        
        jsonParams+="'bgcolor':'"+this.bgColor.replace("#", "*")+"'";
    }
    if (this.queryBgColor!=''){
        if (jsonParams!='')
            jsonParams+=',';
        jsonParams+="'qbgcolor':'"+this.queryBgColor.replace("#", "*")+"'";
    }
    if (this.queryBorderColor!=''){
        if (jsonParams!='')
            jsonParams+=',';
        jsonParams+="'qbrcolor':'"+this.queryBorderColor.replace("#", "*")+"'";
    }
    if (this.queryColumnColor!=''){
        if (jsonParams!='')
            jsonParams+=',';
        jsonParams+="'qcolcolor':'"+this.queryColumnColor.replace("#", "*")+"'";
    }
    if (this.outsideFontColor!=''){
        if (jsonParams!='')
            jsonParams+=',';
        jsonParams+="'ofcolor':'"+this.outsideFontColor.replace("#", "*")+"'";
    }    
    if (this.outsideHoverFontColor!=''){
        if (jsonParams!='')
            jsonParams+=',';
        jsonParams+="'ohfcolor':'"+this.outsideHoverFontColor.replace("#", "*")+"'";
    }    

    if (jsonParams!='')
        params+='^{'+jsonParams+'}'; 

    return params;
},

this.generateFrameMarkup=function() {
    
    var src='<iframe id="JuzWychodzeForm" allowTransparency="true" frameborder="0" scrolling="'+this.scroll+'" style="height:'+this.height+';width:'+this.width+';border:none;" '+
    'src="'+this.frameUrl+'"><a href="www.juzwychodze.pl" title="JuzWychodze.pl - rozkłady jazdy ZTM Gdańsk, ZKM Gdynia i SKM w nowej prostej wyszukiwarce">JuzWychodze.pl - rozkłady jazdy ZTM Gdańsk, ZKM Gdynia i SKM w nowej prostej wyszukiwarce</a></iframe>';
    return src;
},

this.display=function() {
    document.write(this.generateFrameMarkup());
}

}

