
function getObject(obj)	{
	var theObj;
	if(document.all && eval('document.all.'+ obj) ) theObj=eval('document.all.'+ obj +'.style');
	if(document.layers) theObj=eval('document.'+ obj);
	if(!document.all && document.getElementById) {
	  var nodeObject = document.getElementById(obj);
	  if ( nodeObject != null ) {
	    theObj = nodeObject.style;
	  }
	}
	return theObj;
}

function check_default_text(el,default_text) {
	if (el.value == default_text) {
		el.value = "";
	}
}

function track_file( filename, title ){
  var path = window.location.pathname;
  if ( path.lastIndexOf("/") != path.length - 1 ) {
    path += "/";
  }
  path += filename;
  track_url( path, title )
}

function track_url( link, title ){
   if ( isWebtrendsEnbaled ) {
    // Just in case that it is a full URL
    var hostURL = window.location.protocol + "//" + window.location.hostname;
    if ( link.indexOf( hostURL ) == 0 ) {
      link = link.substr( hostURL.length );
    }
    dcsMultiTrack('DCS.dcsuri', link, 'WT.ti', title );
  }
}

// function tracks WebTrends and Google Analytics
function track_url_multi( link, title ){
	track_url (link, title);
	// Google Analytics assumes that a variable pageTracker be defined.
	if ((pageTracker != null) && (pageTracker != 'undefined')) {
   		pageTracker._trackPageview(link);
	}
}


function show_lang(obj){
	var theObj=getObject(obj);
    theObj.visibility='visible';
}
function hide_lang(obj){
	var theObj=getObject(obj);
	theObj.visibility='hidden';
}


function show_div(obj){
	var theObj=getObject(obj);
    theObj.visibility='visible';
}
function hide_div(obj){
	var theObj=getObject(obj);
	theObj.visibility='hidden';
}

function changeImage(name,aktiv,ov_layer){

	if(document.layers) {
		eval('document.'+ov_layer+'.document.images["'+name+'"].src = '+eval('"'+aktiv+'"')+'.src');
		}
	else {
        if (document.images[name].src) document.images[name].src = eval(aktiv+'.src');
    }

}
function changeImage2(name,aktiv){
	if(document.layers) {
	  eval('document.images["'+name+'"].src = '+eval('"'+aktiv+'"')+'.src');
	} else {
	  // Not all images are present under any conditions. Therefore we have to check
	  // for existence first.
	  var image = document.images[name];
      var varactive = document.images[aktiv];
	  if ( image != null ) {
	        image.src = eval(aktiv+'.src');
	  }
	}
	return true;
}
function changeImageSource(name,aktiv_src){
	  var image = document.images[name];
	  if ( image != null) {
	        image.src = aktiv_src;
	  }
	return true;
}

function bs_quick_nav() {
	location=document.bsquicknavform.bsnavpa[document.bsquicknavform.bsnavpa.selectedIndex].value;
}
function sprach_quick_nav() {
	location=document.lang_selectfrom2.lang_select2[document.lang_selectfrom2.lang_select2.selectedIndex].value;
}

function OpenFeedback(pfad){
		 var base = "https://"+location.host;
		 w=window.open(base+'/'+pfad+'/feedbackform.html','Feedback','width=500,height=500,left=100,top=100');
}
function OpenIdee(pfad){
		 var base = "https://"+location.host;
		 w=window.open(base+'/'+pfad+'/ideenform.html','Idee','width=500,height=650,left=100,top=100');
}

/* Used for requesting a counter pixel to count navigation layer calls.
 * The image is not set in all templates and the function deactivated for now
 */
function getImage(name){
    // if (document.images["counterimg"]) {
	//     document.images["counterimg"].src = bild;
	// }
}
// Popup
function funcOpenPopup(thisPath, thisName, thisWidth, thisHeight, thisPosX, thisPosY){
		 newPopup = window.open(thisPath,thisName,'width='+thisWidth+',height='+thisHeight+',left='+thisPosX+',top='+thisPosY);
}



// Popup Tubing Produktselektor
function funcOpenProduct(thisGlassID){
         var uri = "/flash/tubing/selector/popup/index.html?glassid="+thisGlassID;
         newPopup = window.open(uri,'Product','width=790,height=610,left=120,top=120,resizable=no,scrollbars=no,menubar=no,toolbar=no,status=no,location=no');
         newPopup.focus();
}


// Popup Tubing Produktselektor
function funcOpenGroup(groupID){
         var uri = "/flash/tubing/selector/popup/index.html?appid="+groupID;
         newPopup = window.open(uri,'Product','width=790,height=610,left=120,top=120,resizable=no,scrollbars=no,menubar=no,toolbar=no,status=no,location=no');
         newPopup.focus();
}


// Bookmarks
function bookmarkThisPage(){
    varURL = document.URL;
    varName = "Please insert title here.";
    varName = document.title;
	if ((navigator.appName == 'Microsoft Internet Explorer') && (parseInt(navigator.appVersion) >= 4)) {
    	window.external.AddFavorite(varURL, varName);
    }
    // else if (navigator.appName == 'Netscape') {
    //	window.sidebar.addPanel(varName, varURL, '');
    // }
    else {
    	alert("Sorry, your browser does not support this function automatically.\nPlease use your browser's function to bookmark this page.");
    }
}

// view images
tryNr = 0;
function funcViewImage(varImageSrc,varAlt,varLanguage) {
	tryNr = 0;
	imageView = new Image();
	imageView.src=(varImageSrc);
	funcImageData(varImageSrc,varAlt,varLanguage);
}
function funcImageData(varImageSrc,varAlt,varLanguage) {
	if((imageView.width!=0) && (imageView.height!=0)) {
		openSupersizePicture(varImageSrc,varAlt,varLanguage,imageView.width,imageView.height);
	} else {
		if (tryNr < 500) {
			tryAgain = "funcImageData('"+varImageSrc+"','"+varAlt+"','"+varLanguage+"')";
			whileLoadingImage = setTimeout(tryAgain,20);
			tryNr++;
		} else {
			alert("File not found.")
		}
	}
}
function openSupersizePicture(picpath,picalt,picwidth,picheight,lang) {

	var picTitle = "SCHOTT";
	var closeCaption =  "Close<br>window";
	if (lang == "german")  closeCaption = "Fenster<br>schließen";
	if (picalt != "") picTitle += " - " + picalt;
	var windowWidth  = picwidth + 20;
	var windowHeight = picheight + 80;
	var myDate = new Date();
	var popupWindowName = "viewImage" + myDate.getTime();
	var popupWindowParams = 'width=' + windowWidth + ', height=' + windowHeight + ', resizable=no, scrollbars=auto, top=10, left=10';
	popupView = window.open("", popupWindowName, popupWindowParams);
	popupView.document.write ("<html>\n<head>\n");
	popupView.document.write ("<title>"+picTitle+"</title>\n");
	popupView.document.write ("<link href='/css/schott_quickwins.css' rel='stylesheet' type='text/css'>\n");
	popupView.document.write ("</head>\n");
	popupView.document.write ("<body style='margin:0; padding:0;'>\n");
	popupView.document.write ("<p style=\"width:" + windowWidth + "px;margin:10px 0px;text-align:center;\"><img src='"+picpath+"' width='"+picwidth+"' height='"+picheight+"' alt='"+picalt+"' style=\"margin:0px;padding:0px;\"></p>\n");
	popupView.document.write ("<p style=\"width:"+windowWidth+"px;margin:0px;margin-top:20px;text-align:center;\"><a class='blue' href='#' onclick='self.close();'>"+varCloseWindow+"</a></p>");
	popupView.document.write ("\n</body>\n</html>");
	popupView.focus();
}

// Tooltipps

moveDivPosY = "0";

function showTooltipp(cTooltippId,cWidth,diffPosLeft,diffPosTop,moveDivId) {
    var cTooltipp = document.getElementById(cTooltippId);
    var cTooltippContentId = cTooltippId + "_content";
    var cTooltippContent = document.getElementById(cTooltippContentId);
    // Position
    var varX = cTooltipp.offsetLeft;
    var varY = cTooltipp.offsetTop;
    var parentElement = cTooltipp.offsetParent;
    while (parentElement) {
      varX += parentElement.offsetLeft;
      varY += parentElement.offsetTop;
      parentElement = parentElement.offsetParent;
    }
    posX = varX + diffPosLeft;
    posY = varY + diffPosTop;
    cTooltippContent.style.position = "absolute";
    cTooltippContent.style.left = posX + "px";
    cTooltippContent.style.top = posY + "px";
    // Groesse
    if (cWidth != "default") cTooltippContent.style.width = cWidth + "px";
    // Display
    cTooltippContent.style.display = "inline";
    // ggf: einen anderen Container verschieben
    if (moveDivId != "") {
        var cMoveDiv = document.getElementById(moveDivId);
        if (moveDivPosY == "0") {
            moveDivPosY = cMoveDiv.offsetTop;
            var parentElement = cMoveDiv.offsetParent;
            while (parentElement) {
              moveDivPosY += parentElement.offsetTop;
              parentElement = parentElement.offsetParent;
            }
        }
        cTooltippContentHeight = cTooltippContent.offsetHeight;
        cMoveDivNewPosY = moveDivPosY + cTooltippContentHeight;
        cMoveDiv.style.position = "absolute";
        cMoveDiv.style.top = cMoveDivNewPosY + "px";
    }
}

function hideTooltipp(cTooltippContentId,cAction,moveDivId) {
    if (cAction=="opener") cTooltippContentId = cTooltippContentId + "_content";
    var cTooltippContent = document.getElementById(cTooltippContentId);
    cTooltippContent.style.display = "none";
    // ggf.: verschobenes Element an die Ursprungspostion zurücksetzen
    if (moveDivId != "") {
        var cMoveDiv = document.getElementById(moveDivId);
        cMoveDiv.style.top = moveDivPosY + "px";
    }
}

function keepTooltipp(cTooltippContentId,moveDivId) {
    var cTooltippContent = document.getElementById(cTooltippContentId);
    cTooltippContent.style.display = "inline";
    // ggf: einen anderen Container verschoben lassen
    if (moveDivId != "") {
        var cMoveDiv = document.getElementById(moveDivId);
        if (moveDivPosY == "0") {
            moveDivPosY = cMoveDiv.offsetTop;
            var parentElement = cMoveDiv.offsetParent;
            while (parentElement) {
              moveDivPosY += parentElement.offsetTop;
              parentElement = parentElement.offsetParent;
            }
        }
        cTooltippContentHeight = cTooltippContent.offsetHeight;
        cMoveDivNewPosY = moveDivPosY + cTooltippContentHeight;
        cMoveDiv.style.position = "absolute";
        cMoveDiv.style.top = cMoveDivNewPosY + "px";
    }
}
function doNothing() {}
