function filter(n, m){

$("#NoMatches").css("display", "none");
$(".contentsT").css("display", "none");
//if(m==1){
//document.getElementById("SelectColor").selectedIndex = 0;
//}
//else{
//document.getElementById("SelectSize").selectedIndex = 0;
//}


if(document.getElementById("SelectColor").value=="contentsT"&&document.getElementById("SelectSize").value=="contentsT"){
$(".contentsT").css("display", "block");
}

else{
if(m==1){

	
	if(n=="contentsT"){
		for(var i=1; i<document.getElementById("SelectSize").length; i++)
		{
		//$("."+n).css("display", "block");
		//alert("."+n+document.getElementById("SelectSize").options[i].value);
		$("."+document.getElementById("SelectSize").options[i].value+document.getElementById("SelectColor").value).css("display", "block");
		}
		
	}
	else{
	
		if(document.getElementById("SelectColor").value=="contentsT"){
		
		
		for(var i=1; i<document.getElementById("SelectColor").length; i++)
		{
		//$("."+n).css("display", "block");
		//alert("."+n+document.getElementById("SelectColor").options[i].value);
		$("."+n+document.getElementById("SelectColor").options[i].value).css("display", "block");
		
		}
		
		}
		else{
		$("."+n+document.getElementById("SelectColor").value).css("display", "block");
		
		}
	
	}

	}
else{


	if(n=="contentsT")
	{
		for(var i=1; i<document.getElementById("SelectColor").length; i++)
		{
		//$("."+n).css("display", "block");
		//alert("."+n+document.getElementById("SelectSize").options[i].value);
		$("."+document.getElementById("SelectSize").value+document.getElementById("SelectColor").options[i].value).css("display", "block");
		}

	}
	else{
	
		if(document.getElementById("SelectSize").value=="contentsT"){
		
		
		for(var i=1; i<document.getElementById("SelectSize").length; i++)
		{
		//$("."+n).css("display", "block");
		//alert("."+n+document.getElementById("SelectSize").options[i].value);
		$("."+document.getElementById("SelectSize").options[i].value+n).css("display", "block");
		//alert("."+document.getElementById("SelectSize").options[i].value+n);
		}
		
		}
		else{
		$("."+document.getElementById("SelectSize").value+n).css("display", "block");
		//alert("."+document.getElementById("SelectSize").value+n);
		}
	}

}
}



if($(".contentsT:visible").length==0)
{
$("#NoMatches").css("display", "block");
}

}



var distinctColors=new Array();
var distinctColorFlag=0;

document.write("<select id=\"SelectSize\" name=\"colorsSelect\" onchange=\"filter(this.value, 1);\">");
document.write("<option value=\"contentsT\">Select Color</option>");

for (i=0;i<colors.length;i++){

	for (j=0;j<distinctColors.length;j++){
	
		
		if(distinctColors[j]==colors[i]){
		distinctColorFlag=1;
		}
		
	}

	if (distinctColorFlag==0){
	
	distinctColors[distinctColors.length]=colors[i];
	
	}
	else{
	
	distinctColorFlag=0;
	
	}

}

for (i=0;i<distinctColors.length;i++){

	document.write("<option value=\"");
	document.write(distinctColors[i].split(' ').join(''));
	document.write("\">");
	document.write(distinctColors[i]);
	document.write("</option>");

}

document.write("</select>");

/////////////////////////////////////////////////////////////////////////////////////////////////////


var distinctSizes=new Array();
var distinctSizeFlag=0;

document.write("<select id=\"SelectColor\" name=\"sizeSelect\" onchange=\"filter(this.value, 2);\">");
document.write("<option value=\"contentsT\">Select Size</option>");

for (i=0;i<sizes.length;i++){

	for (j=0;j<distinctSizes.length;j++){
	
		
		if(distinctSizes[j]==sizes[i]){
		distinctSizeFlag=1;
		}
		
	}

	if (distinctSizeFlag==0){
	
	distinctSizes[distinctSizes.length]=sizes[i];
	
	}
	else{
	
	distinctSizeFlag=0;
	
	}

}

for (i=0;i<distinctSizes.length;i++){

	document.write("<option value=\"");
	var tempSize=distinctSizes[i].split(' ').join('');
	tempSize=tempSize.split('.').join('');
	document.write(tempSize.split('/').join(''));
	
	document.write("\">");
	document.write(distinctSizes[i]);
	document.write("</option>");
	
	

}

document.write("</select>");
