/**  
 *  com.sehenundernten.images, version 1.0 
 *
 *  Copyright (c) 2008  Ingmar Drewing, http://www.sehenundernten.com
 *
 *  This js-module handles images within HTML-Documents.
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to 
 *  deal in the Software without restriction, including without limitation the 
 *  rights to use, copy, modify, merge, publish, distribute, sublicense, 
 *  and/or sell copies of the Software, and to permit persons to whom the 
 *  Software is furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 *  DEALINGS IN THE SOFTWARE.
 *
 */

var com;
if (!com) com = {};
else if (typeof com != "object") throw new Error("com exists, but is not an Object!");
if (!com.sehenundernten) com.sehenundernten = {};
else if (typeof com.sehenundernten != "object") throw new Error("com.sehenundernten exists, but is not an Object!");
if (com.sehenundernten.images) throw new Error("com.sehenundernten.images already exists");

com.sehenundernten.images= {

over_images:[],
preload:function(){
    for( var i in arguments ){var img = new Image(); img.src = i;over_images.push(img);};
},

makemouseover:function(){
    var these = [];
    for(var i=0, j=1, k=2; i<arguments.length; i+=3, j=i+1, k=j+1) {
        these.push(arguments[j]);
        var id = arguments[i];
        if( com.sehenundernten.images.get_image(id) != null){
            var img = this.get_image(id);
            img.overImage = arguments[k];
            img.outImage = arguments[j];
            img.onmouseover = function(){
                this.src = this.overImage;
            };
            img.onmouseout = function(){
                this.src = this.outImage;
            };
        }
    }
    this.preload(these);
},

get_image:function(a){
     var b = a.split('');
     b.shift();
     a = b.join('');
     if( !document.getElementById && document.all ){ return document.all[a] }
     else{ return document.getElementById(a); }
}
};

