var SORTMODE_PRICEASC = 1;
var SORTMODE_PRICEDESC = 2;
var SORTMODE_NEW = 3;
var SORTMODE_BEST = 4;

function ShortInfo()
{
	this.name;
	this.shortdesc;
	this.longdesc;
	this.price;
	this.productid;
	this.selectedColor;
	this.selectedSize;
	this.colorD;
	this.sizeD;
	this.segementprefix;
	this.selectedCatentryId;
	this.imagePath;
	this.partnumber;
	this.currency;
	this.savepercentage;
	this.catentryid_parent;
	this.categoryName;
	this.categoryIdentifier;
	this.parentCategoryId;
	this.itemArray;	
	this.logo;
	this.brand;
	this.material1;
	this.material2;
	this.material3;
	this.material4;
	this.material5;
	this.cleaning1;
	this.cleaning2;
	this.cleaning3;
	this.cleaning4;
	this.cleaning5;
	this.sleevetext;
	this.lengthtext;
	this.issale;
	this.isnew;
	this.issoldout;
	this.availablesoon;
	this.countsmallimages;
	this.count;
	this.SEOUrl;
	this.webdate;
	this.rank;
	this.minPrice;
	this.maxPrice;
}

function Filter()
{	
	this.color = '';
	this.size = '';
	this.salenew = '';
	this.category = '';
	this.sortmode = 0;
}

function CommonProducts()
{
	this.productattributes;
	this.transimagefile;
	this.originalarray;
	this.array;	
	this.domain;
	this.storedir;
	this.segmentprefix;
	this.iconspath;
	this.logospath;
	this.iconsize;
	this.iconprefix;
	this.currency;
	this.sortindex;
	this.currentProductId;
	this.currentCategoryId;
	this.currentParentCategoryId;
	this.currentCategoryIdentifier;
    this.shortinfos = new Array();
    this.filter = new Filter();
    this.catalogId;
    this.storeId;
    this.langId;
    this.SEOProductURL;
   
}

CommonProducts.prototype.resetProducts = function()
{
	this.array = this.productattributes.catalogEntriesPropertiesArray;

}

CommonProducts.prototype.setArray = function(array)
{
  this.array = array;
  this.originalarray = array;
}

CommonProducts.prototype.setCurrentProductId = function(productId)
{
  this.currentProductId = productId;
}

CommonProducts.prototype.setCurrentCategoryId = function(categoryId)
{
  this.currentCategoryIdId = categoryId;
}

CommonProducts.prototype.setCatalogId = function(catalogId)
{
  this.catalogId = catalogId;
}

CommonProducts.prototype.setStoreId = function(storeId)
{
  this.storeId = storeId;
}

CommonProducts.prototype.setLangId = function(langId)
{
  this.langId = langId;
}


CommonProducts.prototype.showShortInfos = function()
{
	for(i=0;i<this.shortinfos.length;i++)
	{
	   this.renderShortInfo(this.shortinfos[i]);
	}
}

CommonProducts.prototype.showShortInfosByCount = function()
{
	
	for(i=0;i<this.shortinfos.length;i++)
	{
	   this.showContainerByCount(i+1);
	   this.renderShortInfoByCount(this.shortinfos[i],i+1);
	}

	for(y=i;y<this.productattributes.productIdsArray.length;y++)
	{
	  this.hideContainerByCount(y+1);
	}

}

CommonProducts.prototype.createProductShortInfos = function(withitems)
{
	 this.shortinfos = new Array();
	
	 productIds = getDistinctValuesFrom2DArray(this.array,this.productattributes.CATENTRY_ID_PARENT_INDEX);
	
	 for(var x=0;x<productIds.length;x++)
	   {
		 
	     currentItems = filter2DArray(this.array,this.productattributes.CATENTRY_ID_PARENT_INDEX,productIds[x]);	
	
	     shortinfo = new ShortInfo();
	     shortinfo = setMinMaxPrice(shortinfo, currentItems,this.productattributes.CATENTRY_PRICE_INDEX); 
	     
	     shortinfo.name = currentItems[0][this.productattributes.CATENTRY_NAME_INDEX];	     
	     shortinfo.shortdesc =  currentItems[0][this.productattributes.CATENTRY_SHORTDESC_INDEX];
	     shortinfo.longdesc =  currentItems[0][this.productattributes.CATENTRY_SHORTDESC_INDEX];
	     shortinfo.listprice = roundPrice(currentItems[0][this.productattributes.CATENTRY_LISTPRICE_INDEX],2);
	     shortinfo.price =shortinfo.minPrice;
	     if (this.productattributes.productIdsArray[x].length == 6)	     {
           
	       shortinfo.SEOUrl = getSEOUrl(this.productattributes.productIdsArray,currentItems[0][this.productattributes.CATENTRY_PARTNUMBER_INDEX]);	     

	     }
	    
	     if (parseFloat(shortinfo.listprice) > parseFloat(shortinfo.price))	{			 	
		 		shortinfo.savepercentage = (100 - (parseFloat(shortinfo.price) / parseFloat(shortinfo.listprice) * 100));
	     }
	     
	    
	     
	     shortinfo.catentryid_parent = currentItems[0][this.productattributes.CATENTRY_ID_PARENT_INDEX];
	     shortinfo.color =  currentItems[0][getAttributeIndex(this.productattributes,'COLOR')];
	     shortinfo.brand =  currentItems[0][getAttributeIndex(this.productattributes,'BRAND')];

	     shortinfo.size =   currentItems[0][getAttributeIndex(this.productattributes,'SIZE')];
	     shortinfo.colorD = currentItems[0][getAttributeIndex(this.productattributes,'COLORD')];
	     shortinfo.sizeD =   currentItems[0][getAttributeIndex(this.productattributes,'SIZED')];
	     shortinfo.sleevetext =   currentItems[0][getAttributeIndex(this.productattributes,'AERMELLAENGE')];
	     shortinfo.lengthtext =   currentItems[0][getAttributeIndex(this.productattributes,'LAENGE')];
	     shortinfo.countsmallimages = currentItems[0][this.productattributes.CATENTRY_ID_SMALLIMG_INDEX]; 
	     shortinfo = createMaterialAndCleaningShortInfoValues(shortinfo, this.productattributes);
	     shortinfo = createSaleAndNewShortInfoValues(shortinfo, this.productattributes);
	 
	 	 shortinfo.webdate = currentItems[0][this.productattributes.CATENTRY_WEBDATE_INDEX];
	     shortinfo.rank = currentItems[0][this.productattributes.CATENTRY_RANK_INDEX];
	     
	     shortinfo.imagePath = this.storedir+currentItems[0][this.productattributes.CATENTRY_IMAGE_INDEX];
	     
	     shortinfo.categoryName = currentItems[0][this.productattributes.CATENTRY_CATEGORYNAME_INDEX];
	     shortinfo.categoryIdentifier = currentItems[0][this.productattributes.CATENTRY_CATEGORY_IDENTIFIER_INDEX];
	     shortinfo.parentCategoryId = currentItems[0][this.productattributes.CATENTRY_PARENTCATEGORY_INDEX];
	     
	     shortinfo.partnumber = currentItems[0][this.productattributes.CATENTRY_PARTNUMBER_INDEX];
	   
	     shortinfo.segementprefix = this.segmentprefix;
	     shortinfo.currency = this.currency;
	     shortinfo.count = x;
	     shortinfo.issoldout = isSoldOut(currentItems,this.productattributes.CATENTRY_INVENTORY_INDEX);
	     shortinfo.availablesoon = currentItems[0][this.productattributes.CATENTRY_SOON_INDEX];
	     if (withitems)	 shortinfo.itemArray = currentItems;
	    
	     this.shortinfos.push(shortinfo);	    
	   }  
	 
	 
}


function getSEOUrl(array,partnumber)
{
	 for(zz=0;zz<array.length;zz++)
	 {
	   if (array[zz][5].indexOf(partnumber) >= 0)
	      {
		     return array[zz][4];
		   }
	 }
}

function isSoldOut(itemsArray,index)
{
	
	for(i=0;i<itemsArray.length;i++)
    {				
	    if (currentItems[i][index] != '' && currentItems[i][index] != undefined && currentItems[i][index] > 0) return false;
    }
	return true;
}

function setMinMaxPrice(shortinfo,itemsArray,index)
{
	
	
	for(i=0;i<itemsArray.length;i++)
    {			
		
		if (itemsArray[i][index] != undefined)
		{
			curprice = 	roundPrice(itemsArray[i][index],2);
			if (i==0)
			{
				shortinfo.maxPrice = curprice;
				shortinfo.minPrice = curprice;
			}			
		    if (parseFloat(curprice) > parseFloat(shortinfo.maxPrice)) 
		    {
		      shortinfo.maxPrice = 	curprice;
		    }
		    if (parseFloat(curprice) < parseFloat(shortinfo.minPrice)) 
		    {
		      shortinfo.minPrice = curprice;
		    }
				
		}
    }
	return shortinfo;
}

function createSaleAndNewShortInfoValues(shortinfo, productattributes )
{
	 
	var index = getAttributeIndex(productattributes,'SALENEU');
	shortinfo.isnew = false;
	shortinfo.issale = false;
	
	if (index >= 0) {
		if (currentItems[0][index] == 'N' )	shortinfo.isnew = true;		
		if (currentItems[0][index] == 'S' || currentItems[0][index] == 'SN') shortinfo.issale = true;		
	}

	
	return shortinfo;
}


function createMaterialAndCleaningShortInfoValues(shortinfo, productattributes )
{
	 for (var i=0;i<5;i++)
     {
		var index = getAttributeIndex(productattributes,'MATERIAL_'+i);
	   
		if (index >= 0)
		{     
			
			switch (i)
		  	  {
		  	   case 0 :  shortinfo.material1 = currentItems[0][index];
		  	   case 1 :  shortinfo.material2 = currentItems[0][index];
		       case 2 :  shortinfo.material3 = currentItems[0][index];
		  	   case 3 :  shortinfo.material4 = currentItems[0][index];
		  	   case 4 :  shortinfo.material5 = currentItems[0][index];	  	   
		  	  }
			
		}
	 }
    
	 for (var y=0;y<5;y++)
     {
		var indexc = getAttributeIndex(productattributes,'CLEANING_'+y);
		if (indexc >= 0)
		{     switch (y)
		  	  {
		  	   case 0 :   shortinfo.cleaning1 = currentItems[0][indexc];
		  	   case 1 :   shortinfo.cleaning2 = currentItems[0][indexc];
		       case 2 :   shortinfo.cleaning3 = currentItems[0][indexc];
		  	   case 3 :   shortinfo.cleaning4 = currentItems[0][indexc];
		  	   case 4 :   shortinfo.cleaning5 = currentItems[0][indexc];	  	   
		  	  }
			
		}
	 }
	 
	 var indexl = getAttributeIndex(productattributes,'LOGO');

	 shortinfo.logo = currentItems[0][indexl];
	
	 
	return shortinfo;
}

CommonProducts.prototype.renderShortInfo = function (shortinfo)
{		
		//$('#'+shortinfo.segementprefix+'_shortinfo_productimage_'+shortinfo.catentryid_parent).hide();
		$('#'+shortinfo.segementprefix+'_shortinfo_productimageXL_'+shortinfo.catentryid_parent).attr('src',shortinfo.imagePath);
		$('#'+shortinfo.segementprefix+'_shortinfo_productimageL_'+shortinfo.catentryid_parent).attr('src',shortinfo.imagePath.replace('x1x1','x1x2'));
	 	$('#'+shortinfo.segementprefix+'_shortinfo_productimage_'+shortinfo.catentryid_parent).attr('src',shortinfo.imagePath.replace('x1x1','x1x2'));
	 	
	 	if (parseFloat(shortinfo.listprice) > parseFloat(shortinfo.price))	{	
	 		$('#'+shortinfo.segementprefix+'_shortinfo_listprice_'+shortinfo.catentryid_parent).html(shortinfo.listprice.toString().replace('.',',') + ' ' + shortinfo.currency);	
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + this.iconprefix + '-' + roundValue(shortinfo.savepercentage,0) + '_' + 'L' + '.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconXL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + this.iconprefix + '-' + roundValue(shortinfo.savepercentage,0) + '_' + 'XL' + '.gif');	
	 		$('#'+shortinfo.segementprefix+'_shortinfo_savetext_'+shortinfo.catentryid_parent).show();
	 	}	
	 	else
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_listprice_'+shortinfo.catentryid_parent).html('');	
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconXL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_savetext_'+shortinfo.catentryid_parent).hide();	 
	 	}
	 	if (shortinfo.isnew)
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'iconNew_L' + '.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconXL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'iconNew_XL' + '.gif');	
	 	}
	 	
	 	if (shortinfo.brand != undefined && shortinfo.brand != '-')
	 	{
	 	 
	 		$('#'+shortinfo.segementprefix+'_shortinfo_brandicon_'+shortinfo.catentryid_parent).attr('src',this.iconspath.replace('icons/','brands/')+shortinfo.brand +'x1.png');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_brandiconsmall_'+shortinfo.catentryid_parent).attr('src',this.iconspath.replace('icons/','brands/')+shortinfo.brand +'x2.png');
	 	}
	 	else
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_brandicon_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_brandiconsmall_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');

	 	}
	 	
	 	var abStr = '';
	 	if (parseFloat(shortinfo.minPrice) < parseFloat(shortinfo.maxPrice)) 
	 	{ 
	 	  abStr = 'ab ';
	 	}
	 	
	 	$('#'+shortinfo.segementprefix+'_shortinfo_price_'+shortinfo.catentryid_parent).html(abStr + shortinfo.price.toString().replace('.',',') + ' ' + shortinfo.currency);

	 	$('#'+shortinfo.segementprefix+'_shortinfo_name_'+shortinfo.catentryid_parent).html(shortinfo.name);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_partnumber_'+shortinfo.catentryid_parent).html(shortinfo.partnumber);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_shortdesc_'+shortinfo.catentryid_parent).html(shortinfo.shortdesc);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_longdesc_'+shortinfo.catentryid_parent).html(shortinfo.longdesc);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_size_'+shortinfo.catentryid_parent).html(shortinfo.color);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_categoryname_'+shortinfo.catentryid_parent).html(shortinfo.categoryName + ' &raquo;');
	 	$('#'+shortinfo.segementprefix+'_shortinfo_categoryidlink_'+shortinfo.catentryid_parent).attr('href','CategoryDisplay?parentCategoryId='+this.currentCategoryId+'&level=2&catalogId='+this.catalogId+'&identifier='+shortinfo.categoryIdentifier+'&langId='+this.langId+'&storeId='+this.storeId);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_savepercentage_'+shortinfo.catentryid_parent).html(roundValue(shortinfo.savepercentage,0));
	 	$('#'+shortinfo.segementprefix+'_shortinfo_productlink_'+shortinfo.catentryid_parent).attr('href','ProductDisplay?parentCategoryId='+shortinfo.parentCategoryId+'&level=2&catalogId='+this.catalogId+'&identifier='+shortinfo.categoryIdentifier+'&langId='+this.langId+'&storeId='+this.storeId+'&productId='+shortinfo.catentryid_parent+'&level=2');		
	 	
	 	if (shortinfo.availablesoon != undefined && shortinfo.availablesoon == '1' && shortinfo.issoldout == true)
	 	{
	 	  $('#'+shortinfo.segementprefix+'_shortinfo_soon_'+shortinfo.catentryid_parent).attr('src',this.iconspath.replace('icons/','')+'teaserSize_XL_ikv_Overlay.gif');
	 	  $('#'+shortinfo.segementprefix+'_shortinfo_soonsmall_'+shortinfo.catentryid_parent).attr('src',this.iconspath.replace('icons/','')+'teaserSize_L_ikv_Overlay.gif');
	 	  $('#'+shortinfo.segementprefix+'_shortinfo_addToShopCartBtn_'+shortinfo.catentryid_parent).hide();
	 	}	 
	 	else
	 	{
	 		if (shortinfo.issoldout == true)
		 	{
		 	  $('#'+shortinfo.segementprefix+'_shortinfo_soldoutbig_'+shortinfo.catentryid_parent).attr('src',this.iconspath.replace('icons/','')+'teaserSize_XL_ola_Overlay.gif');
		 	  $('#'+shortinfo.segementprefix+'_shortinfo_soldoutsmall_'+shortinfo.catentryid_parent).attr('src',this.iconspath.replace('icons/','')+'teaserSize_L_ola_Overlay.gif');
		 	  $('#'+shortinfo.segementprefix+'_shortinfo_addToShopCartBtn_'+shortinfo.catentryid_parent).hide();
		 	}	 
		 	else
		 	{
		 	   $('#'+shortinfo.segementprefix+'_shortinfo_soldoutbig_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');
			   $('#'+shortinfo.segementprefix+'_shortinfo_soldoutsmall_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');
			   $('#'+shortinfo.segementprefix+'_shortinfo_addToShopCartBtn_'+shortinfo.catentryid_parent).show();
		 	}	
	 		
	 	   $('#'+shortinfo.segementprefix+'_shortinfo_soon_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');
		   $('#'+shortinfo.segementprefix+'_shortinfo_soonsmall_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');

	 	}

	  
	 	if (shortinfo.cleaning1 != '-')
	 		{
	 		  $('#'+shortinfo.segementprefix+'_shortinfo_cleaningheader_'+shortinfo.catentryid_parent).show();
	 		  $('#'+shortinfo.segementprefix+'_shortinfo_cleaning1_'+shortinfo.catentryid_parent).attr('src',this.iconspath+shortinfo.cleaning1+'.gif');
	 		  if (shortinfo.cleaning2 != '-') $('#'+shortinfo.segementprefix+'_shortinfo_cleaning2_'+shortinfo.catentryid_parent).attr('src',this.iconspath+shortinfo.cleaning2+'.gif');
	 		  if (shortinfo.cleaning3 != '-') $('#'+shortinfo.segementprefix+'_shortinfo_cleaning3_'+shortinfo.catentryid_parent).attr('src',this.iconspath+shortinfo.cleaning3+'.gif');
	 		  if (shortinfo.cleaning4 != '-') $('#'+shortinfo.segementprefix+'_shortinfo_cleaning4_'+shortinfo.catentryid_parent).attr('src',this.iconspath+shortinfo.cleaning4+'.gif');
	 		  if (shortinfo.cleaning5 != '-') $('#'+shortinfo.segementprefix+'_shortinfo_cleaning5_'+shortinfo.catentryid_parent).attr('src',this.iconspath+shortinfo.cleaning5+'.gif');
	 		}

	
	 	for (var i = 1; i <= shortinfo.countsmallimages; i++)
	 	{  
	 		$('#'+shortinfo.segementprefix+'_shortinfo_smallimage'+(i)+'_'+shortinfo.catentryid_parent).html('<img src="'+shortinfo.imagePath.replace('x1x1','x'+i+'x5')+'" width="83" height="81" />');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_smallimage'+(i)+'_'+shortinfo.catentryid_parent).show();
	 	}
	  
	 	if ((shortinfo.material1 != 'none' && shortinfo.material1 != '-') ||
	 			(shortinfo.material2 != 'none' && shortinfo.material2 != '-'))
	 	{
		 	if (shortinfo.material1 != 'none' && shortinfo.material1 != '-') 
		 		$('#'+shortinfo.segementprefix+'_shortinfo_materialicon_'+shortinfo.catentryid_parent).attr('src',this.iconspath + shortinfo.material1 + '.gif');
		 	else 
		 		$('#'+shortinfo.segementprefix+'_shortinfo_materialicon_'+shortinfo.catentryid_parent).hide();
		 	if (shortinfo.material2 != 'none' && shortinfo.material2 != '-') 
		 	{
		 		$('#'+shortinfo.segementprefix+'_shortinfo_materialtext_'+shortinfo.catentryid_parent).html(shortinfo.material2);	
		 	}
	 		$('#'+shortinfo.segementprefix+'_shortinfo_materialheader_'+shortinfo.catentryid_parent).show();
	 	}else
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_materialicon_'+shortinfo.catentryid_parent).hide();
	 		//$('#'+shortinfo.segementprefix+'_shortinfo_materialtext_'+shortinfo.catentryid_parent).html(shortinfo.material2);
	 		//$('#'+shortinfo.segementprefix+'_shortinfo_materialheader_'+shortinfo.catentryid_parent).show();
	 	}
	 	
	 	if (shortinfo.material3 != 'none' && shortinfo.material3 != '-')
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_sleevecontent_'+shortinfo.catentryid_parent).html(shortinfo.material3);
	 		$('#'+shortinfo.segementprefix+'_shortinfo_sleeveheader_'+shortinfo.catentryid_parent).show();
	 		$('#'+shortinfo.segementprefix+'_shortinfo_sleevecontent_'+shortinfo.catentryid_parent).show();
	 	}
	 	if (shortinfo.material4 != 'none' && shortinfo.material4 != '-')
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_lengthcontent_'+shortinfo.catentryid_parent).html(shortinfo.material4);
	 		$('#'+shortinfo.segementprefix+'_shortinfo_lengthheader_'+shortinfo.catentryid_parent).show();
	 		$('#'+shortinfo.segementprefix+'_shortinfo_lengthcontent_'+shortinfo.catentryid_parent).show();
	 	}
	 	
		
		
	 	if (shortinfo.logo != undefined && shortinfo.logo != '-')
		  {
	       $('#'+shortinfo.segementprefix+'_shortinfo_logo_'+shortinfo.catentryid_parent).attr('src',this.iconspath.replace('icons/','logos/')+shortinfo.logo+'.gif');
		  }
	 	else	 	
 		{ 	
	 		if (shortinfo.brand != undefined && shortinfo.brand != '-')
		 	{		 	 
		 		$('#'+shortinfo.segementprefix+'_shortinfo_logo_'+shortinfo.catentryid_parent).attr('src',this.iconspath.replace('icons/','brands/')+shortinfo.brand +'x1.png');
		 	}
 		}
	 	
	 	
	 	//$('#'+shortinfo.segementprefix+'_shortinfo_productimage_'+shortinfo.catentryid_parent).fadeIn('slow');
}	
				
				

CommonProducts.prototype.renderShortInfoByCount = function (shortinfo,count)
{
	   
	  
		$('#'+shortinfo.segementprefix+'_shortinfo_productimage_'+count).hide();
		$('#'+shortinfo.segementprefix+'_shortinfo_productimageL_'+count).hide();
		$('#'+shortinfo.segementprefix+'_shortinfo_productimageXL_'+count).hide();
	 	$('#'+shortinfo.segementprefix+'_shortinfo_productimageXL_'+count).attr('src',shortinfo.imagePath);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_productimageL_'+count).attr('src',shortinfo.imagePath.replace('x1x1','x1x2'));
	 	$('#'+shortinfo.segementprefix+'_shortinfo_productimage_'+count).attr('src',shortinfo.imagePath.replace('x1x1','x1x2'));
	 
	 	if (parseFloat(shortinfo.listprice) > parseFloat(shortinfo.price))	{	
	 		$('#'+shortinfo.segementprefix+'_shortinfo_listprice_'+count).html(shortinfo.listprice.toString().replace('.',',') + ' ' + shortinfo.currency);	
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconL_'+count).attr('src',this.iconspath + this.iconprefix + '-' + roundValue(shortinfo.savepercentage,0) + '_' + 'L' + '.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconXL_'+count).attr('src',this.iconspath + this.iconprefix + '-' + roundValue(shortinfo.savepercentage,0) + '_' + 'XL' + '.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_savetext_'+count).show();	 		
	 	}
	 	else
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_listprice_'+count).html('');	
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconL_'+count).attr('src',this.iconspath + 'icon-trans.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconXL_'+count).attr('src',this.iconspath + 'icon-trans.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_savetext_'+count).hide();	 
	 	}
	 	
	 	if (shortinfo.isnew == true)
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconL_'+count).attr('src',this.iconspath + 'iconNew_L' + '.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconXL_'+count).attr('src',this.iconspath + 'iconNew_XL' + '.gif');	
	 	}
	 	
	 	
	 	if (shortinfo.brand != undefined && shortinfo.brand != '-')
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_brandicon_'+count).attr('src',this.iconspath.replace('icons/','brands/')+shortinfo.brand +'x1.png');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_brandiconsmall_'+count).attr('src',this.iconspath.replace('icons/','brands/')+shortinfo.brand +'x2.png');
	 	}else
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_brandicon_'+count).attr('src',this.iconspath + 'icon-trans.gif');
	 		$('#'+shortinfo.segementprefix+'_shortinfo_brandiconsmall_'+count).attr('src',this.iconspath + 'icon-trans.gif');
	 	}
	 	
	 	if (shortinfo.availablesoon != undefined && shortinfo.availablesoon == '1' && shortinfo.issoldout == true) 
	 	{
	 	  $('#'+shortinfo.segementprefix+'_shortinfo_soon_'+count).attr('src',this.iconspath.replace('icons/','')+'teaserSize_XL_ikv_Overlay.gif');
	 	  $('#'+shortinfo.segementprefix+'_shortinfo_soonsmall_'+count).attr('src',this.iconspath.replace('icons/','')+'teaserSize_L_ikv_Overlay.gif');
	 	}	 
	 	else
	 	{
	 		if (shortinfo.issoldout == true)
		 	{
		 	  $('#'+shortinfo.segementprefix+'_shortinfo_soldoutbig_'+count).attr('src',this.iconspath.replace('icons/','')+'teaserSize_XL_ola_Overlay.gif');
		 	  $('#'+shortinfo.segementprefix+'_shortinfo_soldoutsmall_'+count).attr('src',this.iconspath.replace('icons/','')+'teaserSize_L_ola_Overlay.gif');
		 	}
		 	else
		 	{
		 	   $('#'+shortinfo.segementprefix+'_shortinfo_soldoutbig_'+count).attr('src',this.iconspath + 'icon-trans.gif');
			   $('#'+shortinfo.segementprefix+'_shortinfo_soldoutsmall_'+count).attr('src',this.iconspath + 'icon-trans.gif');

		 	}	
	 		
	 	   $('#'+shortinfo.segementprefix+'_shortinfo_soon_'+count).attr('src',this.iconspath + 'icon-trans.gif');
		   $('#'+shortinfo.segementprefix+'_shortinfo_soonsmall_'+count).attr('src',this.iconspath + 'icon-trans.gif');

	 	}
	 	
	 	var abStr = '';
	 	if (parseFloat(shortinfo.minPrice) < parseFloat(shortinfo.maxPrice)) 
	 	{ 
	 	  abStr = 'ab ';
	 	}
	
	 	
	 	$('#'+shortinfo.segementprefix+'_shortinfo_price_'+count).html(abStr + shortinfo.price.toString().replace('.',',') + ' ' + shortinfo.currency);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_name_'+count).html(shortinfo.name);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_shortdesc_'+count).html(shortinfo.shortdesc);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_longdesc_'+count).html(shortinfo.longdesc);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_size_'+count).html(shortinfo.color);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_partnumber_'+count).html(shortinfo.partnumber);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_categoryname_'+count).html(shortinfo.categoryName + ' &raquo;');
	 	$('#'+shortinfo.segementprefix+'_shortinfo_categoryidlink_'+count).attr('href','CategoryDisplay?parentCategoryId='+this.currentCategoryId+'&level=2&catalogId='+this.catalogId+'&identifier='+shortinfo.categoryIdentifier+'&langId='+this.langId+'&storeId='+this.storeId);
	 	$('#'+shortinfo.segementprefix+'_shortinfo_savepercentage_'+count).html(roundValue(shortinfo.savepercentage,0));
	  	$('#'+shortinfo.segementprefix+'_shortinfo_quickproductlink_'+count).attr('href','ProductQuickDisplayView?catalogId='+this.catalogId+'&langId='+this.langId+'&storeId='+this.storeId+'&productId='+shortinfo.catentryid_parent+'&categoryId='+this.currentCategoryId);
	 	

	
		if (shortinfo.cleaning1 != '-')
 		{
 		  $('#'+shortinfo.segementprefix+'_shortinfo_cleaningheader_'+count).show();
 		  $('#'+shortinfo.segementprefix+'_shortinfo_cleaning1_'+count).attr('src',this.iconspath+shortinfo.cleaning1+'.gif');
 		  if (shortinfo.cleaning2 != '-') $('#'+shortinfo.segementprefix+'_shortinfo_cleaning2_'+count).attr('src',this.iconspath+shortinfo.cleaning2+'.gif');
 		  if (shortinfo.cleaning3 != '-') $('#'+shortinfo.segementprefix+'_shortinfo_cleaning3_'+count).attr('src',this.iconspath+shortinfo.cleaning3+'.gif');
 		  if (shortinfo.cleaning4 != '-') $('#'+shortinfo.segementprefix+'_shortinfo_cleaning4_'+count).attr('src',this.iconspath+shortinfo.cleaning4+'.gif');
 		  if (shortinfo.cleaning5 != '-') $('#'+shortinfo.segementprefix+'_shortinfo_cleaning5_'+count).attr('src',this.iconspath+shortinfo.cleaning5+'.gif');
 		}
	 	
	 	
		for (var i = 1; i <= shortinfo.countsmallimages; i++)
	 	{
	 		$('#'+shortinfo.segementprefix+'_shortinfo_smallimage'+(i)+'_'+count).hide();
	 	}
	 	
		
		
		if (shortinfo.logo != undefined && shortinfo.logo != '-')
 		{
 			$('#'+shortinfo.segementprefix+'_shortinfo_logo_'+count).attr('src',this.iconspath.replace('icons/','logos/')+shortinfo.logo+'.gif');
 		}
		
		else
 		{
			if (shortinfo.brand != undefined && shortinfo.brand != '-')
		    {
			 		$('#'+shortinfo.segementprefix+'_shortinfo_logo_'+count).attr('src',this.iconspath.replace('icons/','brands/')+shortinfo.brand +'x1.png');
			}
 		}
		
	 	$('#'+shortinfo.segementprefix+'_shortinfo_productimage_'+count).fadeIn('slow');
	 	$('#'+shortinfo.segementprefix+'_shortinfo_productimageXL_'+count).fadeIn('slow');
	 	$('#'+shortinfo.segementprefix+'_shortinfo_productimageL_'+count).fadeIn('slow');
		
	  	
	
	  	if (shortinfo.SEOUrl != undefined)
	  		if (shortinfo.SEOUrl != undefined)
		  	{
		  	  $('#'+shortinfo.segementprefix+'_shortinfo_productlink_'+count).attr('href','/' + escape(shortinfo.SEOUrl));
		  	
		  	}else
		  	{
		  		if (this.SEOProductURL != undefined) {
			  		
			  		var newurl = this.SEOProductURL;
			  		newurl = newurl.replace('--productId--',shortinfo.catentryid_parent);		  		
			  		newurl = newurl.replace('--name--',escape(shortinfo.name));
			  		
			  	  $('#'+shortinfo.segementprefix+'_shortinfo_productlink_'+count).attr('href',newurl);
			 	}
			 	
			
		  	}
	  	
	  	

}

CommonProducts.prototype.hideContainerByCount = function ( count)
{		
	$('#'+this.segmentprefix+'_element_'+count).hide();	
	if ($('#'+this.segmentprefix+'_element_'+count).parent().children('div:visible').length == 0) {
		$('#'+this.segmentprefix+'_element_'+count).parent().hide();
	}
}
CommonProducts.prototype.showContainerByCount = function ( count)
{		
	$('#'+this.segmentprefix+'_element_'+count).show();
	$('#'+this.segmentprefix+'_element_'+count).parent().show();	
	
}


CommonProducts.prototype.enableHighlighting = function()
{
	$(".teaserHasOverlay").hover(
			function() {
				$(this).addClass('borderStyle_1');
				$(this).find(".overlayFastview").css("display", "block");
			},
			function() {
				$(this).removeClass('borderStyle_1');
				$(this).find(".overlayFastview").css("display", "none");
			}
		);

	   
}

CommonProducts.prototype.showShortInfoProducts = function (segmentprefix)
{
    productIdsArray = getDistinctValuesFrom2DArray(this.array, this.productattributes.CATENTRY_ID_PARENT_INDEX);        

	$('.categorylist_shortinfo_contentholder').hide();

	for (x=0;x<productIdsArray.length;x++)
	{	  
	  $('#'+segmentprefix+'_shortinfo_product_'+productIdsArray[x]).fadeIn(2000);
	}
}

function getAttributeIndex(productattributes,attributeName)
{
	attrindex = -1;
	if (productattributes.filterNamesString != null)
	{
		namesarray = productattributes.filterNamesString.split(',');
	    
		for (i=0;i<namesarray.length;i++)
		{
			
		  	if (namesarray[i] == attributeName)
		  	{
		  		
		  	  switch (i)
		  	  {
		  	   case 0 : return productattributes.CATENTRY_USERDEF1_INDEX;
		  	   case 1 : return productattributes.CATENTRY_USERDEF2_INDEX;
		       case 2 : return productattributes.CATENTRY_USERDEF3_INDEX;
		  	   case 3 : return productattributes.CATENTRY_USERDEF4_INDEX;
		  	   case 4 : return productattributes.CATENTRY_USERDEF5_INDEX;
		  	   case 5 : return productattributes.CATENTRY_USERDEF6_INDEX;
		       case 6 : return productattributes.CATENTRY_USERDEF7_INDEX;
		  	   case 7 : return productattributes.CATENTRY_USERDEF8_INDEX;
		  	   case 8 : return productattributes.CATENTRY_USERDEF9_INDEX;
		  	   case 9 : return productattributes.CATENTRY_USERDEF10_INDEX;
		       case 10 : return productattributes.CATENTRY_USERDEF11_INDEX;
		  	   case 11 : return productattributes.CATENTRY_USERDEF12_INDEX;
		  	   case 12 : return productattributes.CATENTRY_USERDEF13_INDEX;
		  	   case 13 : return productattributes.CATENTRY_USERDEF14_INDEX;
		       case 14 : return productattributes.CATENTRY_USERDEF15_INDEX;
		  	   case 15 : return productattributes.CATENTRY_USERDEF16_INDEX;
		  	   case 16 : return productattributes.CATENTRY_USERDEF17_INDEX;
		  	   case 17 : return productattributes.CATENTRY_USERDEF18_INDEX;
		  	   case 18 : return productattributes.CATENTRY_USERDEF19_INDEX;
		  	   case 19 : return productattributes.CATENTRY_USERDEF20_INDEX;
		  	
		  	  }
		  	  
		  	}
		}
	}	
	return attrindex;
}

CommonProducts.prototype.filterByCustomAttributeValue = function(attributeName, attributeValue)
{
	var attrindex = getAttributeIndex(this.productattributes,attributeName);			
	this.array = filter2DArray(this.array,attrindex,attributeValue);        
}

CommonProducts.prototype.filterByPrice = function(price)
{		
	this.array = filter2DArray(this.array,this.productattributes.CATENTRY_PRICE_INDEX,price);    
	this.createProductShortInfos(false);

}



CommonProducts.prototype.filterAll = function()
{ 
	
	
	this.resetProducts();
	
	if (this.filter.sortmode == SORTMODE_PRICEASC)
	{
	  sortindexmulti = this.productattributes.CATENTRY_PRICE_INDEX;
	  this.array = this.array.sort(sortMultiDimensionalNumberASC);
	}
	if (this.filter.sortmode == SORTMODE_PRICEDESC)
	{
	  sortindexmulti = this.productattributes.CATENTRY_PRICE_INDEX;
	  this.array = this.array.sort(sortMultiDimensionalNumberDESC);
	}
	
	if (this.filter.sortmode == SORTMODE_BEST)
	{
	  sortindexmulti = this.productattributes.CATENTRY_RANK_INDEX;
	  this.array = this.array.sort(sortMultiDimensionalNumberASC);
	}
	
	if (this.filter.sortmode == SORTMODE_NEW)
	{
	  sortindexmulti = this.productattributes.CATENTRY_WEBDATE_INDEX;
	  this.array = this.array.sort(sortMultiDimensionalDESC);
	}
	
	if (this.filter.color != '')
	{
	  this.filterByColor(this.filter.color);	
	}
	if (this.filter.size != '')
	{
	  this.filterBySize(this.filter.size);	
	}
	if (this.filter.category != '')
	{
	 
	  this.filterByCategory(this.filter.category);	
	}
	if (this.filter.salenew != '')
	{
	  var filterval = this.filter.salenew;
	 
	  if (this.filter.salenew == 'Sale') filterval = 'S';
	  if (this.filter.salenew == 'Neu') filterval = 'N'; 
	  if (this.filter.salenew == 'Sale/Neu') filterval = 'SN';	  
	
	  this.filterBySaleNew(filterval);
	}

	this.createProductShortInfos(false);
}

CommonProducts.prototype.isFilterEmpty == function()
{
	return (this.filter.color == '' && this.filter.size == '');
}

CommonProducts.prototype.resetSort = function()
{
	this.filter.sortmode = 0;
}

CommonProducts.prototype.setFilterColor = function(color)
{
	this.filter.color = color;
}

CommonProducts.prototype.setFilterSize= function(size)
{
	this.filter.size = size;
}

CommonProducts.prototype.setFilterCategory= function(category)
{
	this.filter.category = category;
}

CommonProducts.prototype.setFilterSaleNew= function(salenew)
{
	this.filter.salenew = salenew;
}

CommonProducts.prototype.filterByColor = function(color)
{		
	
	var attrindex = getAttributeIndex(this.productattributes,'COLORD');
	
	this.array = filter2DArray(this.array,attrindex,color);    

	
}

CommonProducts.prototype.filterBySize = function(size)
{		
	
	var attrindex = getAttributeIndex(this.productattributes,'SIZED');
	this.array = filter2DArray(this.array,attrindex,size);    
	
}

CommonProducts.prototype.filterByCategory = function(category)
{			
	var attrindex = getAttributeIndex(this.productattributes,'CATEGORY');
	this.array = filter2DArray(this.array,attrindex,category);    	
}

CommonProducts.prototype.filterBySaleNew = function(salenew)
{			

	var attrindex = getAttributeIndex(this.productattributes,'SALENEU');
	var stmp = filter2DArray(this.array,attrindex,salenew); 
	var stmp2 =  filter2DArray(this.array,attrindex,'NS'); 
	this.array = stmp.concat(stmp2);  

}


CommonProducts.prototype.getCurrentShortInfo = function()
{
	if (this.currentProductId != null)
	{
	  	for(var i=0;i<this.shortinfos.length;i++)
	  	{
	  	  	if (this.currentProductId == this.shortinfos[i].catentryid_parent)
	  	  		{ 
	  	  		  return this.shortinfos[i];
	  	  		}
	  	}
	}
	return null;
}

CommonProducts.prototype.getArrayByCatentryId = function(catentryId)
{
	if (catentryId != null)
	{
		if (this.shortinfos.length == 1)
		{
					
	  		tmp = filter2DArray(this.shortinfos[0].itemArray, this.productattributes.CATENTRY_ID_INDEX, catentryId);
	  		return tmp;
		}
			
	 
	}
	return null;
}


CommonProducts.prototype.createProductAttributeDropDown = function (containerId,  attributeName,title)
{

	shortinfo = this.getCurrentShortInfo();
	
	var attrindex = getAttributeIndex(this.productattributes,attributeName);	
	var values = getDistinctValuesFrom2DArray(shortinfo.itemArray, attrindex);
	
	var dropdown = '<ul id="dd_'+attributeName+'" class="sf-menu"><li class="current"><a id="'+attributeName+'_header" class="sf-with-ul" href="#">'+title+'<span class="sf-sub-indicator">&#187;</span></a><ul>';

	for (var i=0;i<values.length;i++)
	{	
	  dropdown = dropdown + "<li><a href=\"#\" onclick=\"javascript:changeTitleOnSelection('"+attributeName+"_header','"+values[i]+"'); \">"+values[i]+"</a></li>";
	}
	
	dropdown = dropdown + '</ul></li></ul>';
	
	$('#'+containerId).html(dropdown);
	
	
}

CommonProducts.prototype.sortByPriceASC = function()
{
	this.filter.sortmode = SORTMODE_PRICEASC;   
}

CommonProducts.prototype.sortByPriceDESC = function()
{
	this.filter.sortmode = SORTMODE_PRICEDESC;	
}

CommonProducts.prototype.sortByBestseller = function()
{
	this.filter.sortmode = SORTMODE_BEST;	
}

CommonProducts.prototype.sortByNewest = function()
{
	this.filter.sortmode = SORTMODE_NEW;	
}


var sortindexmulti = 0;
function sortMultiDimensionalNumberASC(a,b)
{     
 return ((a[sortindexmulti]* 1.0 < b[sortindexmulti]* 1.0) ? -1 : ((a[sortindexmulti]* 1.0 > b[sortindexmulti]* 1.0) ? 1 : 0));
}

function sortMultiDimensionalNumberDESC(b,a)
{     
	return ((a[sortindexmulti]* 1.0 < b[sortindexmulti]* 1.0) ? -1 : ((a[sortindexmulti]* 1.0 > b[sortindexmulti]* 1.0) ? 1 : 0));
}



function sortMultiDimensionalASC(a,b)
{     
 return ((a[sortindexmulti] < b[sortindexmulti]) ? -1 : ((a[sortindexmulti] > b[sortindexmulti]) ? 1 : 0));
}

function sortMultiDimensionalDESC(a,b)
{     
	
 return ((a[sortindexmulti]  > b[sortindexmulti] ) ? -1 : ((a[sortindexmulti] < b[sortindexmulti]) ? 1 : 0));
}

function sortSizesMulti(a,b)
{    
 
 var atemp = a[sortindexmulti];
 var btemp = b[sortindexmulti];

 if (atemp == 'XXS') atemp = 'AA';
 if (atemp == 'XS') atemp = 'AB';
 if (atemp == 'S') atemp = 'AC';
 if (atemp == 'M') atemp = 'BA';
 if (atemp == 'L') atemp = 'BB';
 if (atemp == 'XL') atemp = 'BC';
 if (atemp == 'XXL') atemp = 'BD';
 if (atemp == 'XXXL') atemp = 'BE';
 if (atemp == '4XL') atemp = 'BF';
 if (atemp == '5XL') atemp = 'BG';
 if (atemp == '6XL') atemp = 'BH';
 if (atemp != undefined && atemp != '') {
 if ((isInt(atemp) && atemp.length == 2) || (atemp.length == 6 && atemp.indexOf('/') > 0)) 
 {
	 atemp = '0' + atemp;
 }
 }

 
 
 if (btemp == 'XXS') btemp = 'AA';
 if (btemp == 'XS') btemp = 'AB';
 if (btemp == 'S') btemp = 'AC';
 if (btemp == 'M') btemp = 'BA';
 if (btemp == 'L') btemp = 'BB';
 if (btemp == 'XL') btemp = 'BC';
 if (btemp == 'XXL') btemp = 'BD';
 if (btemp == 'XXXL') btemp = 'BE';
 if (btemp == '4XL') btemp = 'BF';
 if (btemp == '5XL') btemp = 'BG';
 if (btemp == '6XL') btemp = 'BH'; 
 if (btemp != undefined && btemp != '') {
 if ((isInt(btemp) && btemp.length == 2) || (btemp.length == 6 && btemp.indexOf('/') > 0)) 
 {
	 btemp = '0' + btemp;
 }
 }
 
 return ((atemp  < btemp ) ? -1 : ((atemp > btemp) ? 1 : 0));
}


function sortSizes(a,b)
{    
 
 var atemp = a;
 var btemp = b;
 
 if (atemp == 'XXS') atemp = 'AA';
 if (atemp == 'XS') atemp = 'AB';
 if (atemp == 'S') atemp = 'AC';
 if (atemp == 'M') atemp = 'BA';
 if (atemp == 'L') atemp = 'BB';
 if (atemp == 'XL') atemp = 'BC';
 if (atemp == 'XXL') atemp = 'BD';
 if (atemp == 'XXXL') atemp = 'BE';
 if (atemp == '4XL') atemp = 'BF';
 if (atemp == '5XL') atemp = 'BG';
 if (atemp == '6XL') atemp = 'BH';
 if (atemp != undefined && atemp != '') {
 if ((isInt(atemp) && atemp.length == 2) || (atemp.length == 6 && atemp.indexOf('/') > 0))
 {
	 atemp = '0' + atemp;
 }
 }

 
 if (btemp == 'XXS') btemp = 'AA';
 if (btemp == 'XS') btemp = 'AB';
 if (btemp == 'S') btemp = 'AC';
 if (btemp == 'M') btemp = 'BA';
 if (btemp == 'L') btemp = 'BB';
 if (btemp == 'XL') btemp = 'BC';
 if (btemp == 'XXL') btemp = 'BD';
 if (btemp == 'XXXL') btemp = 'BE';
 if (btemp == '4XL') btemp = 'BF';
 if (btemp == '5XL') btemp = 'BG';
 if (btemp == '6XL') btemp = 'BH'; 

 if (btemp != undefined && btemp != '') {
	 if ((isInt(btemp) && btemp.length == 2)  || (btemp.length == 6 && btemp.indexOf('/') > 0) )
	 {
		 btemp = '0' + btemp;
	 }
 }
 
 return ((atemp  < btemp ) ? -1 : ((atemp > btemp) ? 1 : 0));
}


function isInt(x) { 
	   var y=parseInt(x); 
	   if (isNaN(y)) return false; 
	   return x==y && x.toString()==y.toString(); 
	 } 

CommonProducts.prototype.enableFilter = function()
{

}



CommonProducts.prototype.createCategoryColorFilter= function(containerId, none, title)
{
	var attributeName = 'COLORD';
	var attrindex = getAttributeIndex(this.productattributes,attributeName);	
	var values = getDistinctValuesFrom2DArray(this.array, attrindex);
	
	var colorval = '';
	var dropdown = '';
		
	values.sort();
	dropdown = dropdown + $('#'+containerId).html();
	for (var i=0;i<values.length;i++)
	{	
	  
		
		colorval = values[i];
		if (colorval == 'none') colorval = none; 			
		dropdown = dropdown + '<a id="'+i+'_color" onclick="javascript:filterByColor(\''+values[i]+'\')" ddval="'+values[i]+'">'+colorval+'</a>';
		  
	  
	}
	
	$('#'+containerId).html(dropdown);
	
}

CommonProducts.prototype.createCategorySizeFilter= function(containerId, none, title)
{

	
	var attributeName = 'SIZED';
	var attrindex = getAttributeIndex(this.productattributes,attributeName);	
	var values = getDistinctValuesFrom2DArray(this.productattributes.catalogEntriesPropertiesArray, attrindex);
	var sizeval = '';
   
	var dropdown = '';
	
	dropdown = dropdown + $('#'+containerId).html();
	values.sort(sortSizes);
	for (var i=0;i<values.length;i++)
	{	
	  
		
		sizeval = values[i];
		if (sizeval == 'none') sizeval = none; 			
		dropdown = dropdown + '<a id="'+i+'_size" onclick="javascript:filterBySize(\''+values[i]+'\')" ddval="'+values[i]+'">'+sizeval+'</a>';
		  
	  
	}
	
	$('#'+containerId).html(dropdown);
	
	
	
	
}

CommonProducts.prototype.createCategoryCategoryFilter= function(containerId, none, title)
{
	var attributeName = 'CATEGORY';
	var attrindex = getAttributeIndex(this.productattributes,attributeName);	
	var values = getDistinctValuesFrom2DArray(this.array, attrindex);
	var categoryval = '';
	var dropdown = '';
		
	
	dropdown = dropdown + $('#'+containerId).html();
	for (var i=0;i<values.length;i++)
	{	
	  
		
		categoryval = values[i];
		if (categoryval == 'none') categoryval = none; 			
		dropdown = dropdown + '<a id="'+i+'_category" onclick="javascript:filterByCategory(\''+values[i]+'\')" ddval="'+values[i]+'">'+categoryval+'</a>';
		  
	  
	}
	
	$('#'+containerId).html(dropdown);
	
}

CommonProducts.prototype.createCategorySaleNewFilter= function(containerId, none, title)
{
	var attributeName = 'SALENEU';
	var attrindex = getAttributeIndex(this.productattributes,attributeName);	
	var values = getDistinctValuesFrom2DArray(this.array, attrindex);
	var salenewval = '';
	var dropdown = '';
		
	
	dropdown = dropdown + $('#'+containerId).html();
	var saleisindd = false;
	var newisindd = false;
	for (var i=0;i<values.length;i++)
	{	
	  
		
		salenewval = values[i];
		if (salenewval ==  'S') 
		{
			salenewval = 'Sale'; 
			if (saleisindd == false) {
			  dropdown = dropdown + '<a id="'+i+'_salenew" onclick="javascript:filterBySaleNew(\'S\')" ddval="Sale">Sale</a>';
			  saleisindd = true;
			}
		}		
		if (salenewval ==  'N')
		{
			salenewval = 'Neu'; 
			if (newisindd == false) {
			  dropdown = dropdown + '<a id="'+i+'_salenew" onclick="javascript:filterBySaleNew(\'N\')" ddval="Neu">Neu</a>';
			  newisindd = true;
			}
		}
		if (salenewval ==  'NS')
		{ 
			  if (saleisindd == false) {
			    dropdown = dropdown + '<a id="'+i+'_salenew" onclick="javascript:filterBySaleNew(\'S\')" ddval="Sale">Sale</a>';
			    saleisindd = true;
			  }
			  if (newisindd == false) {
			    dropdown = dropdown + '<a id="'+i+'_salenew" onclick="javascript:filterBySaleNew(\'N\')" ddval="Neu">Neu</a>';
			    newisindd = true;
			  }
		}
	
	}
	
	$('#'+containerId).html(dropdown);
	
}




CommonProducts.prototype.fillColorDropDown = function(containerId,title)
{

	shortinfo = this.getCurrentShortInfo();

	var attributeName = 'COLOR';
	var attrindex = getAttributeIndex(this.productattributes,attributeName);	
	
	var values = getDistinctValuesFrom2DArrayWithInventoryAll(shortinfo.itemArray, attrindex, this.productattributes.CATENTRY_INVENTORY_INDEX, shortinfo.catentryid_parent, this.productattributes.CATENTRY_ID_PARENT_INDEX);
   
	var colorval = '';
	var dropdown = '';
	values.sort(sortSizesMulti);
	//dropdown = dropdown + '<option value="-1">'+title+'</option>';	
  
    var isselected = false;
	for (var i=0;i<values.length;i++)
	{	 
	   		
		if (values[i][1] > 0) {
			if (isselected==true) {
			  dropdown = dropdown + '<option  value="'+values[i][0]+'">'+values[i][0]+'</option>';
			}else
			{
				 dropdown = dropdown + '<option  selected="selected" value="'+values[i][0]+'">'+values[i][0]+'</option>';
				 isselected = true;
			}
		}
		else {
			dropdown = dropdown + '<option  disabled="disabled"  value="'+values[i][0]+'">'+values[i][0]+'</option>';
		}
			
	}
	
	
	$('#'+containerId).html(dropdown);
	if (colorval == 'none')
	{
		$('#'+containerId).hide();
		$('#colorlabel').hide();	
		$('#'+containerId).parent().append('<input id="colordd" type="hidden" name="color" value="none" />');
	}
}

CommonProducts.prototype.setSelectedColor = function(color)
{
	

	shortinfo = this.getCurrentShortInfo();
	
	if (color == -1) 	{
		shortinfo.selectedColor  = undefined;
		}
		else {
			shortinfo.selectedColor = color;
		}
	
	
		
}

CommonProducts.prototype.setSelectedSize = function(size)
{
	shortinfo = this.getCurrentShortInfo();
	if (size == -1) 	{
	  shortinfo.selectedSize = undefined;
	}
	else {
		shortinfo.selectedSize = size;
	}
		
}

CommonProducts.prototype.selectSizeDropDownByCatentry = function(catentryId, containerId)
{
	tmparray = this.getArrayByCatentryId(catentryId);
	sizeindex = getAttributeIndex(this.productattributes,'SIZE');	  
	
	$('#'+containerId).val(tmparray[0][sizeindex]);
}

CommonProducts.prototype.selectColorDropDownByCatentry = function(catentryId, containerId)
{
	tmparray = this.getArrayByCatentryId(catentryId);
	
	colorindex = getAttributeIndex(this.productattributes,'COLOR');	

	$('#'+containerId).val(tmparray[0][colorindex]);
}

CommonProducts.prototype.fillSizeDropDown = function(containerId, colorval, title)
{
	var attributeName = 'SIZE';

	var shortinfo = this.getCurrentShortInfo();
	
	var attrindex = getAttributeIndex(this.productattributes,attributeName);	
	var colorindex =  getAttributeIndex(this.productattributes,'COLOR');	

	var values = getDistinctValuesFrom2DArrayWithInventory(shortinfo.itemArray, attrindex, this.productattributes.CATENTRY_INVENTORY_INDEX, colorval, colorindex);

	sortindexmulti = 0;
	values.sort(sortSizesMulti);

	var dropdown = '';
	//dropdown = dropdown + '<option value="-1">'+title+'</option>';
	var countFilled = 0;
	var sizeval = '';
    var isselected = false;
  
	for (var i=0;i<values.length;i++)
	{	 
		if (i == 0) {
			sizeval = values[i][0];
		}
	   		
		if (values[i][1] > 0) {
			if (isselected==true) {
			  dropdown = dropdown + '<option  value="'+values[i][0]+'">'+values[i][0]+'</option>';
			}else
			{
				 dropdown = dropdown + '<option  selected="selected" value="'+values[i][0]+'">'+values[i][0]+'</option>';
				 isselected = true;
			}
		}
		else {
			dropdown = dropdown + '<option  disabled="disabled"  value="'+values[i][0]+'">'+values[i][0]+'</option>';
		}
			
	}
	
	if (isselected == false && sizeval != 'none') {
		dropdown = dropdown + '<option  selected="selected" value="-1">'+title+'</option>';

	}
	
	
	$('#'+containerId).html(dropdown);
	
	if (sizeval == 'none')
	{
		$('#'+containerId).hide();
		$('#sizelabel').hide();		
		$('#groessenbeartung').hide();
		$('#'+containerId).parent().append('<input id="sizedd" type="hidden" name="size" value="none" />');
	}
	
}


CommonProducts.prototype.changeTitleOnSelection = function (headerId,selectedValue,type)
{

	shortinfo = this.getCurrentShortInfo();
	if (type == 'COLOR')
	{
	  shortinfo.selectedColor = selectedValue;	
	}
	if (type == 'SIZE')
	{
	  shortinfo.selectedSize = selectedValue;	
	}
	$('#'+headerId).html(selectedValue + '<span class="sf-sub-indicator">&#187;</span>');
	
}



CommonProducts.prototype.getSelectedCatentryId = function()
{
		shortinfo = this.getCurrentShortInfo();
	   
	  	if (shortinfo.selectedColor != undefined && shortinfo.selectedSize != undefined)
	  	{
	  		colorindex = getAttributeIndex(this.productattributes,'COLOR');	
	  		sizeindex = getAttributeIndex(this.productattributes,'SIZE');
	  		tmp = filter2DArray(shortinfo.itemArray, colorindex, shortinfo.selectedColor);	  		
	  		tmp2 = filter2DArray(tmp, sizeindex, shortinfo.selectedSize);
	  		if (tmp2 == '') {
	  			return '';
	  		}
	  		else {
	  			if (tmp2.length > 1)
	  				{
	  					for(i=0;i<tmp2.length;i++)
	  						{
	  						  if (parseInt(tmp2[i][this.productattributes.CATENTRY_INVENTORY_INDEX]) > 0)
	  							  {
	  							    return tmp2[i][this.productattributes.CATENTRY_ID_INDEX];
	  							  }
	  						  
	  						}
	  					return tmp2[0][this.productattributes.CATENTRY_ID_INDEX];
	  				}else
	  					{
	  						return tmp2[0][this.productattributes.CATENTRY_ID_INDEX];
	  					}
	  		}
	  	}
	  	return '';
	
}




CommonProducts.prototype.changePartNumber = function()
{
		shortinfo = this.getCurrentShortInfo();

		for (xx=0;xx<shortinfo.itemArray.length;xx++)
		{		
			if (shortinfo.itemArray[xx][getAttributeIndex(this.productattributes,'COLOR')] == shortinfo.selectedColor)
			{ 
				if (parseInt(shortinfo.itemArray[xx][this.productattributes.CATENTRY_INVENTORY_INDEX]) > 0)
					{
						var tpartnumber = shortinfo.itemArray[xx][this.productattributes.CATENTRY_PARTNUMBER_INDEX];
		  	        	$('#'+shortinfo.segementprefix+'_shortinfo_partnumber_'+shortinfo.catentryid_parent).html(tpartnumber);
		  	        	break;
					}
  	        	
			}
	  	}
	
}

CommonProducts.prototype.changePrice = function()
{
		shortinfo = this.getCurrentShortInfo();

		for (xx=0;xx<shortinfo.itemArray.length;xx++)
		{		
			if (shortinfo.itemArray[xx][getAttributeIndex(this.productattributes,'COLOR')] == shortinfo.selectedColor 
			 && shortinfo.itemArray[xx][getAttributeIndex(this.productattributes,'SIZE')] == shortinfo.selectedSize
			 && parseInt(shortinfo.itemArray[xx][this.productattributes.CATENTRY_INVENTORY_INDEX]) > 0)
			{
				
				var tprice = roundPrice(shortinfo.itemArray[xx][this.productattributes.CATENTRY_PRICE_INDEX],2);
				if (parseFloat(shortinfo.listprice) > 0)
				{
					tsavepercentage = (100 - (parseFloat(tprice) / parseFloat(shortinfo.listprice) * 100));
					
					if (parseFloat(shortinfo.listprice) > parseFloat(tprice))	{	
				 		$('#'+shortinfo.segementprefix+'_shortinfo_listprice_'+shortinfo.catentryid_parent).html(shortinfo.listprice.toString().replace('.',',') + ' ' + shortinfo.currency);	
				 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + this.iconprefix + '-' + roundValue(tsavepercentage,0) + '_' + 'L' + '.gif');
				 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconXL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + this.iconprefix + '-' + roundValue(tsavepercentage,0) + '_' + 'XL' + '.gif');	
				 		$('#'+shortinfo.segementprefix+'_shortinfo_savepercentage_'+shortinfo.catentryid_parent).html(roundValue(tsavepercentage,0));				 		
				 		$('#'+shortinfo.segementprefix+'_shortinfo_savetext_'+shortinfo.catentryid_parent).show();
				 	}	
				 	else
				 	{
				 		$('#'+shortinfo.segementprefix+'_shortinfo_listprice_'+shortinfo.catentryid_parent).html('');	
				 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');
				 		$('#'+shortinfo.segementprefix+'_shortinfo_diffIconXL_'+shortinfo.catentryid_parent).attr('src',this.iconspath + 'icon-trans.gif');
				 		$('#'+shortinfo.segementprefix+'_shortinfo_savetext_'+shortinfo.catentryid_parent).hide();	 
				 	}		
				}
  	        
  	        	$('#'+shortinfo.segementprefix+'_shortinfo_price_'+shortinfo.catentryid_parent).html(tprice.toString().replace('.',',') + ' ' + shortinfo.currency);
  	        	
  	        	
  	        	break;
			}
	  	}
	
}

 
