var sitesMarginBottom = -195;
function body_load() {
    if (navigator.userAgent.indexOf("Firefox") < 0
        && navigator.userAgent.indexOf("MSIE") < 0
        || navigator.userAgent.indexOf("MSIE 7") > 0) {
        setTimeout("checkSitesMargin()", 10);
        document.getElementById("body").onresize = checkSitesMargin;
    }
    LinkImages_Clean();
}
function checkSitesMargin() {
    var body = document.getElementById("body");
    var site = document.getElementById("site");
    site.style.minHeight = (body.offsetHeight + sitesMarginBottom - 31) + "px";
    if (navigator.userAgent.indexOf("MSIE 7") > 0)
        site.style.marginBottom = "0px";
}

function LinkImages_Clean() {
    var imgs = document.images;
    var l = imgs.length;
    for (var i = 0; i < l; i++) {
        var img = imgs[i];
        if (img.parentNode.tagName == "A" && img.parentNode.title != "" && img.alt != "")
            img.removeAttribute("alt");
    }
}

function switch_click(sender) {
    var div = document.getElementById(sender.id.replace("a", "div"));
    div.style.display = (div.style.display == "block" ? "none" : "block");
}


var Galeries = [];
function Galerie(id, images) {
    this.id = id;
    Galeries[id] = this;
    this.images = [];
    this.currentImageIndex = 0;
    this.div = document.getElementById(id);
    this.image = document.getElementById(id + 'image');
    this.ds = document.getElementById(id + 'switches');

    for (var i = 0; i < images.length; i++) {
        var img = document.createElement("IMG");
        img.src = images[i];
        this.images.push(img);
    }
    this.switchL = document.getElementById(id + 'arrowL');
    this.switchR = document.getElementById(id + 'arrowR');

    this.switchL.setAttribute('gid', this.id);
    this.switchR.setAttribute('gid', this.id);
    this.switchL.onclick = function () {
        var g = Galeries[this.getAttribute('gid')];
        clearTimeout(g.timeoutId);
        g.currentImageIndex--;
        if (g.currentImageIndex < 0)
            g.currentImageIndex = g.images.length - 1;
        g.image.src = g.images[g.currentImageIndex].src;
    };
    this.switchR.onclick = function () {
        var g = Galeries[this.getAttribute('gid')];
        clearTimeout(g.timeoutId);
        g.currentImageIndex++;
        if (g.currentImageIndex >= g.images.length)
            g.currentImageIndex = 0;
        g.image.src = g.images[g.currentImageIndex].src;
    };
    this.init = function () {
        if (this.image.clientHeight < 50)
            setTimeout("Galeries['" + this.id + "'].init();", 500);
        else {
            this.div.style.height = this.image.clientHeight + 'px';
            this.ds.style.marginTop = '-' + ((this.image.clientHeight + 43) / 2) + 'px';
            setTimeout("Galeries['" + this.id + "'].play();", 10000);
        }
    }
    this.timeoutId = 0;
    this.play = function () {
        this.currentImageIndex++;
        if (this.currentImageIndex >= this.images.length)
            this.currentImageIndex = 0;
        this.image.src = this.images[this.currentImageIndex].src;
        this.timeoutId = setTimeout("Galeries['" + this.id + "'].play();", 4000);
    };
}
var currentGalerieImages = [];


var Tab_Container = [];
function Tab_Activate(index) {
    var tabs = document.getElementById("Tabs").childNodes;
    for (var i = 0; i < tabs.length; i++) {
        tabs[i].className = "tab" + (i == tabs.length - 1 ? " last" : "") + (i == index ? " active" : "");
        if (i == index && i > 0)
            tabs[i - 1].className += " nextIsActive";
        Tab_Container[i].style.display = (i == index ? "block" : "none");
    }
    var arrowL = document.getElementById("arrowL");
    var pi = index - 1;
    if (pi < 0)
        pi = tabs.length - 1;
    arrowL.setAttribute("tid", pi);
    arrowL.onclick = function () { clearTimeout(activeTabTimeoutId); Tab_Activate(parseInt(this.getAttribute("tid"))); };
    var arrowR = document.getElementById("arrowR");
    var ni = index + 1;
    if (ni >= tabs.length)
        ni = 0;
    arrowR.setAttribute("tid", ni);
    arrowR.onclick = function () { clearTimeout(activeTabTimeoutId); Tab_Activate(parseInt(this.getAttribute("tid"))); };
}
var activeTab = -1;
var activeTabTimeoutId = 0;
function Tabs_Action_Start() {
    var dummy = document.getElementById("Content").getElementsByTagName("DIV");
    for (var i = 0; i < dummy.length; i++)
        if (dummy[i].className.indexOf("tabCont") == 0)
            Tab_Container.push(dummy[i]);

    var tabs = document.getElementById("Tabs").childNodes;
    if (activeTab < 0)
        for (var i = 0; i < tabs.length; i++) {
            tabs[i].setAttribute("tid", i);
            tabs[i].onclick = function () { clearTimeout(activeTabTimeoutId); Tab_Activate(parseInt(this.getAttribute("tid"))); };
        }
    activeTab++;
    if (activeTab >= tabs.length)
        activeTab = 0;
    Tab_Activate(activeTab);
    activeTabTimeoutId = setTimeout('Tabs_Action_Start();', 10000);
}

var hideMenuId = 0;
var activeMenuId = '';
function showMenu(sender, id) {
    if (activeMenuId != '')
        hideMenu();
    activeMenuId = id;
    var m = document.getElementById(id);
    m.style.left = sender.offsetLeft + 'px';
    m.style.display = 'block';
    if (m.style.width == '') {
        var l = m.childNodes.length;
        var w = sender.clientWidth;
        for (var i = 0; i < l; i++)
            if (m.childNodes[i].tagName == 'A' && m.childNodes[i].clientWidth > w)
                w = m.childNodes[i].clientWidth;
        m.style.width = w + 'px';
        for (var i = 0; i < l; i++)
            if (m.childNodes[i].tagName == 'A')
                m.childNodes[i].style.width = (w - 20) + 'px';
    }
}
function hideMenu() {
    document.getElementById(activeMenuId).style.display = 'none';
}
function stopHideMenu() {
    if (hideMenuId > 0) {
        clearTimeout(hideMenuId);
        hideMenuId = 0;
    }
}
function custom_etc() {
    var vvc = _etc_gc('_vv');
    var s = 0;
    var d = 0.02;
    var u = 'a2c9ba0079b8416a7033899f7aed933e';

    var a, prms, ar;
    if (vvc) {
        if (vvc.indexOf(',') != -1) {
            a = vvc.split(',');
        }
        else {
            a = vvc.split('|');
        }

        u = a[0];
        s = a[1];
    }
    else {
        _etc_sc('_vv', u + '|' + s, d);
    }

    if (!et_blockPlugin)
        et_pd();

    et_cPQ();
    et_pEc();
    et_eC('7l3Q5E');
    if (!et_blockOverlay)
        et_iO();
}

function eTracker_track(title, url) {
    var region = et_pagename;
    var regionUrl = et_url;
    et_pagename = title + " (" + region + ")";
    et_url = url;
    custom_etc();
    et_pagename = region;
    et_url = regionUrl;
}

function Teaser_ToggleVisisibility(srcAId, srcDivId, dstAId, desDivId) {
    var e = document.getElementById(srcAId);
    if (e.className.indexOf('last') == 0)
        e.className = 'last active';
    else
        e.className = 'active';

    e = document.getElementById(srcDivId);
    e.style.display = 'block';

    e = document.getElementById(dstAId);
    e.className = e.className.replace('active', '').replace(' ', '');

    e = document.getElementById(desDivId);
    e.style.display = 'none';
}

var ListContent_LastActiveId = "";
function ListContent_ToggleVisibility(obj) {
    if (ListContent_LastActiveId != "") {
        document.getElementById(ListContent_LastActiveId).className = 'listItemLink';
        document.getElementById(ListContent_LastActiveId.replace('li', 'lic')).className = 'listItemContent';
    }
    if (ListContent_LastActiveId == obj.getAttribute("id")) {
        ListContent_LastActiveId = "";
        return false;
    }
    else {
        ListContent_LastActiveId = obj.getAttribute("id");
        obj.className += ' active';
        document.getElementById(ListContent_LastActiveId.replace('li', 'lic')).className = 'activeListItemContent';
        return true;
    }
}

function printPage(){  
	if (window.print)
		window.print();  
	else{
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box
		WebBrowser1.outerHTML = "";  
	}
}
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function setActiveStyleSheetByTitle(title) {
  var i, links;
  links = getElementsByTagName(document, "style");
  for(i=0; i<links.length; i++) {
  	var a = links[i];
  	if(a.getAttribute("id")){
	    if(a.getAttribute("id") != title)
	    	a.disabled = true;
	    else if(a.getAttribute("id") == title)
	    	a.disabled = false;
	}
  }
  links = getElementsByTagName(document, "link");
  for(i=0; i<links.length; i++) {
  	var a = links[i];
  	if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	  if(!document.all)a.setAttribute("rel", "stylesheet");
      a.disabled = !(a.getAttribute("title") == title);
    }
  }
}
function disableActiveStyleSheetByTitle(title) {
  var i, links;
  links = getElementsByTagName(document, "style");
  for(i=0; i<links.length; i++) {
  	var a = links[i];
  	if(a.getAttribute("id")){
	    if(a.getAttribute("id") == title)
	    	a.disabled = true;
	}
  }
  links = getElementsByTagName(document, "link");
  for(i=0; i<links.length; i++) {
  	var a = links[i];
  	if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	  if(a.getAttribute("title") == title)
		a.disabled = true;
    }
  }
}
function getActiveStyleSheet() {
  var i, links;
  links = getElementsByTagName(document, "style");
  for(i=0; i<links.length; i++) {
  	var a = links[i];
    if(a.getAttribute("id") && !a.disabled) return a.getAttribute("id");
  }
  links = getElementsByTagName(document, "link");
  for(i=0; i<links.length; i++) {
  	var a = links[i];
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}
function getPreferredStyleSheet() {
  var i, links;
  links = getElementsByTagName(document, "style");
  for(i=0; i<links.length; i++) {
  	var a = links[i];
  	if(a.getAttribute("id"))
  		return a.getAttribute("id");
  }
  links = getElementsByTagName(document, "link");
  for(i=0; i<links.length; i++) {
  	var a = links[i];
  	if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function visibilityById(id, val){
	var obj = getElementById(document, id);
    if(obj)obj.style.visibility = val;
}
function switchDisplayByElementId(id, val){
    var obj = getElementById(document, id);
    if(obj)obj.style.display = (obj.style.display == "none" ? val : "none");
}
function displayByElementId(id, val){
    var obj = getElementById(document, id);
    if(obj)obj.style.display = val;
}
function odd(nr){
    var val1 = (nr / 2); 
    var val2 = (Math.floor(val1));
    return (val1 != val2);
}
function cleanURI(uri){
	var href = uri;
	var i = href.indexOf("?");
	if(i>=0)
		href = href.substr(0, i);
	else{
		i = href.indexOf("#");
		if(i>=0)
			href = href.substr(0, i);
	}
	return href;
}
function getGUIDs(oL){
   var arr = oL.split("?");
   var par = arr[1].split("&");
   var pageGUID = "";
   var parentPageGUID = "";
   for(var i=0; i < par.length; i++){
      var field = par[i].split("=");
      if(field[0].toLowerCase() == "pageguid")
         var pageGUID = field[1];
      else if(field[0].toLowerCase() == "parentpageguid")
         var parentPageGUID = field[1];
   }
   return new Array(parentPageGUID, pageGUID);
}
function getElementsByTagName(obj, tagName){
   if(document.all)
      return obj.all.tags(tagName);
   else if(document.getElementsByTagName)
      return obj.getElementsByTagName(tagName);
}
function getParentElement(obj){
   if(document.all)
      return obj.parentElement;
   else
      return obj.parentNode;
}
function getParentElementByTagName(obj, tagName){
   var parentElement = getParentElement(obj);
   if(parentElement.tagName.toLowerCase()==tagName.toLowerCase())
      return parentElement;
   else
      return getParentElementByTagName(parentElement, tagName);
}
function getElementByIndex(obj, index){
   if(document.all)
      return obj.all(index);
   else
      return obj.childNodes[index];
}
function getElementById(obj, id){
   if(document.all)
      return obj.all(id);
   else
      return document.getElementById(id);
}
function getEventClientX(oEvent){
   if(document.all)
      return event.clientX;
   else
      return oEvent.pageX;
}
function getEventClientY(oEvent){
   if(document.all)
      return event.clientY;
   else
      return oEvent.pageY;
}


function openWindow(
	wName,
	wSource,
	wXPosition,
	wYPosition,
	wWidth,
	wHeight,
	wResizable,
	wFullscreen,
	OwnerWindowClose,
	wScrollbars,
	wStatus) {

	var wStyle = "";
	wStyle = wStyle + "width=" + wWidth;
	wStyle = wStyle + ",height=" + wHeight;
	wStyle = wStyle + ",fullscreen=" + wFullscreen;
	wStyle = wStyle + ",resizable=" + wResizable;
	wStyle = wStyle + ",scrollbars=" + wScrollbars;
	if(wResizable==null)wResizable = 0;
	wStyle = wStyle + ",menubar=" + wResizable;
	if(wFullscreen==null)wFullscreen = 0;
	wStyle = wStyle + ",toolbar=" + wFullscreen;
	wStyle = wStyle + ",directories=" + "no";
	wStyle = wStyle + ",location=" + "no";
	if(wStatus==null)wStatus = 0;
	wStyle = wStyle + ",status=" + wStatus;
	wStyle = wStyle + ",dependent=" + "no";

	if (document.layers){
		wStyle = wStyle + ",screenX=" + wXPosition;
		wStyle = wStyle + ",screenY=" + wYPosition;
	}else{
		wStyle = wStyle + ",top=" + wYPosition;
		wStyle = wStyle + ",left=" + wXPosition;
	}

	var newW = window.open(wSource, wName, wStyle);

	if(OwnerWindowClose==true){
		self.focus();
		self.close();
	}
	return newW;
}

