/********************************************************************************/
/*
/*           Author: Frank Reckers
/* letzte Aenderung: 05.03.2004
/*
/********************************************************************************/
/* Patent-No.: 10 2004 027 616.1 - Messe Düsseldorf GmbH.
/********************************************************************************/
chars = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0","@","_","-",".",":"," ");
function decrypt(address) {
  var org_address = "";
  var new_address = address.toLowerCase();
  for (var i=0;i<new_address.length;i++) {
    for (var j=0;j<chars.length;j++) {
      if (new_address.substr(i,1)==chars[j]) {
        org_address += chars[j-1]; break;
      }
    }
  }
  return org_address;
}
/********************************************************************************/

function switch_PlayListItem(ref_Item){
    $(ref_Item).up(1).getElementsBySelector('li').each(
        function (item){
            item.removeClassName('on');
        }
    );
    $(ref_Item).up(0).addClassName('on');
}
var class_FlvPlayer = Class.create();
    class_FlvPlayer.prototype = {
        initialize: function(int_PlayerWidth, int_PlayerHeight){
            //Init FlashVars
            this.obj_FlashVars = {};
            this.obj_FlashVars.playerpath = "http://www.messe-duesseldorf.de/app/flvplayer";
            this.obj_FlashVars.skinscalemaximum = "1";
            this.obj_FlashVars.autoscale = "false";
            this.obj_FlashVars.skincolor = "0x265691";
            //Init Params
            this.obj_Params = {};
            this.obj_Params.scale = "noscale";
            this.obj_Params.allowfullscreen = "true";
            this.obj_Params.salign = "tl";
            //Init Attributes
            this.obj_Attributes = {};
            this.obj_Attributes.align = "center";
            //Init HtmlElementId
            this.str_HtmlElementId = "flvplayer";
            //Init Player Size
            this.obj_PlayerSize = {};
            this.obj_PlayerSize.width = int_PlayerWidth;
            this.obj_PlayerSize.height = int_PlayerHeight;
            //Init Player Source
            this.str_PlayerSource = "http://www.messe-duesseldorf.de/app/flvplayer/flvplayer.swf";
        },
        setPlayerPath: function(str_PlayerPath){
            this.obj_FlashVars.playerpath = str_PlayerPath;
        },
        setPlayerSource: function(str_PlayerSource){
            this.str_PlayerSource = str_PlayerSource;            
        },
        setSkin: function(str_Skin){
            this.obj_FlashVars.skin = str_Skin;
        },
        setHtmlElementId: function(str_EltId){
            this.str_HtmlElementId = str_EltId;            
        },
        setVideoSize: function(int_VideoWidth, int_VideoHeight){
            this.obj_FlashVars.videowidth = int_VideoWidth;
            this.obj_FlashVars.videoheight = int_VideoHeight;
        
        },
        setVideoFormat: function(str_VideoFormat){
            if(str_VideoFormat != "4:3"){
                this.obj_FlashVars.videoheight = parseInt((parseInt(this.obj_FlashVars.videowidth) / 16) * 9);
            }else{
                this.obj_FlashVars.videoheight = parseInt((parseInt(this.obj_FlashVars.videowidth) / 4) * 3);
            }
            this.obj_PlayerSize.height = this.obj_FlashVars.videoheight + 27;
        },
        loadFlvPlayer: function(str_FlvSrc, str_FlvPreview){
            this.obj_FlashVars.video = str_FlvSrc;
            this.obj_FlashVars.preview = str_FlvPreview;
            swfobject.embedSWF(this.str_PlayerSource, this.str_HtmlElementId, this.obj_PlayerSize.width, this.obj_PlayerSize.height, "9.0.28", "http://www.messe-duesseldorf.de/app/flvplayer/expressInstall.swf", this.obj_FlashVars, this.obj_Params, this.obj_Attributes);
        },
        playFlvVideo: function(str_FlvSrc, str_FlvPreview, str_FlvFormat){
            this.obj_FlashVars.autoplay = "true";
            this.obj_FlashVars.video = str_FlvSrc;
            this.obj_FlashVars.preview = str_FlvPreview;
            this.setVideoFormat(str_FlvFormat);
            swfobject.embedSWF(this.str_PlayerSource, this.str_HtmlElementId, this.obj_PlayerSize.width, this.obj_PlayerSize.height, "9.0.28", "http://www.messe-duesseldorf.de/app/flvplayer/expressInstall.swf", this.obj_FlashVars, this.obj_Params, this.obj_Attributes);            
        }
    }

var array_TopicBoxGroup_1 = new Array("top-news-content","top-tipps-content","top-links-content");
var array_TopNewsGroup = new Array();
var int_TickerDuration = 7000;
function setFontSize(sizeTo){
    if(!$("body").style.fontSize){
        $("body").style.fontSize = "0.8em";
    }
    switch ($("body").style.fontSize){
        case "0.8em":
            if (sizeTo == "+"){$("body").style.fontSize = "0.9em"}
        break;
        case "0.9em":
            if (sizeTo == "+"){$("body").style.fontSize = "1em"}else{$("body").style.fontSize = "0.8em"}
        break;
        case "1em":
            if (sizeTo == "-"){$("body").style.fontSize = "0.9em"}
        break;        
    }    
}
function switchTopicBox(array_Group, element_id){
    if ($(element_id).style.display == 'none'){
        for (var i = 0; i < array_Group.length; i++){
            if($(array_Group[i]).style.display != 'none'){
                Effect.BlindUp(array_Group[i], {afterFinish: function(){
                    Effect.BlindDown(element_id);
                }});                
            }
/*            if ($(array_Group[i])){
                if ($(array_Group[i]).style.display != 'none'){
                    $(array_Group[i]).style.display = "none";
                }
            }
*/                
        }        
    }
}
function init_Slidebles(container_id, slide_tag, array_slidebles){
    slide_tag = slide_tag.toUpperCase();
    array_ChildElements = $(container_id).childNodes;
    for (i = 0; i < array_ChildElements.length; i++){
        if (array_ChildElements[i].nodeName == slide_tag){
            array_slidebles.push(array_ChildElements[i]);
        }
    }
    if (array_slidebles[0]){array_slidebles[0].style.display = "block";}
}
function start_NewsTicker(){
    array_slidebles = array_TopNewsGroup;
    init = false;
    max = array_slidebles.length - 1;
    array_slidebles.each(function(item) {
        if (item.style.display != "none"){
            init = true;
            Effect.BlindUp(item, {afterFinish: function(){
                if (item.next()){            
                    Effect.BlindDown(item.next(), {afterFinish: function(){
                        item.style.display = "none";
                        }});
                    
                }else{
                    Effect.BlindDown(array_slidebles[0], {afterFinish: function(){
                        array_slidebles[max].style.display = "none";
                        }});
                                    
                }
            }});                    
        }
    });
    window.setTimeout("start_NewsTicker()", int_TickerDuration);
}
window.onload = function () {
    if (document.getElementById('top-news-content')){
        init_Slidebles('top-news-content', 'p', array_TopNewsGroup);
        window.setTimeout("start_NewsTicker()", int_TickerDuration);
    }
};

// RedDot Testfunktionen

function getRdPageHistory(CurrentPageURL){
    new Ajax.Request('/cms/PlugIns/SmartRql/getHistoryData.asp?LinkTitle='+$$('title')[0].innerHTML+'&LinkReferrer='+ escape(CurrentPageURL), {
        method: 'get',
        encoding: 'UTF-8',
        requestHeaders: { 'Pragma': 'no-cache', 'Cache-Control': 'must-revalidate', 'If-Modified-Since': 'document.lastModified' },
        onSuccess: function(transport) {
            $('RdPageHistory').update(transport.responseText);
        },
        onFailure:function(){
            $('RdPageHistory').update("FALSE");
            
        }
    });    
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

var bool_ToggleStatus = false;
function toggleContentTopicList(ref_ListItem){
    if (bool_ToggleStatus == false){
        if ($(ref_ListItem).getElementsByClassName('description')[0].style.display != 'block'){
              $A($(ref_ListItem).up(0).getElementsByClassName('description')).each(
                function(item){
                    if (item.style.display != "none"){
                        Effect.BlindUp(item, {
                        beforeStart: function(){
                            bool_ToggleStatus = true;
                        },                                                                
                        afterFinish: function(){
                            item.previous(0).className = "inactive";
                            item.style.display = "none";
                            ref_ListItem.down(0).className = "active";
                            Effect.BlindDown($(ref_ListItem).getElementsByClassName('description')[0], {
                                afterFinish: function(){
                                    $(ref_ListItem).getElementsByClassName('description')[0].style.display = "block";
                                    bool_ToggleStatus = false;
                                }                            
                            });                        
                        }});
                    }
                }
            
            );
        }
    }
}


function showhideLocations(obj_This) {
    div_ServiceLocation = $(obj_This).next('.service-location');
    div_ServiceLocation.toggle();
    
    if (typeof SwitchStatus == 'undefined') {
        SwitchStatus = "plus";
    }    
    if (SwitchStatus == "plus") {
        $(obj_This).setStyle({
            backgroundImage: 'url(http://www.md-india.com/img/bg-location-minus.png)'
        });
        SwitchStatus = "minus";
    } else {
        $(obj_This).setStyle({
            backgroundImage: 'url(http://www.md-india.com/img/bg-location-plus.png)'
        });
        SwitchStatus = "plus";
    }
}

var bool_ToggleStatus = false;

    function toggleFactBox(ref_Element){
        if (bool_ToggleStatus == false){
        bool_ToggleStatus = true;
        if ($(ref_Element).next(0).style.display == 'block'){
            Effect.BlindUp($(ref_Element).next(0), {duration:0.5, afterFinish: function(){
                $(ref_Element).next(0).hide();
                $(ref_Element).className = "inactive";
                bool_ToggleStatus = false;
            }});
        }else{
            Effect.BlindDown($(ref_Element).next(0),{duration:0.5, afterFinish: function(){
                $(ref_Element).next(0).show();
                $(ref_Element).next(0).style.display = 'block';
                $(ref_Element).className = "active";
                bool_ToggleStatus = false;
            }});                        
        }
        }
        
    }
 
function switchFairRegion() {
    arr_FairOptions = $$('#switch-fairs-a-z ul');
    source_Element1st = arr_FairOptions[0].innerHTML;
    source_Element2nd = arr_FairOptions[1].innerHTML;
    arr_FairOptions[0].update(source_Element2nd);
    arr_FairOptions[1].update(source_Element1st);
}

function switchCalendarSheet(str_Region) {
    if (str_Region == 'md') {
        $('select-year-md').show(); 
        $('select-year-ww').hide();
    } else {
        $('select-year-md').hide(); 
        $('select-year-ww').show();    
    }
}
 
function showDropDownMenu(str_ClassName, str_Event, bool_CloseOnMouseOut) {
    bool_Close = false;
    arr_Ul = $$('.' + str_ClassName + ' ul');
     
    arr_Ul.each(function(obj_Element) { 
        obj_Element.hide();            
        obj_Element.observe('mouseleave', function(ul_Event) { 
            bool_Close = true;
        });
        obj_Element.observe('mouseenter', function(ul_Event) { 
            bool_Close = false;
        });                                 
        obj_Element.previous('a',0).observe(str_Event, function(a_Event) {  
            obj_Anchor = Event.element(a_Event);
            bool_ShowDropDown = false;
            if(obj_Anchor.next('ul',1)){
                if(obj_Anchor.next('ul',0).style.display == 'none' || obj_Anchor.next('ul',1).style.display == 'none') { bool_ShowDropDown = true; }
            }
            if (!obj_Anchor.next('ul',1)) {
                if(obj_Anchor.next('ul',0).style.display == 'none') { bool_ShowDropDown = true; }
            }
            if(bool_ShowDropDown) {
                arr_Ul.each(function(obj_Element) {
                    obj_Element.hide();
                });
                obj_Anchor.next('ul',0).show();
                obj_AnchorDropDown = Event.element(a_Event)
                obj_AnchorDropDown.observe('mouseleave', function(ul_Event) {
                    bool_Close = true;
                });
                obj_AnchorDropDown.observe('mouseenter', function(ul_Event) {
                    bool_Close = false;
                });                
            } else {
                obj_Anchor.next('ul',0).hide();
                bool_Close = true;
            }
        });   
    });
    
    Event.observe(document, 'click', function(click_Event) {
        if (bool_Close && bool_ShowDropDown){
            arr_Ul.each(function(obj_Element) { 
                obj_Element.hide();
                bool_Close = false;
            });
        }
    });    
    
}
