/**
 * content.js - insert headline here
 *
 * COPYRIGHT: All  title   and  proprietary  rights,  including  trade
 * secrets,   in   the   Software   and   any   copies thereof and the
 * accompanying  written   materials,   are  owned  by   schukai  GmbH
 * and  are  protected  by  German  copyright  laws,  other applicable
 * copyright   laws  and  international  treaty  provisions.
 *
 * @package    alvine
 * @author     schukai GmbH <info@schukai.de>
 * @copyright  Copyright (C) 2002, 2003, 2004, 2005, 2006 schukai GmbH
 * @license    http://www.alvine.de/license/
 * @version    20061114
 * @link       http://www.alvine.de/
 */

if(typeof alvine == 'undefined') var alvine = new Object();
 
function content_js_init(boxID, options){

  if(typeof alvine['session'] == 'undefined') alvine['session'] = new Object();
  if(typeof alvine['plugin']  == 'undefined') alvine['plugin'] = new Object();
  if(typeof alvine['content'] == 'undefined') alvine['content'] = new Object();
  if(typeof alvine['content']['imagePreloader'] == 'undefined') alvine['content']['imagePreloader'] = new Object();
  
  if(typeof options.useImagePreloader != 'undefined'){
    if(options.useImagePreloader){
      event_add(document, 'load', content_js_imagePreloader_preloadImages);
      event_add(window, 'load', content_js_imagePreloader_preloadImages);
    }
  }
}

function content_js_imagePreloader_registerImage(imageUrl, key){
  
  if(typeof imageUrl == 'undefined') return false;
  key = (typeof key == 'undefined')?imageUrl:key;
  
  if(typeof alvine['content']['imagePreloader'][key] == 'undefined') alvine['content']['imagePreloader'][key] = new Object();
  alvine.content.imagePreloader[key]['url'] = imageUrl;
  
  return true;  
}

function content_js_imagePreloader_getStoredImageObject(key){
  if(typeof key == 'undefined') return false;
  if(typeof alvine.content.imagePreloader[key]['object'] == 'undefined') return false;
  
  return alvine.content.imagePreloader[key]['object'];  
}

function content_js_imagePreloader_preloadImages(ev){
  
  if(!ev) ev = window.event;
  
  for(var i in alvine.content.imagePreloader){

    if(typeof alvine.content.imagePreloader[i]['url']    == 'undefined') continue;
    if(typeof alvine.content.imagePreloader[i]['object'] != 'undefined') continue;
    
    alvine.content.imagePreloader[i]['object'] = new Image();    
    alvine.content.imagePreloader[i]['object'].src = alvine.content.imagePreloader[i]['url'];  
  }
  
}

