// SUBNAVIGATION Hover
function subnavHeadHoverOn(id) {
    var linkon = id + '-link-hover';
    var linkoff = id + '-link';
    Element.addClassName(id,'subnav-item-head-hover');
    Element.show(linkon);
    Element.hide(linkoff);
}

function subnavHeadHoverOff(id) {
    var linkon = id + '-link';
    var linkoff = id + '-link-hover';
    Element.removeClassName(id,'subnav-item-head-hover');
    Element.show(linkon);
    Element.hide(linkoff);
}

function subnavHoverOn(id) {
    var arrow1  = "arrow-" + id;
    var arrow2  = "arrowOn-" + id;
    Element.addClassName(id,'subnav-item-content-hover');
    Element.show(arrow2);
    Element.hide(arrow1);
}

function subnavHoverOff(id) {
    var arrow1  = "arrow-" + id;
    var arrow2  = "arrowOn-" + id;
    Element.removeClassName(id,'subnav-item-content-hover');
    Element.show(arrow1);
    Element.hide(arrow2);
}

// PRODUCT OVERVIEW Hover
function prodOvOn(id) {
    var pid = "prodOv"+id;
    Element.addClassName(pid,'headline-on');
    Element.removeClassName(pid,'headline');
}

function prodOvOff(id) {
    var pid = "prodOv"+id;
    Element.removeClassName(pid,'headline-on');
    Element.addClassName(pid,'headline');
}

// PRODUCT DETAIL Icon-Overlay
function detailOverlay(id) {
    var pid = "ovly-" + id;
    var cid = "content-" + id;
    Element.show('overlay-detail');
    Element.show(cid);
    Element.addClassName('icon-overlay',pid);
}

function detailOverlayClose() {
    Element.hide('overlay-detail');
    for (i = 1; i < 5; i++) {
        pid = "ovly-" + i;
        cid = "content-" + i;
        Element.removeClassName('icon-overlay',pid);
        Element.hide(cid);
    }
}

// PRODUCT DETAIL Image-Swap
function showProduct(id,all) {
    var pid = "product-" + id;
    var yall = all+1;
    
    for (i = 0; i < yall; i++) {
        var hid = "product-" + i;
        if (pid == hid) {
            Element.show(pid);
        } else {
            Element.hide(hid);
        }
    }
}

// PRODUCT DETAIL Extras (Benefits, Detail, Refills)
function showProductExtras(id) {
    var pid = "extras-" + id;
        
    for (i = 1; i < 4; i++) {
        var hid = "extras-" + i;
        var tid = "tab" + i +"-active";
        var rid = "tab" + i;
        if (pid == hid) {
            Element.show(pid);
        } else {
            Element.hide(hid);
        }
        
        if (i == id) {
            Element.show(tid);
            Element.hide(rid);
        } else {
            Element.show(rid);
            Element.hide(tid);
        }
        
    }
}

// PRODUCT SUBCATEGORIES Arrows-Toggle
function toggleCat(id, amount) {

    var countAll = amount;

    //check if category is already clicked
    if(Element.visible('products_' + id)){
        Element.setStyle('aright' + id, {display: 'block'});
        Element.setStyle('adown' + id, {display: 'none'});
        Element.setStyle('products_' + id, {display: 'none'});                                  
    }       
    else {

        for (i = 0; i < countAll; i++) {
            if (id == i) {
                if (Element.getStyle('aright' + id, 'display') == 'block') {
                    Element.setStyle('aright' + id, {display: 'none'});
                    Element.setStyle('adown' + id, {display: 'block'});
                    Element.setStyle('products_' + id, {display: 'block'});                 
                }
            } else if(id != i) {
                Element.setStyle('aright' + i, {display: 'block'});
                Element.setStyle('adown' + i, {display: 'none'});
                Element.setStyle('products_' + i, {display: 'none'});                           
            }
        }
        
    }


}

// PRODUCT SUBCATEGORIES Hover
function subcatOn(id) {
    var pid = "subcatHead" + id;
    Element.addClassName(pid,'head-on');
    Element.removeClassName(pid,'head');
}

function subcatOff(id) {
    var pid = "subcatHead" + id;
    Element.addClassName(pid,'head');
    Element.removeClassName(pid,'head-on');
}

// Side-Teaser
function toggleSideTeaser(id, all) {
    
//  alert('toogle');
    
    var pid = "side_" + id;

    for (i = 0; i < all; i++) {
        if (id == i){
//          alert("show");
            Element.addClassName(pid,'handler-on');
//          Effect.SlideDown('panel_image_' + id);          
            Element.removeClassName('panel_image_' + id,'panel_image_off');
            Element.addClassName('panel_image_' + id,'panel_image_on');     
        } else {
//          alert("hide panel_image_" + i);         
            Element.removeClassName('side_' + i,'handler-on');
            Element.addClassName('side_' + i,'handler');
//          Effect.SlideUp('panel_image_' + i);
            Element.addClassName('panel_image_' + i,'panel_image_off');         
            Element.removeClassName('panel_image_' + i,'panel_image_on');
        }
    }
}



// Tell-A-Friend
function toggleLayer(id) {
    if (Element.getStyle(id, 'display') == 'block') {
        Effect.BlindUp(id, {duration: 0.5});
    } else {
        Effect.BlindDown(id, {duration: 0.5});
    }
}

function toggle_remote(element_type, url) {
    if (Element.empty(element_type)) {
      new Ajax.Updater(element_type, url, {
        method:     'post',
        onFailure:  function() { 
            Element.classNames(element_type).add('failure');
            },
        onComplete: function() { 
            new Effect.BlindDown(element_type, {
                duration: 0.25, 
                afterFinish: function() {
                    new Effect.ScrollTo('button-submit', {offset: -14});
                    }
                }); 
            }
      });
    } else {
      new Effect[Element.visible(element_type) ? 'BlindUp' : 'BlindDown'](element_type, { duration: 0.25, afterFinish:function(){ new Effect.ScrollTo('button-submit', {offset: -14});} });
    }

}

// Terms & Conditions Layer Switch
function toggleTerms() {
    Element.toggle('switch_headline1');
    Element.toggle('switch_headline2');
    Element.toggle('switch_content1');
    Element.toggle('switch_content2');
    Element.toggle('switch_link1');
    Element.toggle('switch_link2');
    Element.toggle('switch_side1');
    Element.toggle('switch_side2');
}

// IMAGE Hover (general)
function movepic(img_name,img_src) {
    document[img_name].src=img_src;
}

function toogleCountries(countries, index){
    for (i = 1; i < countries; i++) {           
        if(index != i && document.getElementById('id_' + i) != null){
            document.getElementById('id_' + i).style.display='none';
        }
    }
}


function ie_six_check() {

        var browser=navigator.appName;
        var version=navigator.appVersion;       

        if(browser.indexOf("Microsoft") >= 0 && version.indexOf("6") >= 0){
            return true;
        }
    return false;
}       

//opens printdialog i6
function print_window() {
   

    window.print();
    return false;
    ie_six_check(); 
}

//open popups via this function because of ie6
function openWindow(url, name, width, height){

  alert(url);
  alert(name);
  alert(width);
  alert(height);

  properties = 'width=' + width + ',height=' + height + ',toolbar=no,resizable=no';
  window.open(url, name, properties);
}
