var mapwin;
var win;
function getMap(address, markerLabel){
        if(!mapwin){

            mapwin = new Ext.Window({
                layout: 'fit',
                title: '',
                closeAction: 'hide',
                width:400,
                height:400,
                x: 40,
                y: 60,
                items: {
                    xtype: 'gmappanel',
                    region: 'center',
                    zoomLevel: 14,
                    gmapType: 'map',
                    mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
                    mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
                    setCenter: {
                        /*geoCodeAddr: '33 place werixhas, Montegnee, Belgique',
                        marker: {title: 'Gednius'}*/
                        geoCodeAddr: address,
                        marker: {title: markerLabel}
                    }
                }
            });
            
        }
        
        mapwin.show();
        
    }

function flashCreate(titleHeader,subTitle) {
	var flashvars = {};
	flashvars.titleHeader=titleHeader;
	flashvars.subTitleHeader=subTitle;
	var params = {	 
			wmode:"transparent"
	};

	var attributes = {};
	// Coucou Adrien, 
	// Il faut rajoutter comme paramètre wmode="transparent" dans le tag <embed> pour rendre le flash transparent.
	// Ne pas oublier qu'il y a 2 types de code à mettre pour un flash celui pour les IE & les FF types 
	// Tu trouveras l'aide ici >> http://azur.ironie.org/128-code-html-pour-flash
	swfobject.embedSWF("../++resource++MutNeutresSwf/bannerHeader.swf", "textFlash", " 980", "138", "9.0.0", "../++resource++MutNeutresSwf/expressInstall.swf", flashvars, params, attributes);


}

function createHomeBanner(urlXML) {
	var flashvars = {};
	flashvars.urlXML=urlXML;
	var params = {	 
			wmode:"transparent"
	};
	var attributes = {};
	swfobject.embedSWF("../++resource++MutNeutresSwf/homebanner.swf", "bannerFlash", " 980", "138", "9.0.0", "../++resource++MutNeutresSwf/expressInstall.swf", flashvars, params, attributes);		
}

function createHomeBannerUnion(urlXML) {
	var flashvars = {};
	flashvars.urlXML=urlXML;
	var params = {	 
			wmode:"transparent"
			,scale:'noScale'
			,menu:'false'
			,salign:'lt'
			,allowscriptaccess:"true"				
	};
	var attributes = {};
	attributes.id = 'expo';
	attributes.name = 'expo';
	swfobject.embedSWF("../++resource++MutNeutresSwf/bannerUnion.swf", "bannerFlash", " 980", "312", "9.0.115", "../++resource++MutNeutresSwf/expressInstall.swf", flashvars, params, attributes);		
}

function createMap(flashName,urlXML,urlResult) {
	var flashvars = {};
	flashvars.urlXML=urlXML;
	flashvars.urlResult=urlResult;
	var params = {	 
			wmode:"transparent"
	};
	var attributes = {};
	swfobject.embedSWF("../++resource++MutNeutresSwf/"+flashName+".swf", "vlamsMapFlash", " 650", "250", "9.0.0", "../++resource++MutNeutresSwf/expressInstall.swf", flashvars, params, attributes);		
}

function submitCP() {
	var cp="0";
	if(Ext.get("cp_value")){
		cp=Ext.get("cp_value").getValue()
	}
	if (cp.length == 4){
		win=new Ext.Window({		
			"autoLoad":{"url": "modalContact",
			            "params": {"cp":cp}},
			"unstyled":true,
			"resizable":false,
			"modal":true,
			"width":597,
			"height":457,
			"autoScroll":false,
			"shadow":false, 
			"closable":false
		});	
		win.show(Ext.getBody(),function(){
			
		});
	}
}

function askVignette() {
	Ext.Ajax.request({
		url:Ext.get("actionUrl").getValue()+"/submitTPS",
		success:function(response, action){
            Ext.get("centerCTbody").update(response.responseText,true);
            win.close();
		},
		failure:function(response, action){
			console.log("error");
		}
	});	
}

function vignetteModal(){
	Ext.Ajax.request({
			url:Ext.get("actionUrl").getValue()+"/generatePDF",
			params : { mutUrl : Ext.get("actionUrl").getValue() },
			success:function(response, action){
				Ext.get("TpsModal").parent().update(response.responseText,true);
				
			},
			failure:function(response, action){
				console.log("Error generating PDF");
			}
			
	});
	
}








