var SearchFormClaim = {
	create: function( hParams ){
		hParams.eA.onclick = function(){
			SearchFormClaim.oForm = hParams.oForm;
			Common.Utils.popup( hParams.eA.href, 'orderform', {iWidth:800,iHeight:750} );
			SearchFormClaim.onload();
			return false;
		}
	}

	, onload: function(){
		var eTextarea = false;
		if( oNewWindow && oNewWindow.document ){
			eTextarea = oNewWindow.document.getElementsByTagName('textarea');
			if( eTextarea.length ){
				eTextarea = eTextarea[0];
				SearchFormClaim.aeLabel = [];
				eTextarea.value = SearchFormClaim.print_values( SearchFormClaim.oForm ).replace( /(<[^>]+>|(.|\n)*параметрам\s*)/g, '' ).replace( /(.+)(\n(Цена|Ежемесячная плата):.+)/, '$2$1' ).replace( /(&nbsp;|[\t ][\t ]+)/g, ' ' ).replace( /^[\t ]+/mg, '' );
			}else{
				eTextarea = false;
			}
		}
		if( oNewWindow && !eTextarea ){
			setTimeout( 'SearchFormClaim.onload()', 300 );
		}
	}

	, print_values: function( oWidget ){
		var sResult = '';
		if( oWidget.getChildren ){
			var aoWidget = oWidget.getChildren();
			for( var i = 0, sID, sName, sType, aeLabel, sValue, sLabel, sInner ; i < aoWidget.length ; i++ ){
				sID = aoWidget[i].getId();
				sName = aoWidget[i].getName();
				if(
					!aoWidget[i].isEnabled()
					|| Common.Class.match( aoWidget[i].oElement, 'hidden(_too)?' )
					|| ( sName && sName.match( /^(ShowAs|SearchType|PageSize|sort_by|sort_direction|CityId|HighwayId)$/ ) )
				){
					continue;
				}
				sType = '';
				if( aoWidget[i] instanceof SelectInput ){
					sType = 'select';
				}else if( aoWidget[i] instanceof InputGroup ){
					sType = 'group';
				}else if( aoWidget[i] instanceof StateInput ){
					sType = 'check';
				}else if( aoWidget[i] instanceof FieldContainer ){
					sType = 'set';
				}
				if( sType == 'check' && !aoWidget[i].isChecked() ){
					continue;
				}
				if( sType == 'set' ){
					aeLabel = Common.Dom.getElementsByClassName( aoWidget[i].oClassElement, 'legend' );
				}else if( sType == 'check' ){
					aeLabel = aoWidget[i].oClassElement.getElementsByTagName( 'label' );
				}else{
					aeLabel = aoWidget[i].oClassElement.getElementsByTagName( 'dt' );
					aeLabel = aeLabel[0] ? aeLabel[0].getElementsByTagName( 'label' ) : false;
				}
				sLabel = '';
				if( aeLabel && aeLabel[0] && !SearchFormClaim.aeLabel.contains( aeLabel[0] ) ){
					SearchFormClaim.aeLabel[SearchFormClaim.aeLabel.length] = aeLabel[0];
					sLabel = aeLabel[0].innerHTML;
				}
				sValue = '';
				if( !sType ){
					sValue =  aoWidget[i].getValue().toStr();
				}else if( sType == 'check' ){
					sValue = sLabel;
					sLabel = '';
				}else if( sType == 'select' ){
					sValue = aoWidget[i].oElement.options[aoWidget[i].oElement.selectedIndex].innerHTML;
				}
				if( Common.Class.match( aoWidget[i].oClassElement, 'popup_selected' ) ){
					var eNew = aoWidget[i].oClassElement.cloneNode( true );
					var aeEmpty = Common.Dom.getElementsByClassName( eNew, 'empty' );
					for( var j = 0 ; j < aeEmpty.length ; j++ ){
						aeEmpty[j].parentNode.removeChild( aeEmpty[j] );
					}
					var sTemp = eNew.innerHTML.replace( /\s*<(ins|INS)[^>]+pseudo-link[^>]*>/g, ', ' ).replace( /(<[^>]+>|люб(ой|ые|ое)[^\s<]*)/g, '' ).replace( /[\t ]+/g, ' ' ).replace( /\s*\n+\s*/g, '\n' ).replace( /^\s*,\s*/, '' ).replace( /\s*,\s*$/g, '.' ).replace( /\s*,\s*,\s*/g, '.\n' ).replace( /:\s+/g, ': ' );
					if( sTemp ){
						sResult += '\n\n' + sTemp;
					}
				}else{
					sInner = SearchFormClaim.print_values( aoWidget[i] );
					if( sValue != '' ){
						sResult += sLabel + ( sLabel && sLabel.length > 2 ? ': ' : ' ' ) + sValue + ' ';
					}else if( sType && sInner ){
						if( sLabel ){
							if( sType == 'set' ){
								sResult += '\n';
							}
							sResult += '\n' + sLabel;
						}
						sResult += '\n' + sInner.replace( /^\n+/, '' ) + '';
					}
				}
			}
		}
		return sResult;
	}

};

