﻿function envodium() {


    var gMapsLoaded = false;
	var sIFRLoaded = false;
    //this.init_jquery = (function() {
    //    jsLoad("http://www.roxx.se/code/javascript/jquery.js");
   // });
	
	 this.init_jquery = (function(plugin) {		
        jsLoad("http://www.roxx.se/code/javascript/jquery.js");		
		if (typeof plugin != "undefined") 
		{			
			pluginlist = plugin.split(',');
			for (i=0;i<pluginlist.length;i++)
			{
				jsLoad("http://www.roxx.se/code/javascript/plugins/"+pluginlist[i]+".js");
			}
		}
    });

    
    this.init_googleMaps = (function() {
        jsLoad("http://maps.google.com/maps/api/js?sensor=true");
        gMapsLoaded = true;
    });
	
	 this.isSIFRLoaded = (function() {
        return sIFRLoaded;
    });
	 
    this.isMapLoaded = (function() {
        return gMapsLoaded;
    });
	
    this.init_jqueryUI = (function() {
        jsLoad("http://www.roxx.se/code/javascript/jquery-ui-1.7.2.custom.min.js");
        jsLoad("http://www.roxx.se/code/javascript/draggalbe.js");
    });
	
	  this.init_sifr = (function() {
        jsLoad("http://www.roxx.se/code/javascript/sifr.js");
		cssLoad("http://www.roxx.se/code/javascript/sifr.css");
    });
	  
	  this.init_swf = (function() {
        jsLoad("http://www.roxx.se/code/javascript/swf.js");
    });
	  
	   this.loadPlugin = (function(src) {
        jsLoad("http://www.roxx.se/code/javascript/plugins/"+src+".js");
    });
    
    
    function jsLoad(src) {
        //var headID = document.getElementsByTagName("head")[0];
        //var newScript = document.createElement('script');
        //newScript.type = 'text/javascript';
        //newScript.src = src;
        //headID.appendChild(newScript);		
    	document.write('<' + 'script src="' + src + '"' +
                   ' type="text/javascript"><' + '/script>');
  
    }
	
	function cssLoad(src) {
        var headID = document.getElementsByTagName("head")[0];
        var newScript = document.createElement('link');
        newScript.type = 'text/css';
        newScript.href = src;
		newScript.rel = "stylesheet";
		//newScript.InnerHtml = "asd";
        headID.appendChild(newScript);
    }
	
this.sifr_add = (function(fontsrc,style,element) {
							  
		  var font = {
            src: fontsrc
        };     
        sIFR.activate(font);
        sIFR.replace(font, {
            selector: element,
            css:'.sIFR-root { '+style+' } ',
            wmode: 'transparent'
        });	
							   
    });



    this.height = (function() {       
        if (jQuery.browser.msie) 
            return document.documentElement.offsetHeight;
        else 
            return window.innerHeight;        
    });

    this.width = (function() {
        if (jQuery.browser.msie)
            return document.documentElement.offsetWidth;
         else 
            return window.innerWidth;        
    });

    
    this.altFix = (function(element) {
        $(element).each(function() {
            if ($(this).attr("alt") != "")
                $(this).attr("title", $(this).attr("alt"));
        });
    });

    this.passwordToText = (function(element, InputSettings) {
        var preValue = InputSettings;
        $(element).each(function() {
            var CurrValue = $(this).val();
            var iCount = Math.floor(Math.random() * 11);
            var fieldID = $(this).attr("id");
            if (fieldID.length == 0) { fieldID = "tmpPwInput" + iCount; }
            var fieldName = "";
            if ($(this).attr("name").length > 0) { fieldName = " name=\"" + $(this).attr("name") + "\"" }
            var cssClass = "";
            var cssStyle = "";
            if ($(this).attr("class").length > 0) { cssClass = " class=\"" + $(this).attr("class") + "\""; }
            if ($(this).attr("style") != "undefined") { cssStyle = " style=\"" + $(this).attr("style") + "\""; }
            if (CurrValue == preValue || CurrValue.length == 0 || Currvalue == "") {
                $(this).after("<input" + cssClass + cssStyle + fieldName + " id=\"" + fieldID + "\" type=\"text\" value=\"" + preValue + "\" />");
                $(this).remove();
                $("#" + fieldID).focus(function() {
                    $(this).after("<input" + cssClass + cssStyle + fieldName + " id=\"" + fieldID + "\" type=\"password\" value=\"\" />");
                    $(this).remove();
                    $("#" + fieldID).focus();
                    $("#" + fieldID).blur(function() {
                        if ($(this).val() == preValue || $(this).val() == "") {
                            $(this).after("<input" + cssClass + cssStyle + fieldName + " id=\"" + fieldID + "\" type=\"text\" value=\"" + preValue + "\" />");
                            $(this).remove();
                            $("#" + fieldID).PasswordInput(InputSettings);
                        }
                    });
                });
            }
        });
    });

    
    this.addEvent = (function(obj, type, fn) {
        if (obj.attachEvent) {
            obj['e' + type + fn] = fn;
            obj[type + fn] = function() { obj['e' + type + fn](window.event); }
            obj.attachEvent('on' + type, obj[type + fn]);
        } else
            obj.addEventListener(type, fn, false);
    });

    _mouseX = 0;
    _mouseY = 0;

    this.mouseX = (function() {
        return _mouseX;
    });

    this.mouseY = (function() {
        return _mouseY;
    });

    this.init_mousemove = (function() {
        this.addEvent(document, 'mousemove', function(e) {
            var IE = document.all ? true : false
            if (IE) {
                _mouseX = event.clientX + document.body.scrollLeft
                _mouseY = event.clientY + document.body.scrollTop
            } else {
                _mouseX = e.pageX
                _mouseY = e.pageY
            }
            //alert(this._mouseX);
        });

    });




}
