function checkNav() {
  if (!document.getElementById) {
    clearInterval(domload)
    domload = null;
    return false; 
  }
  if (document.getElementById("menu") && !menuInit) {
    clearInterval(domload);
    $('menu').setStyle('opacity',0);
    domload = null;
    return true;
  } else {
    return false;
  }
}
var menuInit = false;
var domload = setInterval("checkNav()", 25);

var toggleContent = function() {
    if (this.hasClass('openContent')) {
        this.removeClass('openContent');
        this.getElement('img').setAttribute('src','/_images/bread.gif');
        this.getElement('img').setAttribute('width','5');
        this.getElement('img').setAttribute('height','10');
        this.getElement('img').setStyle('padding','0px 3px');
        if (this.getNext().tagName == 'DIV') {
            this.getNext().setStyle('display', 'none');
        }
        if (this.getNext().getNext().tagName == 'FORM') {
            this.getNext().getNext().setStyle('display', 'none');
        }
    } else {

        $('main').getElements('.openContent').each(function(content) {
            toggleContent.apply(content);
        });

        this.addClass('openContent');
        this.getElement('img').setAttribute('src', '/_images/arrow_down.gif');
        this.getElement('img').setAttribute('width','11');
        this.getElement('img').setAttribute('height','5');
        this.getElement('img').setStyle('padding','3px 0px');
        if (this.getNext().tagName == 'DIV') {
            this.getNext().setStyle('display', 'block');
        }
        if (this.getNext().getNext().tagName == 'FORM') {
            this.getNext().getNext().setStyle('display', 'block');
        }
    }
}

window.addEvent('domready',function() {
  //Op de homepage is het logo geen link
  if (location.pathname == '/') {
    var logoimg = $('logolink').getChildren()[0];
    $('logolink').replaceWith(logoimg);
  }

  var mLink = $$('a[href="../../_userdata/_photos/product/ga450-1.png"]');
  if (mLink[0]) {
    mLink[0].setStyle('float', 'right');
    mLink[0].setStyle('margin', '5px 0px 5px 10px');
    //mLink[0].setProperty('rel', 'lightbox');
    mLink[0].addEvent('click', function() {
        if (window.console) {
            console.log('klik');
        }
        Lightbox.open(['../../_userdata/_photos/product/ga450-1.png'], 1);
        return false;
    })
  }
 
  showMenu();
  makeAnchors();
  setHeight();
  setSideContentOpacity();

  if ($('hp500_hotspot_1')) {
    $('hp500_hotspot_1').addEvent('mouseenter', function() {
        $(this).setProperty('src', '/_images/hotspot_o.png');

		if (location.hostname == 'www.fast-fluid.de') {
        	$('hp500_hotspot_text').setHTML('<h4>Sparen Sie Zeit und Geld mit dem RNC (Rotationsd&#252;senverschluss)!</h4><div class="inner"><p>Die Dosierk&#246;pfe in den heutigen Simultandosieranlagen werden mit Problemen wie Verschmutzung und eingetrockneten Farben in der D&#252;se konfrontiert.</p><p>Beide Probleme k&#246;nnen zu Fehlt&#246;nungen und Kundenbeanstandungen f&#252;hren. Eine intensive und h&#228;ufige Reinigung kann diese Probleme zwar beheben, ist jedoch schwierig und zeitraubend f&#252;r den Bediener.</p><p>F&#252;r die HP500 haben wir darum ein einzigartiges System entwickelt: den <strong>Rotationsd&#252;senverschluss (RNC).</strong></p><p><strong>Bedienung:</strong> Unmittelbar nach der Dosierung werden alle D&#252;sen mit einer Metallplatte luftdicht verschlossen. Diese Platte wird anschlie&#223;end automatisch mit einer B&#252;rste und Reinigungsfl&#252;ssigkeit gereinigt. Die t&#228;gliche Reinigung der D&#252;sen entf&#228;llt damit. Die einzige Wartungst&#228;tigkeit des Bedieners ist das Nachf&#252;llen des B&#252;rstenbeh&#228;lters.</p><p><strong>Ergebnis:</strong> Es bleiben keine Reste zur&#252;ck, die in der D&#252;se eintrocknen und damit Farbverschmutzungen und Fehlt&#246;nungen verursachen k&#246;nnten.</p></div>');
	    } else {
			$('hp500_hotspot_text').setHTML('<h4>Save money and time with the RNC (Rotating Nozzle Closure)!</h4><div class="inner"><p>The nozzles / dispenseheads in current simultaneous dispenser generations suffer from issues such as contamination (intermixing of colorants) and drying of colorants in the nozzle.</p><p>Both issues can lead to off colours and customer reclamations. Only intensive and frequent cleaning can prevent these problems. Such cleaning is a difficult and time-consuming task for the operator.</p><p>For the HP500 we have developed a unique system: <strong>Rotary Nozzle Closure (RNC)</strong>.</p><p><strong>Operation:</strong> immediately after dispensing, all nozzles are closed airtight with a metal plate. This plate is then cleaned automatically with a brush and cleaning fluid. No need for daily cleaning of the nozzles. Refilling of brush container is the only maintenance the operator has to perform.</p><p><strong>Result:</strong> no residue left to dry at the nozzle and therefore no contamination of colorants and mistints.</p><p><strong>The operator can rely upon the technology. Clean head / Clean nozzles and no customer complaints.</strong></p></div>');
		}

        $('hp500_hotspot_text').setStyle('display', 'block');
    })
  }

  if ($('hp500_hotspot_2')) {
    $('hp500_hotspot_2').addEvent('mouseenter', function() {
        $(this).setProperty('src', '/_images/hotspot_o.png');

        if (location.hostname == 'www.fast-fluid.de') {
        	$('hp500_hotspot_text').setHTML('<h4>Farben in optimaler Kondition.</h4><div class="inner"><p>Die HP500 wurde f&#252;r die Handhabung von unterschiedlichsten Farben entwickelt. Weil jede Farbe ihre einzigartigen Eigenschaften besitzt, ist die HP mit zwei innovativen Systemen ausgestattet:</p><ol><li><strong>IPS:</strong> individually programmable stirring</li><li><strong>IPR:</strong> individually programmable recirculation</li></ol><p><strong>Welche Vorteile bietet das IPS?</strong><br />Die R&#252;hrfrequenz und -dauer wird f&#252;r <strong>jede Farbe individuell eingestellt</strong>. So wird eine Ablagerung im Beh&#228;lter vermieden. Falls erforderlich, kann das IPS die R&#252;hrfunktion einschr&#228;nken.</p><p><strong>Welche Vorteile bietet die IPR f&#252;r Sie?</strong><br />Vermeidung von Ablagerungen in den Schl&#228;uchen. Die HP500 kann mit einer R&#252;ckf&#252;hrung ausgestattet werden. Konfigurieren Sie die Anzahl der Leitungen, die r&#252;ckgef&#252;hrt werden m&#252;ssen und nehmen Sie individuelle Einstellungen vor.</p></div>');
	    } else {
			$('hp500_hotspot_text').setHTML('<h4>Colorants always in optimum condition with IPR and IPS</h4><div class="inner"><p>The HP500 has been developed to handle all types of colorants. Each colorant has unique properties and the HP is therefore equipped with two innovative systems:</p><ol><li><strong>IPS:</strong> Individually Programmable Stirring</li><li><strong>IPR:</strong> Individually Programmable Recirculation</li></ol><p><strong>What are the benefits of IPS?</strong><br />Set the stirring frequency and duration <u>individually for each colorant</u>. This prevents sedimentation in the canister. Where required by the colorant, IPS allows to limit stirring if required.</p><p><strong>What can IPR mean for you?</strong><br />Prevent sedimentation in the tubing. HP500 can be equipped with recirculation. <u>Configure</u> the number of lines that need recirculation and the settings <u>individually</u>.</p></div>');
		}
        
        $('hp500_hotspot_text').setStyle('display', 'block');
    })
  }

 if ($('hp500_hotspot_3')) {
    $('hp500_hotspot_3').addEvent('mouseenter', function() {
        $(this).setProperty('src', '/_images/hotspot_o.png');

        if (location.hostname == 'www.fast-fluid.de') {
        	$('hp500_hotspot_text').setHTML('<h4 style="margin-bottom: 25px;">Hochgeschwindigkeits-Simultandosierung (0,3- 0,5 L/min).</h4><div class="inner"><p style="margin-bottom: 25px;">Jede einzelne Kolbenpumpe kombiniert hohe Pr&#228;zision und Wiederholbarkeit mit einer hohen Dosiergeschwindigkeit.</p><p>Die HP500 kombiniert diese Kolbenpumpen mit Simultandosierung in 4 Kan&#228;len und ist damit eine Dosieranlage mit Spitzenleistung f&#252;r Ihren Markt.</p></div>');
	    } else {
			$('hp500_hotspot_text').setHTML('<h4 style="margin-bottom: 25px;">High speed simultaneous dispensing 0.3-0.5L/min.</h4><div class="inner"><p style="margin-bottom: 25px;">Each individual piston pump combines high accuracy and repeatability with high dispense speed.</p><p>The HP500 combines these piston pumps in 4 channels simultaneous dispensing, making it the top performance dispenser for your market.</p></div>');
		}
        
        $('hp500_hotspot_text').setStyle('display', 'block');
    })
  }

    

    if ($('hp500_hotspot_4')) {
    $('hp500_hotspot_4').addEvent('mouseenter', function() {
        $(this).setProperty('src', '/_images/hotspot_o.png');

        if (location.hostname == 'www.fast-fluid.de') {
        	$('hp500_hotspot_text').setHTML('<h4>Geringste Gesamtbetriebskosten</h4><div class="inner"><p><strong>Bew&#228;hrte Harbil-Kolbenpumpentechnologie:</strong></p><ul><li>Pumpenbeh&#228;ltermodul: Praktischste L&#246;sungen, die sich im Abt&#246;nmarkt als unschlagbar erwiesen haben.</li><li>Harbil-Kolbenpumpe: Die robusteste und zuverl&#228;ssigste Pumpe, die derzeit im Markt erh&#228;ltlich ist, und die sich f&#252;r alle Farben oder unter allen Bedingungen bew&#228;hrt hat.</li><li>Einfache Wartung:</li><li>Die Konstruktion der Dosieranlage wurde dank der modularen Pumpenbeh&#228;lter und einfachen Elektronik und Software optimiert. Leicht verst&#228;ndlich und leicht zu warten.</li><li>Modulare Bauweise: Komplette Module und/oder Einzelteile k&#246;nnen individuell ersetzt werden. Sie k&#246;nnen den Betrieb einfach fortsetzen, auch wenn ein Modul ausgewechselt werden muss.</li></ul></div>');
	    } else {
			$('hp500_hotspot_text').setHTML('<h4>Lowest Total Cost of Ownership</h4><div class="inner"><p><strong>Proven Harbil Piston Pump technology:</strong></p><ul><li>Pump-canister module : Best practice solutions which have been proved to be unbeatable in the field of tinting.</li><li>Harbil piston pump: The most robust and reliable pump in the market which has proven to work regardless which colorant or condition.</li><li>Serviceability. The dispenser architecture is optimized by using modular pump-canisters and simple electronics and software. Easy to understand and easy to maintain.</li><li>Modular construction: Complete modules or/and separate parts can be replaced individually. Continue working even when a module needs to be replaced.</li></ul></div>');
		}
        
        $('hp500_hotspot_text').setStyle('display', 'block');
    })
  }
  
  if ($('hp500_hotspot_5')) {
    $('hp500_hotspot_5').addEvent('mouseenter', function() {
        $(this).setProperty('src', '/_images/hotspot_o.png');

        if (location.hostname == 'www.fast-fluid.de') {
        	$('hp500_hotspot_text').setHTML('<h4>Optimale Ergonomie</h4><div class="inner"><p>Die HP500 wurde mit Schwerpunkt auf den Bediener entwickelt. Wir strebten dabei nach einem Design mit optimaler Ergonomie:</p><ul><li>Standfl&#228;che: kompakt und viereckig f&#252;r ein Mindestma&#223; an erforderlichen Quadratmetern.</li><li>Design: Bei 103 cm H&#246;he kann der Bediener einfach alle Beh&#228;lter erreichen.</li><li>Frontplatte: Einfach zu entfernen/anzubringen, um einen schnellen Zugriff zu erm&#246;glichen.</li><li>R&#228;der: Einfach zu bewegende Dosieranlagen, die die Arbeit des Bedieners erheblich erleichtern.</li></ul><p>Die HP500 bietet dem Bediener eine gute Nachf&#252;llh&#246;he und alle erforderlichen Peripherieger&#228;te in greifbarer N&#228;he (Tastatur, Bildschirm, Etikettendrucker).</p></div>');
	    } else {
			$('hp500_hotspot_text').setHTML('<h4>Optimum ergonomics</h4><div class="inner"><p>The HP500 is developed with a strong focus on the operator. We have endeavored to achieve a design that provides optimum ergonomics:</p><ul><li>Footprint : compact and square to limit m2.</li><li>Design : at 113 cm high the operator can easily reach all canisters</li><li>Paneling : easy click on / off panels to allow for quick access</li><li>Wheels: easily movable dispensers, which makes the operator\'s life a lot easier.</li></ul><p>The HP500 provides the operator with good refilling height and all requisites within reach (keyboard, screen, label printer).</p></div>');
		}
        
        $('hp500_hotspot_text').setStyle('display', 'block');
    })
  }

  if ($('hp500')) {
    $('hp500').getElements('h2').each(function(handler) {
        handler.addEvent('click', toggleContent);
    });
  }

  if ($('salesmanager')) {
    $('salesmanager').getElements('h2').each(function(handler) {
        handler.addEvent('click', toggleContent);
    });
  }

  if ($('newsname') && $('newsemail')) {

	  //alert('JA');
  
	  $('newsname').addEvent('focus', function() {
		if ($('newsname').value == 'Name') {
			$('newsname').value = '';
		}
	  });

	  $('newsname').addEvent('blur', function() {
		if ($('newsname').value == '') {
			$('newsname').value = 'Name';
		}
	  });

	  $('newsemail').addEvent('focus', function() {
		if ($('newsemail').value == 'E-mail') {
			$('newsemail').value = '';
		}
	  });

	  $('newsemail').addEvent('blur', function() {
		if ($('newsemail').value == '') {
			$('newsemail').value = 'E-mail';
		}
	  });
  }
  
  $('q').addEvent('focus', function() {
	if ($('q').value == 'Search') {
		$('q').value = '';
	}
  });

  $('q').addEvent('blur', function() {
	if ($('q').value == '') {
		$('q').value = 'Search';
	}
  });

});
/*----------------------------------------------------------------------------------------------------*/

function makeAnchors()
{
	var i = 1;
	if (location.href.contains('prismapro'))	{
		$$("h3").each(function(el) { el.id = "f" + i; i++ });
	}
}

/*----------------------------------------------------------------------------------------------------*/

function setHeight() {
  var contentHeight = $('main').getStyle('height').toInt();
  var minHeight = 200;
  if (contentHeight == minHeight){
	  $('main').setStyle('height', 'inherit');
  }
  if (contentHeight < minHeight) $('main').setStyle('height',minHeight+'px');
}

/*----------------------------------------------------------------------------------------------------*/
function showMenu() {
  myLocation = location.pathname;

  if (myLocation == '/software/login.asp') myLocation = '/software/';
  if (myLocation == '/options/login.asp') myLocation = '/options/';
  if (myLocation == '/options/index.asp') myLocation = '/options/';
  
  if (myLocation != '/' && myLocation != '/products/' && myLocation != '/ecs/' && myLocation != '/search/' && myLocation != '/downloads/' && myLocation != '/service/' && myLocation != '/chinese/') {
    var divId = myLocation.replace(/\//g,'');
    
    if (divId == 'news' || divId == 'careers' || divId == 'exhibitions' || divId == 'contact') divId = 'about'; 
	if (divId == 'options') divId = 'options';

    if ($$('#'+divId+' .submenu') != '') {
		$$('#'+divId+' .submenu').setProperty('id','active');

		// Create div-spacer, width the submenu's height
		var spacer = new Element('div');
		var subHeight = $('active').getStyle('height').toInt()+50;
		spacer.setStyle('height',subHeight+'px');
		var sidecontent = $$('#content .left')[0];
		if (sidecontent.getFirst()) spacer.injectBefore(sidecontent.getFirst());
    }
  }
  //getActiveMenu();
  $('menu').setStyle('opacity',1);
  menuInit = true;
}
/*----------------------------------------------------------------------------------------------------*/

function getActiveMenu() {
  var width = 0;
  var i, leftDist;
  $('active').getChildren().each(function(li) {
    i = li.getStyle('width').toInt()
    width = width + i;
  });
   
  $$('.submenu').each(function(hide) {
    if (hide.getProperty('id') != 'active') hide.setStyle('display','none');
  });
}
/*----------------------------------------------------------------------------------------------------*/

function setSideContentOpacity() {
  $$('.sidecontent').each(function(sideContent) {
    var height = sideContent.getChildren()[0].getStyle('height');
    var innerdiv = new Element('div',{
      'styles': {
        'height': height,
        'opacity': 0.7
      },
      'class': 'transbg'
    });
    sideContent.setStyle('height',height);
    innerdiv.injectInside(sideContent);
  });
}
/*----------------------------------------------------------------------------------------------------*/

function selectedLink(link) {
  $$('#productsubnav a').each(function(subLink) {
    subLink.removeClass('selected');
  });
  $(link).addClass('selected');
}

/*----------------------------------------------------------------------------------------------------*/

function toggleSub(aId) {
  var subHeight = 10;
  var sub = $(aId).getParent().getChildren()[1];
  if (sub.getStyle('display') == 'none') {
    sub.setStyle('display','block');
    subHeight = subHeight + sub.getStyle('height').toInt();
    $$('.sidecontent').getChildren()[0].each(function(div) {
      var divHeight = div.getStyle('height').toInt();
      div.setStyle('height',divHeight+subHeight+'px  ');
    });
    $$('.sidecontent')[0].setStyle('height',$$('.sidecontent')[0].getStyle('height').toInt()+subHeight+'px  ');
  } else {
    subHeight = subHeight + sub.getStyle('height').toInt();
    sub.setStyle('display','none');
    $$('.sidecontent').getChildren()[0].each(function(div) {
      var divHeight = div.getStyle('height').toInt();
      div.setStyle('height',divHeight-subHeight+'px  ');
    });
    $$('.sidecontent')[0].setStyle('height',$$('.sidecontent')[0].getStyle('height').toInt()-subHeight+'px  ');    
  }
}

/*----------------------------------------------------------------------------------------------------*/
function getProductData(prodId,dataDescr) {
  var myProduct = new Ajax('/_private/ajax.asp?rnd='+$random(10,999)+'&product='+prodId+'&'+dataDescr,{method:'get',update:$('main')});
  myProduct.request().chain(setHeight).chain(updateLinks);
}
/*----------------------------------------------------------------------------------------------------*/
function updateRegionInfo(regionId) {
  var region = new Ajax('/_private/ajax.asp?rnd='+$random(10,999)+'&region='+regionId,{method:'get',update:$('regioninfo')});
  if (regionId == "") {
	$("googlemap").setStyle("display", "block");
	$("regioninfo").setStyle("display", "none");
  } else {
	//$("googlemap").setStyle("display", "none");
	$("regioninfo").setStyle("display", "block");
  }
  region.request().chain(function() {
    var coords = $('coords').getText().split(';');

    map.setCenter(new google.maps.LatLng(coords[0].split(',')[0], coords[0].split(',')[1]), parseInt(coords[1]));

    setHeight();
  });
}

/*function updateRegionInfo(regionId)
{
	window.location = "?addresses=1&continent=" + regionId;
}*/

/*----------------------------------------------------------------------------------------------------*/
function getProdsByCat(catId) {
	
	$('downloadproduct').innerHTML = '';
	$('downloadtype').innerHTML = '';
	
	if (catId != '') {
		var prodcat = new Ajax('/_private/ajax.asp?rnd='+$random(10,999)+'&prodbycat='+catId,{method:'get',update:$('downloadproduct')});
		prodcat.request();
	}

	getDownloadItems()
}

/*----------------------------------------------------------------------------------------------------*/
function showDownloadTypes(prodId) {

	$('downloadtype').innerHTML = '';
	
	if (prodId != '') {
		var downcat = new Ajax('/_private/ajax.asp?rnd='+$random(10,999)+'&downloadtypes=1',{method:'get',update:$('downloadtype')});
		downcat.request();
	}

	getDownloadItems()
}

/*----------------------------------------------------------------------------------------------------*/
function getDownloadItems() {

	var dCat  = $('groupfilter')   ? $('groupfilter').options[$('groupfilter').selectedIndex].text : 'empty';
	var dProd = $('productfilter') ? $('productfilter').value : 'empty';
	var dType = $('typefilter')	   ? $('typefilter').value	  : 'empty';

    if (dCat == 'Choose a productgroup...' || 'Wählen Sie eine Produktgruppe...')	{
		dCat = 'empty';
	}

	var downloads = new Ajax('/_private/ajax.asp?rnd='+$random(10,999)+'&getdownloaditems=1&dcat=' + dCat + '&dprod=' + dProd + '&dtype=' + dType,{method:'get',update:$('downloaditems')});
	downloads.request();
}


/*----------------------------------------------------------------------------------------------------*/
function showDownTypes(catId) {
  var downType = new Ajax('/_private/ajax.asp?rnd='+$random(10,999)+'&downtypes='+catId,{method:'get',update:$('downtype')});
  downType.request();
}

/*----------------------------------------------------------------------------------------------------*/
function showDownloads(downType,prodId) {
  var downloads = new Ajax('/_private/ajax.asp?rnd='+$random(10,999)+'&getdownloads='+prodId+'&type='+downType,{method:'get',update:$('downloadresult')});
  downloads.request();
}

/*----------------------------------------------------------------------------------------------------*/
function updateDownCount(downType,userId,softwareId) {
  var count = new Ajax('/_private/ajax.asp?rnd='+$random(10,999)+'&updatedownload='+softwareId+'&user='+userId+'&type='+downType,{method:'get'});
  count.request();
}

function updateLinks()
{
	$$('a[rel=external]').each(function(extLink) {
		extLink.setProperty('target', '_blank');
	});
}


window.addEvent('domready',function() {
  // External links open in new window
  $$('a[rel=external]').each(function(extLink) {
    extLink.setProperty('target','_blank');
  });
  
  if($$('form')[0]) {
    var myForm = new Form($$('form')[0]);
  }

  if ($('newsform')) {
	var myNewsForm = new Form($('newsform'));
  }

});

var Form = new Class({
  initialize: function(frm) {
    this.form = frm;
    this.form.addEvent('submit',this.frmCheck);
  },
   
  frmCheck: function(ev) {

    var misFld = false;
    var e = new Event(ev);
    e.stop();

	if (this.newsname) {
		if (this.newsname.value == 'Name') {
			this.newsname.value = '';
		}
	}

	if (this.newsemail) {
		if (this.newsemail.value == 'E-mail') {
			this.newsemail.value = '';
		}
	}
    
    $$('.reqFld').each(function(fld) {
      fld.removeClass('missingField');
      if(fld.getValue() == '') {
        fld.addClass('missingField');
        misFld = true;
      }
    });
    if(misFld == true) {
      alert('Missing required fields.');
    } else {
	  this.submit();
    }
  }
});
