﻿/*!
 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
 
var MX_CONTACT = Ext.extend(Ext.util.Observable, {
    constructor: function(config){
        this.addEvents('finished'); // specify the events we're going to fire
        MX_CONTACT.constructor.call(this, config);
    },
	
    create: function(pid, i, value){
		var inner = '';
		var min = '';
		var max = '';
		var begin = '';
		var end = '';
		if (value.length > 0){
			var jsonData = Ext.util.JSON.decode(value.substring(3,value.length-3));
			
			if (jsonData.type == 2) {	//texte
				var k = 0;
				while (k < jsonData.blocks.length){	
					var j = 0;
					var themes = jsonData.blocks[k].list.split('|||');
					var themes2 = jsonData.blocks[k].list2.split('|||');
					
					while (j < themes2.length){
						if (themes2[j].length > 0){
							if (themes[j] !== undefined){
								inner += '<div class="mt_results_mx_contact_title">';
								inner += themes[j];
								inner += '</div>';
							}
							
							inner += '<div class="mt_results_mx_contact_item">';
							if (isValidURL(themes2[j])){
								if (getProtocol(themes2[j]) == 'http:'){
									inner += '<a href="'+themes2[j]+'" target="_blank">'+themes2[j]+'</a>';
								}
								else{
									inner += '<a href="http://'+themes2[j]+'" target="_blank">'+themes2[j]+'</a>';
								}
							}
							else{
								inner += themes2[j];
							}
							inner += '</div>';
						}
						j++;
					}
					k++;
				}
			}
		}
		
		this.panel = new Ext.Panel({ 
			id: 'mt_results_mx_contact-'+i,
			cls: 'mt_results_mx_contact',
			hideLabel: true,
			layout:'form',
			width:'auto',
			html: inner
		});
		
		this.fireEvent('finished', this.panel);
	}	
});
