
$().ready(function() {
  $('#dialog').jqm();
  $('#dialog').jqmShow();
});

$().ready(function() {
  $('#dialog2').jqm();
  $('#dialog2').jqmShow();
});

function toggleMe(a){
	  var e=document.getElementById(a);
	  if(!e)return true;
	  if(e.style.display=="none"){
	    e.style.display="block";
	  } else {
	    e.style.display="none";
	  }
	  return true;
}

function toggleMeRow(a){
	  var e=document.getElementById(a);
	  if(!e)return true;
	  if(e.style.display=="none"){
		    e.style.display="table-row";
	  } else {
	    e.style.display="none";
	  }
	  return true;
}

function toggleMeVisible(a){
	  var e=document.getElementById(a);
	  if(!e)return true;
	  if(e.style.visibility=="hidden"){
		    e.style.visibility="visible";
	  } else {
	    e.style.visibility="hidden";
	  }
	  return true;
}

function changeClass(a,b,c){
	var e=document.getElementById(a);
	if(!e) e = a;// we consider a is a "this"
	if(!e)return true;
	  
	if(e.className == b){
		e.className=c;
	}else {
		e.className=b;
	}
	return true;
}

function changeImgSrc(a,b,c){
	var e=document.getElementById(a);
	  if(!e)return true;
	  
	  if(e.src == b){
	    e.src=c;
	  } else {
	    e.src=b;
	  }
	return true;
	
	
}

function toggleMeOn(a){
	  var e=document.getElementById(a);
	  if(!e)return true;
	  if(e.style.display=="none"){
	    e.style.display="block"
	  }
	  return true;
}

function toggleMeOff(a){
	  var e=document.getElementById(a);
	  if(!e)return true;
	  if(e.style.display=="block"){
	    e.style.display="none"
	  }
	  return true;
}


function showSubnav(a){
	  var e=document.getElementById(a);


	    e.style.display="block"

	  return true;
}
function hideSubnav(a){
	  var e=document.getElementById(a);


	    e.style.display="none"

	  return true;
}

function reload() {

	document.location.href="#connection";
	document.location.reload();
}

function showCountryInfo() { //used in content.html
	//var CountryID;
	//var CountryInputdID;
	//var CountryLink;
	CountryID = document.getElementById("countryInfo").value;
	CountryInputdID = "countryUrl"+CountryID;
	//alert(CountryInputdID);
	try
	{
		CountryLink = document.getElementById(CountryInputdID).value;
		window.open(CountryLink);
	}
	catch(err)
	{
		alert ('Bitte wählen Sie ein anderes Land');
	}
}

function noop()	{
}


function scroll( updown,productID,movePixel ) {

		var position=0;
		movePixel = parseInt(movePixel);
		position = parseInt(document.getElementById('productScrollValueCurrent'+productID).value);
		positionMax = parseInt(document.getElementById('productScrollValueMax'+productID).value);
		//alert(position+' '+positionMax+' '+updown);
		if ( updown == 'left' && position<0){
			 position = position +movePixel;
		}
		else if ( updown == 'right' && -position<(positionMax-3)*movePixel){
			position = position -movePixel;
		}
		if (position<0){
			document.getElementById('productScrollButtonLeft'+productID).style.display="block";
		}
		else{
			document.getElementById('productScrollButtonLeft'+productID).style.display="none";
		}
		if (-position==(positionMax-3)*movePixel){
			document.getElementById('productScrollButtonRight'+productID).style.display="none";
		}
		else {
			document.getElementById('productScrollButtonRight'+productID).style.display="block";
		}
		document.getElementById(productID).style.marginLeft = position+"px";
		document.getElementById('productScrollValueCurrent'+productID).value =position;
}



function setCheckbox(name) {
	document.getElementById(name).checked = true;
}

function slideDiv(divID, LinkGroupID) {
			
	var openDIV = '';
	
	if (LinkGroupID==1)
	{
		
		changeClass(divID+'_button',"button_w210_grey_down_blue_up center_block bgPosDown","button_w210_grey_down_blue_up center_block bgPosUp");
		
		var div1 = document.getElementById('filterCompanies');
		var div2 = document.getElementById('filterPOS');
		var div3 = document.getElementById('filterBrands');
		var div4 = document.getElementById('categoryShowrooms');
		
		if (div1 && div1.style.display == 'block') {$(document.getElementById('filterCompanies')).slideUp("slow"); openDIV= 'filterCompanies';}
		if (div2 && div2.style.display == 'block') {$(document.getElementById('filterPOS')).slideUp("slow"); openDIV= 'filterPOS';}
		if (div3 && div3.style.display == 'block') {$(document.getElementById('filterBrands')).slideUp("slow"); openDIV= 'filterBrands';}
		if (div4 && div4.style.display == 'block') {$(document.getElementById('categoryShowrooms')).slideUp("slow"); openDIV= 'categoryShowrooms';}
	}
	else
	{
		var div1 = document.getElementById('homeCategories');
		var div2 = document.getElementById('key_account');
		var div3 = document.getElementById('showrooms');
		if (div1.style.display == 'block') {$(document.getElementById('homeCategories')).slideUp("slow"); openDIV= 'homeCategories';}
		if (div2.style.display == 'block') {$(document.getElementById('key_account')).slideUp("slow"); openDIV= 'key_account';}
		if (div3.style.display == 'block') {$(document.getElementById('showrooms')).slideUp("slow"); openDIV= 'showrooms';}
	}
	
	if (openDIV != divID) {
		$(document.getElementById(divID)).slideDown("slow");
		if (LinkGroupID==1){
			changeClass(openDIV+'_button',"button_w210_grey_down_blue_up center_block bgPosDown","button_w210_grey_down_blue_up center_block bgPosUp");
		}
	}
}
		
function slideDivUpDown(divID) {
	if (document.getElementById(divID))
	{
		if (document.getElementById(divID).style.display == 'block') {$(document.getElementById(divID)).slideUp("slow"); }
		else {$(document.getElementById(divID)).slideDown("slow"); }
	}
}

function loadHtmlContent(divID,htmlTitle) {
	 $(document).ready(function(){

		jQuery.get( "/_files/templates/clients/mynetfair/"+htmlTitle, function(d){$('#'+divID).html(d);} )
	});

}
				
function loadHtmlContentFromPhp(divID,phpTitle, typeID) {
	

	jQuery.get( "/_include/mnf_add_user_static.inc.php5?sPhpFile="+phpTitle.replace(/\?/g, '&') );

	if(divID == '') //Only call a php file (don't display the html results in the div divID)
	{
		jQuery.get( "/_include/"+phpTitle );
	}
	else if( typeID == 1) //display with picture wait during loading
	{
		loadWaiting(divID);
		$(document).ready(function(){
			jQuery.get( "/_include/"+phpTitle, function(d){$('#'+divID).html(d); loadStopWaiting(divID);} )
		});	
	}
	else //run the php file phpTitle and display the html result in the div divID
	{
		$(document).ready(function(){
			jQuery.get( "/_include/"+phpTitle, function(d){$('#'+divID).html(d);} )
		});
	}
}

function loadHtmlContentFromPhpByPost(divID,phpTitle,params, typeID) {
	serializedParam = $("#"+params).serialize();
	phpTitle		= phpTitle + '?' + serializedParam;
	loadHtmlContentFromPhp(divID,phpTitle,typeID);
	/*
	if(divID == '') //Only call a php file (don't display the html results in the div divID)
	{
		jQuery.post( "/_include/"+phpTitle,params);
	}
	else if( typeID == 1) //display with picture wait during loading
	{
		if(document.getElementById(divID).style.display == "block"){
			loadWaiting(divID);
			$(document).ready(function(){
				jQuery.post( "/_include/"+phpTitle,serializedParam,function(d){$('#'+divID).html(d); loadStopWaiting(divID);} )
			});	
		}
	}
	else //run the php file phpTitle and display the html result in the div divID
	{
		if(sTestBlock == 'false')
		{
			$(document).ready(function(){
				jQuery.post( "/_include/"+phpTitle,params,function(d){$('#'+divID).html(d);} )
			});
		}
		else
		{
			if(document.getElementById(divID).style.display == "block"){
				$(document).ready(function(){
					jQuery.post( "/_include/"+phpTitle,params,function(d){$('#'+divID).html(d);} )
				});
			}
		}

	}
	*/
}

function changeValue(divID, SearchboxText) {
    if (document.getElementById(divID).value == SearchboxText) {
        document.getElementById(divID).value = "";
    } else if (document.getElementById(divID).value == "") {
        document.getElementById(divID).value = SearchboxText;
    }
}	
				
				
function scrollAnimation(sender)		
{	
	(function($) {
		$(function() { //on DOM ready
			$("#scroller").simplyScroll({
				autoMode: 'loop'
			});
		});
	})(jQuery);
}		

//Display waiting picture during charging div
function loadWaiting(divID)
{
	(function($){
		$.fn.waiting = function(options) {
			var offset = this.offset();
			//Detect IE6
			if ($.browser.msie && $.browser.version.substr(0,1)<7) 
			{
				var offsetLeft = offset.left - 740;
			}
			else
			{
				var offsetLeft = offset.left;
			}
			var offsetLeft = offset.left;
			//Detect IE6 End
			
			var settings 	= $.extend({css: {'opacity':'0.3','background-color':'#00AEEF'},imgsrc: "http://static1.mynetfair.com/images/loader.gif"},options);
			var height 		= this.height();
			var width 		= this.width();			
			var id 			= this[0].id;
			var newid 		= id + "waiting";
			this[0].waitid 	= newid;
			var div 		= $("<div />").css({'position':'absolute','top':offset.top,'left':offsetLeft,'height':height,'width':width}).css(settings.css).attr('id',newid).appendTo("body");
			var img 		= $("<img />").attr("src",settings.imgsrc);
			//var imgheight = img.height();
			//var imgwidth 	= img.width();
			var imgheight 	= 32;
			var imgwidth 	= 32;
			var top 		= ((height/2)-(imgheight/2));
			img.css({'position':'absolute','top':top,'left':((width/2)-(imgwidth/2)),'z-index':3000});
			img.appendTo(div);
			return this;
		}
	})(jQuery);
	$(document.getElementById(divID)).waiting({imgsrc:"http://static2.mynetfair.com/images/loader.gif"});
}

//Stop displaying waiting picture during charging div
function loadStopWaiting(divID)
{
	(function($){
		$.fn.stopWaiting = function() {
			var waitid = this[0].waitid;
			$("#"+waitid).remove();
			return this;
		}

	})(jQuery);
	$(document.getElementById(divID)).stopWaiting();
}


function addElement(divID,id,value) {
	var wantedDIV = "existing_"+id;
	
	var addThis = '<div id="'+wantedDIV+'"><a href="javascript:noop();" onclick="removeElement(\''+wantedDIV+'\')">'+value+'</a><input type="hidden" name="aExistingValue[]" value="'+id+'"/></div>';
	
	jQuery(function ($) {
		$("#"+divID).append(addThis);
	});
}

function removeElement(divID){
	jQuery(function ($) {
		$('#'+divID).empty().remove()
	});	
}


//Modal functions (overlay) used for filter
;(function($){var ie6=$.browser.msie&&parseInt($.browser.version)==6&&typeof window['XMLHttpRequest']!="object",ieQuirks=null,w=[];$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close();};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={appendTo:'body',focus:true,opacity:50,overlayId:'simplemodal-overlay',overlayCss:{},containerId:'simplemodal-container',containerCss:{},dataId:'simplemodal-data',dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:false,autoPosition:true,zIndex:1000,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:'simplemodal-close',escClose:true,overlayClose:false,position:null,persist:false,transient:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={o:null,d:{},init:function(data,options){var s=this;if(s.d.data){return false;}ieQuirks=$.browser.msie&&!$.support.boxModel;s.o=$.extend({},$.modal.defaults,options);s.zIndex=s.o.zIndex;s.occb=false;if(typeof data=='object'){data=data instanceof jQuery?data:$(data);s.d.placeholder=false;if(data.parent().parent().size()>0){data.before($('<span></span>').attr('id','simplemodal-placeholder').css({display:'none'}));s.d.placeholder=true;s.display=data.css('display');if(!s.o.persist){s.d.orig=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=$('<div></div>').html(data);}else{alert('SimpleModal Error: Unsupported data type: '+typeof data);return s;}s.create(data);data=null;s.open();if($.isFunction(s.o.onShow)){s.o.onShow.apply(s,[s.d]);}return s;},create:function(data){var s=this;w=s.getDimensions();if(!s.o.transient&&ie6){s.d.iframe=$('<iframe src="javascript:false;"></iframe>').css($.extend(s.o.iframeCss,{display:'none',opacity:0,position:'fixed',height:w[0],width:w[1],zIndex:s.o.zIndex,top:0,left:0})).appendTo(s.o.appendTo);}s.d.overlay=$('<div></div>').attr('id',s.o.overlayId).addClass('simplemodal-overlay').css($.extend(s.o.overlayCss,{display:'none',opacity:s.o.opacity/100,height:s.o.transient?0:w[0],width:s.o.transient?0:w[1],position:'fixed',left:0,top:0,zIndex:s.o.zIndex+1})).appendTo(s.o.appendTo);s.d.container=$('<div></div>').attr('id',s.o.containerId).addClass('simplemodal-container').css($.extend(s.o.containerCss,{display:'none',position:'fixed',zIndex:s.o.zIndex+2})).append(s.o.close&&s.o.closeHTML?$(s.o.closeHTML).addClass(s.o.closeClass):'').appendTo(s.o.appendTo);s.d.wrap=$('<div></div>').attr('tabIndex',-1).addClass('simplemodal-wrap').css({height:'100%',outline:0,width:'100%'}).appendTo(s.d.container);s.d.data=data.attr('id',data.attr('id')||s.o.dataId).addClass('simplemodal-data').css($.extend(s.o.dataCss,{display:'none'})).appendTo('body');data=null;s.setContainerDimensions();s.d.data.appendTo(s.d.wrap);if(ie6||ieQuirks){s.fixIE();}},bindEvents:function(){var s=this;$('.'+s.o.closeClass).bind('click.simplemodal',function(e){e.preventDefault();s.close();});if(!s.o.transient&&s.o.close&&s.o.overlayClose){s.d.overlay.bind('click.simplemodal',function(e){e.preventDefault();s.close();});}$(document).bind('keydown.simplemodal',function(e){if(!s.o.transient&&s.o.focus&&e.keyCode==9){s.watchTab(e);}else if((s.o.close&&s.o.escClose)&&e.keyCode==27){e.preventDefault();s.close();}});$(window).bind('resize.simplemodal',function(){w=s.getDimensions();s.setContainerDimensions(true);if(ie6||ieQuirks){s.fixIE();}else if(!s.o.transient){s.d.iframe&&s.d.iframe.css({height:w[0],width:w[1]});s.d.overlay.css({height:w[0],width:w[1]});}});},unbindEvents:function(){$('.'+this.o.closeClass).unbind('click.simplemodal');$(document).unbind('keydown.simplemodal');$(window).unbind('resize.simplemodal');this.d.overlay.unbind('click.simplemodal');},fixIE:function(){var s=this,p=s.o.position;$.each([s.d.iframe||null,s.o.transient?null:s.d.overlay,s.d.container],function(i,el){if(el){var bch='document.body.clientHeight',bcw='document.body.clientWidth',bsh='document.body.scrollHeight',bsl='document.body.scrollLeft',bst='document.body.scrollTop',bsw='document.body.scrollWidth',ch='document.documentElement.clientHeight',cw='document.documentElement.clientWidth',sl='document.documentElement.scrollLeft',st='document.documentElement.scrollTop',s=el[0].style;s.position='absolute';if(i<2){s.removeExpression('height');s.removeExpression('width');s.setExpression('height',''+bsh+' > '+bch+' ? '+bsh+' : '+bch+' + "px"');s.setExpression('width',''+bsw+' > '+bcw+' ? '+bsw+' : '+bcw+' + "px"');}else{var te,le;if(p&&p.constructor==Array){var top=p[0]?typeof p[0]=='number'?p[0].toString():p[0].replace(/px/,''):el.css('top').replace(/px/,'');te=top.indexOf('%')==-1?top+' + (t = '+st+' ? '+st+' : '+bst+') + "px"':parseInt(top.replace(/%/,''))+' * (('+ch+' || '+bch+') / 100) + (t = '+st+' ? '+st+' : '+bst+') + "px"';if(p[1]){var left=typeof p[1]=='number'?p[1].toString():p[1].replace(/px/,'');le=left.indexOf('%')==-1?left+' + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"':parseInt(left.replace(/%/,''))+' * (('+cw+' || '+bcw+') / 100) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}}else{te='('+ch+' || '+bch+') / 2 - (this.offsetHeight / 2) + (t = '+st+' ? '+st+' : '+bst+') + "px"';le='('+cw+' || '+bcw+') / 2 - (this.offsetWidth / 2) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}s.removeExpression('top');s.removeExpression('left');s.setExpression('top',te);s.setExpression('left',le);}}});},focus:function(pos){var s=this,p=pos||'first';var input=$(':input:enabled:visible:'+p,s.d.wrap);input.length>0?input.focus():s.d.wrap.focus();},getDimensions:function(){var el=$(window);var h=$.browser.opera&&$.browser.version>'9.5'&&$.fn.jquery<='1.2.6'?document.documentElement['clientHeight']:$.browser.opera&&$.browser.version<'9.5'&&$.fn.jquery>'1.2.6'?window.innerHeight:el.height();return[h,el.width()];},getVal:function(v){return v=='auto'?0:v.indexOf('%')>0?v:parseInt(v.replace(/px/,''));},setContainerDimensions:function(resize){var s=this;if(!resize||(resize&&s.o.autoResize)){var ch=$.browser.opera?s.d.container.height():s.getVal(s.d.container.css('height')),cw=$.browser.opera?s.d.container.width():s.getVal(s.d.container.css('width')),dh=s.d.data.outerHeight(true),dw=s.d.data.outerWidth(true);var mh=s.o.maxHeight&&s.o.maxHeight<w[0]?s.o.maxHeight:w[0],mw=s.o.maxWidth&&s.o.maxWidth<w[1]?s.o.maxWidth:w[1];if(!ch){if(!dh){ch=s.o.minHeight;}else{if(dh>mh){ch=mh;}else if(dh<s.o.minHeight){ch=s.o.minHeight;}else{ch=dh;}}}else{ch=ch>mh?mh:ch;}if(!cw){if(!dw){cw=s.o.minWidth;}else{if(dw>mw){cw=mw;}else if(dw<s.o.minWidth){cw=s.o.minWidth;}else{cw=dw;}}}else{cw=cw>mw?mw:cw;}s.d.container.css({height:ch,width:cw});if(dh>ch||dw>cw){s.d.wrap.css({overflow:'auto'});}}if(s.o.autoPosition){s.setPosition();}},setPosition:function(){var s=this,top,left,hc=(w[0]/2)-(s.d.container.outerHeight(true)/2),vc=(w[1]/2)-(s.d.container.outerWidth(true)/2);if(s.o.position&&Object.prototype.toString.call(s.o.position)==="[object Array]"){top=s.o.position[0]||hc;left=s.o.position[1]||vc;}else{top=hc;left=vc;}s.d.container.css({left:left,top:top});},watchTab:function(e){var s=this;if($(e.target).parents('.simplemodal-container').length>0){s.inputs=$(':input:enabled:visible:first, :input:enabled:visible:last',s.d.data[0]);if((!e.shiftKey&&e.target==s.inputs[s.inputs.length-1])||(e.shiftKey&&e.target==s.inputs[0])||s.inputs.length==0){e.preventDefault();var pos=e.shiftKey?'last':'first';setTimeout(function(){s.focus(pos);},10);}}else{e.preventDefault();setTimeout(function(){s.focus();},10);}},open:function(){var s=this;s.d.iframe&&s.d.iframe.show();if($.isFunction(s.o.onOpen)){s.o.onOpen.apply(s,[s.d]);}else{s.d.overlay.show();s.d.container.show();s.d.data.show();}s.focus();s.bindEvents();},close:function(){var s=this;if(!s.d.data){return false;}s.unbindEvents();if($.isFunction(s.o.onClose)&&!s.occb){s.occb=true;s.o.onClose.apply(s,[s.d]);}else{if(s.d.placeholder){var ph=$('#simplemodal-placeholder');if(s.o.persist){ph.replaceWith(s.d.data.removeClass('simplemodal-data').css('display',s.display));}else{s.d.data.hide().remove();ph.replaceWith(s.d.orig);}}else{s.d.data.hide().remove();}s.d.container.hide().remove();s.d.overlay.hide().remove();s.d.iframe&&s.d.iframe.hide().remove();s.d={};}}};})(jQuery);
function showModal(divID, pID, nextAction)
{
	jQuery(function ($) {
		$('#'+divID).modal({onOpen: function (dialog) {
			dialog.overlay.fadeIn('slow', function () {
				dialog.container.slideDown('slow', function () {
					dialog.data.fadeIn('slow');
				});
			});
		},
		onClose: function (dialog) {
			dialog.data.fadeOut('slow', function () {
				dialog.container.hide('slow', function () {
					$.modal.close();
				});
			});
		},
		//overlayClose:true,
		opacity:80});
	});
	var isiPad = navigator.userAgent.match(/iPad/i) != null;
	if(isiPad)
	{ 
		$('.basic-modal-content').css({'background-color': '#ffffff', 'height':'auto', 'width':'330'});
		$.scrollTo( 0, 800);
	}
	if(nextAction)
	{
		document.headerLoginUpgrade.hiddenModelHeaderLoginUpgradeAction.value = nextAction;
		document.headerLoginUpgrade.hiddenModelHeaderLoginPID.value = pID;
	}
}
//Modal functions (overlay) used for filter End



//function for product notation
function starClick(starID,iProductID)
{
	
	var srcClicked = "http://static1.mynetfair.com/images/icons/feedback_star_clicked.gif";
	var srcOut = "http://static1.mynetfair.com/images/icons/feedback_star_out.gif";
	var i;
	
	for (i = 1; i <= starID ; i++)
	{
		var myID  = i+"_star_"+iProductID;
		document.getElementById(myID).src= srcClicked;
		
	}
	for (j = (starID*1)+1; j <= 5 ; j++)
	{
		var myID  = j+"_star_"+iProductID;
		document.getElementById(myID).src= srcOut;
		
	} 
	
	document.getElementById('noteValue_'+iProductID).value = starID;
	
	
 }

 function resetAllStar(iProductID)
 {
	 for (i = 1; i <= 5 ; i++)
	 {
		var myID  = i+"_star_"+iProductID;
		document.getElementById(myID).src= "http://static1.mynetfair.com/images/icons/feedback_star_out.gif";
		
	 }
	 document.getElementById('noteValue_'+iProductID).value = 0;
	 
 }
//function for product notation End
 
//Google Map 
//Code came from code.google.com --> google V3 
function calcRoute(start,end, way){
	
	// First, clear out any existing markerArray
	// from previous calculations.
	deleteRoute();
	var request = {
		 origin:start, 
		 destination:end,
		 travelMode: google.maps.DirectionsTravelMode.DRIVING
	};
	if(way != 1){
		request.travelMode = google.maps.DirectionsTravelMode.WALKING;
	}
	directionsService.route(request, function(response, status) {
		if (status == google.maps.DirectionsStatus.OK) {
			directionsDisplay.setDirections(response);
//			var myRoute = directionResult.routes[0].legs[0];
//			for (var i = 0; i < myRoute.steps.length; i++) {
//			      var marker = new google.maps.Marker({
//			        position: myRoute.steps[i].start_point, 
//			        map: map
//			      });
////			      attachInstructionText(marker, myRoute.steps[i].instructions);
//			      markersRouteArray[i] = marker;
//			  }
		}
	});
	
}
function attachInstructionText(marker, text) {
	google.maps.event.addListener(marker, 'click', function() {
   stepDisplay.setContent(text+'<br/><a href="#" onclick="deleteRoute()">Delete this route</a>');
   stepDisplay.open(map, marker);
 });
}
function deleteRoute(){
	for (i = 0; i < markersRouteArray.length; i++) {
		markersRouteArray[i].setMap(null);
	}
}

var  map = "";
function loadMap(showID,sCircle,iLat,iLng, iCompany, bShowAllCompanyFromShowroom,more_params,mapID) {

	var bIsSelectMore = false;
		
	directionsService = new google.maps.DirectionsService();
	directionsDisplay = new google.maps.DirectionsRenderer();
	markersArray = [];

	markersArray['sel_categories'] = [];
	markersArray['sel_free_text_1'] = [];
	markersArray['sel_free_text_2'] = [];
	markersArray['sel_free_text_3'] = [];
	markersArray['sel_free_text_4'] = [];

	markersArray['markers'] = [];
	markersRouteArray = [];

	var myOptions = {
	zoom: 8,
	center: new google.maps.LatLng(0,0),
	mapTypeId: google.maps.MapTypeId.ROADMAP
	};

	if(!mapID)mapID = "map";
	map = new google.maps.Map(document.getElementById(mapID), myOptions);
	directionsDisplay.setMap(map);

	var googleCustomIcons = {
			blue_one: {
				icon: 'http://static2.mynetfair.com/images/profil/app/google_blue.png',
				shadow: ''
			},
			orange_one: {
				icon: 'http://static2.mynetfair.com/images/profil/app/google_orange.png',
				shadow: ''
			},
			green_one: {
				icon: 'http://static2.mynetfair.com/images/profil/app/google_green.png',
				shadow: ''
			},
			mypoint: {
				icon: 'http://static2.mynetfair.com/images/profil/app/google_00aeef.png',
				shadow: ''
			},
			red_one: {
				icon: 'http://static2.mynetfair.com/images/profil/app/google_nadel.png',
				shadow: ''
			},
			yellow_one: {
				icon: 'http://static2.mynetfair.com/images/profil/app/google_yellow.png',
//				shadow: 'http://static2.mynetfair.com/images/profil/app/mm_20_shadow.png'
				shadow:''
			}
	};

	//On given lat and lon if exists
	var bInitilized = false;
	var bIsStartPoint = false;
	if(iLat!="" && iLng !="" ){
		
		//My position , start position
		var point = new google.maps.LatLng(iLat,iLng);
		var startPoint = point;
		bIsStartPoint = true;
		/*bInitilized =true;
		map.setCenter(point);*/
		
		var html = "Meine aktuelle Position";
		var icon = googleCustomIcons["bar"] || {};
		var marker = new google.maps.Marker({
		map: map,
		position: point,
		icon: icon.icon,
		shadow: icon.shadow
		});
		bindInfoWindow(marker, map, infoWindow, html);
	}else{
		/*** ask for geocode the client **/
//		if(navigator.geolocation) {
//		    var browserSupportFlag = true;
//		    navigator.geolocation.getCurrentPosition(function(position) {
//		    	point = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
//		    	var startPoint = point;
//		    	bIsStartPoint = true;
//		    	map.setCenter(startPoint);
//		    }, function() {
//		    	 alert("Geolocation service failed.");
//		    });
//		 }
	}


	var infoWindow = new google.maps.InfoWindow;

	if(!iCompany){iCompany = 0;}
	if(!more_params){more_params = "";}

	if(!bShowAllCompanyFromShowroom){bShowAllCompanyFromShowroom = 0;}

	var bIsAnoptherKeyCat =  false;
	var sParam = "showroom_id="+showID+"&circle="+sCircle+"&lat="+iLat+"&lon="+iLng+"&company_id="+iCompany+"&bSearchAllCompanyFromShowroom="+bShowAllCompanyFromShowroom+more_params;
	//construct XML from circleSearch and parse it



	downloadUrl("/_include/mnf_getGoogleMapCustom.inc.php5?"+sParam, function(data,dataStatus){
		var xml = data.responseXML;
		
		if(mapID != 'map'){
			var eDPosError = document.getElementById(mapID+"_"+"div_position_error");
		}else{
			var eDPosError = document.getElementById("div_position_error");
		}
		eDPosError.innerHTML = "";
		
		var plzFoundNode= xml.documentElement.getElementsByTagName("plzFound");
		if(typeof(plzFoundNode[0]) != "undefined" ){
			if(typeof(plzFoundNode[0].childNodes[0]) != "undefined" && plzFoundNode[0].childNodes[0] != null ){
				if(typeof(plzFoundNode[0].childNodes[0].nodeValue) != "undefined" && plzFoundNode[0].childNodes[0].nodeValue !="" ){
					eDPosError.innerHTML = parseXmlStringReverse(plzFoundNode[0].childNodes[0].nodeValue);
				}
			}
		}
		var markers = xml.documentElement.getElementsByTagName("marker");
		var bounds = new google.maps.LatLngBounds();
		var markerLength = markers.length;
		for (var i = 0; i < markerLength; i++) {
			
			var point = new google.maps.LatLng(
					parseFloat(markers[i].getAttribute("lat")),
					parseFloat(markers[i].getAttribute("lng")));
			
			
			
			
			if(markers[i].getAttribute("filiale_title") && markers[i].getAttribute("filiale_title") !="" ){
				var name = markers[i].getAttribute("filiale_title");
				name = parseXmlStringReverse(name);
			}else{
				var name = parseXmlStringReverse(markers[i].getAttribute("title"));
			}
			bounds.extend(point);
			

			var html = "<div class='gmap_bulle_left'><strong>"+name+"</strong>";
			if(markers[i].getAttribute("address")){
				var address = markers[i].getAttribute("address");
				html =  html+ "<br/>"+address;
			}
			if(markers[i].getAttribute("plz") && markers[i].getAttribute("city") ){
				html = html+"<br/>"+markers[i].getAttribute("plz")+" "+parseXmlStringReverse(markers[i].getAttribute("city"));
			}
			
			if(markers[i].getAttribute("oH")){
				var sTmp = markers[i].getAttribute("oH");
				sTmp = parseXmlStringReverse(sTmp);
				html = html+"<br/>"+sTmp;
			}
			for(var j = 2; j <= 3; j++){
				if(markers[i].getAttribute("free_text_" + j)){
					var sTmp = markers[i].getAttribute("free_text_" + j);
					sTmp = parseXmlStringReverse(sTmp);
					html = html+"<br/>"+sTmp;
				}
			}
			j= 1;
			if(markers[i].getAttribute("free_text_" +j)){
				var sTmp = parseXmlStringReverse(markers[i].getAttribute("free_text_" + j));
				html = html+"<br/>"+sTmp;
			}
			
			
			if(markers[i].getAttribute("description")){
				html = html+"<br/><br/>"+parseXmlStringReverse(markers[i].getAttribute("description"));
			}
			html+="</div>";
			
			if(bIsStartPoint == true ){
				html += "<div class='gmap_direction'>";
				html += "<strong>Zu dieser Stelle gehen</strong><br/><a class='driving_route' href='javascript:noop();' onclick='calcRoute(\""+startPoint+"\",\""+point+"\",1);'></a>";
				html += "<a class='walking_route' href='javascript:noop();' onclick='calcRoute(\""+startPoint+"\",\""+point+"\",2);'></a>";
				html += "</div>";
			}
			
			
			//MyPoint->setCenter map
			if(markers[i].getAttribute("free_text_2") && markers[i].getAttribute("free_text_2") != "" ){
				if(markers[i].getAttribute("free_text_2").indexOf("Cool-Cup") != -1){
					var type = "green_one";
				}else if(markers[i].getAttribute("free_text_2").indexOf("Frucht Preis") != -1){
					var type = "orange_one";
				}else{
					var type = "blue_one";
				}
			}
			else if(markers[i].getAttribute("type")){
				/*bInitilized =true;
				map.setCenter(point);*/
				var type = markers[i].getAttribute("type");
			}else{
				var type = "red_one";
			}	
			var icon = googleCustomIcons[type];
			var marker = new google.maps.Marker({
				map: map,
				position: point,
				icon: icon.icon,
				shadow: icon.shadow
			});
			
			
			var categoryName =  '--';
			if(markers[i].getAttribute("category") && markers[i].getAttribute("category")!=""){
				bIsAnoptherKeyCat = true;
				categoryName =  markers[i].getAttribute("category").replace('+','&#134;');
			}
			if(!markersArray['markers'][categoryName]){
				markersArray['sel_categories'][categoryName] = {};
				markersArray['sel_categories'][categoryName]['name'] = categoryName;
				markersArray['sel_categories'][categoryName]['markers'] = {};
			}
			
			
			var sRefID = markersArray['markers'].length;
			markersArray['markers'][sRefID] = marker;
			
			markersArray['sel_categories'][categoryName]['markers']['m_'+sRefID] = sRefID;
			
			if(gup('show_carte') == 1){
				var iForFreeText = 1;
				for(iForFreeText = 1; iForFreeText <= 3; iForFreeText++){
					var tmpAttr = markers[i].getAttribute("free_text_" + iForFreeText);
					if(tmpAttr && tmpAttr !="" ){
						if(!markersArray['sel_free_text_'+iForFreeText]['c_'+tmpAttr]){
							var bIsSelectMore = true;
							markersArray['sel_free_text_'+iForFreeText]['c_'+tmpAttr] = [];
							markersArray['sel_free_text_'+iForFreeText]['c_'+tmpAttr]['name'] = tmpAttr;
							markersArray['sel_free_text_'+iForFreeText]['c_'+tmpAttr]['markers'] = [];
						}
						markersArray['sel_free_text_'+iForFreeText]['c_'+tmpAttr]['markers']['m_'+sRefID] = sRefID;
					}
				}
				
			}
			bindInfoWindow(marker, map, infoWindow, html);
			
			//Show HTML element for charge Company
			if(more_params != "" && more_params.indexOf('sChargeNumber=') != -1 && type == "blue_one" ){
				
				if(mapID != 'map'){
					var e = document.getElementById(mapID+"_"+"marker_explanation");
				}
				else{
					var e = document.getElementById('marker_explanation');
				}
				e.innerHTML = html+'<div class="cl"></div>';
				e.className = 'dBlock';
			}
			
		}
		map.fitBounds(bounds);
		if(markers.length < 4){
			map.setZoom(6);
		}
		if(bIsAnoptherKeyCat == true){
			addSelectForgoogleMap(markersArray['sel_categories'],'sel_categories','loadNewMarkerForMapWithSelect(this,false)');
		}
		if(bIsSelectMore){
			iForFreeText = 1;
			for(iForFreeText = 1; iForFreeText <= 2; iForFreeText++){
				
//				if(gup('app') == "rundschau" && iForFreeText == 1){
////					b = b.replace('c_')*1;
////					a = a.replace('c_')*1;
////					alert('b '+b+' a'+a);
//					sortSelectDesc;
////					markersArray['sel_free_text_'+iForFreeText].sort(sortSelectDesc);
//				}else{
//					
//				}
				markersArray['sel_free_text_'+iForFreeText].sort();
				addSelectForgoogleMap(markersArray['sel_free_text_'+iForFreeText],'sel_free_text_'+iForFreeText,'loadNewMarkerForMapWithSelect(this,true)',iForFreeText);
			}
		}
		
		
			
		
		
		});


	}

function addSelectForgoogleMap(aSelect, id, sFunction,iForTableName){
	
	var aLabelForFreeText = [];
	if(gup('app') == 'rundschau'){
		aLabelForFreeText[1] = "Jahrgang";
		aLabelForFreeText[2] = "Auszeichnung";
		
		var pNode3 = document.createElement("table");
		pNode3.setAttribute("style","width:100%;");
		var pNode2 = document.createElement("tr");
		var pNode1 = document.createElement("td");
		pNode1.setAttribute("style","width:85px;");
		if(iForTableName != "" && iForTableName > 0 && typeof(aLabelForFreeText[iForTableName]) != "undefined"){
			var textNode = document.createTextNode(aLabelForFreeText[iForTableName]);
			pNode1.appendChild(textNode);
		}
		pNode2.appendChild(pNode1);
		var pNode = document.createElement("td");

	}else{
		var pNode = document.createElement("p");
		pNode.setAttribute('style','padding-left:10px;');
	}

	
	var sSelectCategories = document.createElement("select");
	sSelectCategories.setAttribute("style","width:100%;max-width:100%");
	sSelectCategories.setAttribute("id",id);
	sSelectCategories.setAttribute("onchange",sFunction);
	var options1 = document.createElement("option");
	options1.setAttribute("value","--");
	var textNode = document.createTextNode('--');
	options1.appendChild(textNode);
	sSelectCategories.appendChild(options1);
	
	for(var i in aSelect){
		//Jahrgang
		//Auszeichnung
		var options1 = document.createElement('option');
		options1.setAttribute('value',i);
		var textNode = document.createTextNode(aSelect[i]['name'].replace('&#134;','+'));
		options1.appendChild(textNode);
		sSelectCategories.appendChild(options1);
	}
	pNode.appendChild(sSelectCategories);
	
	if(gup('app') == 'rundschau'){
		pNode2.appendChild(pNode);
		pNode3.appendChild(pNode2);
		document.getElementById('select_boxes').appendChild(pNode3);
	}
	else{
		document.getElementById('select_boxes').appendChild(pNode);
	}
}

function loadNewMarkerForMapWithSelect(thisSelect,bLookForOther){
	
	var IcountTmp= 0;
	tmpCatID = thisSelect.options[thisSelect.selectedIndex].value;
	var aSelectedToMatch = [];
	if(bLookForOther){ 
	// beispiel rundschau -> we have more than one select box and they have to match all together
		var iTesxtFree = 1;
		var aSelectedToMatch = [];
		for (iTesxtFree = 1; iTesxtFree <=2; iTesxtFree++){
			if(thisSelect.id != 'sel_free_text_'+iTesxtFree ){
				var tmpSel = document.getElementById('sel_free_text_'+iTesxtFree).options[document.getElementById('sel_free_text_'+iTesxtFree).selectedIndex].value;
				if(tmpSel != '--'){
					aSelectedToMatch['sel_free_text_'+iTesxtFree]= tmpSel;
				}
			}
		}
		
		
		for(var i in markersArray[thisSelect.id]){
			if(tmpCatID == i || tmpCatID == '--'){
				for (jMarkRef in markersArray[thisSelect.id][i]['markers'] ){
					var tmpTrueRef = markersArray[thisSelect.id][i]['markers'][jMarkRef];
					var showMe = true;
					for(iFreeText0 in aSelectedToMatch){
						if(typeof markersArray[iFreeText0][aSelectedToMatch[iFreeText0]]['markers'][jMarkRef] == 'undefined'){
							showMe = false;
						}
					}
					if(showMe){
						IcountTmp++;
						markersArray['markers'][tmpTrueRef].setMap(map);
					}else{
						markersArray['markers'][tmpTrueRef].setMap(null);
					}
					
				}
			}else{
				for (jMarkRef in markersArray[thisSelect.id][i]['markers'] ){
					var tmpTrueRef = markersArray[thisSelect.id][i]['markers'][jMarkRef];
					markersArray['markers'][tmpTrueRef].setMap(null);
				}
			}
				
			
		}

	}else{
		for(var i in markersArray[thisSelect.id]){
			if(tmpCatID == '--'){	//case 1 : we show all
				for (jMarkRef in markersArray[thisSelect.id][i]['markers'] ){
					var tmpTrueRef = markersArray[thisSelect.id][i]['markers'][jMarkRef];
					markersArray['markers'][tmpTrueRef].setMap(map);
					IcountTmp++;
				}
			}else{
				if(tmpCatID != '--' && tmpCatID == i){
					for (jMarkRef in markersArray[thisSelect.id][i]['markers'] ){
						var tmpTrueRef = markersArray[thisSelect.id][i]['markers'][jMarkRef];
						markersArray['markers'][tmpTrueRef].setMap(map);
						IcountTmp++;
					}
				}else{
					for (jMarkRef in markersArray[thisSelect.id][i]['markers'] ){
						var tmpTrueRef = markersArray[thisSelect.id][i]['markers'][jMarkRef];
						markersArray['markers'][tmpTrueRef].setMap(null);
					}
				}
				
			}
			
		}
	}
	
	var textCount = document.getElementById('count_result_map');
	if(typeof(textCount) != 'undefined'){
		textCount.innerHTML = IcountTmp*1 + 1;//Object.size(markersArray[thisSelect.id][tmpCatID]["markers"]);
	}
		
}
function bindInfoWindow(marker, map, infoWindow, html)
{
	google.maps.event.addListener(marker, 'click', function(){
		var e = document.getElementById('marker_explanation');
		if(!e){
			infoWindow.setContent(html);
			infoWindow.open(map, marker);
		}else{
			e.innerHTML = html+'<div class="cl"></div>';
			e.style.display = 'block';
		}
	});
}

function parseXmlStringReverse(me){
	me = me.replace(/&lt;/g,"<"); 
	me = me.replace(/&gt;/g,">"); 
	me = me.replace(/&quot;/g,"\""); 
	me = me.replace(/&#39;/g,"'"); 
	me = me.replace(/&amp;/g,"&"); 
	return me;
}

function downloadUrl(url, callback) {
	var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest;

	request.onreadystatechange = function() {
	if (request.readyState == 4) {
		request.onreadystatechange = noop;//do nothing
		callback(request, request.status);
	}
	};

	request.open('GET', url, true);
	request.send(null);
}
	
/*functions for tracability in the product box*/
var aMap=[];
function tracabilityInitialize(productID,id,lat,lon) {
	
	var initLat = 48.57403744875462;
	var initLon = 7.811987400054932;
	var initZoom = 4;
	
	//center the map on the saved geocode
	if(lat != "" && lon != "")
	{
		var myLatlng = new google.maps.LatLng(lat,lon);
		var myOptions = {
				zoom: initZoom,
				center: myLatlng,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			}
		aMap[productID+"_"+id] = new google.maps.Map(document.getElementById("gmap_"+productID+"_"+id), myOptions);
		//create marker with the saved lat and lon
		var marker = new google.maps.Marker({
			  position: myLatlng, 
			  map: aMap[productID+"_"+id]
			});
		var infoWindow = new google.maps.InfoWindow;
		tracabilityBindInfoWindow(marker,infoWindow,productID,id);//bind the info window
		tracabilityAddDragListener(marker,productID,id);
		tracabilityUpdateInputDisplay(myLatlng,productID,id);
	}
	else
	{
		var myLatlng = new google.maps.LatLng(initLat,initLon);
		var myOptions = {
				zoom: initZoom,
				center: myLatlng,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			}
		aMap[productID+"_"+id] = new google.maps.Map(document.getElementById("gmap_"+productID+"_"+id), myOptions);
	}
	
	//Map Event Handler 
	google.maps.event.addListener(aMap[productID+"_"+id], 'click', function(event) {
		tracabilityPlaceMarker(event.latLng,productID,id);
		tracabilityUpdateInputDisplay(event.latLng,productID,id);
	});
	tracabilityUpdateInputDisplay(myLatlng,productID,id);
}

function tracabilityUpdateInputDisplay(location,productID,id){
	document.getElementById("gmap_lat_"+productID+"_"+id).value = location.lat();
	document.getElementById("gmap_lon_"+productID+"_"+id).value = location.lng();
} 
function tracabilityAddDragListener(marker,productID,id){
	google.maps.event.addListener(marker, 'drag', function() {
		tracabilityUpdateInputDisplay(marker.getPosition(),productID,id);
	});
	google.maps.event.addListener(marker, 'dragend', function() {
		tracabilityUpdateInfoWindow(marker,productID);
		tracabilityUpdateInputDisplay(marker.getPosition(),productID,id);
	});
}
function tracabilityPlaceMarker(location,productID,id){
	var infoWindow = new google.maps.InfoWindow;
	var marker = new google.maps.Marker({//create the new marker at the given geocode (given within the addListener call)
	  position: location, 
	  map: aMap[productID+"_"+id]
	});
	marker.setDraggable(true);
	tracabilityBindInfoWindow(marker,infoWindow,productID,id);//bind the info window
	tracabilityAddDragListener(marker,productID,id);//add the drag listener to the marker
}
function tracabilityBindInfoWindow(marker, infoWindow,productID,id)
{
	google.maps.event.addListener(marker, 'click', function(){
		var location = marker.getPosition();
		html = " This marker is positionned at : lat:"+location.lat()+" lon:"+location.lng();
		infoWindow.setContent(html);
		infoWindow.open(aMap[productID+"_"+id], marker);
		tracabilityUpdateInputDisplay(location,productID,id);
	});
	
}
function tracabilityUpdateInfoWindow(marker){

} 


/*functions for tracability in the product box END*/





function toggleOrLoad(sDiv,sWhat){// To load just the content one time and toogle later
	var e = document.getElementById(sDiv);
	if(e){
		if(e.innerHTML != ""){
			toggleMe(sDiv);
		}else{
			loadHtmlContentFromPhp(sDiv,sWhat,1);
		}
	}
}


function addDeleteFromShoppingList(object,productID,bIsInShoppingList){
	var e = document.getElementById(object);
	if(!e) e = object;
	
	if(e.className == "canAddThisToNotepad"){
		var action = 'add';
		var concernedText = 'mobi.shoppingList.deleteFrom';
	}else{
		var action = 'del';
		var concernedText = 'mobi.shoppingList.addTo';
	}
	loadHtmlContentFromPhp('','mnf_app.inc.php5?cameFromAjax=1&shoppingList=1&quantity=1&productID='+productID+'&action='+action,0);
	if(bIsInShoppingList && action == 'del' ){
		removeElement('SmallProductBox_'+productID);
	}else{
		if(e){
			if(e.parentNode){
				if(e.parentNode.id == "notepadFalse"){
					e.parentNode.id = "notepadTrue";
				}else if(e.parentNode.id == "notepadTrue"){
					e.parentNode.id = "notepadFalse";
				}
			}
			changeClass(e.id,'canAddThisToNotepad','isProductInNotepad');
			loadHtmlContentFromPhp(e.id,'mnf_app.inc.php5?searchTexts=1&concernedText='+concernedText,0);
		}
		
	}
}

//google translate 
function translateMe(div1,div2,translateIn){
	var myDiv = document.getElementById(div1);
	var divToFullfill = document.getElementById(div2);
	
	var aMy = [];
	// georgian and greek are in the google format
	aMy[1]= 'de'; aMy[10]= 'de'; aMy[14]= 'fr'; aMy[15]='el'; aMy[17] = 'ka'; aMy[18]= 'en'; aMy[21] = 'it'; aMy[32] = 'nl';aMy[35] = 'pl';aMy[36] = 'pt'; aMy[39]= 'ru'; aMy[45]= 'es'; aMy[49] = 'tr';
	
	if(myDiv && divToFullfill && aMy[translateIn]!= "" ){
		var text = myDiv.value;
		google.language.translate(text, '', aMy[translateIn] , function(result) { // first '' because google can auto detect the language
			if (result.translation) {
				divToFullfill.value = parseXmlStringReverse(result.translation);
		    }
		});
	}
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

//load div with ajax only if no child
function loadWhenEmptyOnly(id,reffunction){
	if(hasNoChildElements(id)){
		reffunction;
	}
	return true;
}
function hasNoChildElements(id){
	var me = document.getElementById(id);
	if(me && !me.hasChildNodes() ) return true;
	return false;
}
function mMulli(thisLi){
	//we loop through the "li" of this 'ul' to toogle them off
	var aLi = thisLi.parentNode.children;
	var i = 0;
	for(i; i < aLi.length; i++){
		if(aLi[i].id !="" && aLi[i].id != thisLi.id && typeof ('de_'+aLi[i].id) != 'undefined' ){
			toggleMeOff('de_'+aLi[i].id);
		}
	}
	toggleMe('de_'+thisLi.id);
}
function mTAnchor(anchor){
	window.location.hash= anchor; 
}

function aDomTagCreation(a,b){//a array with the data to create, b, parent name/object
	/** Create HTML tag and add them to the DOM **/
	var tmpMeCss = [];
	if(typeof(b) == 'string'){
		b = $(b);
	}
	for(i in a){
		var tmpMe = a[i];
		var me = $("<"+tmpMe.tag+">");
		if(tmpMe.css){
			var tmpMeCss = tmpMe.css;
			for(j in tmpMeCss){
				me.css(j,tmpMeCss[j]);
			}
		}
		if(tmpMe.attr){
			var tmpMeAttr = tmpMe.attr;
			for(j in tmpMeAttr){
				me.attr(j,tmpMeAttr[j]);
			}
		}
		if(tmpMe.addClass){
			me.addClass(tmpMe.addClass);
		}
		if(tmpMe.html){
			me.html(tmpMe.html);
		}
		b.append(me);
		if(tmpMe.childs){
			aDomTagCreation(tmpMe.childs,$(me));
		}
	}
}



/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 9/11/2008
 * @author Ariel Flesler
 * @version 1.4
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);




/**
 * jQuery.ScrollTo
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 9/11/2008
 *
 * @projectDescription Easy element scrolling using jQuery.
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 * Tested with jQuery 1.2.6. On FF 2/3, IE 6/7, Opera 9.2/5 and Safari 3. on Windows.
 *
 * @author Ariel Flesler
 * @version 1.4
 *
 * @id jQuery.scrollTo
 * @id jQuery.fn.scrollTo
 * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements.
 *	  The different options for target are:
 *		- A number position (will be applied to all axes).
 *		- A string position ('44', '100px', '+=90', etc ) will be applied to all axes
 *		- A jQuery/DOM element ( logically, child of the element to scroll )
 *		- A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc )
 *		- A hash { top:x, left:y }, x and y can be any kind of number/string like above.
 * @param {Number} duration The OVERALL length of the animation, this argument can be the settings object instead.
 * @param {Object,Function} settings Optional set of settings or the onAfter callback.
 *	 @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
 *	 @option {Number} duration The OVERALL length of the animation.
 *	 @option {String} easing The easing method for the animation.
 *	 @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
 *	 @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }.
 *	 @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes.
 *	 @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
 *	 @option {Function} onAfter Function to be called after the scrolling ends. 
 *	 @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.
 * @return {jQuery} Returns the same jQuery object, for chaining.
 *
 * @desc Scroll to a fixed position
 * @example $('div').scrollTo( 340 );
 *
 * @desc Scroll relatively to the actual position
 * @example $('div').scrollTo( '+=340px', { axis:'y' } );
 *
 * @dec Scroll using a selector (relative to the scrolled element)
 * @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } );
 *
 * @ Scroll to a DOM element (same for jQuery object)
 * @example var second_child = document.getElementById('container').firstChild.nextSibling;
 *			$('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){
 *				alert('scrolled!!');																   
 *			}});
 *
 * @desc Scroll on both axes, to different values
 * @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } );
 */
;(function( $ ){
	
	var $scrollTo = $.scrollTo = function( target, duration, settings ){
		$(window).scrollTo( target, duration, settings );
	};

	$scrollTo.defaults = {
		axis:'y',
		duration:1
	};

	// Returns the element that needs to be animated to scroll the window.
	// Kept for backwards compatibility (specially for localScroll & serialScroll)
	$scrollTo.window = function( scope ){
		return $(window).scrollable();
	};

	// Hack, hack, hack... stay away!
	// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
	$.fn.scrollable = function(){
		return this.map(function(){
			// Just store it, we might need it
			var win = this.parentWindow || this.defaultView,
				// If it's a document, get its iframe or the window if it's THE document
				elem = this.nodeName == '#document' ? win.frameElement || win : this,
				// Get the corresponding document
				doc = elem.contentDocument || (elem.contentWindow || elem).document,
				isWin = elem.setInterval;

			return elem.nodeName == 'IFRAME' || isWin && $.browser.safari ? doc.body
				: isWin ? doc.documentElement
				: this;
		});
	};

	$.fn.scrollTo = function( target, duration, settings ){
		if( typeof duration == 'object' ){
			settings = duration;
			duration = 0;
		}
		if( typeof settings == 'function' )
			settings = { onAfter:settings };
			
		settings = $.extend( {}, $scrollTo.defaults, settings );
		// Speed is still recognized for backwards compatibility
		duration = duration || settings.speed || settings.duration;
		// Make sure the settings are given right
		settings.queue = settings.queue && settings.axis.length > 1;
		
		if( settings.queue )
			// Let's keep the overall duration
			duration /= 2;
		settings.offset = both( settings.offset );
		settings.over = both( settings.over );

		return this.scrollable().each(function(){
			var elem = this,
				$elem = $(elem),
				targ = target, toff, attr = {},
				win = $elem.is('html,body');

			switch( typeof targ ){
				// A number will pass the regex
				case 'number':
				case 'string':
					if( /^([+-]=)?\d+(px)?$/.test(targ) ){
						targ = both( targ );
						// We are done
						break;
					}
					// Relative selector, no break!
					targ = $(targ,this);
				case 'object':
					// DOMElement / jQuery
					if( targ.is || targ.style )
						// Get the real position of the target 
						toff = (targ = $(targ)).offset();
			}
			$.each( settings.axis.split(''), function( i, axis ){
				var Pos	= axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					old = elem[key],
					Dim = axis == 'x' ? 'Width' : 'Height',
					dim = Dim.toLowerCase();

				if( toff ){// jQuery / DOMElement
					attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );

					// If it's a dom element, reduce the margin
					if( settings.margin ){
						attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
						attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
					}
					
					attr[key] += settings.offset[pos] || 0;
					
					if( settings.over[pos] )
						// Scroll to a fraction of its width/height
						attr[key] += targ[dim]() * settings.over[pos];
				}else
					attr[key] = targ[pos];

				// Number or 'number'
				if( /^\d+$/.test(attr[key]) )
					// Check the limits
					attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max(Dim) );

				// Queueing axes
				if( !i && settings.queue ){
					// Don't waste time animating, if there's no need.
					if( old != attr[key] )
						// Intermediate animation
						animate( settings.onAfterFirst );
					// Don't animate this axis again in the next iteration.
					delete attr[key];
				}
			});			
			animate( settings.onAfter );			

			function animate( callback ){
				$elem.animate( attr, duration, settings.easing, callback && function(){
					callback.call(this, target, settings);
				});
			};
			function max( Dim ){
				var attr ='scroll'+Dim,
					doc = elem.ownerDocument;
				
				return win
						? Math.max( doc.documentElement[attr], doc.body[attr]  )
						: elem[attr];
			};
		}).end();
	};

	function both( val ){
		return typeof val == 'object' ? val : { top:val, left:val };
	};

})( jQuery );

/** Christophe property / brands suggestions **/
function getSuggestions(iProductID, iCategoryID, iLanguageDirectory, div, script)
{
	var sTitle = '';
	var aLanguages = new Array(1, 10, 14, 15, 17, 18, 21, 32, 35, 36, 39, 45, 49);
	
	if(document.getElementById("aProductModifications["+iProductID+"][productTitle][1]") || document.getElementById("aProductModifications["+iProductID+"][productTitle][10]"))
	{
		for (iLanguageKey in aLanguages)
		{ 
			if(document.getElementById("aProductModifications["+iProductID+"][productTitle]["+aLanguages[iLanguageKey]+"]"))
			{
				sTitle = sTitle + ' ' + document.getElementById("aProductModifications["+iProductID+"][productTitle]["+aLanguages[iLanguageKey]+"]").value;
			}
		}
	}
	
	if(document.getElementById("aProductModifications["+iProductID+"][description][1]"))
	{
		for (iLanguageKey in aLanguages)
		{ 
			if(document.getElementById("aProductModifications["+iProductID+"][description]["+aLanguages[iLanguageKey]+"]"))
			{
				sTitle = sTitle + ' ' + document.getElementById("aProductModifications["+iProductID+"][description]["+aLanguages[iLanguageKey]+"]").value;
			}
		}
	}
	sTitle = sTitle.toLowerCase();
	sTitle = sTitle.replace(new RegExp(/[àáâãäå]/g),"a");
	sTitle = sTitle.replace(new RegExp(/æ/g),"ae");
	sTitle = sTitle.replace(new RegExp(/ç/g),"c");
	sTitle = sTitle.replace(new RegExp(/[èéêë]/g),"e");
	sTitle = sTitle.replace(new RegExp(/[ìíîï]/g),"i");
	sTitle = sTitle.replace(new RegExp(/ñ/g),"n");
	sTitle = sTitle.replace(new RegExp(/[òóôõö]/g),"o");
	sTitle = sTitle.replace(new RegExp(/œ/g),"oe");
	sTitle = sTitle.replace(new RegExp(/[ùúûü]/g),"u");
	sTitle = sTitle.replace(new RegExp(/[ýÿ]/g),"y");
	sTitle = sTitle.replace(/\W/g,' ');

	if(sTitle != '')
	{
		var url = script + '?iProductID=' + iProductID + '&iCategoryID=' + iCategoryID + '&iLanguage=' + iLanguageDirectory + '&sTitles=' + sTitle;
		loadHtmlContentFromPhp(div, url);
	}
}

function getProductPropertySuggestions(iProductID, iCategoryID, iLanguageID, iLanguageDirectory)
{
	getSuggestions(iProductID, iCategoryID, iLanguageDirectory, 'productPropertySuggestionsJavascript_' + iProductID, 'mnf_ajax_get_property_suggestions.inc.php5');
}

function getProductBrandsSuggestions(iProductID, iCategoryID, iLanguageID, iLanguageDirectory)
{
	getSuggestions(iProductID, iCategoryID, iLanguageDirectory, 'aProductModificationBrandSuggestions_' + iProductID, 'mnf_ajax_get_suggestions.inc.php5');
}
/** Christophe property / brands suggestions End **/

/** Jcarousel HomePage for new products http://sorgalla.com/projects/jcarousel/ to configure **/
(function(i){var q={vertical:false,rtl:false,start:1,offset:1,size:null,scroll:6,visible:null,animation:"slow",easing:"swing",auto:7,wrap:"circular",initCallback:null,reloadCallback:null,itemLoadCallback:null,itemFirstInCallback:null,itemFirstOutCallback:null,itemLastInCallback:null,itemLastOutCallback:null,itemVisibleInCallback:null,itemVisibleOutCallback:null,buttonNextHTML:"<div></div>",buttonPrevHTML:"<div></div>",buttonNextEvent:"click",buttonPrevEvent:"click",buttonNextCallback:null,buttonPrevCallback:null, itemFallbackDimension:null},r=false;i(window).bind("load.jcarousel",function(){r=true});i.jcarousel=function(a,c){this.options=i.extend({},q,c||{});this.autoStopped=this.locked=false;this.buttonPrevState=this.buttonNextState=this.buttonPrev=this.buttonNext=this.list=this.clip=this.container=null;if(!c||c.rtl===undefined)this.options.rtl=(i(a).attr("dir")||i("html").attr("dir")||"").toLowerCase()=="rtl";this.wh=!this.options.vertical?"width":"height";this.lt=!this.options.vertical?this.options.rtl? "right":"left":"top";for(var b="",d=a.className.split(" "),f=0;f<d.length;f++)if(d[f].indexOf("jcarousel-skin")!=-1){i(a).removeClass(d[f]);b=d[f];break}if(a.nodeName.toUpperCase()=="UL"||a.nodeName.toUpperCase()=="OL"){this.list=i(a);this.container=this.list.parent();if(this.container.hasClass("jcarousel-clip")){if(!this.container.parent().hasClass("jcarousel-container"))this.container=this.container.wrap("<div></div>");this.container=this.container.parent()}else if(!this.container.hasClass("jcarousel-container"))this.container= this.list.wrap("<div></div>").parent()}else{this.container=i(a);this.list=this.container.find("ul,ol").eq(0)}b!==""&&this.container.parent()[0].className.indexOf("jcarousel-skin")==-1&&this.container.wrap('<div class=" '+b+'"></div>');this.clip=this.list.parent();if(!this.clip.length||!this.clip.hasClass("jcarousel-clip"))this.clip=this.list.wrap("<div></div>").parent();this.buttonNext=i(".jcarousel-next",this.container);if(this.buttonNext.size()===0&&this.options.buttonNextHTML!==null)this.buttonNext= this.clip.after(this.options.buttonNextHTML).next();this.buttonNext.addClass(this.className("jcarousel-next"));this.buttonPrev=i(".jcarousel-prev",this.container);if(this.buttonPrev.size()===0&&this.options.buttonPrevHTML!==null)this.buttonPrev=this.clip.after(this.options.buttonPrevHTML).next();this.buttonPrev.addClass(this.className("jcarousel-prev"));this.clip.addClass(this.className("jcarousel-clip")).css({overflow:"hidden",position:"relative"});this.list.addClass(this.className("jcarousel-list")).css({overflow:"hidden", position:"relative",top:0,margin:0,padding:0}).css(this.options.rtl?"right":"left",0);this.container.addClass(this.className("jcarousel-container")).css({position:"relative"});!this.options.vertical&&this.options.rtl&&this.container.addClass("jcarousel-direction-rtl").attr("dir","rtl");var j=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null;b=this.list.children("li");var e=this;if(b.size()>0){var g=0,k=this.options.offset;b.each(function(){e.format(this,k++);g+=e.dimension(this, j)});this.list.css(this.wh,g+100+"px");if(!c||c.size===undefined)this.options.size=b.size()}this.container.css("display","block");this.buttonNext.css("display","block");this.buttonPrev.css("display","block");this.funcNext=function(){e.next()};this.funcPrev=function(){e.prev()};this.funcResize=function(){e.reload()};this.options.initCallback!==null&&this.options.initCallback(this,"init");if(!r&&i.browser.safari){this.buttons(false,false);i(window).bind("load.jcarousel",function(){e.setup()})}else this.setup()}; var h=i.jcarousel;h.fn=h.prototype={jcarousel:"0.2.7"};h.fn.extend=h.extend=i.extend;h.fn.extend({setup:function(){this.prevLast=this.prevFirst=this.last=this.first=null;this.animating=false;this.tail=this.timer=null;this.inTail=false;if(!this.locked){this.list.css(this.lt,this.pos(this.options.offset)+"px");var a=this.pos(this.options.start,true);this.prevFirst=this.prevLast=null;this.animate(a,false);i(window).unbind("resize.jcarousel",this.funcResize).bind("resize.jcarousel",this.funcResize)}}, reset:function(){this.list.empty();this.list.css(this.lt,"0px");this.list.css(this.wh,"10px");this.options.initCallback!==null&&this.options.initCallback(this,"reset");this.setup()},reload:function(){this.tail!==null&&this.inTail&&this.list.css(this.lt,h.intval(this.list.css(this.lt))+this.tail);this.tail=null;this.inTail=false;this.options.reloadCallback!==null&&this.options.reloadCallback(this);if(this.options.visible!==null){var a=this,c=Math.ceil(this.clipping()/this.options.visible),b=0,d=0; this.list.children("li").each(function(f){b+=a.dimension(this,c);if(f+1<a.first)d=b});this.list.css(this.wh,b+"px");this.list.css(this.lt,-d+"px")}this.scroll(this.first,false)},lock:function(){this.locked=true;this.buttons()},unlock:function(){this.locked=false;this.buttons()},size:function(a){if(a!==undefined){this.options.size=a;this.locked||this.buttons()}return this.options.size},has:function(a,c){if(c===undefined||!c)c=a;if(this.options.size!==null&&c>this.options.size)c=this.options.size;for(var b= a;b<=c;b++){var d=this.get(b);if(!d.length||d.hasClass("jcarousel-item-placeholder"))return false}return true},get:function(a){return i(".jcarousel-item-"+a,this.list)},add:function(a,c){var b=this.get(a),d=0,f=i(c);if(b.length===0){var j,e=h.intval(a);for(b=this.create(a);;){j=this.get(--e);if(e<=0||j.length){e<=0?this.list.prepend(b):j.after(b);break}}}else d=this.dimension(b);if(f.get(0).nodeName.toUpperCase()=="LI"){b.replaceWith(f);b=f}else b.empty().append(c);this.format(b.removeClass(this.className("jcarousel-item-placeholder")), a);f=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null;d=this.dimension(b,f)-d;a>0&&a<this.first&&this.list.css(this.lt,h.intval(this.list.css(this.lt))-d+"px");this.list.css(this.wh,h.intval(this.list.css(this.wh))+d+"px");return b},remove:function(a){var c=this.get(a);if(!(!c.length||a>=this.first&&a<=this.last)){var b=this.dimension(c);a<this.first&&this.list.css(this.lt,h.intval(this.list.css(this.lt))+b+"px");c.remove();this.list.css(this.wh,h.intval(this.list.css(this.wh))- b+"px")}},next:function(){this.tail!==null&&!this.inTail?this.scrollTail(false):this.scroll((this.options.wrap=="both"||this.options.wrap=="last")&&this.options.size!==null&&this.last==this.options.size?1:this.first+this.options.scroll)},prev:function(){this.tail!==null&&this.inTail?this.scrollTail(true):this.scroll((this.options.wrap=="both"||this.options.wrap=="first")&&this.options.size!==null&&this.first==1?this.options.size:this.first-this.options.scroll)},scrollTail:function(a){if(!(this.locked|| this.animating||!this.tail)){this.pauseAuto();var c=h.intval(this.list.css(this.lt));c=!a?c-this.tail:c+this.tail;this.inTail=!a;this.prevFirst=this.first;this.prevLast=this.last;this.animate(c)}},scroll:function(a,c){if(!(this.locked||this.animating)){this.pauseAuto();this.animate(this.pos(a),c)}},pos:function(a,c){var b=h.intval(this.list.css(this.lt));if(this.locked||this.animating)return b;if(this.options.wrap!="circular")a=a<1?1:this.options.size&&a>this.options.size?this.options.size:a;for(var d= this.first>a,f=this.options.wrap!="circular"&&this.first<=1?1:this.first,j=d?this.get(f):this.get(this.last),e=d?f:f-1,g=null,k=0,l=false,m=0;d?--e>=a:++e<a;){g=this.get(e);l=!g.length;if(g.length===0){g=this.create(e).addClass(this.className("jcarousel-item-placeholder"));j[d?"before":"after"](g);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size)){j=this.get(this.index(e));if(j.length)g=this.add(e,j.clone(true))}}j=g;m=this.dimension(g);if(l)k+= m;if(this.first!==null&&(this.options.wrap=="circular"||e>=1&&(this.options.size===null||e<=this.options.size)))b=d?b+m:b-m}f=this.clipping();var p=[],o=0,n=0;j=this.get(a-1);for(e=a;++o;){g=this.get(e);l=!g.length;if(g.length===0){g=this.create(e).addClass(this.className("jcarousel-item-placeholder"));j.length===0?this.list.prepend(g):j[d?"before":"after"](g);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size)){j=this.get(this.index(e));if(j.length)g= this.add(e,j.clone(true))}}j=g;m=this.dimension(g);if(m===0)throw Error("jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...");if(this.options.wrap!="circular"&&this.options.size!==null&&e>this.options.size)p.push(g);else if(l)k+=m;n+=m;if(n>=f)break;e++}for(g=0;g<p.length;g++)p[g].remove();if(k>0){this.list.css(this.wh,this.dimension(this.list)+k+"px");if(d){b-=k;this.list.css(this.lt,h.intval(this.list.css(this.lt))-k+"px")}}k=a+o-1;if(this.options.wrap!="circular"&& this.options.size&&k>this.options.size)k=this.options.size;if(e>k){o=0;e=k;for(n=0;++o;){g=this.get(e--);if(!g.length)break;n+=this.dimension(g);if(n>=f)break}}e=k-o+1;if(this.options.wrap!="circular"&&e<1)e=1;if(this.inTail&&d){b+=this.tail;this.inTail=false}this.tail=null;if(this.options.wrap!="circular"&&k==this.options.size&&k-o+1>=1){d=h.margin(this.get(k),!this.options.vertical?"marginRight":"marginBottom");if(n-d>f)this.tail=n-f-d}if(c&&a===this.options.size&&this.tail){b-=this.tail;this.inTail= true}for(;a-- >e;)b+=this.dimension(this.get(a));this.prevFirst=this.first;this.prevLast=this.last;this.first=e;this.last=k;return b},animate:function(a,c){if(!(this.locked||this.animating)){this.animating=true;var b=this,d=function(){b.animating=false;a===0&&b.list.css(b.lt,0);if(!b.autoStopped&&(b.options.wrap=="circular"||b.options.wrap=="both"||b.options.wrap=="last"||b.options.size===null||b.last<b.options.size||b.last==b.options.size&&b.tail!==null&&!b.inTail))b.startAuto();b.buttons();b.notify("onAfterAnimation"); if(b.options.wrap=="circular"&&b.options.size!==null)for(var f=b.prevFirst;f<=b.prevLast;f++)if(f!==null&&!(f>=b.first&&f<=b.last)&&(f<1||f>b.options.size))b.remove(f)};this.notify("onBeforeAnimation");if(!this.options.animation||c===false){this.list.css(this.lt,a+"px");d()}else this.list.animate(!this.options.vertical?this.options.rtl?{right:a}:{left:a}:{top:a},this.options.animation,this.options.easing,d)}},startAuto:function(a){if(a!==undefined)this.options.auto=a;if(this.options.auto===0)return this.stopAuto(); if(this.timer===null){this.autoStopped=false;var c=this;this.timer=window.setTimeout(function(){c.next()},this.options.auto*1E3)}},stopAuto:function(){this.pauseAuto();this.autoStopped=true},pauseAuto:function(){if(this.timer!==null){window.clearTimeout(this.timer);this.timer=null}},buttons:function(a,c){if(a==null){a=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="first"||this.options.size===null||this.last<this.options.size);if(!this.locked&&(!this.options.wrap||this.options.wrap== "first")&&this.options.size!==null&&this.last>=this.options.size)a=this.tail!==null&&!this.inTail}if(c==null){c=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="last"||this.first>1);if(!this.locked&&(!this.options.wrap||this.options.wrap=="last")&&this.options.size!==null&&this.first==1)c=this.tail!==null&&this.inTail}var b=this;if(this.buttonNext.size()>0){this.buttonNext.unbind(this.options.buttonNextEvent+".jcarousel",this.funcNext);a&&this.buttonNext.bind(this.options.buttonNextEvent+ ".jcarousel",this.funcNext);this.buttonNext[a?"removeClass":"addClass"](this.className("jcarousel-next-disabled")).attr("disabled",a?false:true);this.options.buttonNextCallback!==null&&this.buttonNext.data("jcarouselstate")!=a&&this.buttonNext.each(function(){b.options.buttonNextCallback(b,this,a)}).data("jcarouselstate",a)}else this.options.buttonNextCallback!==null&&this.buttonNextState!=a&&this.options.buttonNextCallback(b,null,a);if(this.buttonPrev.size()>0){this.buttonPrev.unbind(this.options.buttonPrevEvent+ ".jcarousel",this.funcPrev);c&&this.buttonPrev.bind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev);this.buttonPrev[c?"removeClass":"addClass"](this.className("jcarousel-prev-disabled")).attr("disabled",c?false:true);this.options.buttonPrevCallback!==null&&this.buttonPrev.data("jcarouselstate")!=c&&this.buttonPrev.each(function(){b.options.buttonPrevCallback(b,this,c)}).data("jcarouselstate",c)}else this.options.buttonPrevCallback!==null&&this.buttonPrevState!=c&&this.options.buttonPrevCallback(b, null,c);this.buttonNextState=a;this.buttonPrevState=c},notify:function(a){var c=this.prevFirst===null?"init":this.prevFirst<this.first?"next":"prev";this.callback("itemLoadCallback",a,c);if(this.prevFirst!==this.first){this.callback("itemFirstInCallback",a,c,this.first);this.callback("itemFirstOutCallback",a,c,this.prevFirst)}if(this.prevLast!==this.last){this.callback("itemLastInCallback",a,c,this.last);this.callback("itemLastOutCallback",a,c,this.prevLast)}this.callback("itemVisibleInCallback", a,c,this.first,this.last,this.prevFirst,this.prevLast);this.callback("itemVisibleOutCallback",a,c,this.prevFirst,this.prevLast,this.first,this.last)},callback:function(a,c,b,d,f,j,e){if(!(this.options[a]==null||typeof this.options[a]!="object"&&c!="onAfterAnimation")){var g=typeof this.options[a]=="object"?this.options[a][c]:this.options[a];if(i.isFunction(g)){var k=this;if(d===undefined)g(k,b,c);else if(f===undefined)this.get(d).each(function(){g(k,this,d,b,c)});else{a=function(m){k.get(m).each(function(){g(k, this,m,b,c)})};for(var l=d;l<=f;l++)l!==null&&!(l>=j&&l<=e)&&a(l)}}}},create:function(a){return this.format("<li></li>",a)},format:function(a,c){a=i(a);for(var b=a.get(0).className.split(" "),d=0;d<b.length;d++)b[d].indexOf("jcarousel-")!=-1&&a.removeClass(b[d]);a.addClass(this.className("jcarousel-item")).addClass(this.className("jcarousel-item-"+c)).css({"float":this.options.rtl?"right":"left","list-style":"none"}).attr("jcarouselindex",c);return a},className:function(a){return a+" "+a+(!this.options.vertical? "-horizontal":"-vertical")},dimension:function(a,c){var b=a.jquery!==undefined?a[0]:a,d=!this.options.vertical?(b.offsetWidth||h.intval(this.options.itemFallbackDimension))+h.margin(b,"marginLeft")+h.margin(b,"marginRight"):(b.offsetHeight||h.intval(this.options.itemFallbackDimension))+h.margin(b,"marginTop")+h.margin(b,"marginBottom");if(c==null||d==c)return d;d=!this.options.vertical?c-h.margin(b,"marginLeft")-h.margin(b,"marginRight"):c-h.margin(b,"marginTop")-h.margin(b,"marginBottom");i(b).css(this.wh, d+"px");return this.dimension(b)},clipping:function(){return!this.options.vertical?this.clip[0].offsetWidth-h.intval(this.clip.css("borderLeftWidth"))-h.intval(this.clip.css("borderRightWidth")):this.clip[0].offsetHeight-h.intval(this.clip.css("borderTopWidth"))-h.intval(this.clip.css("borderBottomWidth"))},index:function(a,c){if(c==null)c=this.options.size;return Math.round(((a-1)/c-Math.floor((a-1)/c))*c)+1}});h.extend({defaults:function(a){return i.extend(q,a||{})},margin:function(a,c){if(!a)return 0; var b=a.jquery!==undefined?a[0]:a;if(c=="marginRight"&&i.browser.safari){var d={display:"block","float":"none",width:"auto"},f,j;i.swap(b,d,function(){f=b.offsetWidth});d.marginRight=0;i.swap(b,d,function(){j=b.offsetWidth});return j-f}return h.intval(i.css(b,c))},intval:function(a){a=parseInt(a,10);return isNaN(a)?0:a}});i.fn.jcarousel=function(a){if(typeof a=="string"){var c=i(this).data("jcarousel"),b=Array.prototype.slice.call(arguments,1);return c[a].apply(c,b)}else return this.each(function(){i(this).data("jcarousel", new h(this,a))})}})(jQuery);

function ChangeFilterProductStatus(iStatus, iProductID){
	//change class div
		for( i=0 ; i<3 ; i++ )
		{
			var currentClass 	= "light_" + i;
			var sBtn 			= currentClass + "_filter_"+iProductID;
			var btn 			= document.getElementById(sBtn);
			if(btn)
			{
				if(i == iStatus)
				{
					btn.className= "float-0-0 " + currentClass + "_checked";
				}
				else
				{
					btn.className= "float-0-0 " + currentClass;
				}
			}
		}
		
		var sBtn 			= "productStatusDiv_"+iProductID;
		var btn 			= document.getElementById(sBtn);
		btn.className		= "no_float-5-0 div_light_" + iStatus;
		
	//change status value
		var sBtn 			= "aProductModifications["+iProductID+"][status]";
		var btn 			= document.getElementById(sBtn);
		btn.value 			= iStatus;	
	return true;
}
