function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}

//  puhelinluettelon haku-sivun focus

function putFocus(formInst, elementInst) {
  if (document.forms.length > 0) {
   document.forms[formInst].elements[elementInst].focus();
  }
}

function printpage() {

window.print();  
}

<!--
// Nannette Thacker http://www.shiningstar.net
function confirmDeleteCountry()
{
var agree=confirm("Before deleting a country, \nplease take a look at the list of all countries. \nPress ok to proceed.");
if (agree)
	return true ;
else
	return false ;
}
// -->
<!--
// Nannette Thacker http://www.shiningstar.net
function confirmDelete()
{
var agree=confirm("Delete?");
if (agree)
	return true ;
else
	return false ;
}
// -->

function blocking(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}

//show content
function showcontent() {
	
var myWidth = 0, myHeight = 0; var height = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		height = myHeight-120;//-150
	  } else if( document.documentElement &&
		  ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		height = myHeight-175;//-140
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		height = myHeight-165;//-125
	  }
	//window.alert( 'Height= ' + myHeight );
	//document.write('<td class="content" height="100%">');
	//window.alert( 'height= ' + height );
	if( typeof( window.innerWidth ) == 'number' ) {
		//for moz, firefox, opera, safari
		
		document.write('<div style="padding-top: 0px; padding-right: 0px; height: ' + height +'px; overflow: auto;">');
	} else {
		//for ie
		//document.write('<div style="height: ' + height +'px;">');
		
		document.write('<div style="padding-top: 0px; padding-right: 0px; height: ' + height +'px; overflow: auto;">');
	}
}

//show content
function closecontent() {
	
	document.write('</div>');
}

/*DW scripts*/

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ChangeSectionVisibilityCheckbox(ElementId, ElementToHide) {
    
    //alert(ElementId);
    
    var elem = document.getElementById(ElementId);
    
    var elemToHide = document.getElementById(ElementToHide);
      
    if (elem && elemToHide) {
    
        //alert(ElementToHide);
        if (!elem.checked)
            elemToHide.style.display = 'none';
        else 
            elemToHide.style.display = 'block';    
    
    }
    
}

function ChangeSectionVisibility(ElementId, ElementToHide) {
    
    var elem = document.getElementById(ElementId);
    
    var elemToHide = document.getElementById(ElementToHide);
    
      
    if (elem && elemToHide) {
    
        if (elem.value!='true') {
        
            elemToHide.style.display = 'none';
            elem.value = 'false';
            
            
        } else {
        
            elemToHide.style.display = 'block'; 
            elem.value = 'true';
            
        } 
            
    
    }
    
    
    
    //elemToHide.style.display = 'block';
    
}

function ChangeInputValue(elementToChange, setToValue) {

    var el = document.getElementById(elementToChange);
 
    if (el && setToValue!='') {

        el.value = setToValue;
        
    }
    
}


function CascadeLevelElement(elementId, level, idtolookfor) {

    var innerelementid = '';
    
    var result = false;
    
    if (document.Feedback.elements[elementId]) {
    
        innerelementid = document.Feedback.elements[elementId].value;
        
        var array = innerelementid.split('-');
        
        if (array[level]==idtolookfor) {
        
            result = true;
        }    
    }
    //alert(array[1]);
    //alert(result);
    
    return result;
}

function ChangeFeedbackInputValue(elementToChange, setToValue) {

    //alert(document.Feedback.elements.length);
    
    var el = document.Feedback.elements[elementToChange]; 
    
    ChangeInputValue(elementToChange, setToValue);
    
    //alert('elementToChange: '+el);
    
    el.value = setToValue;
    
    //alert('element value: ' + el.value);
   
    // By default set sections hidden and false
    
    ChangeInputValue('ProductTypeSectionVisible', 'false');
    ChangeSectionVisibility('ProductTypeSectionVisible', 'ProductTypeSection');
    
    ChangeInputValue('XrayProductSectionVisible', 'false');
    ChangeSectionVisibility('XRayProductSectionVisible', 'XRayProductSection');
    
    ChangeInputValue('UnitProductSectionVisible', 'false');
    ChangeSectionVisibility('UnitProductSectionVisible', 'UnitProductSection');
    
    ChangeInputValue('SWProductSectionVisible', 'false');
    ChangeSectionVisibility('SWProductSectionVisible', 'SWProductSection');     
            
    ChangeInputValue('ProductAdditionalSectionVisible', 'false');
    ChangeSectionVisibility('ProductAdditionalSectionVisible', 'ProductAdditionalSection');
    
    ChangeInputValue('DeliveryAdditionalSectionVisible', 'false');
    ChangeSectionVisibility('DeliveryAdditionalSectionVisible', 'DeliveryAdditionalSection');
    
    // see if first level type is product
   
    
    // Product-type-level
    if (CascadeLevelElement('FeedbackTypeElementId', 1, 3)) {
        
        ChangeInputValue('ProductTypeSectionVisible', 'true');
        ChangeSectionVisibility('ProductTypeSectionVisible', 'ProductTypeSection');
        
        // Product-level
    
        // Units
        if (CascadeLevelElement('FeedbackProductTypeElementId', 1, 10)) {
        
            ChangeInputValue('UnitProductSectionVisible', 'true');
            ChangeSectionVisibility('UnitProductSectionVisible', 'UnitProductSection');
            
            ChangeInputValue('ProductAdditionalSectionVisible', 'true');
            ChangeSectionVisibility('ProductAdditionalSectionVisible', 'ProductAdditionalSection');
        }
        
        // XRay
        if (CascadeLevelElement('FeedbackProductTypeElementId', 1, 11)) {
        
            ChangeInputValue('XrayProductSectionVisible', 'true');
            ChangeSectionVisibility('XRayProductSectionVisible', 'XRayProductSection');
            
            ChangeInputValue('ProductAdditionalSectionVisible', 'true');
            ChangeSectionVisibility('ProductAdditionalSectionVisible', 'ProductAdditionalSection');
        }
        
        // SW
        if (CascadeLevelElement('FeedbackProductTypeElementId', 1, 12)) {
        
            ChangeInputValue('SWProductSectionVisible', 'true');
            ChangeSectionVisibility('SWProductSectionVisible', 'SWProductSection');     
                
            ChangeInputValue('ProductAdditionalSectionVisible', 'true');
            ChangeSectionVisibility('ProductAdditionalSectionVisible', 'ProductAdditionalSection');
        }
        
    }
    
    if (CascadeLevelElement('FeedbackTypeElementId', 1, 2)) {
    
        ChangeInputValue('DeliveryAdditionalSectionVisible', 'true');
        ChangeSectionVisibility('DeliveryAdditionalSectionVisible', 'DeliveryAdditionalSection');
        
    } 
    
     
}

function ChangeBorderOfAnFeedbackImage(elementToChange, setToValue, setStartPrefix, setStart, hiddenElementName) {

    //alert(document.Feedback.elements.length);
    
    var elementstart = setStartPrefix + '-';
    
    var elementsend = setStart + 10;
    
    // if elementToChange.length
    
    //alert(elementToChange.length);
    
    //alert(elementsend);
    
    if (elementToChange.length>4) {
    
        //alert(document.Feedback.elements['FeedbackProductTypeElementId'].value);
        
        for (j=1; j<10; j++) {
    
            elementstart = document.Feedback.elements['FeedbackProductTypeElementId'].value;
            
            elementstartwithid = elementstart + '-' + j;
            
            //elementstartwithid = elementstartwithid + i;
            
            //alert(elementstartwithid);
            
            if (document.getElementById(elementstartwithid)) {
            
                //alert('el: ' + j + ' found');
                
                document.getElementById(elementstartwithid).style.border = '3px solid white';
            }
        
        
        }
        
    } else {
    
        for (i=setStart; i<elementsend; i++) {
    
            elementstartwithid = '';
            
            elementstartwithid = elementstart + i;
            
            if (document.getElementById(elementstartwithid)) {
            
                //alert('el: ' + i + ' found');
                
                document.getElementById(elementstartwithid).style.border = '3px solid white';
            }
        
        
        }
    
    }
    
    
    
    //alert(elementToChange);
    
    
    
    var el = document.getElementById(elementToChange); 
    
    if (el && setToValue!='') {
    
        //if (el.style.border==setToValue) {
        
          //  el.style.border = '3px solid white';
            
        //} else {
            
            el.style.border = setToValue;
            
            //alert(document.Feedback.elements[hiddenElementName]);
        //}
            document.Feedback.elements[hiddenElementName].value = elementToChange;
        
    }
   
    
}

function SetBorderOfAnFeedbackImage(hiddenElementName) {

    var borderstyle = '3px solid green';
    var elementToChange = '';
    
    if (document.Feedback) {
    
        if (document.getElementsByName(hiddenElementName)) {
    
            //alert(hiddenElementName + " found");
            //alert(document.Feedback.elements[hiddenElementName].value + " value");
        }
    }
    
    
    if (document.Feedback) {
    
        if (document.Feedback.elements[hiddenElementName]) {
            
            //alert(hiddenElementName);
            
            elementToChange = document.Feedback.elements[hiddenElementName].value;
            
            //alert(elementToChange);
            
            document.getElementById(elementToChange).style.border = borderstyle;
     
        
        }
        
    }
      
    
}

function SelectorChangeProductTypeSectionVisibility(selObj,restore){ 
  
  //alert("selected value: " + selObj.options[selObj.selectedIndex].value);
  
  
    // By default set sections hidden and false
    
    ChangeInputValue('ProductTypeSectionVisible', 'false');
    ChangeSectionVisibility('ProductTypeSectionVisible', 'ProductTypeSection');

    ChangeInputValue('XrayProductSectionVisible', 'false');
    ChangeSectionVisibility('XRayProductSectionVisible', 'XRayProductSection');

    ChangeInputValue('UnitProductSectionVisible', 'false');
    ChangeSectionVisibility('UnitProductSectionVisible', 'UnitProductSection');

    ChangeInputValue('SWProductSectionVisible', 'false');
    ChangeSectionVisibility('SWProductSectionVisible', 'SWProductSection');     
            
    ChangeInputValue('ProductAdditionalSectionVisible', 'false');
    ChangeSectionVisibility('ProductAdditionalSectionVisible', 'ProductAdditionalSection');

    ChangeInputValue('DeliveryAdditionalSectionVisible', 'false');
    ChangeSectionVisibility('DeliveryAdditionalSectionVisible', 'DeliveryAdditionalSection');
   
  // Delivery  
  if (selObj.options[selObj.selectedIndex].index=='2') {
  
    ChangeInputValue('DeliveryAdditionalSectionVisible', 'true');
    ChangeSectionVisibility('DeliveryAdditionalSectionVisible', 'DeliveryAdditionalSection');
    
  } 
    
  // Product  
  if (selObj.options[selObj.selectedIndex].index=='3') {
  
    ChangeInputValue('ProductTypeSectionVisible', 'true');
    ChangeSectionVisibility('ProductTypeSectionVisible', 'ProductTypeSection');

  } 
  
  
  
  if (restore) selObj.selectedIndex=0;
  
}

function SelectorChangeProductSectionVisibility(selObj,restore){ 
  

  // add info section false
  ChangeInputValue('ProductAdditionalSectionVisible', 'false');
  ChangeSectionVisibility('ProductAdditionalSectionVisible', 'ProductAdditionalSection');
  
  // XRay false
  ChangeInputValue('XrayProductSectionVisible', 'false');
  ChangeSectionVisibility('XrayProductSectionVisible', 'XrayProductSection');
  
  // Unit false
  ChangeInputValue('UnitProductSectionVisible', 'false');
  ChangeSectionVisibility('UnitProductSectionVisible', 'UnitProductSection');
    
  // SW false
  ChangeInputValue('SWProductSectionVisible', 'false');
  ChangeSectionVisibility('SWProductSectionVisible', 'SWProductSection');
  
  //alert(selObj.options[selObj.selectedIndex].index);
  
  // selObj.selectedIndex == 1 / Dental units
  if (selObj.options[selObj.selectedIndex].index==1) {
  
    //
    ChangeInputValue('UnitProductSectionVisible', 'true');
    ChangeSectionVisibility('UnitProductSectionVisible', 'UnitProductSection');
    
    //
    ChangeInputValue('ProductAdditionalSectionVisible', 'true');
    ChangeSectionVisibility('ProductAdditionalSectionVisible', 'ProductAdditionalSection');
    
  }
  
  // selObj.selectedIndex == 2 / Dental imaging
  if (selObj.options[selObj.selectedIndex].index==2) {
  
    //
    ChangeInputValue('XRayProductSectionVisible', 'true');
    ChangeSectionVisibility('XRayProductSectionVisible', 'XRayProductSection');
    
    //
    ChangeInputValue('ProductAdditionalSectionVisible', 'true');
    ChangeSectionVisibility('ProductAdditionalSectionVisible', 'ProductAdditionalSection');
    
  } 
  
  // selObj.selectedIndex == 3 / Software
  if (selObj.options[selObj.selectedIndex].index==3) {
  
    //
    ChangeInputValue('SWProductSectionVisible', 'true');
    ChangeSectionVisibility('SWProductSectionVisible', 'SWProductSection');
    
    //
    ChangeInputValue('ProductAdditionalSectionVisible', 'true');
    ChangeSectionVisibility('ProductAdditionalSectionVisible', 'ProductAdditionalSection');
    
  } 
  
  if (restore) selObj.selectedIndex=0;
  
}





