
/*
 Copyright (c) 2008-2009, Red Universal de Marketing y Bookings Online, S.A. (Rumbo) All rights reserved.
 */
/**
 * Create the Namespace Manager that we'll use to
 * make creating namespaces a little easier.
 */
if (typeof Namespace == 'undefined') var Namespace = {};
if (!Namespace.Manager) Namespace.Manager = {};
Namespace.Manager = {
    Register: function(namespace){
        namespace = namespace.split('.');
        
        if (!window[namespace[0]]) window[namespace[0]] = {};
        
        var strFullNamespace = namespace[0];
        for (var i = 1; i < namespace.length; i++) {
            strFullNamespace += "." + namespace[i];
            eval("if(!window." + strFullNamespace + ")window." + strFullNamespace + "={};");
        }
    }
};







/**
 * LoadScripts Namespace
 */
Namespace.Manager.Register("LoadScripts");

/**
 * Function loadScript
 * This function waits for javascript was loaded
 * @param {Object}
 *            url
 * @param {Object}
 *            callback
 */
LoadScripts.loadScript = function(urls, callback, context){
    var url = urls[0];
    //console.log(url);
    var head = document.getElementsByTagName("head")[0];
    var script = document.createElement("script");
    script.type = 'text/javascript';
    script.src = url;
    
    // Attach handlers for all browsers
    var done = false;
    script.onload = script.onreadystatechange = function(){
        if (!done &&
        (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
            done = true;
            //console.log('done-->' + url);
            if (urls.length == 1) {
                // Continue your code
                if (typeof callback != 'undefined' && callback != null) {
                    if (typeof context != 'undefined' && context != null) {
                        setTimeout(dojo.hitch(context, callback), 0);
                    } else {
                        callback();
                    }
                }
                // Handle memory leak in IE
                script.onload = script.onreadystatechange = null;
                // head.removeChild(script);
            } else {
                var newUrls = new Array;
                if (urls.length == 2) {
                    LoadScripts.loadScript(['' + urls[1] + ''], callback, context);
                } else {
                    for (var i = 1; i < urls.length; i++) {
                        newUrls.push(urls[i]);
                    }
                    LoadScripts.loadScript(newUrls, callback, context);
                }
            }
        }
    };
    head.appendChild(script);
};


/**
 * RmbuiLogs Namespace
 */
Namespace.Manager.Register("RmbuiConsole");

RmbuiConsole = {
    loggerRoot: '',
    typeList: [],
    
    init: function(){
        try {
            var obj = this;
            window.onerror = function(e){
                var error = {};
                error.name = e.name || 'Rmbui: undefined name';
                error.number = e.number || 'Rmbui: undefined number';
                error.message = e.message || (typeof e == 'string') ? e : 'Rmbui: undefined message';
                
                if (obj.logger.debug) {
                    obj.showError(error);
                }
                
                if (typeof IncludeRmbui != 'undefined' && IncludeRmbui.rmbConfig.logs.active) {
                    error.message += (obj.isIE) ? '\nError from IE.\n' : '\nNo IE\n';
                    error.message = error.message.replace(/^\s+|\s+$/g, "") + '\n';
                    obj.addError(error);
                }
                return true;
            };
            
            this.isIE = (/MSIE (\S+)/).test(navigator.userAgent);
            this.logger = IncludeRmbui.rmbConfig.logs;
            this.loggerRoot = this.logger.url;
            this.logger.active = false;
            
            dojo.require("dojo.cookie");
            var context = this;
            if (typeof dojo.cookie(context.logger.cookie.name) == 'undefined') {
                if (dojo.cookie.isSupported()) {
                    dojo.cookie(context.logger.cookie.name, context.isLogger(), {
                        expires: context.logger.cookie.expires
                    });
                } else {
                    throw e;
                }
            }
            context.logger.active = dojo.cookie(context.logger.cookie.name);
            
            //dojo.addOnLoad(function(){
            if (typeof pageTracker != 'undefined' && pageTracker._trackPageview) {
                pageTracker._trackPageview('/virtual/javascriptLogger/activo=' + context.logger.active);
            }
            //});
        } catch (e) {
            this.lite(e);
        }
    },
    
    /**
     * add an error to the typeList and errorList if not exists, or increase the error´s quantity property
     * @param {Object} oe the error to add
     */
    addError: function(error){
        if (this.typeList.length == 0) dojo.addOnUnload(this.send);
        var oe = {
            quantity: 1,
            name: error.name,
            number: error.number,
            message: error.message,
            stack: error.stack
        };
        var addType = true;
        for (i = 0; i < this.typeList.length; i++) {
            var errorType = this.typeList[i];
            if (error.type && error.type == errorType.type) {
                addType = false;
                var addError = true;
                for (j = 0; j < errorType.errors.length; j++) {
                    var le = errorType.errors[j];
                    if (oe.message == le.message && oe.number == le.number && oe.name == le.name) {
                        addError = false;
                        le.quantity++;
                    }
                }
                if (addError) {
                    errorType.errors.push(oe);
                }
            }
        }
        if (addType) {
            this.typeList.push({
                type: error.type,
                errors: [oe]
            });
        }
    },
    
    lite: function(o){
        if (typeof console != 'undefined') {
            console.log(o);
        }
    },
    
    isLogger: function(){
        function isPercent(threshold){
            var random = Math.ceil(Math.random() * 100);
            return (random <= threshold);
        };
        
        var verPercent = 100;
        if (typeof dojo.isIE != 'undefined') {
            this.logger.navPercent = 75;
            switch (dojo.isIE) {
                case 6:
                    verPercent = 30;
                    break
                case 7:
                    verPercent = 45;
                    break
                case 8:
                    verPercent = 25;
                    break
                default:
                    this.logger.navPercent = 5;
                    break
            }
        } else if (dojo.isFF) {
            this.logger.navPercent = 20;
            switch (dojo.isFF) {
                case 2:
                    verPercent = 10;
                    break
                case 3:
                    verPercent = 75;
                    break
                case 3.5:
                    verPercent = 15;
                    break
                default:
                    this.logger.navPercent = 5;
                    break
            }
        }
        return (isPercent(this.logger.navPercent) && isPercent(verPercent) && isPercent(this.logger.percent));
    }
};

RmbuiConsole.debug = function(str, fx){
    object = {
        type: 'DEBUG',
        str: str,
        fx: (typeof fx != 'undefined') ? fx : 'undefined'
    }
    
    this.handle(object)
};

RmbuiConsole.info = function(str, fx){
    object = {
        type: 'INFO',
        str: str,
        fx: (typeof fx != 'undefined') ? fx : 'undefined'
    }
    
    this.handle(object)
};

RmbuiConsole.warn = function(str, fx){
    object = {
        type: 'WARN',
        str: str,
        fx: (typeof fx != 'undefined') ? fx : 'undefined'
    }
    
    this.handle(object)
};

RmbuiConsole.error = function(e){
	object = {
        type: 'ERROR',
        e: e,
        fx: (typeof fx != 'undefined') ? fx : 'undefined'
    }
    
    this.handle(object)
};

RmbuiConsole.fatal = function(e){
    object = {
        type: 'FATAL',
        e: e,
        fx: (typeof fx != 'undefined') ? fx : 'undefined'
    }
    
    this.handle(object)
};

RmbuiConsole.showError = function(error){
    if (typeof console != 'undefined') {
        console.log(error.name + ': ' + error.number);
        console.log(error.message);
        console.log(error.stack);
    }
};

/**
 * sends the errors to the javasriptLogger servlet
 */
RmbuiConsole.send = function(){
    try {
        // request arguments
        var xhrArgs = {
            url: RmbuiConsole.loggerRoot,
            handleAs: "text"
        }
        
        for (i = 0; i < RmbuiConsole.typeList.length; i++) {
            var errorType = RmbuiConsole.typeList[i];
            var errors = '';
            
            // concatenate the same level errors
            for (j = 0; j < errorType.errors.length; j++) {
                var error = errorType.errors[j];
                errors += ('\n' + error.quantity + ': ' + error.message);
                errors += error.name;
                errors += (': ' + error.number + '\n');
            }
            
            // request parameters
            xhrArgs.content = {
                level: errorType.type,
                msg: errors
            };
            
            // send the request
            dojo.xhrPost(xhrArgs);
        }
    } catch (e) {
        RmbuiConsole.lite(e);
    }
};

RmbuiConsole.handle = function(o){
    try {
        var error = {};
        error.type = o.type;
        error.message = o.str || o.e.message;
        error.stack = o.e.stack || '';
        error.name = o.e.fileName || o.e.name;
        error.number = o.e.lineNumber || (o.e.number & 0xFFFF);
        
        // To debug errors
        if (this.logger.debug && typeof console != 'undefined') {
            if (error.type != 'ERROR' && error.type != 'FATAL') {
                var typeLow = error.type.toLowercase();
                console[typeLow]('[rmbui fx]: ' + o.fx);
                console[typeLow]('[rmbui msg]: ', o.str);
            } else {
                this.showError(error);
            }
        }
        
        // To trace errors in the server
        if (typeof IncludeRmbui != 'undefined' && IncludeRmbui.rmbConfig.logs.active) {
            if (this.isIE) {
                throw (error);
            } else if (error.type == 'ERROR' || error.type == 'FATAL') {
                error.message += '\nNo IE\n';
                error.message = error.message.replace(/^\s+|\s+$/g, "") + '\n';
            }
            this.addError(error);
        }
    } catch (error) {
        if (this.isIE) {
            window.onerror(error);
        }
    }
    
    return false;
};

RmbuiConsole.time = function(e){
    if (typeof console != 'undefined' && true) {
        console.time(e);
        //console.log(new Date());
        
    }
};

RmbuiConsole.timeEnd = function(e){
    if (typeof console != 'undefined' && true) {
        console.timeEnd(e);
    }
};


(function(){
    /**
     * InlcudeRmbui Namespace
     */
    Namespace.Manager.Register("IncludeRmbui");
    
    
    /**
     * InlcudeRmbui Namespace
     * @param {Object}
     *            siteConfig
     */
    IncludeRmbui.general = function(siteConfig){
        this.siteConfig = siteConfig;
        this.site = {};
        
        /**
         * SearchBox common params
         */
        this.mainPars = function(){
            try {
                this.debug = false;
                this.local = (typeof this.siteConfig.local != 'undefined' && this.siteConfig.local);
                this.changeJson = !(this.local);
                this.build = !this.local;
                this.ext = (this.debug) ? '.uncompressed.js' : '';
                
                // La version de cada subproyecto se especificara en el include
                // especifico del site
                this.version = {};
                
                // Rutas del rmbui y del rmbuiConfig
                // Revisar esto para ser cambiado por redirecciones en el apache
                if (this.local) {
                    if (this.build) {
                        this.root = '/common/release/rmbui';
                    } else {
                        this.root = '/ui/src/rmbui';
                    }
                    this.includeRoot = '/ui/src/rmbuiConfig';
                } else {
                    this.root = '/common/ui';
                    this.includeRoot = '/common/rmbuiConfig';
                }
                
				/**
                 * SearchBox Params
                 */
				
                this.searchBoxPar = {
                    locations: {
                        depIata: 'depIata*',
                        arrIata: 'arrIata*',
                        depCity: 'depCity*',
                        arrCity: 'arrCity*',
                        arrCountry: 'arrCountry',
                        depDefault: '',
                        depDescDefault: '',
                        arrDefault: '',
                        arrDescDefault: '',
                        defaultValue: false,
                        showArrCity: true,
                        comboLocations: false,
                        autocompleterOff: false,
                        depCityBox: '',
                        arrCityBox: ''
                    },
                    
                    country: {
                        defaultValue: false,
                        arrCountry: '',
                        showArrCountry: true
                    },
                    
                    hotel: {
                        defaultValue: false,
                        arrHotel: '',
                        showArrHotel: true
                    },
                    
                    dates: {
                        depDate: 'depDate*',
                        retDate: 'retDate*',
                        depCal: {
                            name: 'calendarDeparture*',
                            container: 'depCalContainer*',
                            icon: 'showCalDep*'
                        },
                        retCal: {
                            name: 'calendarReturn*',
                            container: 'retCalContainer*',
                            icon: 'showCalRet*'
                        },
                        nights: 'dias_en_sa',
                        defaultValue: false
                    },
                    
                    paxs: {
                        container: 'pax-quantities*',
                        paxAdt: 'paxAdt*',
                        adtQty: '1',
                        paxChd: 'paxChd*',
                        chdQty: '0',
                        paxInf: 'paxInf*',
                        infQty: '0',
                        paxHab: 'paxHab'
                    },
                    
                    options: {
                        click: true,
                        link: 'more-options-link*',
                        lessLink: 'less-options-link*',
                        container: 'more-options*',
                        lessContainer: 'less-options*',
                        changeLocations: 'change-locations*',
                        heightMax: 0,
                        heightMin: 0,
                        
                        directOnly: 'directOnly*',
                        lowCost: 'lowCost*',
                        train: 'trainCheck*',
                        searchTrain: 'train*',
                        renfe: 'onlyRenfe*',
                        promCode: 'promCode*',
                        flowType: 'flowType*',
                        cabin: 'cabin*',
                        byHotel: 'porHotel',
                        distance: 'distance'
                    },
                    
                    others: {
                        loaderClass: 'ajax-loader*',
                        moreRoutes: 'more-routes*',
                        
                        from: '--',
                        change: false
                    },
                    
                    general: {
                        type: "--",
                        sufix: '',
                        error: 'error*',
                        
                        sb: 'search-box*',
                        form: '--',
                        submit: 'search-box-submit*',
                        
                        resultType: {
                            id: 'resultType*',
                            no: 'rt-no*',
                            nr: 'rt-nr*'
                        },
                        
                        queryType: {
                            name: 'queryType*',
                            row: 'row*',
                            rrt: 'rrt*'
                        }
                    },
                    
                    accommodation: {
                        numRooms: 'numRooms',
                        hotel: 'arrHotel'
                    },
                    
                    testABParams: {
                        elementId: '',
                        A: '',
                        B: '',
                        testABConfig: {
                            percentage: 0,
                            testName: '',
                            subTestName: ''
                        }
                    }
                };
                
                
				/**
                 * Specific Project's Params
                 */
                this.specific = {};
				
				this.specific.ua = {
					news:{
						container: 'newsContainer',
						errorContainer: 'newsError',
						form:{
							id: 'newsForm',
							name: 'newsForm',
							inputId: 'mail',
							submitId: 'newsSubmit'
						},
						ajaxPath: './useraccount/home/grabaSuscripcionesConf.action'
					}
				};
				
				
				
				/**
                 * Rmbui Config
                 */
                this.rmbConfig = {
                    version: this.version,
                    build: this.build,
                    debug: this.debug,
                    
                    logs: {
                        active: true,
                        debug: true, // Hay que decidir si toma el mismo valor que this.debug
                        percent: 10,
                        navPercent: 10,
                        url: '/viajes/javascriptLogger.log',
                        cookie: {
                            name: 'rmbui-logs',
                            expires: 2
                        }
                    },
                    
                    locale: this.siteConfig.lang + '-' + this.siteConfig.lang,
                    tm: this.siteConfig.tm,
                    path: {
                        image: '/pictures',
                        imageCompanies: this.local ? '/images/companies' : '/common/compagnies',
                        json: '/json',
                        build: '/ui/ui',
                        src: '/ui/src'
                    },
                    //defaultResultDisplayType: 'R',
                    defaultResultDisplayType: (typeof siteConfig.availability != 'undefined') ? siteConfig.availability.defaultResultDisplayType : 'O',
                    showCompanyName: true,
                    showScheduleMatrix: true,
                    showFilters: true,
                    defaultOptionPageLength: 10,
                    defaultRecPageLength: 55,
                    defaultPageLength: 10
                
                };
                rmbConfig = this.rmbConfig;
                
                var obj = this;
                this.djConfig = {
                    isDebug: false,
                    locale: this.rmbConfig.locale,
                    addOnLoad: function(){
                        var sc = [];
                        sc.push(obj.includeRoot + '/rmbuiInclude' + obj.siteConfig.from + '.js');
                        LoadScripts.loadScript(sc, obj.initBuild, obj);
                    }
                };
            } catch (e) {
                RmbuiConsole.lite(e);
            }
        };
        
        
        
        this.createTabs = function(){
            /* Create Tabs */
            try {
                var sbTabs = dojo.query('.sbTab');
                var sbTabLinks = dojo.query('.sbTab-link')
                
                dojo.forEach(sbTabLinks, function(item){
                    dojo.connect(item, 'click', function(){
                        dojo.forEach(sbTabLinks, function(it){
                            dojo.removeClass(it, 'active');
                        });
                        dojo.addClass(item, 'active');
                        
                        dojo.forEach(sbTabs, function(it){
                            dojo.removeClass(it, 'active');
                            dojo.addClass(it, 'hidden');
                        });
                        var reqId = item.id.replace('-link', '');
                        dojo.removeClass(dojo.byId(reqId), 'hidden');
                        dojo.addClass(dojo.byId(reqId), 'active');
                    })
                });
            } catch (e) {
                RmbuiConsole.error(e);
            }
        };
        
        
		this.loadAds = function(){
            /*
			try {
            	for (item in siteConfig.ads.el) {
					console.log(siteConfig.ads.el[item].url);
					
					var currentNode = siteConfig.ads.el[item].node;
					var xhrArgs = {
						url: siteConfig.ads.el[item].url,
						handleAs: "text",
						headers: {
							"Accept": "text/javascript" 
						},
						preventCache: true,
						content: {
							node: currentNode
						},
						timeout: 3000,
						load: function(response, ioArgs){
							var sc = "document.write(\"<div id='" + this.content.node + "_c' class='hidden>\");"
							sc += response;
							sc += "document.write(\"</div>\")";
							
							//dojo.eval(sc);
						},
						error: function(error){
							console.log('-->error loading js')
						}
					}
					dojo.xhrGet(xhrArgs);
				}
				
				console.log('nodo')
				console.log(dojo.byId(siteConfig.ads.el[item].node))
				console.log(dojo.byId(siteConfig.ads.el[item].node + '_c'))  
				//dojo.byId(siteConfig.ads.el[item].node).appendChild(dojo.byId(siteConfig.ads.el[item].node + "_c"));
				
            } catch (e) {
				console.log('loadAds error');
				console.log(e);
                //RmbuiConsole.error(e);
            }
            */
        };
		
		
        /**
         *
         * @param {Object}
         *            testABParams
         */
        this.initTestAB = function(testABParams){
            try {
                // Rmbui  available for IE7+ and FF3.5+
                if (dojo.isIE >= 7 || dojo.isFF > 3) {
                    result = rmb.seo.testAB.TestABClass(testABParams.testABConfig);
                    dojo.byId(testABParams.elementId).value = testABParams[result];
                }
				dojo.byId(testABParams.elementId).value = 'P';
				
				var getPar = new Array();
				var getUrl = document.location.href.split('?');
				if (getUrl.length > 1) {
					getPar = getUrl[1].split('&');
				}
				
				if (getPar.length > 0) {
					for (var i = 0; i < getPar.length; i++) {
						if (getPar[i] == 'lt=NR') {
							document.getElementById('resultType-flight').value = "NR";
						}
					}
				}
				
			} catch (e) {
                RmbuiConsole.error(e);
            }
        };
        
        
        
        /**
         *
         */
        this.initRmbui = function(){
        
            try {
                // Requires
                if (this.local && this.site.getRequires) {
                    // requires especificos del site
                    var requires = this.site.getRequires();
                    
                    //>>excludeStart("general", true)
                    dojo.forEach(requires, function(require){
                        dojo.require(require);
                    })
                    //>>excludeEnd("general")
                }
                
                /**
                 * convertPar: set the Object b into Object a all fields in b must
                 * be in a, but with diferent value
                 *
                 * @param {Object}
                 *            a
                 * @param {Object}
                 *            b
                 */
                var convertPar = function(a, b){
                    for (var item in b) {
                        a[item] = (dojo.isObject(b[item])) ? convertPar(a[item], b[item]) : b[item];
                    }
                    return a;
                };
                
                /**
                 * setSufix: replace the * by the appropriate suffix all fields in b
                 * must be in a, but with diferent value
                 *
                 * @param {Object}
                 *            a
                 * @param {String}
                 *            b
                 */
                var setSufix = function(a, sufix){
                    var concat = (sufix) ? sufix : '';
                    for (var item in a) {
                        if (dojo.isObject(a[item])) {
                            a[item] = setSufix(a[item], concat);
                        } else {
                            if (!dojo.isFunction((a[item]))) {
                                var str = '' + a[item];
                                if (str.indexOf('*') != -1) {
                                    a[item] = str.replace('*', concat);
                                }
                            }
                        }
                    }
                    return a;
                }
                
                // Por cada buscador hay un objeto de configuración
                var siteConfigs = this.site.configs || null;
                if (siteConfigs) {
                    for (var sb in siteConfigs) {
                        var siteParams = siteConfigs[sb];
                        if (siteParams && siteParams.active) {
                            this.site.sbParams = setSufix(convertPar(dojo.clone(this.searchBoxPar), siteParams), siteParams.general.sufix);
                            this.site.buildObj(this.site.sbParams);
                        }
                    }
                }
                
                // Acciones especificas del site que se ejecutan después de inicializar el buscador
                if (this.site.afterHourAction) {
                    this.site.afterHourAction(this);
                }
				
				setTimeout(dojo.hitch(this, this.devFx), 1000);
				
            } catch (e) {
                RmbuiConsole.error(e);
            }
        };
        
        
        
        /**
         *
         */
        this.initBuild = function(){
            if (!this.local) {
                dojo.registerModulePath('dojo', '/ui/core/dojo1.1');
            }
            
			try {
                this.site = new Site(this.root, this.local);
                this.version = this.site.version;
                
                // Activate logs
                RmbuiConsole.init();
                
                // For tabbers & others
                if (this.siteConfig.tabs && this.siteConfig.tabs.active) {
                    this.createTabs();
                }
                
                if (this.siteConfig.from == 'HomeHome' && this.siteConfig.tm == 'vjr') {
                    if (this.build) {
                        LoadScripts.loadScript([this.site.path.util + '/xtrasVjr.js' + this.ext]);
                    } else {
                        LoadScripts.loadScript(['/ui/src/rmbui/util/ui/tabber.js']);
                        LoadScripts.loadScript(['/ui/src/rmbui/util/ui/iepngfix_tilebg.js']);
                    }
                }
                
                // Scripts comunes para todos los sites
                var commonScripts = [];
                if (this.local && !this.build) {
                    dojo.registerModulePath('rmbui', this.rmbConfig.path.src + '/rmbui');
                    dojo.registerModulePath('YAHOO', this.rmbConfig.path.src + '/yui');
                    dojo.registerModulePath('dojo', this.rmbConfig.path.src + '/dojo/dojo');
                    dojo.registerModulePath('dijit', this.rmbConfig.path.src + '/dojo/dijit');
                    dojo.registerModulePath('dojox', this.rmbConfig.path.src + '/dojo/dojox');
                    commonScripts = [
                        '/ui/src/yui/YahooDomEvent.js', 
                        '/ui/src/rmbui/rmbui.js'
                    ];
                } else {
                    if (this.changeJson) {
                        rmbConfig.path.json = '/js/JSON';
                    }
                    commonScripts = [
                        this.site.path.util + '/rmbui.js' + this.ext, 
                        this.site.path.util + '/i18n-' + this.siteConfig.lang + '.js' + this.ext
                    ];
                }
                
                // scripts/layers especificos del site
                var siteScripts = this.site.getScripts(this.local, this.build, this.ext);
                LoadScripts.loadScript(commonScripts.concat(siteScripts), this.initRmbui, this);
                
				// For advertisement
				/*
                if (this.siteConfig.ads && this.siteConfig.ads.active) {
                    setTimeout(this.loadAds, 1000);
                }
                */
				
				
            } catch (e) {
				//console.log(e);
                RmbuiConsole.error(e);
            }
        };
        
        
        
        /**
         *
         */
        this.init = function(){
            try {
                this.mainPars();
                
                var rmbConfig = this.rmbConfig;
                var djConfig = this.djConfig;
                
                // Cargo el include especifico del site
                var sc = [];
                
                if (typeof dojo == 'undefined') {
                    //var djConfig = this.djConfig;
                    var djConfig = {
                        isDebug: true,
                        afterOnLoad: true,
                        locale: 'es-es'
                    };
                    djConfig.addOnLoad = function(){
                        //RmbuiConsole.lite('dojo loaded');
                    }
                    //LoadScripts.loadScript(['/ui/src/dojo/dojo/dojo.js']);
                    LoadScripts.loadScript(['/ui/core/dojo1.1/dojo.js']);
                } else {
                    sc.push(this.includeRoot + '/rmbuiInclude' + this.siteConfig.from + '.js');
                    LoadScripts.loadScript(sc, this.initBuild, this);
                }
            } catch (e) {
                RmbuiConsole.lite(e);
            }
        };
        
        /**
         * Checks to see if Chrome Frame is available and sends the data to ga
         */
        this.checkCF = function(){
            // only for IE
            if ((/MSIE (\S+)/).test(navigator.userAgent)) {
                var cfAvailable = false;
                
                // Look for CF in the User Agent before trying more expensive checks
                var ua = navigator.userAgent.toLowerCase();
                
                if (ua.indexOf("chromeframe") >= 0 || ua.indexOf("x-clock") >= 0) {
                    cfAvailable = true;
                } else if (typeof window['ActiveXObject'] != 'undefined') {
                    try {
                        var obj = new ActiveXObject('ChromeTab.ChromeFrame');
                        if (obj) {
                            cfAvailable = true;
                        }
                    } catch (e) {
                        // squelch
                    }
                }
                
                if (typeof pageTracker != 'undefined' && pageTracker._trackPageview) {
                    pageTracker._trackPageview('/virtual/cf-user=' + cfAvailable);
                }
            }
        };
        
		this.devFx = function(){
			try {
				this.getPar = new Array();
				var getUrl = document.location.href.split('?');
				if (getUrl.length > 1) {
					this.getPar = getUrl[1].split('&');
				}
				//console.log(this.getPar);
				
				if (this.getPar.length > 0) {
					for (var i = 0; i < this.getPar.length; i++) {
						
					}
				}
			}
			catch(e){
				RmbuiConsole.error(e);
			}
		};
		
		
        this.init();
		this.checkCF();
	};
    
    IncludeRmbui.general(siteConfig);
})();
