function OptionListAttribute(name, value) {
	this.name=name;
	this.value=value;
	
	this.getName=function() {
		return this.name;
	}
	this.getValue=function() {
		return this.value;
	}		
}

// todo use Size.prototype
function Color(name, value){
	this.name=name;
	this.value=value;
	
	this.getName=function() {
		return this.name;
	}
	this.getValue=function() {
		return this.value;
	}
	
		
}

// todo use Size.prototype
function Size(name, value){
	this.name=name;
	this.value=value;
	
	this.getName=function() {
		return this.name;
	}
	this.getValue=function() {
		return this.value;
	}
	this.getNormalized=function() {		
		var result1 = this.name;
       	n = 4 - this.name.length;
        for(i=0;i<n;i++) {
            result1 = '0'+result1;            
        }
        return result1;				
	}	
		
}


function Variant(color, size, oldPrice, price, sku, infoColombus, isDiscount, markdown, thumbsArray, zoomArray) {
	
	this.color=color;
	this.size=size;
	this.oldPrice=oldPrice;
	this.price=price;				
	this.sku=sku;
	this.infoColombus=infoColombus;
	this.isDiscount=isDiscount;
	this.markdown=markdown;
	this.thumbsArray=thumbsArray;
	this.zoomArray=zoomArray;
	
	this.getColor=function() {
		return this.color;
	}
	
	this.getSize=function(){
		return this.size;
	}
	
	this.getOldPrice=function(){
		return this.oldPrice;
	}
	
	this.getPrice=function(){
		return this.price;
	}
	
	this.getSku=function(){
		return this.sku;
	}
	
	this.getInfoColombus=function(){
		return this.colombusInfo;
	}
	
	this.getIsDiscount=function(){
		return this.isDiscount;
	}
	
	this.getMarkdown=function(){
		return this.markdown;
	}
	
	this.getzoomArray=function(){
		return this.zoomArray;
	}
	
	this.getthumbsArray=function(){
		return this.thumbsArray;
	}
}
  function TrierColAsc(x1,x2){   
     return (x1.getNormalized().toUpperCase() < x2.getNormalized().toUpperCase())? -1 : 1;
  }  
  
function Product(){
	this.variants = new Array();	
		
	this.addVariant=function (variant) {		
		this.variants[this.variants.length]=variant;
	}
	
	this.getVariants=function (){
		return this.variants;
	}
	
	this.getAvailableSize=function(colorValue){
		var result = new Array();
		for(i=0; i<this.variants.length; i++){
			if ( this.variants[i].getColor().getValue()==colorValue ) 
			{
				var found=false;
				// excluding duplicate entry
				for(j=0; j<result.length; j++) {					
					if ( result[j].getValue()==this.variants[i].getSize().getValue()) {
						found=true;
					}
				}
				if( !found && (this.variants[i].getPrice() != null) ) {					
					 //alert(this.variants[i].getPrice());
					 result[result.length]=this.variants[i].getSize();
				}
			}
		}
		result.sort(TrierColAsc);
		return result;
	}		
	
	this.findVariant=function(colorValue, sizeValue) {
		var result = new Array();
		for(i=0; i<this.variants.length; i++){
			if ( this.variants[i].getColor().getValue()==colorValue && this.variants[i].getSize().getValue()==sizeValue ) 
			{
				return this.variants[i];
			}
		}
		return null;
	}
	
}
