function manageCardsPage(vc_id) {
	if (!vc_id) vc_id='' ;
	if (!MyVCFApp.ManageCards) {
		MyVCFApp.ManageCards = new MyVCFApp.ManageCardsObj({}) ;
		MyVCFApp.setView(MyVCFApp.ManageCards, $("#div_main_managecard").hide()) ;
		MyVCFApp.ManageCards.drawCardEdit($("#div_cardToEdit")) ;
	} else {
	}
	MyVCFApp.initPage('div_main_managecard', 2) ;
	MyVCFApp.ManageCards.loadCards(false, vc_id) ;
}

MyVCFApp.ManageCardsObj = $.inherit(MyVCFApp.View, {
	scope: this,
	_initView: function() {
		this.idLinkSupress = MyVCFApp.Utils.nextId() ;
	},
	moveArrow: function() {
		if (!MyVCFApp.currentCard) return ;
		var p = $("#a_cardname_"+MyVCFApp.currentCard.vc_id).position() ;
		var w = $("#a_cardname_"+MyVCFApp.currentCard.vc_id).width() ;
		//var p2 = $("#a_cardname_"+data.vc_id).position() ;
		//window.setTimeout(function() {
			$("#div_arrowallcards").show().css({top:p.top+31, left:Math.ceil(p.left+w/2)-12}) ;
		//}, 1000) ;
	},
	_generate: function() {
		var txt = "" ;
		txt += "<div id='div_arrowallcards'></div>" ;
		txt += "<h1>"+i18n.my_cards+"<!-- <a href='javascript:void(0);' onclick='welcomePage();'>"+i18n.back+"</a>--></h1>" ;
		txt += "<div style='padding:0 0 10px 0;'>"+i18n.welcome_manage_cards+"</div>" ;
		txt += "<div style='background-color:#b3c5cf; height:100px; margin-bottom:10px; overflow:auto;' id='div_managecards_cards'></div>" ;
		txt += "<div id='div_cardToEdit' class='fleft'></div>" ;
		txt += "<div class='cardinfo'><form action='#' method='POST'><div style='padding:0 0 10px 0; font-weight:bold;'><span class='red'>"+i18n.help+" :</span> "+i18n.help_modify_card+"</div><div>"+i18n.card_name+" :</div><div id='div_managecards_vc_cardname'></div><div>"+i18n.card_option+"</div><div id='div_managecards_vc_right'></div><div id='div_bt_savecardname'></div><div><a id='"+this.idLinkSupress+"' href='javascript:void(0);'>"+i18n.delete_card+"</a></div><div style='margin-top:10px;'>"+i18n.link_of_card+" (<a href='javascript:void(0);' onclick='MyVCFApp.ManageCards.showHelpEmail();'>"+i18n.insert_on_my_email+"</a>)</div><div id='div_managecards_mainlink'></div>" ;
		txt += "<div style='margin-top:10px;'>"+i18n.share_on_social_network+" :</div>" ;
		txt += "<div id='div_manage_facebook'></div>" ;
		txt += "</form></div>" ;
		txt += "<div class='clear'></div>" ;
		return txt ;
	},
	showHelpEmail: function() {
		MyVCFApp.Alert.show(i18n.insert_on_email_explain) ;
	},
	generateFacebook: function(vc_cardname, vc_lastname) {
		//var fb = '<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fmyvcf.3doublev.fr%2F'+vc_name+'&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>' ;
		/*
		var fb = '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://myvcf.3doublev.fr/'+vc_name+'" layout="button_count" show_faces="true" width="150" font=""></fb:like>' ;
		$('#div_manage_facebook').html(fb) ;
		FB.init({appId: 'your app id', status: true, cookie: true, xfbml: true});
		*/
		var idT = MyVCFApp.Utils.nextId() ;
		$("#div_manage_facebook").html("<div id='"+idT+"'></div>") ;
		addthis.button("#"+idT, {}, {url: "http://"+MyVCFApp.hostname+"/"+vc_cardname, title: i18n.card_of+" "+vc_lastname});

	},
	_generateEvents: function() {
		this.__base() ;
		$("#"+this.idLinkSupress).click({view:this}, function(evt) {
			evt.data.view.deleteCard() ;
		}) ;
	},
	_onRender: function() {
		var tf = new MyVCFApp.TextField({
			id: 'tf_managecards_vc_cardname',
			name: 'vc_cardname',
			emptyText: i18n.card_name,
			style: 'width:130px;'
		}) ;
		tf.render($('#div_managecards_vc_cardname')) ;

		var tf2 = new MyVCFApp.TextField({
			id: 'tf_managecards_mainlink',
			name: 'mainlink',
			style: 'width:130px;'
		}) ;
		tf2.render($('#div_managecards_mainlink')) ;

		var sf = new MyVCFApp.SelectField({
			id: 'tf_managecards_vc_right',
			name: 'vc_right',
			style: 'width:130px;',
			selectOptions: i18n.tabTypesCard
		}) ;
		sf.render($('#div_managecards_vc_right')) ;

		var bt = new MyVCFApp.Button({
			text: i18n.save,
			scope: this,
			onClick: function(evt) {
				var valCardName = $('#tf_managecards_vc_cardname').val() ;
				if (valCardName.length<=3) {
					$('#tf_managecards_vc_cardname').val(MyVCFApp.currentCard.vc_cardname) ;
					MyVCFApp.Alert.show(i18n.more_than_6_char) ;
					return false ;
				}
				$.ajax({
					type: 'POST',
					url: 'io.php',
					data: {action:'saveForCardname', vc_id:MyVCFApp.currentCard.vc_id, vc_cardname:$('#tf_managecards_vc_cardname').val(), vc_right:$('#tf_managecards_vc_right').val()},
					context: this,
					dataType: 'json',
					success: function(data) {
						//this.loadCards() ;
						if (!data.success) {
							MyVCFApp.Alert.show(i18n.card_name_already_existcard_name_already_exist) ;
						}
						MyVCFApp.updateCard(this.idCard, data.card, true) ;
					}
				});
			}
		}) ;
		bt.render($('#div_bt_savecardname')) ;

	},
	deleteCard: function() {
		var txt = "" ;
		txt += i18n.lincked_to_part1+" "+MyVCFApp.currentCard.nbRelations+" "+i18n.lincked_to_part2 ;
		txt += "<form action=''>" ;
		txt += "<select name='sel_manage_choosecard' id='sel_manage_choosecard'><option value=''>Aucune</option>" ;
		var tabCards = MyVCFApp.tabCards ;
		for(i=0 ; i<tabCards.length ; i++) {
			if (tabCards[i].vc_id==MyVCFApp.currentCard.vc_id) continue ;
			if (tabCards[i].vc_id=='') continue ;
			if (tabCards[i].vc_right!=0) continue ;
			txt += "<option value='"+tabCards[i].vc_id+"'>"+tabCards[i].vc_cardname+"</option>" ;
		}
		txt += "</select>" ;
		txt += "</form><br/><br/>" ;
		MyVCFApp.Confirm.show(txt, function() {
			//alert("choix"+$('#sel_manage_choosecard').val()) ;
			$.ajax({
				type: 'POST',
				url: 'io.php',
				data: {action: 'deleteCard', vc_id: MyVCFApp.currentCard.vc_id, reattribute:$('#sel_manage_choosecard').val()},
				context: this,
				dataType: 'json',
				success: function(data) {
					//this.loadCards(false,'') ;
					MyVCFApp.ManageCards.loadCards(false, '') ;
				}
			});
		}) ;
		/*
		if (window.confirm(i18n.confirm_delete_card+" "+i18n.lincked_to_part1+" "+MyVCFApp.currentCard.nbRelations+" "+i18n.lincked_to_part2)) {
			$.ajax({
				type: 'POST',
				url: 'io.php',
				data: {action: 'deleteCard', vc_id: MyVCFApp.currentCard.vc_id},
				context: this,
				dataType: 'json',
				success: function(data) {
					this.loadCards(false,'') ;
				}
			});
		}
		*/
	},
	createGraphicsCard: function() {
		log("createGraphicsCard") ;
		$("#a_cardname_"+MyVCFApp.currentCard.vc_id).prepend("<div style='position:relative; width:0; height:0;'><div style='position:absolute; left:20px; top:10px;'><img src='/statics/images/large-loading.gif' alt='' /></div></div>") ;
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'createGraphicsCard', vc_id:MyVCFApp.currentCard.vc_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				//this.loadCards(false) ;
				$("#a_cardname_"+MyVCFApp.currentCard.vc_id).html("<img width='83' height='50' src='/dynamics/pp_"+MyVCFApp.currentCard.vc_id+".png?d="+(new Date()).getMilliseconds()+"' alt='' /><br/>"+MyVCFApp.currentCard.vc_cardname) ;
			}
		});
	},
	loadCards: function(createNewCard, vc_id) {
		var create = 0 ;
		if (createNewCard) create=1 ;
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'getCards',createNewCard:create, vc_id:vc_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				MyVCFApp.tabCards = data.tabCards ;
				MyVCFApp.tabCards.push({vc_id:'', vc_cardname:i18n.new_card, vc_right:0}) ;
				//var tabIdsLinks = [] ;
				var txt = "" ;
				for(var i=0 ; i<MyVCFApp.tabCards.length ; i++) {
					var idTemp = MyVCFApp.Utils.nextId() ;
					//log("/dynamics/pp_"+MyVCFApp.tabCards[i].vc_id+".jpg") ;
					var img = "/statics/images/pp_.png" ;
					if (MyVCFApp.tabCards[i].vc_id!='') img = "/dynamics/pp_"+MyVCFApp.tabCards[i].vc_id+".png" ;
					txt += "<div class='div_manage_allcards'><a id='a_cardname_"+MyVCFApp.tabCards[i].vc_id+"' href='javascript:void(0);'><img width='83' height='50' src='"+img+"?d="+(new Date()).getMilliseconds()+"' alt='' /><br/><span id='span_managecard_name_"+MyVCFApp.tabCards[i].vc_id+"'>"+MyVCFApp.tabCards[i].vc_cardname+"</span></a></div>" ;
					//tabIdsLinks.push([idTemp, MyVCFApp.tabCards[i].vc_id]) ;
				}
				
				txt += "<div class='clear'></div>" ;
				$("#div_managecards_cards").html(txt) ;
				
				for(var i=0 ; i<MyVCFApp.tabCards.length ; i++) {
					$("#a_cardname_"+MyVCFApp.tabCards[i].vc_id).click({view:this, vc_id:MyVCFApp.tabCards[i].vc_id}, function(evt) {
						evt.data.view.loadCard(evt.data.vc_id) ;
					}) ;
				}
				if (MyVCFApp.tabCards.length>0) {
					MyVCFApp.updateCard(this.idCard, data.card, true) ;
				}
			}
		});
	},
	loadCard: function(vc_id) {
		this.closeAllWin() ;
		if (vc_id=='') {
			this.loadCards(true,'') ;
			return ;
		}
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'getCard', vc_id: vc_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				MyVCFApp.updateCard(this.idCard, data.card, true) ;
			}
		});
	},
	drawCardEdit: function(jqEl) {
		this.idCard = MyVCFApp.drawCard(jqEl, true) ;
	},
	closeAllWin: function() {
		if (this.winForName) this.winForName.hide() ;
		if (this.winForOrganisation) this.winForOrganisation.hide() ;
		if (this.winForTelephons) this.winForTelephons.hide() ;
		if (this.winForEmails) this.winForEmails.hide() ;
		if (this.winForAddresses) this.winForAddresses.hide() ;
		if (this.winForNotes) this.winForNotes.hide() ;
		if (this.winForImg) this.winForImg.hide() ;
	},
	showWinForName: function(evt) {
		this.closeAllWin() ;
		if (!this.winForName) {
			this.winForName = new MyVCFApp.WinProperties({
				items: [
					new MyVCFApp.View({
						html: "<h2 style='margin:0 0 10px 0; padding:0; color:white;'>"+i18n.your_identity+"</h2>"
					}),
					new MyVCFApp.Form({
						ref: 'form',
						url: 'io.php',
						scope: this,
						onSubmit: function(data) {
							this.winForName.hide() ;
							MyVCFApp.updateCard(this.idCard, data.card, true) ;
							this.createGraphicsCard() ;
						},
						items: [
							new MyVCFApp.View({
								id: 'div_managecards_infoname',
								html: "<i>"+i18n.loading+"</i>"
							}),
							new MyVCFApp.View({
								ref: 'view_form',
								items: [
									new MyVCFApp.TextField({
										ref: 'vc_firstname',
										name: 'vc_firstname',
										emptyText: i18n.firstname
									}),
									new MyVCFApp.TextField({
										ref: 'vc_lastname',
										name: 'vc_lastname',
										emptyText: i18n.name
									})
								]
							}),
							new MyVCFApp.Button({
								ref: '',
								text: i18n.save,
								scope: this,
								onClick: function(evt) {
									this.winForName.findByRef('form').submit({action:'saveForName', vc_id:MyVCFApp.currentCard.vc_id}) ;
								}
							})
						]
					})
				],
				onBeforeShow: function() {
					return true ;
				}
			}) ;
			this.winForName.openForm = function() {
				this.findByRef('view_form').getEl().slideDown() ;
				$('#div_managecards_infoname').slideUp() ;
			} ;
			this.winForName.closeForm = function() {
				this.findByRef('view_form').getEl().hide() ;
				$('#div_managecards_infoname').show() ;
			} ;
		}
		this.winForName.showAt(evt.pageX+20, evt.pageY-50) ;
		this.winForName.findByRef('form').reset() ;
		this.winForName.closeForm() ;
		//$("#div_managecards_infoname").html("") ;
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'getInfoName', vc_id: MyVCFApp.currentCard.vc_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				//log("data", data) ;
				var txt = "" ;
				var idLink = MyVCFApp.Utils.nextId() ;
				if (data.tabNames.length<=1) this.winForName.openForm() ;
				//data.tabNames.push({vc_id:'',vc_firstname:'Aucune',vc_lastname:'identité'}) ;
				for(var i=0 ; i<data.tabNames.length ; i++) {
					var checked = "" ;
					if (data.tabNames[i].checked==1) checked = "checked='checked'" ;
					txt += "<div class='pointilles'><div class='float'><input "+checked+" type='radio' name='vc_id_' id='vc_id_"+data.tabNames[i].vc_id+"' value='"+data.tabNames[i].vc_id+"' /></div>" ;
					txt += "<div class='float'><label for='vc_id_"+data.tabNames[i].vc_id+"'>"+data.tabNames[i].vc_firstname+" / "+data.tabNames[i].vc_lastname+"</label></div>" ;
					txt += "<div class='clear'></div></div>" ;
				}
				txt += "<div style='padding-bottom:10px;'><a id='"+idLink+"' href='javascript:void(0);'>"+i18n.new_identity+"</a></div>" ;
				$("#div_managecards_infoname").html(txt) ;
				$("#"+idLink).click({view:this},function(evt) {
					evt.data.view.winForName.openForm()
				}) ;
			}
		});		
	},
	showWinForOrganisation: function(evt) {
		this.closeAllWin() ;
		if (!this.winForOrganisation) {
			this.winForOrganisation = new MyVCFApp.WinProperties({
				items: [
					new MyVCFApp.View({
						html: "<h2 style='margin:0 0 10px 0; padding:0; color:white;'>"+i18n.your_society_and_function+"</h2>"
					}),
					new MyVCFApp.Form({
						ref: 'form',
						url: 'io.php',
						scope: this,
						onSubmit: function(data) {
							this.winForOrganisation.hide() ;
							MyVCFApp.updateCard(this.idCard, data.card, true) ;
							this.createGraphicsCard() ;
						},
						items: [
							new MyVCFApp.View({
								id: 'div_managecards_infoorganisation',
								html: "<i>"+i18n.loading+"</i>"
							}),
							new MyVCFApp.View({
								ref: 'view_form',
								items: [
									new MyVCFApp.TextField({
										ref: 'vc_organisation',
										name: 'vc_organisation',
										emptyText: i18n.society
									}),
									new MyVCFApp.TextField({
										ref: 'vc_title',
										name: 'vc_title',
										emptyText: i18n.function_
									})
								]
							}),
							new MyVCFApp.Button({
								text: i18n.save,
								scope: this,
								onClick: function(evt) {
									this.winForOrganisation.findByRef('form').submit({action:'saveForOrganisation', vc_id:MyVCFApp.currentCard.vc_id}) ;
								}
							})
						]
					})
				],
				onBeforeShow: function() {
					return true ;
				}
			}) ;
			this.winForOrganisation.openForm = function() {
				this.findByRef('view_form').getEl().slideDown() ;
				$('#div_managecards_infoorganisation').slideUp() ;
			} ;
			this.winForOrganisation.closeForm = function() {
				this.findByRef('view_form').getEl().hide() ;
				$('#div_managecards_infoorganisation').show() ;
			} ;
		}
		this.winForOrganisation.showAt(evt.pageX+20, evt.pageY-50) ;
		this.winForOrganisation.findByRef('form').reset() ;
		this.winForOrganisation.closeForm() ;
		//$("#div_managecards_infoorganisation").html("") ;
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'getInfoOrganisation', vc_id: MyVCFApp.currentCard.vc_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				//log("data", data) ;
				var txt = "" ;
				var idLink = MyVCFApp.Utils.nextId() ;
				if (data.tabOrganisations.length<=1) this.winForOrganisation.openForm() ;
				for(var i=0 ; i<data.tabOrganisations.length ; i++) {
					var checked = "" ;
					if (data.tabOrganisations[i].checked==1) checked = "checked='checked'" ;
					txt += "<div class='pointilles'><div class='float'><input "+checked+" type='radio' name='vc_id_' id='vc_id_"+data.tabOrganisations[i].vc_id+"' value='"+data.tabOrganisations[i].vc_id+"' /></div>" ;
					txt += "<div class='float'><label for='vc_id_"+data.tabOrganisations[i].vc_id+"'>"+data.tabOrganisations[i].vc_title+" / "+data.tabOrganisations[i].vc_organisation+"</label></div>" ;
					txt += "<div class='clear'></div></div>" ;
				}
				txt += "<div style='padding-bottom:10px;'><a id='"+idLink+"' href='javascript:void(0);'>Nouvelle société / fonction</a></div>" ;
				$("#div_managecards_infoorganisation").html(txt) ;
				$("#"+idLink).click({view:this},function(evt) {
					evt.data.view.winForOrganisation.openForm()
				}) ;
			}
		});		
	},
	showWinForImg: function(evt) {
		this.closeAllWin() ;
		if (!this.winForImg) {
			this.winForImg = new MyVCFApp.WinProperties({
				items: [
					new MyVCFApp.View({
						html: "<h2 style='margin:0 0 10px 0; padding:0; color:white;'>"+i18n.your_image+"</h2>"
					}),
					new MyVCFApp.Form({
						ref: 'form',
						url: 'io.php',
						scope: this,
						onSubmit: function(data) {
							this.winForImg.hide() ;
							MyVCFApp.updateCard(this.idCard, data.card, true) ;
							this.createGraphicsCard() ;
						},
						items: [
							new MyVCFApp.View({
								id: 'div_managecards_infoimg',
								html: "<i>"+i18n.loading+"</i>"
							}),
							new MyVCFApp.View({
								ref: 'view_form',
								items: [
									new MyVCFApp.BrowseField({
										ref: 'vc_photo',
										id: 'vc_photo_edit',
										name: 'vc_photo',
										emptyText: ""
									})
								]
							}),
							new MyVCFApp.Button({
								text: i18n.save,
								scope: this,
								onClick: function(evt) {
									//this.winForImg.findByRef('form').submit({action:'saveForImg', vc_id:MyVCFApp.currentCard.vc_id}) ;
									var f = $("#"+MyVCFApp.ManageCards.winForImg.findByRef('form').id).get(0) ;
									var sel = '' ;
									for(var i=0 ; i<f.vc_photo_.length ; i++) {
										if (f.vc_photo_[i].checked) sel = f.vc_photo_[i].value ;
									}
									$.ajaxFileUpload({
										url:'io.php?action=sendPhoto&vc_id='+MyVCFApp.currentCard.vc_id+"&sel="+sel, 
										secureuri:false,
										fileElementId:'vc_photo_edit',
										context: this,
										dataType: 'json',
										success: function (data, status) {
											log('dataokokok0',data) ;
											//log('status',status) ;
											MyVCFApp.ManageCards.winForImg.hide() ;
											log('dataokokok1',data) ;
											this.createGraphicsCard() ;
											log('dataokokok2',data) ;
											MyVCFApp.updateCard(MyVCFApp.ManageCards.idCard, data.card, true) ;
											log('dataokokok3',data) ;
											if(typeof(data.error) != 'undefined') {
												if(data.error != '') {
													//alert(data.error);
												} else {
													//alert(data.msg);
												}
											}
										},
										error: function (data, status, e) {
											log('ajaxFileUploaderror') ;
											log('data',data) ;
											log('status',status) ;
											//alert(e);
										}
            						})
								}
							})
						]
					})
				],
				onBeforeShow: function() {
					return true ;
				}
			}) ;
			this.winForImg.openForm = function() {
				this.findByRef('view_form').getEl().slideDown() ;
				$('#div_managecards_infoimg').slideUp() ;
			} ;
			this.winForImg.closeForm = function() {
				this.findByRef('view_form').getEl().hide() ;
				$('#div_managecards_infoimg').show() ;
			} ;
		}
		this.winForImg.showAt(evt.pageX+20, evt.pageY-50) ;
		this.winForImg.findByRef('form').reset() ;
		this.winForImg.closeForm() ;
		//$("#div_managecards_infoimg").html("") ;
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'getInfoImg', vc_id: MyVCFApp.currentCard.vc_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				//log("data", data) ;
				var txt = "" ;
				var idLink = MyVCFApp.Utils.nextId() ;
				if (data.tabImgs.length==0) this.winForImg.openForm() ;
				for(var i=0 ; i<data.tabImgs.length ; i++) {
					var checked = "" ;
					if (data.tabImgs[i].checked==1) checked = "checked='checked'" ;
					txt += "<div class='pointilles'><div class='float'><input "+checked+" type='radio' name='vc_photo_' id='vc_photo_"+data.tabImgs[i].vc_id+"' value='"+data.tabImgs[i].vc_photo+"' /></div>" ;
					txt += "<div class='float'><label for='vc_photo_"+data.tabImgs[i].vc_id+"'>" ;
					if (data.tabImgs[i].vc_photo=='') txt += "<img src='/statics/images/im_default-femme-petit.jpg' alt='' />" ;
					else txt += "<img src='/dynamics/ip2_"+data.tabImgs[i].vc_photo+".jpg' alt='' />" ;
					txt += "</label></div>" ;
					txt += "<div class='clear'></div></div>" ;
				}
				txt += "<div style='padding-bottom:10px;'><a id='"+idLink+"' href='javascript:void(0);'>"+i18n.new_photo+"</a></div>" ;
				$("#div_managecards_infoimg").html(txt) ;
				$("#"+idLink).click({view:this},function(evt) {
					evt.data.view.winForImg.openForm()
				}) ;
			}
		});		
	},
	showWinForAddresses: function(evt) {
		this.closeAllWin() ;
		if (!this.winForAddresses) {
			this.winForAddresses = new MyVCFApp.WinProperties({
				items: [
					new MyVCFApp.View({
						html: "<h2 style='margin:0 0 10px 0; padding:0; color:white;'>"+i18n.address+"(s)</h2>"
					}),
					new MyVCFApp.Form({
						ref: 'form',
						url: 'io.php',
						scope: this,
						onSubmit: function(data) {
							this.winForAddresses.hide() ;
							MyVCFApp.updateCard(this.idCard, data.card, true) ;
							this.createGraphicsCard() ;
						},
						items: [
							new MyVCFApp.View({
								id: 'div_managecards_infoaddresses',
								html: "<i>"+i18n.loading+"</i>"
							}),
							new MyVCFApp.View({
								ref: 'view_form',
								items: [
									new MyVCFApp.TextField({
										ref: 'ad_address1',
										name: 'ad_address1',
										emptyText: i18n.address+" 1"
									}),
									new MyVCFApp.TextField({
										ref: 'ad_address2',
										name: 'ad_address2',
										emptyText: i18n.address+" 2"
									}),
									new MyVCFApp.TextField({
										ref: 'ad_zip',
										name: 'ad_zip',
										emptyText: i18n.zip2
									}),
									new MyVCFApp.TextField({
										ref: 'ad_city',
										name: 'ad_city',
										emptyText: i18n.city
									}),
									new MyVCFApp.TextField({
										ref: 'ad_region',
										name: 'ad_region',
										emptyText: "Région"
									}),
									new MyVCFApp.TextField({
										ref: 'ad_country',
										name: 'ad_country',
										emptyText: i18n.country
									})
								]
							}),
							new MyVCFApp.Button({
								text: i18n.save,
								scope: this,
								onClick: function(evt) {
									this.winForAddresses.findByRef('form').submit({action:'saveForAddresses', newAddress:1, vc_id:MyVCFApp.currentCard.vc_id}) ;//, tabAddresses:$.toJSON(MyVCFApp.currentCard.tabAddresses)
								}
							})
						]
					})
				],
				onBeforeShow: function() {
					return true ;
				}
			}) ;
			this.winForAddresses.openForm = function() {
				this.findByRef('view_form').getEl().slideDown() ;
			} ;
			this.winForAddresses.closeForm = function() {
				this.findByRef('view_form').getEl().hide() ;
			} ;
		}
		this.winForAddresses.showAt(evt.pageX+20, evt.pageY-50) ;
		this.winForAddresses.findByRef('form').reset() ;
		this.winForAddresses.closeForm() ;
		//$("#div_managecards_infoaddresses").html("") ;
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'getInfoAddresses', vc_id: MyVCFApp.currentCard.vc_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				//log("data", data) ;
				var idLink = MyVCFApp.Utils.nextId() ;
				var txt = "" ;
				if (data.tabAddresses.length==0) this.winForAddresses.openForm() ;
				for(var i=0 ; i<data.tabAddresses.length ; i++) {
					var checked = "" ;
					if (data.tabAddresses[i].checked==1) checked = "checked='checked'" ;
					txt += "<div class='pointilles'><div class='float'><input "+checked+" type='checkbox' name='ad_id_"+data.tabAddresses[i].ad_id+"' id='ad_id_"+data.tabAddresses[i].ad_id+"' value='"+data.tabAddresses[i].ad_id+"' /></div>" ;
					txt += "<div class='float'><label for='ad_id_"+data.tabAddresses[i].ad_id+"'>"+MyVCFApp.Utils.formatAddress(data.tabAddresses[i])+"</label></div>" ;
					txt += "<div class='clear'></div></div>" ;
				}
				txt += "<div style='padding-bottom:10px;'><a id='"+idLink+"' href='javascript:void(0);'>"+i18n.new_address+"</a></div>" ;
				$("#div_managecards_infoaddresses").html(txt) ;
				$("#"+idLink).click({view:this},function(evt) {
					evt.data.view.winForAddresses.openForm()
				}) ;
			}
		});		
	},
	showWinForTelephons: function(evt) {
		this.closeAllWin() ;
		if (!this.winForTelephons) {
			this.winForTelephons = new MyVCFApp.WinProperties({
				items: [
					new MyVCFApp.View({
						html: "<h2 style='margin:0 0 10px 0; padding:0; color:white;'>"+i18n.telephon+"(s)</h2>"
					}),
					new MyVCFApp.Form({
						ref: 'form',
						url: 'io.php',
						scope: this,
						onSubmit: function(data) {
							this.winForTelephons.hide() ;
							MyVCFApp.updateCard(this.idCard, data.card, true) ;
							this.createGraphicsCard() ;
						},
						items: [
							new MyVCFApp.View({
								id: 'div_managecards_infotelephons',
								html: "<i>"+i18n.loading+"</i>"
							}),
							new MyVCFApp.View({
								ref: 'view_form',
								items: [
									new MyVCFApp.SelectField({
										ref: 'te_type',
										name: 'te_type',
										selectOptions: MyVCFApp.Utils.getTypesTelephon()
									}),
									new MyVCFApp.TextField({
										ref: 'te_num',
										name: 'te_num',
										emptyText: i18n.number
									})
								]
							}),
							new MyVCFApp.Button({
								text: i18n.save,
								scope: this,
								onClick: function(evt) {
									this.winForTelephons.findByRef('form').submit({action:'saveForTelephons', isTel: 1, newTelephon:1, vc_id:MyVCFApp.currentCard.vc_id}) ;//, tabAddresses:$.toJSON(MyVCFApp.currentCard.tabAddresses)
								}
							})
						]
					})
				],
				onBeforeShow: function() {
					return true ;
				}
			}) ;
			this.winForTelephons.openForm = function() {
				this.findByRef('view_form').getEl().slideDown() ;
			} ;
			this.winForTelephons.closeForm = function() {
				this.findByRef('view_form').getEl().hide() ;
			} ;
		}
		this.winForTelephons.showAt(evt.pageX+20, evt.pageY-50) ;
		this.winForTelephons.findByRef('form').reset() ;
		this.winForTelephons.closeForm() ;
		//$("#div_managecards_infotelephons").html("") ;
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'getInfoTelephons', isTel: 1, vc_id: MyVCFApp.currentCard.vc_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				//log("data", data) ;
				var idLink = MyVCFApp.Utils.nextId() ;
				var txt = "" ;
				if (data.tabTelephons.length==0) this.winForTelephons.openForm() ;
				for(var i=0 ; i<data.tabTelephons.length ; i++) {
					var checked = "" ;
					if (data.tabTelephons[i].checked==1) checked = "checked='checked'" ;
					var typeTxt = MyVCFApp.Utils.searchInSimpleArray(MyVCFApp.Utils.getTypesTelephon(), data.tabTelephons[i].te_type, 1) ;
					txt += "<div class='pointilles'><div class='float'><input "+checked+" type='checkbox' name='te_id_"+data.tabTelephons[i].te_id+"' id='te_id_"+data.tabTelephons[i].te_id+"' value='"+data.tabTelephons[i].te_id+"' /></div>" ;
					txt += "<div class='float'><label for='te_id_"+data.tabTelephons[i].te_id+"'>"+typeTxt+" : "+(data.tabTelephons[i].te_num)+"</label></div>" ;
					txt += "<div class='clear'></div></div>" ;
				}
				txt += "<div style='padding-bottom:10px;'><a id='"+idLink+"' href='javascript:void(0);'>"+i18n.new_telephon+"</a></div>" ;
				$("#div_managecards_infotelephons").html(txt) ;
				$("#"+idLink).click({view:this},function(evt) {
					evt.data.view.winForTelephons.openForm()
				}) ;
			}
		});		
	},
	showWinForEmails: function(evt) {
		this.closeAllWin() ;
		if (!this.winForEmails) {
			this.winForEmails = new MyVCFApp.WinProperties({
				items: [
					new MyVCFApp.View({
						html: "<h2 style='margin:0 0 10px 0; padding:0; color:white;'>"+i18n.emails_and_websites+"</h2>"
					}),
					new MyVCFApp.Form({
						ref: 'form',
						url: 'io.php',
						scope: this,
						onSubmit: function(data) {
							this.winForEmails.hide() ;
							MyVCFApp.updateCard(this.idCard, data.card, true) ;
							this.createGraphicsCard() ;
							if (data.validEmail=="ok") {
								this.alertValidEmail() ;
							}
						},
						items: [
							new MyVCFApp.View({
								id: 'div_managecards_infoEmails',
								html: "<i>"+i18n.loading+"</i>"
							}),
							new MyVCFApp.View({
								ref: 'view_form',
								items: [
									new MyVCFApp.SelectField({
										ref: 'te_type',
										name: 'te_type',
										selectOptions: MyVCFApp.Utils.getTypesEmail()
									}),
									new MyVCFApp.TextField({
										ref: 'te_num',
										name: 'te_num',
										emptyText: "Saisir"
									})
								]
							}),
							new MyVCFApp.Button({
								text: i18n.save,
								scope: this,
								onClick: function(evt) {
									this.winForEmails.findByRef('form').submit({action:'saveForTelephons', isTel: 0, newTelephon:1, vc_id:MyVCFApp.currentCard.vc_id}) ;//, tabAddresses:$.toJSON(MyVCFApp.currentCard.tabAddresses)
								}
							})
						]
					})
				],
				onBeforeShow: function() {
					return true ;
				}
			}) ;
			this.winForEmails.openForm = function() {
				this.findByRef('view_form').getEl().slideDown() ;
			} ;
			this.winForEmails.closeForm = function() {
				this.findByRef('view_form').getEl().hide() ;
			} ;
		}
		this.winForEmails.showAt(evt.pageX+20, evt.pageY-50) ;
		this.winForEmails.findByRef('form').reset() ;
		this.winForEmails.closeForm() ;
		//$("#div_managecards_infoEmails").html("") ;
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'getInfoTelephons', isTel: 0, vc_id: MyVCFApp.currentCard.vc_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				//log("data", data) ;
				var idLink = MyVCFApp.Utils.nextId() ;
				var txt = "" ;
				if (data.tabTelephons.length==0) this.winForEmails.openForm() ;
				for(var i=0 ; i<data.tabTelephons.length ; i++) {
					var checked = "" ;
					if (data.tabTelephons[i].checked==1) checked = "checked='checked'" ;
					var typeTxt = MyVCFApp.Utils.searchInSimpleArray(MyVCFApp.Utils.getTypesEmail(), data.tabTelephons[i].te_type, 1) ;
					var txtValid = "" ;
					if ((data.tabTelephons[i].te_type==11 || data.tabTelephons[i].te_type==12) && data.tabTelephons[i].te_valid==0) txtValid = " <span class='red'>(<a href='javascript:void(0);' onclick=\"MyVCFApp.ManageCards.validEmail('"+data.tabTelephons[i].te_id+"');\">"+i18n.not_valid+"</a>)</span>" ;
					txt += "<div class='pointilles'><div class='float'><input "+checked+" type='checkbox' name='te_id_"+data.tabTelephons[i].te_id+"' id='te_id_"+data.tabTelephons[i].te_id+"' value='"+data.tabTelephons[i].te_id+"' /></div>" ;
					txt += "<div class='float'><label for='te_id_"+data.tabTelephons[i].te_id+"'>"+typeTxt+" : "+(data.tabTelephons[i].te_num)+"</label>"+txtValid+"</div>" ;
					txt += "<div class='clear'></div></div>" ;
				}
				txt += "<div style='padding-bottom:10px;'><a id='"+idLink+"' href='javascript:void(0);'>"+i18n.new_email+"</a></div>" ;
				$("#div_managecards_infoEmails").html(txt) ;
				$("#"+idLink).click({view:this},function(evt) {
					evt.data.view.winForEmails.openForm()
				}) ;
			}
		});		
	},
	// warning mettre une vérification sur te_id
	validEmail: function(te_id) {
		this.winForEmails.hide() ;
		$.ajax({
			type: 'POST',
			url: 'io.php',
			data: {action: 'validEmail', te_id: te_id},
			context: this,
			dataType: 'json',
			success: function(data) {
				if (data.validEmail=="ok") {
					this.alertValidEmail() ;
				}
			}
		}) ;
	},
	alertValidEmail: function() {
		MyVCFApp.Alert.show(i18n.check_mail_message) ;
	},
	showWinForNotes: function(evt) {
		this.closeAllWin() ;
		if (!this.winForNotes) {
			this.winForNotes = new MyVCFApp.WinProperties({
				items: [
					new MyVCFApp.View({
						html: "<h2 style='margin:0 0 10px 0; padding:0; color:white;'>"+i18n.comment+"</h2>"
					}),
					new MyVCFApp.Form({
						ref: 'form',
						url: 'io.php',
						scope: this,
						onSubmit: function(data) {
							this.winForNotes.hide() ;
							MyVCFApp.updateCard(this.idCard, data.card, true) ;
							this.createGraphicsCard() ;
						},
						items: [
							new MyVCFApp.TextArea({
								ref: 'vc_notes',
								name: 'vc_notes',
								emptyText: i18n.notes_comment_hobbies
							}),
							new MyVCFApp.Button({
								ref: '',
								text: i18n.save,
								scope: this,
								onClick: function(evt) {
									this.winForNotes.findByRef('form').submit({action:'saveForNotes', vc_id:MyVCFApp.currentCard.vc_id}) ;
								}
							})
						]
					})
				],
				onBeforeShow: function() {
					return true ;
				}
			}) ;
		}
		this.winForNotes.showAt(evt.pageX+20, evt.pageY-50) ;
		this.winForNotes.findByRef('form').reset() ;
		this.winForNotes.findByRef('vc_notes').setValue(MyVCFApp.currentCard.vc_notes) ;
	}
}) ;


















