
var html ='\
	<div class="second_menu"> \
		<div class="second_menu_l"> \
			<div class="second_menu_r"> \
				<div class="second_menu_c"> \
					<ul> \
						<li id="second_1" class="second_menu_unselected tag">Vos Coordonn&eacute;es</li> \
						<li id="second_2" class="second_menu_unselected">Vos Statistiques</li> \
						<li id="second_3" class="second_menu_selected">Bandeaux & Outils</li> \
						<li id="second_4" class="second_menu_unselected">Facturation</li> \
					</ul> \
				</div> \
			</div> \
		</div> \
		<div id="box01_outer"> \
			<div class="box01_t_c"> \
				<div class="box01_b_c"> \
					<div class="box01_l"> \
						<div class="box01_r"> \
							<div class="box01_t_l"> \
								<div class="box01_t_r"> \
									<div class="box01_b_l"> \
										<div class="box01_b_r"> \
											<div class="box01_content"> \
												<div class="box01_title"> \
													<ul> \
														<li id="third_01" class="third_menu_selected">Les bandeaux</li> \
														<li id="third_02">Les liens</li> \
														<li id="third_03">La Div Glissante</li> \
														<li id="third_04">Sp&eacute;cial Bandeaux</li> \
														<li id="third_05"><div class="rss">RSS</div></li> \
													</ul> \
												</div> \
												<div class="box01_c"> \
													<div class="box01_forth_menu"> \
														<div class="box01_forth_menu_01"> \
															<ul> \
																<li id="bottommenu_01" class="forth_menu_selected"><img src="images/smile.gif" border="0" /></li> \
																<li id="bottommenu_02">Ex</li> \
																<li id="bottommenu_03">60x60</li> \
																<li id="bottommenu_04">88x31</li> \
																<li id="bottommenu_05">90x53</li> \
																<li id="bottommenu_06">120x90</li> \
																<li id="bottommenu_07">234x60</li> \
																<li id="bottommenu_08">260x80</li> \
																<li id="bottommenu_09">300x250</li> \
																<li id="bottommenu_10">468x60</li> \
																<li id="bottommenu_11">120x600</li> \
																<li id="bottommenu_12">Top</li> \
															</ul> \
														</div> \
													</div> \
													<div class="content"> \
													</div> \
												</div> \
											</div> \
										</div> \
									</div> \
								</div> \
							</div> \
						</div> \
					</div> \
				</div> \
			</div> \
		</div> \
	</div>';

var html1 ='\
		<div class="box01_forth_menu"> \
			<div class="box01_forth_menu_01"> \
				<ul> \
					<li id="bottommenu_s_01" class="forth_menu_selected">60x60</li> \
					<li id="bottommenu_s_02">88x31</li> \
					<li id="bottommenu_s_03">90x53</li> \
					<li id="bottommenu_s_04">120x90</li> \
					<li id="bottommenu_s_05">234x60</li> \
					<li id="bottommenu_s_06">260x80</li> \
					<li id="bottommenu_s_07">468x60</li> \
					<li id="bottommenu_s_08">120x600</li> \
				</ul> \
			</div> \
		</div> \
		<div class="content_c"> \
		</div>';
		
var html2 ='\
		<div class="box01_forth_menu"> \
			<div class="box01_forth_menu_01"> \
				<ul> \
					<li id="bottommenu_14" class="forth_menu_selected"><img src="images/smile.gif" border="0" /></li> \
					<li id="bottommenu_15">#</li> \
				</ul> \
			</div> \
		</div> \
		<div class="content"> \
		</div>';
	
var html3 ='\
		<div class="box01_forth_menu"> \
			<div class="box01_forth_menu_01"> \
				<ul> \
					<li id="bottommenu_16" class="forth_menu_selected">popdiv couleur lyad</li> \
					<li id="bottommenu_17">popdiv N&amp;B</li> \
				</ul> \
			</div> \
		</div> \
		<div class="content"> \
		</div>';
	
var div = "box_c";
var storeTagMenu = "";
var storeFlag = "";
var storeThird = "";

window.dhtmlHistory.create();

window.onload = function() {
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(handleHistoryChange);
	
   var currentLocation = 
      dhtmlHistory.getCurrentLocation();
   var browser = "";
   
	if (currentLocation == "") {
		currentLocation = "section:default";
		currentLocation = currentLocation.replace(/section\:/, "");
		menutop(currentLocation, div);
	}
	
	$(".box_c").html(html);

	if(currentLocation.substring(0,18)=="section:bottommenu"){
		div = "content";

		if (currentLocation == "section:bottommenu_14" || currentLocation=="section:bottommenu_15"){					
			$(".box01_c").html(html2);	
			$('.box01_title li').removeClass('third_menu_selected');
			$('#third_02').addClass('third_menu_selected');
			$('.box01_forth_menu_01 li').removeClass('forth_menu_selected');
			$('#'+currentLocation.substring(8,23)).addClass('forth_menu_selected');
		}
		
		if (currentLocation == "section:bottommenu_16" || currentLocation=="section:bottommenu_17"){
			$(".box01_c").html(html3);	
			$('.box01_title li').removeClass('third_menu_selected');
			$('#third_03').addClass('third_menu_selected');
			$('.box01_forth_menu_01 li').removeClass('forth_menu_selected');
			$('#'+currentLocation.substring(8,23)).addClass('forth_menu_selected');
		}

	}
	
	if(currentLocation.substring(0,13)=="section:third"){
		$(".box_c").html(html);	
		div = "box01_c";
		$('.box01_title li').removeClass('third_menu_selected');
		$('#'+currentLocation.substring(8,16)).addClass('third_menu_selected');
	}
	
	if(currentLocation.substring(0,20)=="section:bottommenu_s"){
		$(".box01_c").html(html1);	
		div = "content_c";
		$('.box01_title li').removeClass('third_menu_selected');
		$('#third_04').addClass('third_menu_selected');
		$('.box01_forth_menu_01 li').removeClass('forth_menu_selected');
		$('#'+currentLocation.substring(8,23)).addClass('forth_menu_selected');
	}
	
	if(currentLocation.substring(0,16)=="section:third_04"){
		$(".box01_c").html(html1);
		div = "box01_c";
		$('.box01_title li').removeClass('third_menu_selected');
		$('#third_04').addClass('third_menu_selected');
	}
	
	currentLocation = currentLocation.replace(/section\:/, "");
	menutop(currentLocation, div);	

};

function checkBrowser(){
	if ($.browser.msie){
		browser = "IE";
	}else{
		if ($.browser.safari){
			browser = "SAFARI&CHROME";
		}else{
			if 	($.browser.opera){
				browser = "OPERA";
			}else{
				if ($.browser.mozilla){
					browser = "MOZILLA";
				}else{
					browser = "OTHERS";	
				}	
			}
		}	
	}
	
	return browser;
}

function handleHistoryChange(newLocation, historyData) {
	switch(checkBrowser()){
		case "OPERA":
			if(newLocation.substring(0,18)=="section:bottommenu"){
				historyData = "content";
			}
			
			if (newLocation == "section:bottommenu_01"){
				historyData = "box01_c";
			}
		break;
		
		case "SAFARI&CHROME":
			if(newLocation.substring(0,18)=="section:bottommenu"){
				$(".box_c").html(html);
				if (newLocation == "section:bottommenu_14" || newLocation=="section:bottommenu_15"){
					$(".box01_c").html(html2);	
					$('.box01_title li').removeClass('third_menu_selected');
					$('#third_02').addClass('third_menu_selected');
					$('.box01_forth_menu_01 li').removeClass('forth_menu_selected');
					$('#'+newLocation.substring(8,23)).addClass('forth_menu_selected');
				}
				
				if (newLocation == "section:bottommenu_16" || newLocation=="section:bottommenu_17"){
					$(".box01_c").html(html3);	
					$('.box01_title li').removeClass('third_menu_selected');
					$('#third_03').addClass('third_menu_selected');
					$('.box01_forth_menu_01 li').removeClass('forth_menu_selected');
					$('#'+newLocation.substring(8,23)).addClass('forth_menu_selected');
				}
			}
			
			if(newLocation.substring(0,20)=="section:bottommenu_s"){
				$(".box01_c").html(html1);	
				$('.box01_title li').removeClass('third_menu_selected');
				$('#third_04').addClass('third_menu_selected');
				$('.box01_forth_menu_01 li').removeClass('forth_menu_selected');
				$('#'+newLocation.substring(8,23)).addClass('forth_menu_selected');
			}
		
			if(newLocation.substring(0,13)=="section:third"){
				$(".box_c").html(html);	
				$('.box01_title li').removeClass('third_menu_selected');
				$('#'+newLocation.substring(8,16)).addClass('third_menu_selected');
			}
			
			if(newLocation.substring(0,16)=="section:third_04"){
				$(".box01_c").html(html1);
				$('.box01_title li').removeClass('third_menu_selected');
				$('#third_04').addClass('third_menu_selected');
			}
			
			
		break;

		default:
			if(newLocation.substring(0,18)=="section:bottommenu"){
				$(".box_c").html(html);
				if (newLocation == "section:bottommenu_14" || newLocation=="section:bottommenu_15"){
					$(".box01_c").html(html2);	
					$('.box01_title li').removeClass('third_menu_selected');
					$('#third_02').addClass('third_menu_selected');
					$('.box01_forth_menu_01 li').removeClass('forth_menu_selected');
					$('#'+newLocation.substring(8,23)).addClass('forth_menu_selected');
				}
				
				if (newLocation == "section:bottommenu_16" || newLocation=="section:bottommenu_17"){
					$(".box01_c").html(html3);	
					$('.box01_title li').removeClass('third_menu_selected');
					$('#third_03').addClass('third_menu_selected');
					$('.box01_forth_menu_01 li').removeClass('forth_menu_selected');
					$('#'+newLocation.substring(8,23)).addClass('forth_menu_selected');
				}
			}
			
			if(newLocation.substring(0,20)=="section:bottommenu_s"){
				$(".box01_c").html(html1);	
				$('.box01_title li').removeClass('third_menu_selected');
				$('#third_04').addClass('third_menu_selected');
				$('.box01_forth_menu_01 li').removeClass('forth_menu_selected');
				$('#'+newLocation.substring(8,23)).addClass('forth_menu_selected');
			}
			
			if(newLocation.substring(0,13)=="section:third"){
				$(".box_c").html(html);	
				$('.box01_title li').removeClass('third_menu_selected');
				$('#'+newLocation.substring(8,16)).addClass('third_menu_selected');
			}
			
			if(newLocation.substring(0,16)=="section:third_04"){
				$(".box01_c").html(html1);
				$('.box01_title li').removeClass('third_menu_selected');
				$('#third_04').addClass('third_menu_selected');
			}
			
	}
	
	newLocation = newLocation.replace(/section\:/, "");
	
	if (storeTagMenu!="" && newLocation!=""){
		if (storeTagMenu.substring(0,10) == "bottommenu"){
			$('#'+storeTagMenu).removeClass('forth_menu_selected');
			$('#'+newLocation).addClass('forth_menu_selected');
		}
	}
	
	if (newLocation!=""){
		menutop(newLocation, historyData);
	}

} 


$('document').ready(function(){
	$('.topmenu li').click(function(){
		menutop(this.id,'box_c');
		dhtmlHistory.add("section:"+this.id,"box_c");
	});
		
});


function bindEvent(){
	var div = 'content';
	$('.box01_forth_menu_01 li').unbind('click');
	$('.box01_forth_menu_01 li').bind('click',function(){
		$('.box01_forth_menu_01 li').each(function(){
			$(this).removeClass('forth_menu_selected');
		});	

		$(this).addClass('forth_menu_selected');
		if (this.id=="bottommenu_01"){
			div = 'box01_c';
		}
		
		if((this.id).substring(0,12)=="bottommenu_s"){
			div  = "content_c";
		}
		
		menutop(this.id,div);
		dhtmlHistory.add("section:"+this.id,div);
	});
	
	$('.box01_title li').unbind('click');
	$('.box01_title li').bind('click',function(){
		$('.box01_title li').each(function(){
			$(this).removeClass('third_menu_selected');
		})
		
		$(this).addClass('third_menu_selected');
		if (this.id=='third_04'){
			$('.box01_c').html(html1);
			menutop('bottommenu_s_01','content_c');
		}else{
			menutop(this.id, 'box01_c');
		}
		dhtmlHistory.add("section:"+this.id,'box01_c');
	});
	
	$('.box01_title_c li').unbind('click');
	$('.box01_title_c li').bind('click',function(){
		$('.box01_title_c li').each(function(){
			$(this).removeClass('third_menu_selected');
		})
		
		menutop(this.id, 'box_c');
		dhtmlHistory.add("section:"+this.id,'box_c');
	});
	
	$('.second_menu_c li').unbind('click');
	$('.second_menu_c li').bind('click',function(){
		id = this.id;
		removetopmenu();
		$(this).removeClass('second_menu_unselected').addClass('second_menu_selected');
		switch(id){
			case 'second_1': $('#second_2').addClass('tag'); $('#second_3').addClass('tag'); break;
			case 'second_2': $('#second_3').addClass('tag'); break;
			case 'second_3': $('#second_1').addClass('tag'); break;
			case 'second_4': $('#second_1').addClass('tag'); $('#second_2').addClass('tag'); break;
		}
		menutop(this.id, 'box_c');
		dhtmlHistory.add("section:"+this.id,'box_c');
	});
	
}

function removetopmenu(){
	$('.second_menu_c li').each(function(){
		$(this).removeClass('second_menu_selected tag');
		$(this).addClass('second_menu_unselected');
	});
}

function menutop(str,div){
	storeTagMenu = str;
	var url = "";
	switch(str){
		case 'default': url = "homepage/accueil.asp"; $('.box_title').html("Accueil"); break;
		case 'topmenu_01': url = "homepage/presentations.asp"; $('.box_title').html("Presentations"); break;
		case 'topmenu_02': url = "homepage/inscriptions.asp"; $('.box_title').html("Inscriptions"); break;
		case 'topmenu_03': url = "homepage/membres.asp"; $('.box_title').html("Membres"); break;
		//case 'topmenu_04': url = "bandeaux/default.asp"; $('.box_title').html("D&eacute;mo"); break;
		case 'topmenu_04': url = "lelien/default.asp"; $('.box_title').html("D&eacute;mo"); break;
		case 'topmenu_05': url = "homepage/faq.asp"; $('.box_title').html("FAQ"); break;
		case 'topmenu_06': url = "homepage/contact.asp"; $('.box_title').html("Contact"); break;
		case 'reversenments': url = "homepage/reversements.asp"; $('.box_title').html("Reversenments"); break;

		case 'second_1': url = "third/coordonnees.asp"; $('.box_title').html("Modification de vos donn&eacute;es personnelles"); break;
		case 'second_2': url="controllers/indexstats.asp"; break;
		//case 'second_3': url="bandeaux/exemple_.asp"; break;
		case 'second_3': url="lelien/default.asp"; break;
		case 'second_4': url="facturaction/default.asp"; break;
		
		case 'bottommenu_01': url = "bandeaux/exemple.asp"; break;
		case 'bottommenu_02': url = "bandeaux/ex.asp"; break;
		case 'bottommenu_03': url = "bandeaux/60x60.asp"; break;
		case 'bottommenu_04': url = "bandeaux/88x31.asp"; break;
		case 'bottommenu_05': url = "bandeaux/90x53.asp"; break;
		case 'bottommenu_06': url = "bandeaux/120x90.asp"; break;
		case 'bottommenu_07': url = "bandeaux/234x60.asp"; break;
		case 'bottommenu_08': url = "bandeaux/260x80.asp"; break;
		case 'bottommenu_09': url = "bandeaux/300x250.asp"; break;
		case 'bottommenu_10': url = "bandeaux/468x60.asp"; break;
		case 'bottommenu_11': url = "bandeaux/120x600.asp"; break;
		case 'bottommenu_12': url = "bandeaux/top.asp"; break;
		case 'bottommenu_14': url = "lelien/smile.asp"; break;
		case 'bottommenu_15': url = "lelien/blank.asp"; break;
		case 'bottommenu_16': url = "glissante/popdivcouleurlyad.asp"; break;
		case 'bottommenu_17': url = "glissante/popdivnab.asp"; break;


		case 'bottommenu_s_01': url = "Special_Bandeaux/60x60.asp"; break;
		case 'bottommenu_s_02': url = "Special_Bandeaux/88x31.asp"; break;
		case 'bottommenu_s_03': url = "Special_Bandeaux/90x53.asp"; break;
		case 'bottommenu_s_04': url = "Special_Bandeaux/120x90.asp"; break;
		case 'bottommenu_s_05': url = "Special_Bandeaux/234x60.asp"; break;
		case 'bottommenu_s_06': url = "Special_Bandeaux/260x80.asp"; break;
		case 'bottommenu_s_07': url = "Special_Bandeaux/468x60.asp"; break;
		case 'bottommenu_s_08': url = "Special_Bandeaux/120x600.asp"; break;
		case 'bottommenu_s_09': url = "Special_Bandeaux/top.asp"; break;
		
		case 'third_01': url = "bandeaux/bandeaux.asp"; break;
		case 'third_02': url = "lelien/default.asp"; break;
		case 'third_03': url = "glissante/default.asp"; break;
		case 'third_04': url = "Special_Bandeaux/default.asp"; break;
		case 'third_05': url = "Special_Bandeaux/rss.asp"; break;
		case "third_c_01": url="controllers/indexstats.asp?recul=150&n=150"; break;
		case "third_c_02": url="controllers/indexstats.asp?recul=120&n=120"; break;
		case "third_c_03": url="controllers/indexstats.asp?recul=90&n=90"; break;
		case "third_c_04": url="controllers/indexstats.asp?recul=60&n=60"; break;
		case "third_c_05": url="controllers/indexstats.asp?recul=30&n=30"; break;
		case "third_c_06": url="controllers/indexstats.asp?recul=365&n=annuelles"; break;
		case "third_c_07": url="controllers/indexstats.asp?n=analyses"; break;
		case "third_c_08": url="controllers/indexstats.asp?n=mois"; break;
		
		case 'es_01': url = "facturaction/declaration-commission.htm"; break;
	}
	jQuery.ajax({type: 'GET',url: url,success: function(data){$("."+div).html(data); bindEvent();},beforeSend: function(){}});
	
	if (str.substring(0,10) == "bottommenu"){
		$('#bottommenu_01').removeClass('forth_menu_selected');
		$("#"+str).addClass('forth_menu_selected');
	}
}

function submitAjax(url, method, data){
	jQuery.ajax({type: method,url: url, data:data, success: function(dataReturn){storeFlag = dataReturn;},beforeSend: function(){}});
}
