﻿function onMouseOverTable (column) {
    column.style.backgroundColor="#e8edf4";
}
function onMouseOutTable (column) {
    column.style.backgroundColor='#fff';
}

function clearInput(defaultValue, inputObj)
{
    if(inputObj.value == defaultValue)
    {inputObj.value='';}
}


var mainNaviArray = new Array();
function change_mainnavigation() {
    clear_all();
    var mainnavigationAuswahl = document.forms.quicklink.mainnavigation;
    var subnavigationAuswahl = document.forms.quicklink.subnavigation;
    var mainnavigationValue = mainnavigationAuswahl.options[mainnavigationAuswahl.selectedIndex].value;
    mainNavi(mainnavigationValue);
}
function goto_subnavigation() {
    var subnavigationAuswahl = document.forms.quicklink.subnavigation;
    if (subnavigationAuswahl.options[subnavigationAuswahl.selectedIndex].value!="" && subnavigationAuswahl.options[subnavigationAuswahl.selectedIndex].value!="bitte wählen") {
        eval("parent.location='"+subnavigationAuswahl.options[subnavigationAuswahl.selectedIndex].value+"'");
    }
}
function clear_all() {   
    var subnavigationAuswahl = document.forms.quicklink.subnavigation;
    for (i=0; i<=subnavigationAuswahl.length; i++) {
        subnavigationAuswahl.options[i] = null;
    }
}
function mainNavi(mainnavigationValue) {
    var subnavigationAuswahl = document.forms.quicklink.subnavigation;
    var mainNaviArrayLength = mainNaviArray.length;
    for (var i=0; i<mainNaviArrayLength; i++) {
        var mainNavi = mainNaviArray[i];
        var subNaviArrayLength = mainNaviArray[mainNaviArray[i]].length;
        for (var j=0; j<subNaviArrayLength; j++) {
            var teilen = mainNaviArray[mainNaviArray[i]][j].split("|");
            var subNaviLink = teilen[0]
            var subNaviTitle = teilen[1];
            if (mainnavigationValue==mainNavi) {
                subnavigationAuswahl.options[j] = new Option(subNaviTitle, subNaviLink);
            }
        }
    }
}

 
/* Schriftgröße */
function getElementsByClassName(classname,tag) {
     if(!tag) tag = "*";
     var anchs =  document.getElementsByTagName(tag);
     var total_anchs = anchs.length;
     var regexp = new RegExp('\\b' + classname + '\\b');
     var class_items = new Array()
     var idname = document.getElementById(classname);
     if (idname) {
        class_items.push(idname);
     }
     else {
        for(var i=0;i<total_anchs;i++) { //Go thru all the links seaching for the class name
            var this_item = anchs[i];
            if(regexp.test(this_item.className)) {
                class_items.push(this_item);
            }
        }
    }
    if (class_items.length==0) {
        class_items.push(document.getElementById('logo'));  
    }
    return class_items;
}

function changeContentFontSize(nameClass, mode, factor, maxSize, minSize) {
    var schriftgroesse = getElementsByClassName(nameClass, 'div')[0].style;
    if (schriftgroesse.fontSize==""){
        getElementsByClassName(nameClass, 'div')[0].style.fontSize="1em"
    }    
    if (mode=="raise"){
        if (schriftgroesse.fontSize.replace("em", '') < maxSize) {
            schriftgroesse.fontSize = schriftgroesse.fontSize.replace("em", '') * factor+'em';
        }
    }
    if (mode=="decrease"){
        if (schriftgroesse.fontSize.replace("em", '') > minSize) {
            schriftgroesse.fontSize = schriftgroesse.fontSize.replace("em", '') / factor+'em';
        }
    }
    if (nameClass=='headerNavi') {
        if (schriftgroesse.fontSize.replace("em", '') >= 1.21) {
            schriftgroesse.height = '3.5em';
        } else {
            schriftgroesse.height = '1.9em';        
        } 
    }
    document.getElementById('footer').style.position="static";
    document.getElementById('footer').style.position="absolute";
 }
 
 
function raiseContentSize() {
     //changeContentFontSize('classe/id', 'raise', 'factor', 'max', 'min');
     changeContentFontSize('headerNavi', 'raise', '1.1', '1.2', '0.8');
     changeContentFontSize('subNaviLeft', 'raise', '1.1', '1.2', '0.8');
     changeContentFontSize('subNaviRight', 'raise', '1.1', '1.2', '0.8');
     changeContentFontSize('leftNavi', 'raise', '1.1', '1.2', '0.8');
     changeContentFontSize('rightTeaser', 'raise', '1.1', '1.2', '0.8');
     changeContentFontSize('content', 'raise', '1.1', '1.2', '0.8');
     //changeContentFontSize('footer', 'raise', '1.1', '1.2', '0.8');
     changeContentFontSize('bottomTeaser', 'raise', '1.1', '1.2', '0.6');
     changeContentFontSize('leftText', 'raise', '1.1', '1.2', '0.8');
}
 function decreaseContentSize() {
     changeContentFontSize('headerNavi', 'decrease', '1.1', '1.2', '0.8');
     changeContentFontSize('subNaviLeft', 'decrease', '1.1', '1.2', '0.8');
     changeContentFontSize('subNaviRight', 'decrease', '1.1', '1.2', '0.8');
     changeContentFontSize('leftNavi', 'decrease', '1.1', '1.2', '0.8');
     changeContentFontSize('rightTeaser', 'decrease', '1.1', '1.2', '0.8');
     changeContentFontSize('content', 'decrease', '1.1', '1.2', '0.8');
     //changeContentFontSize('footer', 'decrease', '1.1', '1.2', '0.8');
     changeContentFontSize('bottomTeaser', 'decrease', '1.1', '1.2', '0.6');
     changeContentFontSize('leftText', 'decrease', '1.1', '1.2', '0.8');
 }
 function standardContentSize() {
     getElementsByClassName('headerNavi', 'div')[0].style.fontSize='1em';
     getElementsByClassName('subNaviLeft', 'div')[0].style.fontSize='1em';
     getElementsByClassName('subNaviRight', 'div')[0].style.fontSize='1.1em';
     getElementsByClassName('leftNavi', 'div')[0].style.fontSize='1em';
     getElementsByClassName('rightTeaser', 'div')[0].style.fontSize='1em';
     getElementsByClassName('content', 'div')[0].style.fontSize='1em';
     //getElementsByClassName('footer', 'div')[0].style.fontSize='1em';
     getElementsByClassName('headerNavi', 'div')[0].style.height='1.9em';
     getElementsByClassName('bottomTeaser', 'div')[0].style.fontSize='1em';
     getElementsByClassName('leftText', 'div')[0].style.fontSize='1.1em';
}
/* Schriftgröße */
 

/*
 * EuKr Popupscript - You can change here the HTML-Code of the POPUP  
 */
function slideshow(elementId)
{
  this.slideshowImages       = new Array();
  this.slideshowCaption         = new Array();
  this.slideshowDescriptions = new Array();
  this.slideshowPopupLinks   = new Array();
  this.slideshowPopupHeadline= new Array();
  this.slideshowPopupText    = new Array();
  this.counter               = 0;
  this.totalImages           = 0;
  this.elementId             = elementId;
  /**
   * Push an image into the slideshow
   *
   * @param  image        Image filename
   * @param  description  Image description
   * @param  popuplink    Link to the image popup template
   */  
  this.pushImage = function(image, caption, description, popuplink, popupheadline, popuptext)
  {
    this.slideshowImages.push(image);
    this.slideshowCaption.push(caption);
    this.slideshowDescriptions.push(description);
    this.slideshowPopupLinks.push(popuplink);
    this.slideshowPopupHeadline.push(popupheadline);
    this.slideshowPopupText.push(popuptext);
  }
  this.imagePopUp = function(slideshowItem, itemNumber){
 
    popUpImage = window.open('', "ueberschrift", "width=500,height=700,scrollbars=yes,resizable=yes");
    popUpImage.document.open('text/html');
    // POPUP HTML-TEXT
    popUpImage.document.writeln('<!'+'DOC'+'TYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
    popUpImage.document.writeln('<ht'+'ml xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">');
    popUpImage.document.writeln('<he'+'ad>');
    popUpImage.document.writeln('<title>'+this.slideshowCaption[itemNumber]+'</title>');
    popUpImage.document.writeln('<meta name="keywords" content="" />    <meta name="description" content="Indexwerke" />');
    popUpImage.document.writeln('<meta http-equiv="content-type" content="text/html; charset=utf-8" />');
    popUpImage.document.writeln('<meta http-equiv="imagetoolbar" content="no" />');
    popUpImage.document.writeln('<meta name="author" content="Indexwerke" />');
    popUpImage.document.writeln('<meta name="copyright" content="Indexwerke" />');
    popUpImage.document.writeln('<meta name="page-topic" content="" />');
    popUpImage.document.writeln('<meta name="audience" content="all" />');
    popUpImage.document.writeln('<meta name="robots" content="index, follow" />');
    popUpImage.document.writeln('<style>');
    popUpImage.document.writeln('</he'+'ad>');
    popUpImage.document.writeln('<bo'+'dy>');
    popUpImage.document.writeln('html {height:100%; width:100%;}');
    popUpImage.document.writeln('body {font-family: arial, verdana; height:100%; width:100%; background:#ffffff; font-size:62.5%; margin:0px;}');
    popUpImage.document.writeln('img {border:0px; float:right;    }');
    popUpImage.document.writeln('img {border:0px; float:right;    }');
    popUpImage.document.writeln('.homelink img{margin:11px;}');
    popUpImage.document.writeln('.clear {clear:both; line-height:0px;}');
    popUpImage.document.writeln('.popup {text-align:left; margin:0px; width:100%;}');
    popUpImage.document.writeln('.popup h1 {background:#b9babe; color:#FFFFFF; font-size:1.2em; text-align:left; padding:0px 0px 0px 10px;    }');
    popUpImage.document.writeln('.popup .popupdescription {background:transparent url() repeat-x bottom; color:#000; font-size:1.1em; text-align:left; padding:0px 0px 3px 0px; margin:0px 10px 0px 10px;}');
    popUpImage.document.writeln('.popup .popupimg {background:transparent url() repeat-x bottom;    margin:0px 10px;padding:1px 0px 2px 0px;}');
    popUpImage.document.writeln('.popup .popupimg img {float:none;    }');
    popUpImage.document.writeln('.popup .ancicon {        font-size:1.1em; font-weight:bold; float:right; background-image: url(); background-position: 0 .45em; background-repeat: no-repeat; color:#747378; padding-left:6px; margin:5px 10px;    text-decoration:none;}    ');
    popUpImage.document.writeln('.popup .ancicon:hover {        background-image: url(); color:#000;    text-decoration:none; }');
    popUpImage.document.writeln('</style>');
    popUpImage.document.writeln('<div style="height:25px;"><br class="clear" /></div>');
    popUpImage.document.writeln('<div class="popup">    ');
    popUpImage.document.writeln('<h1 style="margin-bottom:5px; padding:3px 0 3px 10px;">'+ this.slideshowPopupHeadline[itemNumber]+'</h1><span class="clear" /></span>');
    popUpImage.document.writeln('<div class="popupdescription" style="padding-bottom:5px;">'+this.slideshowPopupText[itemNumber]+'</div><br class="clear" />');
    popUpImage.document.writeln('<div class="popupimg"><img src="'+this.slideshowPopupLinks[itemNumber]+'" onload="window.resizeTo(this.offsetWidth+50,this.offsetHeight+280)"  /></div>');
    popUpImage.document.writeln('<a class="ancicon" onclick="window.close();" href="#"  >Close</a>');
    popUpImage.document.writeln('<br class="clear" />');
    popUpImage.document.writeln('</div>');
    popUpImage.document.writeln('</body>');
    popUpImage.document.writeln('</html>');
    
    popUpImage.document.close();
  }
  /**
   * Init slideshow after all images were added, load the first image in array
   */     
  this.initSlideshow = function()
  {
    document.getElementById('defaultImage' + this.elementId).style.display="none";
    document.getElementById('border' + this.elementId).style.display="block";
    document.getElementById('max' + this.elementId).innerHTML     = this.slideshowImages.length;
    
    this.totalImages = this.slideshowImages.length;
    
    if (this.totalImages > 0)
    {
      // Load first picture and properties
      //document.getElementById('MainArticleInBlock' + this.elementId).style.display = 'block';
      this.updateSlideshow(this.elementId, 0);
      // Display slideshow navigation only if there is more than one image
      if (this.totalImages >= 2) {
        document.getElementById('galleryHeader' + this.elementId).style.display = 'block';
        document.getElementById('GalleryNavigation' + this.elementId).style.display = 'block';
        document.getElementById('border' + this.elementId).className                = 'gallerImageCont';
      } else {
          
        if (document.getElementById('text' + this.elementId).innerHTML == ''){
            document.getElementById('border' + this.elementId).className = 'gallerImageCont noBorder';
        } else {
            document.getElementById('border' + this.elementId).className = 'gallerImageCont';    
        }      
      }
    
      // Set total number of images
      document.getElementById('max' + this.elementId).innerHTML     = this.slideshowImages.length;
      
    }
    
  }
  /**
   * Loads previous image if current image is not the first slideshow image
   */     
  this.previousImage = function()
  {
    if (this.counter > 0)
    {
      this.counter--;
      this.updateSlideshow(this.elementId, this.counter);
    }
  }
  /**
   * Loads next image if current image is not the last slideshow image
   */     
  this.nextImage = function()
  {
    if (this.counter < this.slideshowImages.length - 1)
    {
      this.counter++;
      this.updateSlideshow(this.elementId, this.counter);
    }
  }
  /**
   * Opens the detail image popup
   * 
   * @param  width   width of the popup window
   * @param  height  height of the popup window         
   */     
  this.zoomImage = function(width, height)
  {
    var popupUrl = (this.slideshowPopupLinks[this.counter] != '') ? this.slideshowPopupLinks[this.counter] : '';
    window.open(popupUrl, 'slideshowPopup', 'width=' + width + ', height='+ height + ', resizable=yes');
  }
  /*
   * Used internally to update the slideshow element
   */
  this.updateSlideshow = function(slideshowItem, itemNumber)
  {
    document.getElementById('image' + slideshowItem).src                = this.slideshowImages[itemNumber];    
    
    // Display current image number and description
    document.getElementById('akt' + slideshowItem).innerHTML              = itemNumber + 1;
    
   
    document.getElementById('imageCaption' + slideshowItem).innerHTML     = this.slideshowCaption[itemNumber];
    
    document.getElementById('zoomIcon' + slideshowItem).style.display = (this.slideshowPopupLinks[itemNumber] != "")? "block" : "none";
    
    if (document.getElementById('imageCaption' + slideshowItem).innerHTML != ''){        
        document.getElementById('imageCaption' + slideshowItem).style.display = 'block';
    }else{
        document.getElementById('imageCaption' + this.elementId).style.display = 'none';    
    }
    
    document.getElementById('text' + slideshowItem).innerHTML            = this.slideshowDescriptions[itemNumber];
    
    if (document.getElementById('text' + slideshowItem).innerHTML == ''){
        document.getElementById('text' + slideshowItem).style.display = 'none';
    } else {
        document.getElementById('text' + slideshowItem).style.display = 'block';
        document.getElementById('border' + slideshowItem).className   = 'gallerImageCont';
    }    
    }    
}
 


    
    jQuery().ready(function(){ 
    $(".lightboxLink").click(function(){
        $(this).prevAll("a.lightboxImage").triggerHandler('click');
        return false;
   });
    
    $(".imageslider").attr("class","sliederframe imageslider-active");        
    // $(".imagesliderReddot").attr("class","sliederframe imageslider"); // RedDot Editing Mode
    
    $(".sliederframe").each(function(i){
        if (($(this).hasClass("reddot"))){alert("test")}
        if ($(this).find(".slideitem").css("width")){ 
            var slideItem = $(this).find(".slideitem");
            var slideItemWidth = slideItem.css("width").replace(/px/,"");            
            //var slideItemSpace = parseInt(slideItem.css("border-left-width").replace(/px/,"")) + parseInt(slideItem.css("border-right-width").replace(/px/,"")) + parseInt(slideItem.css("margin-left").replace(/px/,"")) + parseInt(slideItem.css("margin-right").replace(/px/,"")) + parseInt(slideItem.css("padding-left").replace(/px/,"")) + parseInt(slideItem.css("padding-right").replace(/px/,"")) ;      
            var itemCount = $(this).find(".slideitem").length;            
            //$(this).find(".slideitemcontainer").width((parseInt(slideItemSpace) + parseInt(slideItemWidth))*itemCount);
            $(this).find(".slideitemcontainer").width(parseInt(slideItemWidth)*itemCount);
        }                
    })
    
    var Slidingspeed = 2000;
        
    $(".sliederframe .left").mousedown(function(){
        var $slideItemContainer = $(this).closest(".sliederframe").find(".slideitemcontainer");
        var sliderPosition = $slideItemContainer.css("left").replace(/px/,"");    
        var slideItem = $slideItemContainer.find(".slideitem");        
        var slideItemWidth = $(slideItem).css("width").replace(/px/,"");
        var slideItemCount = $(slideItem).length;            
        $slideItemContainer.animate({ left: 0 }, Slidingspeed);    
        return false;
    }).mouseup(function() {
        var $slideItemContainer = $(this).closest(".sliederframe").find(".slideitemcontainer");    
        var sliderPosition = $slideItemContainer.css("left").replace(/px/,"");        
        //$slideItemContainer.animate({ left: sliderPosition = sliderPosition}, Slidingspeed);
        
        $slideItemContainer.stop();
        return false;
            
    }).click(function() {
        return false;
    });
    
    $(".sliederframe .right").mousedown(function(){
        var $slideItemContainer = $(this).closest(".sliederframe").find(".slideitemcontainer");    
        var sliderPosition = $slideItemContainer.css("left").replace(/px/,"");        
        var slideItem = $slideItemContainer.find(".slideitem");        
        var slideItemWidth = $(slideItem).css("width").replace(/px/,"");
        //var slideItemSpace = parseInt(slideItem.css("border-left-width").replace(/px/,"")) + parseInt(slideItem.css("border-right-width").replace(/px/,"")) + parseInt(slideItem.css("margin-left").replace(/px/,"")) + parseInt(slideItem.css("margin-right").replace(/px/,"")) + parseInt(slideItem.css("padding-left").replace(/px/,"")) + parseInt(slideItem.css("padding-right").replace(/px/,"")) ;      
        var slideItemCount = $(slideItem).length;
        /*
        if ((((-1) * sliderPosition) < ( parseInt(slideItemWidth)*(slideItemCount-1))  ) && ((sliderPosition*(-1))%parseInt(slideItemWidth)) == 0) {
            //$slideItemContainer.animate({ left: sliderPosition-parseInt(slideItemWidth)}, Slidingspeed)        
        }
        */
        //alert($slideItemContainer.width());
        $slideItemContainer.animate({ left: -($slideItemContainer.width()-410)}, Slidingspeed);    
        return false;
        //if ((((-1) * sliderPosition) < ( (parseInt(slideItemSpace) + parseInt(slideItemWidth))*(slideItemCount-1))  ) && ((sliderPosition*(-1))%(parseInt(slideItemSpace) + parseInt(slideItemWidth))) == 0) { $slideItemContainer.animate({ left: sliderPosition-(parseInt(slideItemSpace) + parseInt(slideItemWidth))}, 300)    }                    
    }).mouseup(function() {
        var $slideItemContainer = $(this).closest(".sliederframe").find(".slideitemcontainer");    
        var sliderPosition = $slideItemContainer.css("left").replace(/px/,"");        
        //$slideItemContainer.animate({ left: sliderPosition = sliderPosition}, Slidingspeed);
        
        $slideItemContainer.stop();
        return false;
            
    }).click(function() {
        return false;
    });
}); 


/*Change worldmap, europemap, germanymap with thumbnails*/
jQuery().ready(function(){ 
    /*Change map*/
    jQuery("#map_thumb a").mouseover(function(){return $(this).onMouseOverAndClick();}).click(function(){return $(this).onMouseOverAndClick();});
    $.fn.onMouseOverAndClick = function() {
        var indexMap = jQuery("#map_thumb a").index(this);
        var mapPath = $(this).attr("href");
        $("#startmap").attr({ src: mapPath }); 
        jQuery("#map_location_links>div").hide();
        jQuery("#map_location_links>div:eq("+indexMap+")").show();
        return false;
    };
    
    /*Default worldmap*/
    jQuery("#map_thumb a#worldmap-thumb").addClass("active");
    jQuery("#rightText").mouseout(function(){
        $("#map_thumb a").removeClass("active");
        $("#map_thumb a#worldmap-thumb").addClass("active");
        $("#map_thumb").show(); 
        $("#map_location_links>div ").hide(); 
        $("#map_location_links").show(); 
        $("#map_location_links>div#worldmapanchorblock ").show(); 
    });
    
    jQuery("#rightText").mouseover(function(){
        $("#map_thumb").hide(); 
        $("#map_location_links").hide(); 
    });
    
    /*Active thumbnails*/
    jQuery("#map_thumb a").click(function(){
        $("#map_thumb a").removeClass("active");
        $(this).addClass("active");
    });
    
    jQuery("#map_thumb a").hover(
        function () {
            $("#map_thumb a").removeClass("active");
            $(this).addClass("active");
        }, 
        function () {
        }
     ); 
    /*Change IT-link images*/ 
    jQuery("#rightText>ul>li").hover(function(){
        changeImage($("#rightText>ul>li").index(this)+1);
    },function(){
        changeImage(0);
    });
});

(function($){
    
    //closeDOMWindow
    $.fn.closeDOMWindow = function(settings){
        
        if(!settings){settings={};}
        
        var run = function(passingThis){
            
            if(settings.anchoredClassName){
                var $anchorClassName = $('.'+settings.anchoredClassName);
                $anchorClassName.fadeOut('fast',function(){
                    if($.fn.draggable){
                        $anchorClassName.draggable('destory').trigger("unload").remove();    
                    }else{
                        $anchorClassName.trigger("unload").remove();
                    }
                });
                if(settings.functionCallOnClose){settings.functionCallAfterClose();}
            }else{
                var $DOMWindowOverlay = $('#DOMWindowOverlay');
                var $DOMWindow = $('#DOMWindow');
                $DOMWindowOverlay.fadeOut('fast',function(){
                    $DOMWindowOverlay.trigger('unload').unbind().remove();                                                                      
                });
                $DOMWindow.fadeOut('fast',function(){
                    if($.fn.draggable){
                        $DOMWindow.draggable("destroy").trigger("unload").remove();
                    }else{
                        $DOMWindow.trigger("unload").remove();
                    }
                });
            
                $(window).unbind('scroll.DOMWindow');
                $(window).unbind('resize.DOMWindow');
                
                if($.fn.openDOMWindow.isIE6){$('#DOMWindowIE6FixIframe').remove();}
                if(settings.functionCallOnClose){settings.functionCallAfterClose();}
            }    
        };
        
        if(settings.eventType){//if used with $().
            return this.each(function(index){
                $(this).bind(settings.eventType, function(){
                    run(this);
                    return false;
                });
            });
        }else{//else called as $.function
            run();
        }
        
    };
    
    //allow for public call, pass settings
    $.closeDOMWindow = function(s){$.fn.closeDOMWindow(s);};
    
    //openDOMWindow
    $.fn.openDOMWindow = function(instanceSettings){    
        
        var shortcut =  $.fn.openDOMWindow;
    
        //default settings combined with callerSettings////////////////////////////////////////////////////////////////////////
        
        shortcut.defaultsSettings = {
            anchoredClassName:'',
            anchoredSelector:'',
            borderColor:'#ccc',
            borderSize:'0',
            draggable:0,
            eventType:null, //click, blur, change, dblclick, error, focus, load, mousedown, mouseout, mouseup etc...
            fixedWindowY:100,
            functionCallOnOpen:null,
            functionCallOnClose:null,
            height:500,
            loader:0,
            loaderHeight:0,
            loaderImagePath:'',
            loaderWidth:0,
            modal:0,
            overlay:1,
            overlayColor:'#fff',
            overlayOpacity:'70',
            positionLeft:0,
            positionTop:0,
            positionType:'centered', // centered, anchored, absolute, fixed
            width:500, 
            windowBGColor:'#fff',
            windowBGImage:'Null', // http path
            windowHTTPType:'get',
            windowPadding:10,
            windowSource:'inline', //inline, ajax, iframe
            windowSourceID:'',
            windowSourceURL:'',
            windowSourceAttrURL:'href',
            iframeScrolling: "auto"
        };
        
        var settings = $.extend({}, $.fn.openDOMWindow.defaultsSettings , instanceSettings || {});
        
        //Public functions
        
        shortcut.viewPortHeight = function(){ return self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;};
        shortcut.viewPortWidth = function(){ return self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;};
        shortcut.scrollOffsetHeight = function(){ return self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;};
        shortcut.scrollOffsetWidth = function(){ return self.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;};
        shortcut.isIE6 = typeof document.body.style.maxHeight === "undefined";
        
        //Private Functions/////////////////////////////////////////////////////////////////////////////////////////////////////////
        
        var sizeOverlay = function(){
            var $DOMWindowOverlay = $('#DOMWindowOverlay');
            if(shortcut.isIE6){//if IE 6
                var overlayViewportHeight = document.documentElement.offsetHeight + document.documentElement.scrollTop - 4;
                var overlayViewportWidth = document.documentElement.offsetWidth - 21;
                $DOMWindowOverlay.css({'height':overlayViewportHeight +'px','width':overlayViewportWidth+'px'});
            }else{//else Firefox, safari, opera, IE 7+
                $DOMWindowOverlay.css({'height':'100%','width':'100%','position':'fixed'});
            }    
        };
        
        var sizeIE6Iframe = function(){
            var overlayViewportHeight = document.documentElement.offsetHeight + document.documentElement.scrollTop - 4;
            var overlayViewportWidth = document.documentElement.offsetWidth - 21;
            $('#DOMWindowIE6FixIframe').css({'height':overlayViewportHeight +'px','width':overlayViewportWidth+'px'});
        };
        
        var centerDOMWindow = function() {
            var $DOMWindow = $('#DOMWindow');
            if(settings.height + 50 > shortcut.viewPortHeight()){//added 50 to be safe
                $DOMWindow.css('left',Math.round(shortcut.viewPortWidth()/2) + shortcut.scrollOffsetWidth() - Math.round(($DOMWindow.outerWidth())/2));
            }else{
                $DOMWindow.css('left',Math.round(shortcut.viewPortWidth()/2) + shortcut.scrollOffsetWidth() - Math.round(($DOMWindow.outerWidth())/2));
                $DOMWindow.css('top',Math.round(shortcut.viewPortHeight()/2) + shortcut.scrollOffsetHeight() - Math.round(($DOMWindow.outerHeight())/2));
            }
        };
        
        var centerLoader = function() {
            var $DOMWindowLoader = $('#DOMWindowLoader');
            if(shortcut.isIE6){//if IE 6
                $DOMWindowLoader.css({'left':Math.round(shortcut.viewPortWidth()/2) + shortcut.scrollOffsetWidth() - Math.round(($DOMWindowLoader.innerWidth())/2),'position':'absolute'});
                $DOMWindowLoader.css({'top':Math.round(shortcut.viewPortHeight()/2) + shortcut.scrollOffsetHeight() - Math.round(($DOMWindowLoader.innerHeight())/2),'position':'absolute'});
            }else{
                $DOMWindowLoader.css({'left':'50%','top':'50%','position':'fixed'});
            }
            
        };
        
        var fixedDOMWindow = function(){
            var $DOMWindow = $('#DOMWindow');
            $DOMWindow.css('left', settings.positionLeft + shortcut.scrollOffsetWidth());
            $DOMWindow.css('top', + settings.positionTop + shortcut.scrollOffsetHeight());
        };
        
        var showDOMWindow = function(instance){
            if(arguments[0]){
                $('.'+instance+' #DOMWindowLoader').remove();
                $('.'+instance+' #DOMWindowContent').fadeIn('fast',function(){if(settings.functionCallOnOpen){settings.functionCallOnOpen();}});
                $('.'+instance+ '.closeDOMWindow').click(function(){
                    $.closeDOMWindow();    
                    return false;
                });
            }else{
                $('#DOMWindowLoader').remove();
                $('#DOMWindow').fadeIn('fast',function(){if(settings.functionCallOnOpen){settings.functionCallOnOpen();}});
                $('#DOMWindow .closeDOMWindow').click(function(){                        
                    $.closeDOMWindow();
                    return false;
                });
            }
            
        };
        
        var urlQueryToObject = function(s){
              var query = {};
              s.replace(/b([^&=]*)=([^&=]*)b/g, function (m, a, d) {
                if (typeof query[a] != 'undefined') {
                  query[a] += ',' + d;
                } else {
                  query[a] = d;
                }
              });
              return query;
        };
            
        //Run Routine ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
        var run = function(passingThis){
            
            //get values from element clicked, or assume its passed as an option
            settings.windowSourceID = $(passingThis).attr('href') || settings.windowSourceID;
            settings.windowSourceURL = $(passingThis).attr(settings.windowSourceAttrURL) || settings.windowSourceURL;
            settings.windowBGImage = settings.windowBGImage ? 'background-image:url('+settings.windowBGImage+')' : '';
            var urlOnly, urlQueryObject;
            
            if(settings.positionType == 'anchored'){//anchored DOM window
                
                var anchoredPositions = $(settings.anchoredSelector).position();
                var anchoredPositionX = anchoredPositions.left + settings.positionLeft;
                var anchoredPositionY = anchoredPositions.top + settings.positionTop;
                
                $('body').append('<div class="'+settings.anchoredClassName+'" style="'+settings.windowBGImage+';background-repeat:no-repeat;padding:'+settings.windowPadding+'px;overflow:hidden;padding-left:12px!important;padding-right:1px!important;position:absolute;top:'+anchoredPositionY+'px;left:'+anchoredPositionX+'px;height:'+settings.height+'px;width:'+settings.width+'px;background-color:'+settings.windowBGColor+';border:0px;z-index:10001"><div id="DOMWindowContent" style="display:none"></div></div>');        
                //loader
                if(settings.loader && settings.loaderImagePath !== ''){
                    $('.'+settings.anchoredClassName).append('<div id="DOMWindowLoader" style="width:'+settings.loaderWidth+'px;height:'+settings.loaderHeight+'px;"><img src="'+settings.loaderImagePath+'" /></div>');
                    
                }
                if($.fn.draggable){
                    if(settings.draggable){$('.' + settings.anchoredClassName).draggable({cursor:'move'});}
                }
                
                switch(settings.windowSource){
                    case 'inline'://////////////////////////////// inline //////////////////////////////////////////
                        $('.' + settings.anchoredClassName+" #DOMWindowContent").append($(settings.windowSourceID).children());
                        $('.' + settings.anchoredClassName).unload(function(){// move elements back when you're finished
                            $('.' + settings.windowSourceID).append( $('.' + settings.anchoredClassName+" #DOMWindowContent").children());                
                        });
                        showDOMWindow(settings.anchoredClassName);
                    break;
                    case 'iframe'://////////////////////////////// iframe //////////////////////////////////////////
                        $('.' + settings.anchoredClassName+" #DOMWindowContent").append('<iframe frameborder="0" hspace="0" wspace="0" src="'+settings.windowSourceURL+'" name="DOMWindowIframe'+Math.round(Math.random()*1000)+'" style="width:100%;height:100%;border:none;background-color:#fff;" scrolling="'+settings.iframeScrolling+'" class="'+settings.anchoredClassName+'Iframe" ></iframe>');
                        $('.'+settings.anchoredClassName+'Iframe').load(showDOMWindow(settings.anchoredClassName));
                    break;
                    case 'ajax'://////////////////////////////// ajax //////////////////////////////////////////    
                        if(settings.windowHTTPType == 'post'){
                            
                            if(settings.windowSourceURL.indexOf("?") !== -1){//has a query string
                                urlOnly = settings.windowSourceURL.substr(0, settings.windowSourceURL.indexOf("?"));
                                urlQueryObject = urlQueryToObject(settings.windowSourceURL);
                            }else{
                                urlOnly = settings.windowSourceURL;
                                urlQueryObject = {};
                            }
                            $('.' + settings.anchoredClassName+" #DOMWindowContent").load(urlOnly,urlQueryObject,function(){
                                showDOMWindow(settings.anchoredClassName);
                            });
                        }else{
                            if(settings.windowSourceURL.indexOf("?") == -1){ //no query string, so add one
                                settings.windowSourceURL += '?';
                            }
                            $('.' + settings.anchoredClassName+" #DOMWindowContent").load(
                                settings.windowSourceURL + '&random=' + (new Date().getTime()),function(){
                                showDOMWindow(settings.anchoredClassName);
                            });
                        }
                    break;
                }
                
            }else{//centered, fixed, absolute DOM window
                
                //overlay & modal
                if(settings.overlay){
                    $('body').append('<div id="DOMWindowOverlay" style="z-index:10000;display:none;position:absolute;top:0;left:0;background-color:'+settings.overlayColor+';filter:alpha(opacity='+settings.overlayOpacity+');-moz-opacity: 0.'+settings.overlayOpacity+';opacity: 0.'+settings.overlayOpacity+';"></div>');
                    if(shortcut.isIE6){//if IE 6
                        $('body').append('<iframe id="DOMWindowIE6FixIframe"  src="blank.html"  style="width:100%;height:100%;z-index:9999;position:absolute;top:0;left:0;filter:alpha(opacity=0);"></iframe>');
                        sizeIE6Iframe();
                    }
                    sizeOverlay();
                    var $DOMWindowOverlay = $('#DOMWindowOverlay');
                    $DOMWindowOverlay.fadeIn('fast');
                    if(!settings.modal){$DOMWindowOverlay.click(function(){$.closeDOMWindow();});}
                }
                
                //loader
                if(settings.loader && settings.loaderImagePath !== ''){
                    $('body').append('<div id="DOMWindowLoader" style="z-index:10002;width:'+settings.loaderWidth+'px;height:'+settings.loaderHeight+'px;"><img src="'+settings.loaderImagePath+'" /></div>');
                    centerLoader();
                }
                //add DOMwindow
                $('body').append('<div id="DOMWindow" style="float:left;background-repeat:no-repeat;'+settings.windowBGImage+';overflow:show;padding:'+settings.windowPadding+'px;padding-left:12px!important;padding-right:1px!important;display:none;height:'+settings.height+'px;width:'+settings.width+'px;background-color:#fafafa;border:0px; position:absolute;z-index:10001"></div>');
                
                var $DOMWindow = $('#DOMWindow');
                //centered, absolute, or fixed
                switch(settings.positionType){
                    case 'centered':
                        centerDOMWindow();
                        if(settings.height + 50 > shortcut.viewPortHeight()){//added 50 to be safe
                            $DOMWindow.css('top', (settings.fixedWindowY + shortcut.scrollOffsetHeight()) + 'px');
                        }
                    break;
                    case 'absolute':
                        $DOMWindow.css({'top':(settings.positionTop+shortcut.scrollOffsetHeight())+'px','left':'50%','margin-left':'-'+(settings.width/2)+'px'});
                        if($.fn.draggable){
                            if(settings.draggable){$DOMWindow.draggable({cursor:'move'});}
                        }
                    break;
                    case 'fixed':
                        fixedDOMWindow();
                    break;
                    case 'anchoredSingleWindow':
                        var anchoredPositions = $(settings.anchoredSelector).position();
                        var anchoredPositionX = anchoredPositions.left + settings.positionLeft;
                        var anchoredPositionY = anchoredPositions.top + settings.positionTop;
                        $DOMWindow.css({'top':anchoredPositionY + 'px','left':anchoredPositionX+'px'});
                                
                    break;
                }
                
                $(window).bind('scroll.DOMWindow',function(){
                    if(settings.overlay){sizeOverlay();}
                    if(shortcut.isIE6){sizeIE6Iframe();}
                    if(settings.positionType == 'centered'){centerDOMWindow();}
                    if(settings.positionType == 'fixed'){fixedDOMWindow();}
                });
                $(window).bind('resize.DOMWindow',function(){
                    if(shortcut.isIE6){sizeIE6Iframe();}
                    if(settings.overlay){sizeOverlay();}
                    if(settings.positionType == 'centered'){centerDOMWindow();}
                });

                $DOMWindow.append("<div id=\"closeLightBoxPopup\" style=\"width:100%!important; text-align:right; margin-top:13px;\"><a href=\"#\" style=\"text-decoration:none;color:#999999;\" onclick=\"javascript:$('#DOMWindowOverlay, #DOMWindow').hide(200,function(){$(this).remove();});return false;\">&nbsp;<img src=\"structure/icon_lightbox_close.jpg\" style=\"padding:0 12px 0 3px;\" /></a></div>");
                $DOMWindow.append("<div id=\"rightLightBoxShadow\">&nbsp</div>");
                $DOMWindow.append("<div id=\"bottomLightBoxShadow\">&nbsp</div>");

                
                switch(settings.windowSource){
                    case 'inline'://////////////////////////////// inline //////////////////////////////////////////
                        $DOMWindow.append($(settings.windowSourceID).children());
                        $DOMWindow.unload(function(){// move elements back when you're finished
                            $(settings.windowSourceID).append($DOMWindow.children());                
                        });
                        showDOMWindow();
                    break;
                    case 'iframe'://////////////////////////////// iframe //////////////////////////////////////////
                        $DOMWindow.append('<iframe frameborder="0" hspace="0" wspace="0" src="'+settings.windowSourceURL+'" name="DOMWindowIframe'+Math.round(Math.random()*1000)+'" style="width:100%;height:344px;border:none;background-color:#fff;" scrolling="'+settings.iframeScrolling+'" id="DOMWindowIframe" ></iframe>');
                        $('#DOMWindowIframe').load(showDOMWindow());
                    break;
                    case 'ajax'://////////////////////////////// ajax //////////////////////////////////////////
                        if(settings.windowHTTPType == 'post'){
                            
                            if(settings.windowSourceURL.indexOf("?") !== -1){//has a query string
                                urlOnly = settings.windowSourceURL.substr(0, settings.windowSourceURL.indexOf("?"));
                                urlQueryObject = urlQueryToObject(settings.windowSourceURL);
                            }else{
                                urlOnly = settings.windowSourceURL;
                                urlQueryObject = {};
                            }
                            $DOMWindow.load(urlOnly,urlQueryObject,function(){
                                showDOMWindow();
                            });
                        }else{
                            if(settings.windowSourceURL.indexOf("?") == -1){ //no query string, so add one
                                settings.windowSourceURL += '?';
                            }
                            $DOMWindow.load(
                                settings.windowSourceURL + '&random=' + (new Date().getTime()),function(){
                                showDOMWindow();
                            });
                        }
                    break;
                }
                
            }//end if anchored, or absolute, fixed, centered
            
        };//end run()
        
        if(settings.eventType){//if used with $().
            return this.each(function(index){                  
                $(this).bind(settings.eventType,function(){
                    run(this);
                    return false;
                });
            });    
        }else{//else called as $.function
            run();
        }
        
    };//end function openDOMWindow
    
    //allow for public call, pass settings
    $.openDOMWindow = function(s){$.fn.openDOMWindow(s);};
    
})(jQuery);
