/*
===============================================
Definition Block 
===============================================
*/

var URLpath="http://www.outlet-agent.de/";

var iditem = new Array;
var brand = new Array;
var brandi = new Array;
var tit = new Array;
var category = new Array;
var latitude = new Array;
var longitude = new Array;
var street = new Array;
var postal = new Array;
var city = new Array;
/* set marker properties for maps */

var tinyIcon = new GIcon();
tinyIcon.image = "http://www.outlet-agent.de/imgz/iconz/smallStar.png";
tinyIcon.shadow = "http://www.outlet-agent.de/imgz/iconz/shadow-smallStar.png";
tinyIcon.iconSize = new GSize(18, 17);
tinyIcon.shadowSize = new GSize(27, 17);
tinyIcon.iconAnchor = new GPoint(9, 17);
tinyIcon.infoWindowAnchor = new GPoint(5, 1);

var clusterIcon = new GIcon();
clusterIcon.image = "http://www.outlet-agent.de/imgz/iconz/bigStar.png";
clusterIcon.shadow = "http://www.outlet-agent.de/imgz/iconz/shadow-bigStar.png";
clusterIcon.iconSize = new GSize(29, 30);
clusterIcon.shadowSize = new GSize(45, 29);
clusterIcon.iconAnchor = new GPoint(14, 30);
clusterIcon.infoWindowAnchor = new GPoint(9, 2);


/*
===============================================
Set Up Map and trigger XML-call
===============================================
*/
	 

function setupfrontMap()
	{
	if (GBrowserIsCompatible())
		{
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.enableScrollWheelZoom();
		map.enableDoubleClickZoom();
		map.setMapType(G_HYBRID_MAP); 
		map.setCenter(new GLatLng(51.00, 10.00), 5);
			mgr = new MarkerManager(map);

		

		
		processCats();

		}
	}

/*
===============================================
Get Starting Adress and calculate Driving Directions
===============================================
*/


function startAddress()
	{
		
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
			{
				query=document.getElementById('ad_in').value;
				query = implodeAd(query);
				xmlHttp.open("GET", URLpath+"func/getGeo.php?q=" + query, true);
				xmlHttp.onreadystatechange = handleServerResponse;
				xmlHttp.send(null);
				
			}
		else
			{
			setTimeout('startAddress()',100);
			}
		
	}
	
	
	
function handleServerResponse()	{
			
	if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status == 200)
				{
				xmlResponse = xmlHttp.responseXML;
				xmlLng=xmlResponse.getElementsByTagName("longitude");
				xmlLat=xmlResponse.getElementsByTagName("latitude");
				
				
					for (var loop = 0; loop < xmlLng.length; loop++) 
						{
						xmlFirst=xmlLng[loop];
						longi=xmlFirst.firstChild.nodeValue;
						} 
				
					for (var loop = 0; loop < xmlLat.length; loop++) 
						{
						xmlFirst=xmlLat[loop];
						lati=xmlFirst.firstChild.nodeValue;
						} 	
				
				setDirections(lati+","+longi,destination,locale);
											
				}
			else
				{
				alert("Problem accessing Server: " + xmlHttp.statusText);
				}
		}
	}
	
	
var map;
var gdir;
var geocoder = null;
var addressMarker;
locale="de";

 function setDirections(fromAddress, toAddress, locale) 
 	{
 	GEvent.addListener(gdir, "error", handleErrors);
 	gdir.load("from: " + fromAddress + " to: " + toAddress,
        { "locale": locale });
   	 }




function setupMap()
	{
	if (GBrowserIsCompatible())
		{
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.enableScrollWheelZoom();
		map.setMapType(G_HYBRID_MAP); 
		map.setCenter(new GLatLng(51.00, 10.00), 5);
		gdir = new GDirections(map, document.getElementById("directions"));

		setOrigMarker();
		
		}
	}
	
function setOrigMarker()
	{
			var htmlCode=createInfoWindowHtmlCode();
			var point = new GLatLng(lat,lng);
			mark=createMark(point,htmlCode);
			map.addOverlay(mark);
	}
	
	

	
function createInfoWindowHtmlCode()
	{
	htmlCode='<h1>' +ampCh(name)+ '</h1>' + html_entity_decode(street.replace(/&#38;/g,"&")) + '<br>' + postal +' '+html_entity_decode(city.replace(/&#38;/g,"&"))+ '<br><a href="'+link+'">Weitere Infos</a>';
	return htmlCode;
	}	
	

   function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	    
	   else alert("An unknown error occurred.");
	   
	}	
	

/*
===============================================
Cat-and-Brand-Map-Division
===============================================
*/
	
	
function processCats()
	{
		
	//Object  not running?	
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
			{		
				xmlHttp.open("GET", URLpath+"func/getCats.php", true);
				xmlHttp.onreadystatechange = handleCats;
				xmlHttp.send(null);
				
				
			}
		else
			{
			setTimeout('processCats()',100);
			}
		
	}	
	
function handleCats()	
	{
	
	
	if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status == 200)
				{
				xmlResponse = xmlHttp.responseXML;
												
				xmlID=xmlResponse.getElementsByTagName("IDitem");
				xmlTit=xmlResponse.getElementsByTagName("title");
				xmlCat=xmlResponse.getElementsByTagName("category");
				xmlBrand=xmlResponse.getElementsByTagName("brand");
				xmlLat=xmlResponse.getElementsByTagName("latitude");
				xmlLng=xmlResponse.getElementsByTagName("longitude");
				xmlStreet=xmlResponse.getElementsByTagName("street");
				xmlPostal=xmlResponse.getElementsByTagName("postal");
				xmlCity=xmlResponse.getElementsByTagName("city");

								
				for (var loop = 0; loop < xmlID.length; loop++) 
						{
						xmlFirst=xmlID[loop];
						iditem[loop]=xmlFirst.firstChild.nodeValue;
						} 
		
				for (var loop = 0; loop < xmlTit.length; loop++) 
						{
						xmlFirst=xmlTit[loop];
						tit[loop]=xmlFirst.firstChild.nodeValue;
						} 	

				for (var loop = 0; loop < xmlCat.length; loop++) 
						{
						xmlFirst=xmlCat[loop];
						category[loop]=xmlFirst.firstChild.nodeValue;
						} 
				
				for (var loop = 0; loop < xmlBrand.length; loop++) 
						{
						xmlFirst=xmlBrand[loop];
						brand[loop]=xmlFirst.firstChild.nodeValue;
						} 
						
				
				for (var loop = 0; loop < xmlStreet.length; loop++) 
						{
						xmlFirst=xmlStreet[loop];
						street[loop]=xmlFirst.firstChild.nodeValue;
						} 
						
				for (var loop = 0; loop < xmlPostal.length; loop++) 
						{
						xmlFirst=xmlPostal[loop];
						postal[loop]=xmlFirst.firstChild.nodeValue;
						} 
						
				for (var loop = 0; loop < xmlCity.length; loop++) 
						{
						xmlFirst=xmlCity[loop];
						city[loop]=xmlFirst.firstChild.nodeValue;
						} 		
						
				for (var loop = 0; loop < xmlLat.length; loop++) 
						{
						xmlFirst=xmlLat[loop];
						latitude[loop]=xmlFirst.firstChild.nodeValue;
						} 

				for (var loop = 0; loop < xmlLng.length; loop++) 
						{
						xmlFirst=xmlLng[loop];
						longitude[loop]=xmlFirst.firstChild.nodeValue;
						} 
						
					mgr.clearMarkers();
					callMarkermanager();
					
										
				}
			else
				{
				alert("Problem accessing Server: " + xmlHttp.statusText);
				}
		}
	}


/*
===============================================
Clustering and defining markers
===============================================
*/

//markermanager functions	
function callMarkermanager() 
	{
	//alert('call');

	var gmarkers0=new Array;
	gmarkers0=mergeMarks(latitude,longitude,500);
	
	var gmarkers3=new Array;
	gmarkers3=mergeMarks(latitude,longitude,40);
	
	var gmarkers6=new Array;
	gmarkers6=mergeMarks(latitude,longitude,10);
	
	//var gmarkers8=new Array;
	//gmarkers8=mergeMarks(latitude,longitude,10);
	
	var gmarkers10=new Array;
	gmarkers10=mergeMarks(latitude,longitude,1);
	
	var gmarkers19=new Array;
	gmarkers19=mergeMarks(latitude,longitude,0);
	
	mgr.addMarkers(gmarkers0,0,2);
	mgr.addMarkers(gmarkers3,3,5);
	mgr.addMarkers(gmarkers6,6,9);
 	//mgr.addMarkers(gmarkers8,8,9);
 	mgr.addMarkers(gmarkers10,10,15);
 	mgr.addMarkers(gmarkers19,16);
	mgr.refresh();
	$('loader').hide();

	}	



function setM(avlat,avlng,clusterCodes,countItems)
	{	
	var batch = new Array;
  	for (var i = 0; i < avlat.length; i++) 
		{
			
		var lat=avlat[i];
		var lng=avlng[i];
		var point = new GLatLng(lat,lng);
		batch[i]=createM(point,clusterCodes[i],countItems[i]);
		}
  	return batch;
	}	
	
function createM(point,clusterCodes,countItems) 
	{

	if(countItems<2)
		{
        	markerOptions = { icon:tinyIcon };
        	}
        else
        	{
        	markerOptions = { icon:clusterIcon };
        	}
        
        var mark = new GMarker(point, markerOptions);
	
        GEvent.addListener(mark, "click", function() { mark.openInfoWindowHtml('<div class="infoWindow"'+clusterCodes+'<div>'); });
        return mark;
      	}	
      	
function createClustercodes(i)
	{
	htmlCode='<h1>' +ampCh(tit[i])+ '</h1><span style="color: #c4d739; font-weight: bold; ">'+ampCh(brand[i])+'</span><br>'+ html_entity_decode(street[i].replace(/&#38;/g,"&")) + '<br>' + postal[i] +' '+html_entity_decode(city[i].replace(/&#38;/g,"&"))+ '<br><a href="'+URLpath + category[i].replace(/ /g,"+") + '/' + brand[i].replace(/ /g,"+") + '/' +tit[i].replace(/ /g,"+") + '/' + iditem[i] + '" title="Details zu '+ampCh(tit[i])+'">Weitere Infos</a><br>___________________________';
	return htmlCode;
	}       	

//not using markermanager	
function setMarkers()
	{

		for (var i = 0; i < latitude.length; i++) 
			{
			var lat=latitude[i];
			var lng=longitude[i];
			var htmlCode=createIWHC(i);
			var point = new GLatLng(lat,lng);
			var mark = new Array;
			mark[i]=createMark(point,htmlCode);
			map.addOverlay(mark[i]);
			}
	}
	
	
function createMark(point,htmlCode) 
	{
        var mark = new GMarker(point);
        GEvent.addListener(mark, "click", function() { mark.openInfoWindowHtml(htmlCode, {maxWidth:10})});
        return mark;
      	}
      	
      	
	
function createIWHC(i)
	{
	htmlCode='<h1>' +tit[i]+ '</h1>'+ street[i] + '<br>' + postal[i] +' '+city[i]+ '<br><a href="'+URLpath + category[i].replace(/ /g,"+") + '/' + brand[i].replace(/ /g,"+") + '/' +tit[i].replace(/ /g,"+") + '/' + iditem[i] + '">Weitere Infos</a>';
	return htmlCode;
	} 
		

/*
===============================================
Check & Uncheck
===============================================
*/

function checkAll(nCats)
	{
	for (var cnt = 0; cnt < nCats; cnt++) 
		{

		if(document.getElementById('cat'+cnt))
			{
			if(document.getElementById('cat'+cnt).checked==false)
				{
				document.getElementById('cat'+cnt).checked=true;
				}
			}
		
		else
			{
			break;
			}
	
		
		
		}
	renewMarks(cnt);
	}
	
function checkAllBrands(nCats)
	{
	for (var cnt = 0; cnt < nCats; cnt++) 
		{

		if(document.getElementById('cat'+cnt))
			{
			if(document.getElementById('cat'+cnt).checked==false)
				{
				document.getElementById('cat'+cnt).checked=true;
				}
			}
		
		else
			{

			break;
			}
	
		
		
		}
	renewBMarks(cnt);
	}	
	

function uncheckAll(nCats)
	{
	for (var cnt = 0; cnt < nCats; cnt++) 
		{

		if(document.getElementById('cat'+cnt))
			{
			if(document.getElementById('cat'+cnt).checked==true)
				{
				document.getElementById('cat'+cnt).checked=false;
				}
			}	

		else		
			{
			break;
			}
		}
	map.clearOverlays();	
	}	


/*
===============================================
Updating
===============================================
*/

	
function renewMarks(cntCat)
	{
	catArray= new Array();
	
	for (var cnt = 0; cnt < cntCat; cnt++) 
		{
	
		if (document.getElementById('cat'+cnt).checked == true) 
			{
			catArray.push(document.getElementById('cat'+cnt).value);
			}
		}
		
	map.clearOverlays();
	
	iditem.length = 0;
	tit.length = 0;
	category.length = 0;
	latitude.length = 0;
	longitude.length = 0;
	brand.length = 0;
	street.length = 0;
	postal.length = 0;
	city.length = 0;
	
	if (catArray.length >0) 
		{
		processMarks(catArray);
		}
	}   
	
	
function processMarks(catArray)
	{

	var phpPar='';
	for (var cnt = 0; cnt < catArray.length; cnt++)
		{
		phpPar=phpPar + '_' + encodeUTF8(catArray[cnt]);
		}
		
	if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
			{	
				xmlHttp.open("GET", URLpath+"func/getCats.php?cats=" + phpPar, true);
				xmlHttp.onreadystatechange = handleCats;
				xmlHttp.send(null);
			}
		else
			{
			setTimeout('processMarks(catArray)',100);
			}	
	
	}
	
function renewBMarks(cntCat)
	{
	catArray= new Array();
	
	for (var cnt = 0; cnt < cntCat; cnt++) 
		{
	
		if (document.getElementById('cat'+cnt).checked == true) 
			{
			catArray.push(document.getElementById('cat'+cnt).value);
			}
		}
		
	mgr.clearMarkers();

	iditem.length = 0;
	tit.length = 0;
	category.length = 0;
	latitude.length = 0;
	longitude.length = 0;
	brand.length = 0;
	street.length = 0;
	postal.length = 0;
	city.length = 0;

	if (catArray.length >0) 
		{
		processBMarks(catArray);
		}
	}   
	
	
function processBMarks(catArray)
	{

	var phpPar='';
	for (var cnt = 0; cnt < catArray.length; cnt++)
		{
		phpPar=phpPar + '_' + encodeUTF8(catArray[cnt]);
		}
		
	if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
		{
	
		
		//var URLcomp = URLpath+'func/getBrands.php';
		//var drequest= new Ajax.Request(URLcomp, {method: 'get', parameters: 'cats='+phpPar, onComplete: handleCats() } );
		xmlHttp.open("GET", URLpath+'func/getBrands.php?cats=' + phpPar, true);
		xmlHttp.onreadystatechange = handleCats;
		xmlHttp.send(null);
		}
	else
		{
		setTimeout('processBMarks(catArray)',100);
		}	
	
	}	
	

function handleBrands()	
	{
	
	
	if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status == 200)
				{
				xmlResponse = xmlHttp.responseXML;
								
				xmlID=xmlResponse.getElementsByTagName("IDitem");
				xmlTit=xmlResponse.getElementsByTagName("title");
				xmlCat=xmlResponse.getElementsByTagName("category");
				xmlBrand=xmlResponse.getElementsByTagName("brand");
				xmlLat=xmlResponse.getElementsByTagName("latitude");
				xmlLng=xmlResponse.getElementsByTagName("longitude");
				xmlStreet=xmlResponse.getElementsByTagName("street");
				xmlPostal=xmlResponse.getElementsByTagName("postal");
				xmlCity=xmlResponse.getElementsByTagName("city");


								
				for (var loop = 0; loop < xmlID.length; loop++) 
						{
						xmlFirst=xmlID[loop];
						iditem[loop]=xmlFirst.firstChild.nodeValue;
						} 
		
				for (var loop = 0; loop < xmlTit.length; loop++) 
						{
						xmlFirst=xmlTit[loop];
						tit[loop]=xmlFirst.firstChild.nodeValue;
						} 	

				for (var loop = 0; loop < xmlCat.length; loop++) 
						{
						xmlFirst=xmlCat[loop];
						category[loop]=xmlFirst.firstChild.nodeValue;
						} 
				
				for (var loop = 0; loop < xmlBrand.length; loop++) 
						{
						xmlFirst=xmlBrand[loop];
						brand[loop]=xmlFirst.firstChild.nodeValue;
						} 
						
				
				for (var loop = 0; loop < xmlStreet.length; loop++) 
						{
						xmlFirst=xmlStreet[loop];
						street[loop]=xmlFirst.firstChild.nodeValue;
						} 
						
				for (var loop = 0; loop < xmlPostal.length; loop++) 
						{
						xmlFirst=xmlPostal[loop];
						postal[loop]=xmlFirst.firstChild.nodeValue;
						} 
						
				for (var loop = 0; loop < xmlCity.length; loop++) 
						{
						xmlFirst=xmlCity[loop];
						city[loop]=xmlFirst.firstChild.nodeValue;
						} 		
						
				for (var loop = 0; loop < xmlLat.length; loop++) 
						{
						xmlFirst=xmlLat[loop];
						latitude[loop]=xmlFirst.firstChild.nodeValue;
						} 

				for (var loop = 0; loop < xmlLng.length; loop++) 
						{
						xmlFirst=xmlLng[loop];
						longitude[loop]=xmlFirst.firstChild.nodeValue;
						} 
				
				var brandslice= brand.slice();
				brandslice.sort();
				var co=0;
				for(i=0;i<brandslice.length;i++)
					{
					if(brandslice[i]!=brandslice[i+1])
						{
						brandi[co]=brandslice[i];
						co++;
						}
					}
	
					
				j=0;
				var htmlForm='<form id="catform"  name="catform"  onsubmit="return false;"><table>';

				for(i=0;i<brandi.length;i++)
				       {
				
						if(j==0)
						   {
						   htmlForm=htmlForm+'<tr><td width="130"><input id="cat'+i+'" name="'+brandi[i]+'" value="'+brandi[i]+'" type="checkbox" checked="checked" onClick="renewBMarks('+brandi.length+');">'+ampCh(brandi[i])+'</td>';
						   j++;
						   }
				       else if(j<3)
						   {
						   htmlForm=htmlForm+'<td width="130"><input id="cat'+i+'" name="'+brandi[i]+'" value="'+brandi[i]+'" type="checkbox" checked="checked" onClick="renewBMarks('+brandi.length+');">'+ampCh(brandi[i])+'</td>';
						   j++;
						   }
				       else
						   {
					           htmlForm=htmlForm+'<td width="130"><input id="cat'+i+'" name="'+brandi[i]+'" value="'+brandi[i]+'" type="checkbox" checked="checked" onClick="renewBMarks('+brandi.length+');">'+ampCh(brandi[i])+'</td></tr>';
						   j=0;
						   }
				       }	
				
				htmlForm+='</table></form>';      

				$('massa').update(htmlForm);	
				
				
					mgr.clearMarkers();

				callMarkermanager();
					
										
				}
			else
				{
				alert("Problem accessing Server: " + xmlHttp.statusText);
				}
		}
	}	
	
	
function gettingBrandsCategory(catEgory)
	{
	
	iditem.length = 0;
	tit.length = 0;
	category.length = 0;
	latitude.length = 0;
	longitude.length = 0;
	brand.length = 0;
	street.length = 0;
	postal.length = 0;
	city.length = 0;
	brandi.length=0;
		
	var phpPar='_'+encodeUTF8(catEgory);
	
		
	if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
			{	
				xmlHttp.open("GET", URLpath+"func/getCats.php?cats=" + phpPar, true);
				xmlHttp.onreadystatechange = handleBrands;
				xmlHttp.send(null);
			}
		else
			{
			setTimeout('gettingBrandsCategory(catEgory)',100);
			}	
	
	}	
	
	

/*
===============================================
***********************************************
mlib
************************************************+
===============================================
*/
	
	
function sC(url)
 	{
    	i = new Image();
	i.src = url;
  	}

function dC(url,delay)
	{
	uri=url
	setTimeout("sC(uri)",delay*1000);
	}
function randomToN(maxVal,floatVal)
	{
   	var randVal = Math.random()*maxVal;
    	return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
	}
    	
function jump(obj)
 	{ 
        if(obj.selectedIndex != 0)
        	{ 
        	window.location=obj.options[obj.selectedIndex].value;
        	}
    	} 

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function writeCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function ampCh(strng)
	{
	strng=strng.replace(/amp23/g, '&amp;');
	return strng;
	}
	
function html_entity_decode(str) 
	{
   	var ta = document.createElement("textarea");
 	ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
	toReturn = ta.value;
        ta = null;
        return toReturn
        }

function implodeAd(query)
	
	{
	var pureAd = query;
	 impAd= encodeURI(pureAd);
	 return impAd;
	}

function encodeUTF8(string) 
	{
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++)
        	{

		    var c = string.charCodeAt(n);

		    if (c < 128) 
			{
			utftext += String.fromCharCode(c);
			}
		    else if((c > 127) && (c < 2048)) 
			{
			utftext += String.fromCharCode((c >> 6) | 192);
			utftext += String.fromCharCode((c & 63) | 128);
			}
		    else 
			{
			utftext += String.fromCharCode((c >> 12) | 224);
			utftext += String.fromCharCode(((c >> 6) & 63) | 128);
			utftext += String.fromCharCode((c & 63) | 128);
			}

        	}

        return utftext;
        }

function decodeUTF8(utftext) 
	{
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) 
        	{

		    c = utftext.charCodeAt(i);

		    if (c < 128) 
		    {
			string += String.fromCharCode(c);
			i++;
		    }
		    
		    else if((c > 191) && (c < 224)) 
		    {
			c2 = utftext.charCodeAt(i+1);
			string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
			i += 2;
		    }
		    
		    else 
		    {
			c2 = utftext.charCodeAt(i+1);
			c3 = utftext.charCodeAt(i+2);
			string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
			i += 3;
		    }

		}

        return string;
    	}    
//dropdowmenu ie    	
    	
function startList()
	{
	if (document.all&&document.getElementById)
			{
			navRoot = document.getElementById("nav");
				for (i=0; i<navRoot.childNodes.length; i++)
					{
					node = navRoot.childNodes[i];
						if (node.nodeName=="LI")
							{
							node.onmouseover=function()
								{
								this.className+=" over";
								}
							node.onmouseout=function()
								{
								this.className=this.className.replace(" over", "");
								}
							}
					}
			}
	}	
	

//brandmap dropdown menue	
function selVal()
	{
	gettingBrandsCategory($F('kategorien'));
    	}		
