/**
 * Java Script funktionen für swisshaus.ch
 *
 * Copyright 2004 by DACHCOM digital AG.
 * All rights reserved.
 *
 * Author: Walter Canal, wcanal@dachcomdigital.com
 * Version 1.0, 29.01.2004
 *
 * History:
 *  1.0 29.01.2004	wcanal	initial relase
 *
 */
 
 
// File-Download
function openFile(id) {
	document.location.href = '/admin/include/downloadFile.php?action=d&id='+id;
}

// Browserweiche
var bNo = 0;
var ua    = navigator.userAgent.toLowerCase();
var bName = navigator.appName.toLowerCase();
var bVers = parseInt(navigator.appVersion); 

// IE-5 und IE-6 geben bei appVersion 4.0 aus, deshalb Sonderbehandlung:
var ie = ((bName.indexOf("explorer") >-1) && document.all) ? true : false;

if(ie){
    var msie = ua.indexOf("msie");
    bNo = parseInt(ua.substring(msie+5, msie+7));
}
else {
    if(document.layers){ 
        // Netscape 4.x
        bNo = 0; 
    }
    else{ 
        bNo = bVers; 
    }
}
browser = navigator.appName;


// tr ein / ausblenden
function showhide_tr(srcfield,dstfield){

    if(browser == 'Microsoft Internet Explorer'){
        document.getElementById(srcfield).style.display='none';
        document.getElementById(dstfield).style.display='block';
    }else{
        document.getElementById(srcfield).style.display='none';
        document.getElementById(dstfield).style.display='table-row';
    }
}

function Techshowhide_tr(srcfield,dstfield){
	//alert(document.getElementById(srcfield) + '\n' +dstfield);
    if(browser == 'Microsoft Internet Explorer'){
        document.getElementById(srcfield).style.display='none';
        document.getElementById(dstfield).style.display='block';
    }else{
        document.getElementById(srcfield).style.display='none';
        document.getElementById(dstfield).style.display='table-cell';
    }
}

// Style Productlist Frankreich
var selectedProductObj = null;

function setActiveProduct(productObj, action) {
    
	if (action == 'over') {
        document.getElementById(productObj + '_number').className = 'listcat_active';
        document.getElementById(productObj + '_text').className = 'listcat_active';
	}
	else if (action == 'out') {
        document.getElementById(productObj + '_number').className = 'listcat';
        document.getElementById(productObj + '_text').className = 'listcat';
	}
}


// Style Categorylist
var selectedCategoryObj = null;

function setActiveCategory(categoryObj, action) {
    
	if (action == 'over') {
		if (selectedCategoryObj != null) {
            document.getElementById(selectedCategoryObj + '_number').className = 'listcat';
            document.getElementById(selectedCategoryObj + '_text').className = 'listcat';
		}
        document.getElementById(categoryObj + '_number').className = 'listcat_active';
        document.getElementById(categoryObj + '_text').className = 'listcat_active';
        
        // Show Category Solution List
        showhide_tr(selectedCategoryObj + '_solution',categoryObj + '_solution');
        
        selectedCategoryObj = categoryObj;
	}
	else if (action == 'out') {
		if (categoryObj != selectedCategoryObj) {
            document.getElementById(categoryObj + '_number').className = 'listcat';
            document.getElementById(categoryObj + '_text').className = 'listcat';
		}
	}
}

function setActiveCattech(categoryObj, action) {
//alert(document.getElementById(categoryObj + '_text').className);

	if (action == 'over') {
		if (selectedCategoryObj != null) {
            document.getElementById(selectedCategoryObj + '_text').className = 'listcat color';
		}
        document.getElementById(categoryObj + '_text').className = 'listcat_active color';
        
        // Show Category Solution List
        Techshowhide_tr(selectedCategoryObj + '_solution',categoryObj + '_solution');

        selectedCategoryObj = categoryObj;        
	}
	else if (action == 'out') {
		if (categoryObj != selectedCategoryObj) {
            document.getElementById(categoryObj + '_text').className = 'listcat color';
		}
	}
}

// Layer
function showLayers() {
	var i,v,obj,args=showLayers.arguments;
	// alle layers verschwinden lassen
	for (i=0; i < (arrayLayer.length); i++) {
		if ((obj=MM_findObj(arrayLayer[i]))!=null) {
			if (obj.style) {
				obj=obj.style;
				obj.visibility='hidden';
			}
			else {
				obj.visibility='hide';
			}
		}
	}

	// gewünschte layers anzeigen
	for (i=0; i < (args.length); i++) {
		if ((obj=MM_findObj(args[i]))!=null) {
			if (in_array(args[i], arrayLayer)) {
				if (obj.style) {
					obj=obj.style;
					obj.visibility='visible';
				}
				else {
					obj.visibility='show';
				}
			}
		}
	}
}

function in_array(str, array) {
	if (array != null && array.length > 0) {
		for (var i = 0; i < array.length; i++) {
			if (array[i] == str) {
				return true;
			}
		}
	}
	return false;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
