// JavaScript Document//jQuery.noConflict();
function striper(parentElementTag, parentElementClass, childElementTag, styleClasses) {
	var l=0,styles = styleClasses.split(',');
	jQuery.each( jQuery(parentElementTag+"."+parentElementClass), function(j, m){	
		jQuery.each( jQuery(m).children(childElementTag), function(i, n){	
		l = (i+(styles.length)) % styles.length;
		jQuery(this).addClass(styles[l]);
		});	
	});	
}
function simpleStriper(ElementTag, ElementClass, styleClasses) {
	var l=0,styles = styleClasses.split(',');
	jQuery.each( jQuery(ElementTag+"."+ElementClass), function(i, n){
		l = (i+(styles.length)) % styles.length;
		jQuery(this).addClass(styles[l]);
	});	
}
function specialstriper(parentElementTag, parentElementClass, childElementTag, styleClasses) {
	var l=0,styles = styleClasses.split(',');
	jQuery.each( jQuery(parentElementTag+"."+parentElementClass), function(j, m){	
		jQuery.each( jQuery("div.checked > div > ul").children(childElementTag), function(i, n){	
		l = (i+(styles.length)) % styles.length;
		jQuery(this).addClass(styles[l]);
		});	
	});	
}

function zoomin() {
 jQuery("#keyvisual").animate({height: '540'},1000);
}
function zoomout() {
 jQuery("#keyvisual").animate({height: '290'},1000);
}

function zoominsmall() {
 jQuery("#keyvisual").animate({height: '450'},1000);
}
function zoomoutsmall() {
 jQuery("#keyvisual").animate({height: '198'},1000);
}



function addEvent(obj, evType, fn){ 
  if (obj.addEventListener){ 
    obj.addEventListener(evType, fn, false); 
    return true; 
  } else if (obj.attachEvent){ 
    var r = obj.attachEvent("on"+evType, fn); 
    return r; 
  } else { 
    return false; 
  } 
}

function dohides(){
  var h3s,tohide,newlink,newtext;
// get all h3 elements, loop over them
  h3s=document.getElementsByTagName('h3');
var expand = querySt("expand");
if(expand){
	var mytest = expand.split('|');
}
  for (i=0;i<h3s.length;i++){
// check if the class contains showhide
    if(/showhide/.test(h3s[i].className)){
      h3s[i].className+=" isactive";
// get the next sibling until it really is an element, if so, hide it
      tohide=h3s[i].nextSibling;
      while(tohide.nodeType!=1){
        tohide=tohide.nextSibling;
      }
      //tohide.style.display='none';

	var nr = i + 1;
	tohide.className = 'ishidden';
if(expand){
	for (j=0;j<mytest.length;j++){
	//alert(mytest[j]);
		
		/*if(mytest[j] != nr) {
		}*/
		if(mytest[j] == nr) {
			tohide.style.display='block';
			h3s[i].className+=" isopen";
		}
	}
}
/// assemble a link and take the content of the span inside the h3 as its text
      newlink=document.createElement('a');
      newtext=document.createTextNode(h3s[i].firstChild.firstChild.nodeValue);
      newlink.appendChild(newtext);
      newlink.href='#'
// create a new object attribute, this saves us looping in the showhide function
// add the event handlers
      newlink.colobj=tohide;

      newlink.onmouseover=function() {
        this.parentNode.className+=" isover";
      }
      newlink.onmouseout=function() {
        this.parentNode.className=this.parentNode.className.replace(new RegExp(" isover\\b"), "");
      }

      newlink.onclick=function(){
		$(this.colobj).animate({
      "height": "toggle", "opacity": "toggle"
    }, "slow");
showhide(this.parentNode);
        //new Effect.toggle(this.colobj, 'blind',{queue:'start', afterFinish:showhide(this.parentNode)});
        //Effect.Combo(this.colobj, {duration: 1, scaleX: false, scaleContent: false});
        return false;
      }
      //newlink.onkeypress=function(){showhide(this.colobj);return false}
// replace the h3 with the link
      h3s[i].replaceChild(newlink,h3s[i].firstChild)
    }
  }
}

function showhide(o){
// toggle class
  //if(o){o.className = o.className == 'showhidehidden'?'showhide':'showhidehidden';}
  if(o.className.match(new RegExp(" isopen\\b"))){
    o.className=o.className.replace(new RegExp(" isopen\\b"), "");
  } else {
    o.className+=" isopen";
  }

}

function querySt(ji) {
 hu = window.location.search.substring(1);
 gy = hu.split("&");
 for (i=0;i<gy.length;i++) {

 ft = gy[i].split("=");
 if (ft[0] == ji) {
 return ft[1];
 }
 }
}

function getQuery() {
 var action = querySt("action");
 if(action == "go") {
 document.getElementById("btn").style.display = "none";
 document.getElementById("winner").style.display = "block";
 letitSnow();
 }
}




// if the browser can deal with DOM, addEventlisteners  
if(document.getElementById && document.createTextNode){
  addEvent(window, 'load', dohides);
  addEvent(window, 'load', initBehaviourLayer);
  //addEvent(window, 'load', bar);
}



function initBehaviourLayer(){

	/*striper('tbody', 'striped', 'tr', 'even,odd');
	simpleStriper('div', 'news', 'even,odd');
	simpleStriper('ul', 'checked', 'even,odd');
  specialstriper('div', 'checked', 'li', 'even,odd');*/

	//jQuery('.newtable > table > tbody > tr > td:last-child').css({backgroundColor: '#ebf6fa'});
	
/*  jQuery(".newtable > tbody > tr").not(":last-child")
.children("td:last-child").addClass("em");*/

  jQuery(".emphlast > tbody > tr").children("td:last-child").addClass("em");
  jQuery(".newtable > tbody > tr > td > p.x0-allgem-fussnote-5-5pt").parent().addClass("newlegal");
  jQuery(".newtable > tbody > tr > td > p.x0-allgem-fussnote-5pt").parent().addClass("newlegal");

for (i = 1; i <= 40; i++) {
  jQuery(".col"+i+"emph > tbody > tr").children("td:nth-child("+i+")").addClass("em");
  jQuery(".col"+i+"borderright > tbody > tr").children("td:nth-child("+i+")").addClass("borderright");
  jQuery(".colth"+i+"borderright > tbody > tr").children("th:nth-child("+i+")").addClass("borderright");
}
  jQuery("table.separate").css({"border-collapse" : "separate"});
  jQuery("table.separate").attr({"cellpadding" : "0"});
  jQuery("table.separate").attr({"cellspacing" : "0"});

  jQuery("table.separate > tbody > tr.bold").next("tr.bold").children("td").css({"border-top" : "0"});


jQuery("td:empty").text(" ");

	jQuery(".newtable > tbody > tr:first").addClass("em");

  jQuery("table.newtable > tbody > tr > td:first-child").addClass("leftaligned");
  jQuery("table.newtable > tbody > tr > th:first-child").addClass("leftaligned");

	//jQuery('.newtable > table > thead > tr:first').css({backgroundColor: '#ebf6fa'});

jQuery(".newtable > tbody > tr:not(.blank) > td").hover(
      function () {
        jQuery(this).parent("tr").addClass("betterhover");
      }, 
      function () {
        jQuery(this).parent("tr").removeClass("betterhover");
      }
    );

    jQuery("#divfixed").click(function () { 
      jQuery(this).hide();
      jQuery("#container").hide();
      jQuery("#container").empty();
      jQuery("body").css({ overflow:"auto" });
    });
	try {document.execCommand("BackgroundImageCache", false, true);} catch(err) {}
}

