
function ShopOrder(){
	
	this.ids = [ 'product_category', 'product_description', 'product_material', 
	             'product_amount', 'product_printcover',
	             'product_printmethodcolor', 'product_printmethod', 'product_sizeforms',
	             'product_types', 'product_sizes'];
	
	this.cols = [ 'category', 'product', 'material', 'amount', 'printcover', 'print_methodcolor', 'printmethod', 'sizeforms', 'types', 'sizes' ];
	
	this.articleId;
	
	this.setDisable = function ( id ) {
		
		var elm = document.getElementById(id);
		if ( elm != null ) {
			elm.disabled = true;
		}
	}
	
	this.getOptionValue = function(el){
		var elm = document.getElementById(el);
		if(elm != null) {
			var v = elm[elm.selectedIndex].value;
			return v;
		}
		return 0;
	}
	
	this.getExtra = function(){
		
		var tmpStr = '';
		for (var i=0; i < this.cols.length; i++) {
			tmpStr += this.cols[i]+':' + this.getOptionValue( this.ids[i] ) + ',';
		}		
		return tmpStr;
	}
	
	this.setListeners = function(){
		
		var oThis = this;
		
		for (var i=0; i < this.ids.length; i++) {
			
			YAHOO.util.Event.removeListener ( this.ids[i] );
			YAHOO.util.Event.addListener(this.ids[i], "change", function(){
				oThis.callServer( oThis );
			});			
		}
	}
	
	this.callServer = function(obj){
/*		
		if(pUp !=null) {
			pUp.show();
		}
*/		
		var comId = document.getElementById('shopComId');
		if( comId != null ) {
			comId = comId.value;
		}
		
		var success = function ( response ) {

			document.getElementById('aOrderForm').innerHTML = response;
			obj.setListeners();
			obj.setDisable ( 'product_category' );
			obj.setDisable ( 'product_description' );
			//pUp.hide();
		};
		
		var other = { "extra" : obj.getExtra(), "componentid" : comId, "article" : obj.articleId };
		WawClient.callComponent ( 'shopcart', 'view', 'get_selected_article', success, 'html', other );    
	}
}

var oShopOrder;
YAHOO.util.Event.onDOMReady(function(){
	oShopOrder = new ShopOrder();
	var elmArticle = document.getElementById('articleId');
	if(elmArticle != null){
		oShopOrder.articleId = elmArticle.value;
	}
	oShopOrder.setListeners();
	oShopOrder.setDisable ( 'product_category' );
	oShopOrder.setDisable ( 'product_description' );
}); 
