function switchImage(imgName, imgSrc, id) 
{
	if (document.images)
	{
		if (imgSrc != "none") document.images[imgName].src = imgSrc;
	}
}

/* Show and Hide Layer */
	function changeLayer(LayerName) {
		if (document.getElementById(LayerName).style.display == "block") {
			document.getElementById(LayerName).style.display = "none";
		} else {
			document.getElementById(LayerName).style.display = "block";
		}
	}
	
function openSF(){
	window.open('/en/solution_finder/index.php', 'finder', 'width=760px, height=550px, scrollbars=no, resizable=no status=yes');
}

function openDirections(){
	window.open('/includes/popup_directions.php', '', 'width=760px, height=451px, scrollbars=no, resizable=no');
}

function openRoutePlanner(){
	window.open('/en/contact_us/route_planner.php', '', 'width=600px, height=565px, scrollbars=no, resizable=no');
}

function openMovie(version){
	if(version == 1){
		// groß
		width	= 600;
		height	= 530;
	} else {
		// klein
		width	= 400;
		height	= 400;
	}
	window.open('/includes/popup_movie.php?v=' + version, '', 'width='+width+', height='+height+', scrollbars=no, resizable=no');
}

function openCertificate_name(certificateName){
	window.open('/includes/popup_certificate_name.php?certificateName='+certificateName, '', 'width=500px, height=700px, scrollbars=yes, resizable=no');
}

/*
 * Skript zum automatischen Ausblenden
 * des Movieselectors auf der Homepage
 */
	function displayLink(link) {
		document.getElementById("link"+link).style.visibility = "visible";
	}
	function hideLink(link) {
		document.getElementById("link"+link).style.visibility = "hidden";
	}
		
	function displayMovie() {
		document.getElementById("movieselector").style.visibility = "visible";
	}
	function hideMovie() {
		document.getElementById("movieselector").style.visibility = "hidden";
	}
	
	var hideTimerMovie	= 0;
	var hideTimeMovie	= 600;
	var myCounterMovie;
	
	function initHideMovie(){
		hideTimerMovie = 0;
		if(hideTimerMovie >= 0)autoHideMovie();
	}
	
	function stopAutoHideMovie(){
		hideTimerMovie = 0;
		clearTimeout(myCounterMovie);
	}
	
	function autoHideMovie(){
	
		if(hideTimerMovie > hideTimeMovie){
			hideMovie();
			hideLink(1);
			hideLink(2);
			clearTimeout(myCounterMovie);
		} else {
			if(hideTimerMovie >= 0){
				hideTimerMovie += 50;
				myCounterMovie = setTimeout('autoHideMovie()',50);
			}
		}
	}

/*
 * Skript zum automatischen Ausblenden
 * des FruitIndex
 */

 	function displayFruitDetail(){
		document.getElementById("fruitdetail").style.visibility = "visible";
	}
	
	function closeFruitDetail(){
		document.getElementById("fruitdetail").style.visibility = "hidden";
	}
 
	function displayFruitIndex(left, top){
		/* 
		document.getElementById("fruitindex").style.left = left+"px";
		document.getElementById("fruitindex").style.top = top+"px";
		*/
		document.getElementById("fruitindex").style.visibility = "visible";
	}
	
	function hideFruitIndex(){
		/* 
		document.getElementById("fruitindex").style.left = 0+"px";
		document.getElementById("fruitindex").style.top = 0+"px";
		*/
		document.getElementById("fruitindex").style.visibility = "hidden";
	}
	
	var hideTimer	= 0;
	var hideTime	= 600;
	var myCounter;
	
	function initHide(){
		hideTimer = 0;
		if(hideTimer >= 0)autoHide();
	}
	
	function stopAutoHide(){
		hideTimer = 0;
		clearTimeout(myCounter);
	}
	
	function autoHide(){
		
		if(hideTimer > hideTime){
			hideFruitIndex();
			clearTimeout(myCounter);
		} else {
			if(hideTimer >= 0){
				hideTimer += 50;
				myCounter = setTimeout('autoHide()',50);
			}
		}
	}
	

    var http_request = false;

    function makeRequest() {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        } else {
			return http_request;
		}
    }
	
	var http = makeRequest();
	var fieldList = new Array(
					'fi_headline', 
					'fi_latin', 
					'fi_image', 
					'fi_name', 
					'fi_origin', 
					'fi_countries', 
					'fi_description', 
					'fi_facts', 
					'fi_nutrition', 
					'fi_options');
	
	function sendReq(fruit) {
		if(fruit != ''){
			http.open('get', '/includes/getFruitInfo.php?name='+fruit);
		    http.onreadystatechange = handleResponse;
		    http.send(null);
		}
	}
	
	function handleResponse() {
	    if(http.readyState == 4){
			 if (http_request.status == 200) {
				var response = http.responseText;
				if(response != 'Fruit not found'){
					var update = new Array();
					update = response.split('|||');
					counter = 0;
					for(i in fieldList){
						
						if(fieldList[i] == 'fi_image'){
							path = '/images/fruitindex/'+update[counter]+'.jpg';
							document.getElementById(fieldList[i]).src = path;
						} else {
							document.getElementById(fieldList[i]).innerHTML = update[counter];
						}
						counter++;
					}
					displayFruitDetail();
				} else {
					alert(response);
				}				
			} else {
				// alert('Übertragungsfehler');
			}
	    }
	}

	/*
	 * Kontaktkarte
	 *
	 */
	
	mapContacts = Array(
		
		Array(	
		'Ecuador', 'Tropifrutas S.A.', 'Maria Pia Fondevilla', 'KM 12&frac12; Via a Daule<br>PO Box 09-01-3957', 'Guayaquil', 'Equador', '', '+593-4 211-5044', '+593-4 211-5057', 'info@tropifrutas.com', 'mariapia.jpg', 284, 294, 1),
		Array(
		'Netherlands', 'Passina Products BV.', 'Ammerens Houweling<br>James Donaldson<br>Tatiana Novikova', 'Veilingkade 4<br>4815 HA Breda<br>P.O. Box 3548', '4800 DM Breda', 'The Netherlands', '', '+31 (0)76 572 28 80', '+31 (0)76 572 28 88', 'info@passina.nl', 'team_netherlands_2.jpg',394, 220, 2),
		Array(
		'USA', 'Passina Products USA Inc.', 'Milan Houweling', '2111 W. Swann Ave.<br>Suite 203<br>FL 33606 Tampa<br>PO Box 20306', 'FL 33622-0306 Tampa', 'USA', '', '+1 813 250 0560', '+1 813 250 0760', '<a href="mailto:mhouweling@passina.net" target="_blank">mhouweling@passina.net</a><br><a href="mailto:mikki@passina.net" target="_blank">mikki@passina.net</a>', 'team_usa.jpg', 260, 229, 2, false), 
		Array(
		//'India, Middle- and Far East', 'Passina Products Middle East', 'K.K. Girish', 'PO Box 20338', 'Dubai', 'United Arab Emirates', '', '+971 50 559 3748', '+971 4 297 5222', 'kkgirish@passiname.com', 'girish.jpg', 428, 259, 3), 
		'India, Middle- and Far East', 'Passina Products Middle East', 'James Donaldson', 'Veilingkade 4<br>4815 HA Breda<br>P.O. Box 3548', '4800 DM Breda', 'The Netherlands', '', '+31 (0)76 572 28 80', '+31 (0)76 572 28 88', 'jdonaldson@passina.nl', 'jamie_donaldson.jpg', 394, 220, 1), 
		Array(
		'Germany', 'Leo Niehoff GmbH', 'Uli, Jochem und Leo Niehoff', 'Reinhard-Freericks-Strasse 2', '45721 Haltern am See', '', 'www.leo-niehoff.de', '+49 (0) 2364 926 90', '+49 (0) 2364 160 03', 'info@leo-niehoff.de', 'niehoffs_2.jpg', 420, 220, 2), 
		Array(
		'Switzerland', 'Allfood AG', 'Sandro Molteni', 'Bahnhofstrasse 57 ', '3401 Burgdorf', 'Switzerland', 'www.allfood.ch', '+41 34 420 34 34', '+41 34 420 34 35', 'info@allfood.ch', 'molteni.jpg', 420, 270, 1), 
		Array(
		'Spain', 'Plantation Foods .Representaciones SL', 'Javier Hernandez', 'P.O. Box 64', '45003 Toledo', 'Spain', 'www.plantationfoods.com', '+34 925 25 23 12', '+34 925 25 24 40', 'toledo@plantationfoods.com', 'javier_hernandez.jpg', 333, 323, 1),
		Array(
		'United Kingdom', 'E.E. & Brian Smith Ltd.', 'Julian DeCruz', 'Brookfarm<br>Dorton', 'HP18 9NQ Aylesbury Bucks', 'England', 'www.eebriansmith.com', '+44 1844 239 500', '+44 1844 239 501', 'enquiries@eebriansmith.com', 'julian_decruz.jpg', 348, 220, 1),
		Array(
		'Australia & New Zealand', 'Juremont (Pty) Ltd.', 'Rob Richards, Andrew and Stuart Rolle', '205, Canterbury Road', 'Canterbury VIC 3126', 'Australia', '', '+61 3 9830 2870', '+61 3 9830 2790', 'andrewrolle@jure.com.au', 'a_rolle.jpg', 450, 200, 1),
		Array(
		'Turkey', 'HD ULUSLARARASI Tic. ve AMBALAJ SAN. LTD. STI..', 'Elif Ozhuy', 'Alemdag Cad. No: 33/12-13', '64764 Ümraniye - Istanbul', 'Turkey', 'www.hd.biz.tr', '+90 216 523 60 27', '+90 216 521 66 38', 'eozhuy@hd.biz.tr', 'mah.jpg', 450, 200, 1),
		Array(
		'Russia and Eastern Europa', 'Passina Products BV.', 'Tatiana Novikova', 'Veilingkade 4<br>4815 HA Breda<br>P.O. Box 3548', '4800 DM Breda', 'The Netherlands', '', '+31 (0)76 572 28 80', '+31 (0)76 572 28 88', 'tnovikova@passina.nl', 'tatiana.jpg',394, 220, 1)
	);
	
	function setAdress(n){
		
		if (mapContacts[n][13] == 1) {
			var bgImage = "bg_adress.gif";
			var heightLayer = "190px";
		}
		if (mapContacts[n][13] == 2) {
			var bgImage = "bg_adress_2.gif";
			var heightLayer = "210px";
		}
		if (mapContacts[n][13] == 3) {
			var bgImage = "bg_adress_3.gif";
			var heightLayer = "320px";
		}
	
		var adresse = "";
		
		adresse = adresse + '<strong>' + mapContacts[n][2] + '</strong><br>'; 	// Name
		adresse = adresse + mapContacts[n][3] + '<br>';							// Adresse
		adresse = adresse + mapContacts[n][4] + '<br>';							// Ort
		adresse = adresse + mapContacts[n][5] + '<br>';							// Land
		if(mapContacts[n][6] != ''){
		adresse = adresse + '<a href="http://' + mapContacts[n][6] + '" target="_blank">' + mapContacts[n][6] + '</a><br>';	// Web
		}
		adresse = adresse + 'Phone: ' + mapContacts[n][7] + '<br>';							// Telefon
		adresse = adresse + 'Fax: ' + mapContacts[n][8] + '<br>';							// Fax
		if(mapContacts[n][9] != '' && mapContacts[n][14] != "0"){
		adresse = adresse + '<a href="mailto:' + mapContacts[n][9] + '" target="_blank">' + mapContacts[n][9] + '</a><br>';	// Mail
		} else {
			adresse = adresse + mapContacts[n][9] + '<br>';	// Mail
		}
		document.getElementById("vcard").innerHTML = adresse;
		
		document.getElementById('idcard').style.backgroundImage = 'url(/images/'+bgImage+')';
		document.getElementById('idcard').style.height = heightLayer;
		bild = '<img src="/images/team/' + mapContacts[n][10] + '" alt="">';
		document.getElementById("vcpic").innerHTML = bild;
		document.getElementById('idcard').style.left = mapContacts[n][11] +"px";
		document.getElementById('idcard').style.top = mapContacts[n][12] +"px";
		document.getElementById('idcard').style.visibility = "visible";
	}
	
	function closeCard(){
		document.getElementById("vcard").innerHTML = '';
		document.getElementById('idcard').style.visibility = "hidden";
	}
	
	function switchCard(card){
		card1 = '<img src="/images/map_world_neu_3.gif" width="456" height="253" alt="" usemap="#world" border="0">';
		card2 = '<img src="/images/map_europe_3.gif" width="455" height="253" border="0" usemap="#europe">';
		
		karte = 'card' + card;
		document.getElementById('content_wide').innerHTML = eval(karte);
	}
	
	function buildAdresses(){
		var tableContent = '';
		
		for(i in mapContacts){
		
			tableContent = tableContent + '<tr>';
			
			tableContent = tableContent + '<td width="91" valign="top">';
			tableContent = tableContent + '<img src="/images/team/' + mapContacts[i][10] + '" width="60" height="60" alt="">';
			tableContent = tableContent + '</td>';
			tableContent = tableContent + '<td valign="top">';
			
			tableContent = tableContent + '<strong>' + mapContacts[i][0] + '</strong><br>'; 	// Country
			tableContent = tableContent + '<strong>' + mapContacts[i][1] + '</strong><br>'; 	// Company
			tableContent = tableContent + '<strong>' + mapContacts[i][2] + '</strong><br>'; 	// Name
			tableContent = tableContent + mapContacts[i][3] + '<br>';							// Adresse
			tableContent = tableContent + mapContacts[i][4] + '<br>';							// Ort
			tableContent = tableContent + mapContacts[i][5] + '<br>';							// Land
			if(mapContacts[i][6] != ''){
			tableContent = tableContent + '<a href="http://' + mapContacts[i][6] + '" target="_blank">' + mapContacts[i][6] + '</a><br>';	// Web
			}
			tableContent = tableContent + 'Phone: ' + mapContacts[i][7] + '<br>';							// Telefon
			tableContent = tableContent + 'Fax: ' + mapContacts[i][8] + '<br>';							// Fax
			if(mapContacts[i][9] != ''){
			tableContent = tableContent + '<a href="mailto:' + mapContacts[i][9] + '" target="_blank">' + mapContacts[i][9] + '</a><br>';	// Mail
			}
			tableContent = tableContent + '<br>';
			tableContent = tableContent + '</td>';
			
			tableContent = tableContent + '</tr>';
		}
		document.getElementById('adrtab').innerHTML = tableContent;
		
		
	}
	
	
	
	
/* Tooltipp */

var tipwidth			= '150px';
var tipbgcolor			= '#fff';
var disappeardelay		= 100;
var vertical_offset		= "100px";
var horizontal_offset	= "120px";

/////No further editting needed
var ie4 = document.all
var ns6 = document.getElementById&&!document.all

function generateTooltipp(){
	var ie4 = document.all
	var ns6 = document.getElementById&&!document.all
	if (ie4||ns6){
		document.write('<div id="tooltipp" style="visibility:hidden; width:'+tipwidth+'; background-color:'+tipbgcolor+'" ></div>');
	}
}

function getposOffset(what, offsettype){
	// alert('getposOffset');
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset = (offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl = parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, tipwidth){
	// alert('showhide '+obj+' '+tipwidth);
	if (ie4||ns6){
		dropmenuobj.style.left = dropmenuobj.style.top=-500;
	}
	if (tipwidth != ""){
		dropmenuobj.widthobj = dropmenuobj.style;
		dropmenuobj.widthobj.width = tipwidth;
	}
	if (e.type == "click" && obj.visibility == hidden || e.type=="mouseover"){
		obj.visibility = visible;
	} else if (e.type == "click"){
		obj.visibility = hidden
	}
}

function iecompattest(){
	// alert('iecompattest');
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function clearbrowseredge(obj, whichedge){
	// alert('clearbrowseredge');
	var edgeoffset = (whichedge=="rightedge") ? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1;
	if (whichedge=="rightedge"){
		var windowedge = ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure = dropmenuobj.offsetWidth;
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure){
			edgeoffset = dropmenuobj.contentmeasure-obj.offsetWidth;
		}
	} else{
	var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
	dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){
			edgeoffset = dropmenuobj.contentmeasure+obj.offsetHeight;
		}
	}
	return edgeoffset
}


function showTooltip(menucontents, obj, e, tipwidth, offx, offy){	
	
	//alert('showTooltip');
	if(document.all){
		horizontal_offset = (offx * 0.01) + 150;
		vertical_offset = (offy * 0.01) + 200;
	} else {
		horizontal_offset = offx;
		vertical_offset = offy;
	}
	
	
	if (window.event){
		event.cancelBubble = true;
	} else if (e.stopPropagation){
		e.stopPropagation();
	}
	
	clearhidetip();
	dropmenuobj = document.getElementById ? document.getElementById("tooltipp") : tooltipp;
	dropmenuobj.innerHTML = menucontents;
	
	if (ie4 || ns6){
		//alert('inside');
		showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth);
		dropmenuobj.x = getposOffset(obj, "left");
		dropmenuobj.y = getposOffset(obj, "top");
		dropmenuobj.style.left = dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px";
		dropmenuobj.style.top = dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px";
	}
	//document.getElementById('maincontent').style.height = "800px";
}

function hidetip(e){
	// alert('hidetip');
	if (typeof dropmenuobj!="undefined"){
		if (ie4 || ns6){
			dropmenuobj.style.visibility="hidden";
		}
	}
}

function hidingDelay(){
	// alert('hidingDelay');
	if (ie4||ns6){
		delayhide = setTimeout("hidetip()",disappeardelay);
	}
}

function clearhidetip(){
	// alert('clearhidetip');
	if (typeof delayhide != "undefined"){
		clearTimeout(delayhide);
	}
}

/* END Tooltipp */