/* Config Var */

var currentCustomer = "novoprom";

var defaultVal = {
	/* for icon */
	iconSize:new GSize(30,30)
	,iconAnchor :new GPoint(15,15)
	,infoWindowAnchor:new GPoint(30,1)
	/* for positionning*/
	,globalView_France:{center:new GLatLng(46.6795944656402, 2.5048828125),zoom:5} // not used for now. it is hard coded on line +/- 74
	
	/* for markersMgr */
	,markervisibility:{step:{one:{minZoom:0,maxZoom:17},two:{minZoom:0,maxZoom:17}}} //arbitrary for now.  choose some !  // rr404
	
	/* for Div calls*/
	  //todo :
	  	// redo page architecture with clearly done divs
		
	/* For program resume length*/
	,progResLength:35
	};

/* Nav Buttons */
var button1_off = '<img name="progArea1" id="progArea1" src="../../images/bouton1_off.jpg" width="85" height="37" border="0" >';
var button2_off = '<img name="progArea2" id="progArea2" src="../../images/bouton2_off.jpg" width="71" height="37" border="0" >';
var button3_off = '<img name="progArea3" id="progArea3" src="../../images/bouton3_off.jpg" width="63" height="37" border="0" >';

var button1_on = '<img name="progArea1" id="progArea1" src="../../images/bouton1_on.jpg" width="85" height="37" border="0" >';
var button2_on = '<img name="progArea2" id="progArea2" src="../../images/bouton2_on.jpg" width="71" height="37" border="0" >';
var button3_on = '<img name="progArea3" id="progArea3" src="../../images/bouton3_on.jpg" width="63" height="37" border="0" >';

var button1_roll = '<img name="progArea1" id="progArea1" src="../../images/bouton1_roll.jpg" width="85" height="37" border="0" >';
var button2_roll = '<img name="progArea2" id="progArea2" src="../../images/bouton2_roll.jpg" width="71" height="37" border="0" >';
var button3_roll = '<img name="progArea3" id="progArea3" src="../../images/bouton3_roll.jpg" width="63" height="37" border="0" >';

var contenuDivButton1 = '<div id="bouton1" style="background:red" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'progArea1\',\'\',\'../../images/bouton1_roll.jpg\',1)"><img name="progArea1" id="progArea1" src="../../images/bouton1_on.jpg" width="85" height="37" border="0" align="top"></div>';
var contenuDivButton2 = '<div id="bouton2" style="background:red" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'progArea2\',\'\',\'../../images/bouton2_roll.jpg\',1)"><img name="progArea2" id="progArea2" src="../../images/bouton2_on.jpg" width="85" height="37" border="0" align="top"></div>';
var contenuDivButton3 = '<div id="bouton3" style="background:red" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'progArea3\',\'\',\'../../images/bouton3_roll.jpg\',1)"><img name="progArea3" id="progArea3" src="../../images/bouton3_on.jpg" width="85" height="37" border="0" align="top"></div>';

var currentButton1 = button1_on;
var currentButton2 = button2_off;
var currentButton3 = button3_off;

/****************/
//setStep3Pdm dimensions
var setStep3Pdm_w_ifNull = 360;
var setStep3Pdm_h_ifNull = 244;

var setStep3Pdm_w = 363;
var setStep3Pdm_h = 416;

// setStep3Preview_step3_thumb_style
var setStep3Preview_step3_thumb_style_null    = "margin-bottom:2px; padding-right:2px;";
var setStep3Preview_step3_thumb_style_jpg     = "margin-bottom:2px; padding-right:2px;";
var setStep3Preview_step3_thumb_style_default = "margin-bottom:2px; padding-right:2px;";

//from load() function
var searchAtStart = true;

//gotoSection3 config
var step3_persp_visible = true; //the perspective thumb under the PDM

//OpenPopUp and OpenPopHtml 
var setFocusOnPop = false;
/*************************************************************************************************************/

function load_config_tdv_map_init(tdv_map){
	//tdv_map.setCenter(new GLatLng(46.6795944656402, 2.5048828125), 5);
	tdv_map.setCenter(new GLatLng(46.6795944656402, 2.5048828125), 5);
	
	// # CONTROLS #
	tdv_map.addControl(new GSmallMapControl()); // only for cap2J, pas de minimap
	//tdv_map.addControl(new GOverviewMapControl());
	//tdv_map.addControl(new GScaleControl());
	
	//tdv_geocoder.getLatLng("paris,france",shoutCoords); //for test // rr404
	
	//tdv_marker_mgr = new GMarkerManager(tdv_map,  {borderPadding:50});
	tdv_marker_mgr = new GMarkerManager(tdv_map);
}

function lotsResultsProcessor_titlePanel_step2_update(theResults){
	if($('titlePanel_step2')!=null){
		/*eli : id du div effacé parcke le nom du programme ne saffichait pas*/
		$('titlePanel_step2').update('<div class="titrePage2" style="height:25px"><table border="0" class="titrePage2" width="100%"><tr><td width="45%" align="left">'+theResults.nomProg + '</td><td><img src="../../images/stock_add-bookmark.gif" border="0"></td><td> Disponible le: ' +theResults.date_dispo+'</td></tr></table></div>') ;				
	}
}

function lotsResultsProcessor_dateMiseADispo_update(){
	if($('dateMiseADispo')!=null)
		$('dateMiseADispo').update('<div onclick="popProgDesc()" style="cursor:pointer; text-align:center;" class="title"><table width="436px" style="background:url(../../images/bg_descr.gif); border:solid 1px #096475;"><tr><td align="right" width="33%"><img src="../../images/editpaste.gif" border="0"></td><td><strong><font color="#096475"> Description du Programme </font></strong></td></tr></table></div>');
}

function lotsResultsProcessor_current_lots_list_print(theResults){
	try{
		current_lots_list = theResults.lots;
		var nplace = 0;
		var _separator = "";
		
		if($('LOT_list_container')!=null){
			
			current_lots_list.each(function(theR){							
				// Print the results // printResult:function(sId,nb_p,nom,ot,ob,op,oc,oj,url_thumb,ref_pdm,superf,prix,dispo)
				$('LOT_list_container').insert({bottom:tdvTemplate.step2.printResult(theR.lot_id,theR.nb_p,theR.nom,theR.ot,theR.ob,theR.op,theR.oc,theR.oj,theR.url_thumb,theR.ref_pdm,theR.sup,theR.prix,theR.dispo,nplace)});
						
				current_lots_details += _separator+theR.nom+"#"+theR.prix+"-"+theR.sup+"~"+"T"+theR.nb_p+"@"+theR.dispo;
				_separator = "|";
				
				nplace++;		
			});
		}
	}
	catch(e){
			
	}
}

/*************/
function lotsDetailssProcessor_les_plus_update(theResults){
	if($('les_plus')!=null){
		try{
			$('les_plus').update("");
			if(theResults.p1 != "" && theResults.p1 !="null") $('les_plus').insert({bottom:"<li>"+theResults.p1+"</li>"});
			if(theResults.p2 != "" && theResults.p2 !="null") $('les_plus').insert({bottom:"<li>"+theResults.p2+"</li>"});
			if(theResults.p3 != "" && theResults.p3 !="null") $('les_plus').insert({bottom:"<li>"+theResults.p3+"</li>"});
			if(theResults.p4 != "" && theResults.p4 !="null") $('les_plus').insert({bottom:"<li>"+theResults.p4+"</li>"});
			if(theResults.p5 != "" && theResults.p5 !="null") $('les_plus').insert({bottom:"<li>"+theResults.p5+"</li>"});
		}
		catch(e){
				 //
		}
	}
}


/**************/

function lotsDetailsProcessor_step3_persp_update(theResults){
	/* Images en bas page 3*/
	if(theResults.i1 != "" && theResults.i1 != "null"){
		$('step3_persp').insert('<img  align="top" width="123" heigt="92" src="'+theResults.i1+'" onclick="popImg(\''+theResults.i1+'\')" style="cursor:pointer;margin-left:2px;border:1px solid #000000" />');
	}
	if(theResults.i2 != "" && theResults.i2 != "null"){
		$('step3_persp').insert('<img  align="top" width="123" heigt="92" src="'+theResults.i2+'" onclick="popImg(\''+theResults.i2+'\')" style="cursor:pointer;margin-left:2px;border:1px solid #000000" />');
	}
	if(theResults.i3 != "" && theResults.i3 != "null"){
		$('step3_persp').insert('<img  align="top" width="123" heigt="92" src="'+theResults.i3+'" onclick="popImg(\''+theResults.i3+'\')" style="cursor:pointer;margin-left:2px;border:1px solid #000000" />');
	}
}

/***************/
function gotoSelection_case2(idSelection,headingTo,refPDM){
	current_hl_lot = '';
		
	currentVal.step = 'two';
	step3_relevant = false; prog_3_active(false); // see if we want this // rr404
	step2_relevant = true; prog_2_active(true);
	
	//$('theProgression').update('<img src="../../images/page2_03.jpg" usemap="#Map" border="0">');

	$('progressTD2').update(contenuDivButton2);
	
	//Eli***** Ajout de variables pour le roll sur la barre de progression/
	currentButton1 = button1_off;
	currentButton2 = button2_on;
	currentButton3 = button3_off;
	highLightButtons();
	//////////////////////////////////////////////////////////////////////
	
	currentVal.program_id = idSelection;
	centerOnMarker(idSelection,14);
	tdv_map.setMapType(G_HYBRID_MAP);
	
	$('rightPanel_step1').hide();
	$('rightPanel_step3').hide();
	$('rightPanel_step2').show();			
	
	
	listProgramLots(idSelection);
	
	$('theMap').hide();
	$('thePDM').show();
	
	$('step3_persp').hide();
	$('leftPanelBottom').show();
}

/*****************/
function gotoSelection_case3(idSelection,headingTo,refPDM){
	current_hl_lot='';
	
	current_hl_lot='';

	currentVal.step = 'three';
	step3_relevant = true; //prog_3_active(true);
	
	$('progressTD3').update(contenuDivButton3);
	
	//Eli***** Ajout de variables pour le roll sur la barre de progression/
	currentButton1 = button1_off;
	currentButton2 = button2_off;
	currentButton3 = button3_on;
	highLightButtons();
	////////////////////////////////////////////////////////////////////////
	
	//$('theProgression').update('<img src="../../images/page3_03.jpg" usemap="#Map" border="0">');
	
	if(refPDM == undefined){
		refPDM = "";
	}
	currentVal.lot_refPDM = refPDM;
	
	getLotDetails(idSelection);
	
	currentVal.lot_id = idSelection;
	$('rightPanel_step1').hide();
	$('rightPanel_step2').hide();
	$('rightPanel_step3').show();
	
	
	$('theMap').hide();
	$('thePDM').show();
	
	$('leftPanelBottom').hide();
	$('step3_persp').show();
}

/**************/
function displayImage_popContent_update(img,width,height){
	$('popContent').update('<img src="'+img.src+'" alt="wait" style="border:4px solid #990000;'+width+height+'" />');
}


/************/
function gotoSection1_div_actions(){
	// Hide the PDM div
	$('rightPanel_step2').hide();
	$('rightPanel_step3').hide();
	
	// Show Map, Hide bigPDM
	$('thePDM').hide();
	$('theMap').show();
	
	$('step3_persp').hide();
	$('leftPanelBottom').show();
	
	tdv_map.setCenter(new GLatLng(46.6795944656402, 2.5048828125), 5);
	//centerOnMarker(currentVal.program_id,7); not on marker anymore
	tdv_map.setMapType(G_NORMAL_MAP)
	
	$('rightPanel_step1').show();
}

/***/
function gotoSection2_div_actions(){
	// Hide the PDM div
	$('rightPanel_step1').hide();
	$('rightPanel_step3').hide();
	
	$('theMap').hide();
	$('thePDM').show();
	
	
	$('step3_persp').hide();
	$('leftPanelBottom').show()
		
	//centerOnMarker(currentVal.program_id,14); //not used for novoprom // rr404
	//tdv_map.setMapType(G_HYBRID_MAP); //not used for novoprom // rr404
	
	$('rightPanel_step2').show();
	
	setLotPDM("");
}

function gotoSection3_div_actions(){
	// Hide the PDM div
	$('rightPanel_step1').hide();
	$('rightPanel_step2').hide();
	
	$('theMap').hide();
	$('thePDM').show();
	
	$('leftPanelBottom').hide()
	$('step3_persp').show();
	
	$('rightPanel_step3').show();
}


