/**
 * @author Wen Okunhon
 */
		
			
		function newUrl(href){ 			
				$("#modal_box").css("display","block");	
				$('#tab-right').html(" ");			
				$.get("include/ajax.php",{loc : ""+href+""},function(data){
					if(href != "http://www.dominiquelehmann.com/admin/client/" & href != "client/"){
						if(data.length>1){
							$('#tab-left').animate({ 
								width: "243px"
							  }, 500 );
							  $('#tab-right').animate({ 
								width: "705px"
							  }, 500 );
							$('#tab-left').load(data);
						}else{
							$('#gest-error').html("<p>Cette page n'as pas été trouvé.</p>");
						}
					}else{
						if(data.length>1){
							$('#tab-right').animate({ 
									width: "0px"
								  }, 500  );
							$('#tab-left').animate({ 
									width: "940px"
								  }, 500 );
							$('#tab-left').load(data);
						}else{
							$('#gest-error').html("<p>Cette page n'as pas été trouvé.</p>");
						}
					}						
				});
				$("#modal_box").css("display","none");
			}
			
			function addArticle(qstring){
				$.post("include/add.php",{art : ""+qstring+""},function(data){
					if(data==true){
						$('#gest-error').html('Enregistrement effectué');
						newUrl(qstring);
					}else{
						$('#gest-error').html(data);						
					}
				});
			}
			
			function modArticle(qstring,qint) {
				$.post("include/change.php",{art : ""+qstring+"", artid : ""+qint+""},function(data){
					if(data==true){
						$('#gest-error').html('Modifications effectué');
						newUrl(qstring);
					}else{
						$('#gest-error').html(data);
					}
				});
			}
			
			function delArticle(qstring,qint) {
				if (confirm('Êtes-vous certain de vouloir supprimer cet article ?')) {
					$.post("include/delete.php", {
						art: "" + qstring + "",
						artid: "" + qint + ""
					}, function(data){
						if (data == true) {
							$('#gest-error').html('L\'article a été supprimé.');
							if(qstring=="detail_astro"){
								qstring = "astro";
							}
							newUrl(qstring);
						}
						else {
							$('#gest-error').html(data);
						}
					});
				}
			}
			
			function viewArticle(qstring,qint) {
				$.get("include/view.php",{wht : "view",art : ""+qstring+"", artid : ""+qint+""},function(data){
					if(data.length>0){
						if(qstring == "question"){
							$("#tab-left").html(" ");
							$("#modal_box").css("display","block"); 
							$('#tab-left').animate({ 
								width: "0px"
							  }, 500 );
							  $('#tab-right').animate({ 
								width: "940px"
							  }, 500 );
							$('#tab-right').load(data);
							$("#modal_box").css("display","none");
						}else{
						$('#tab-right').load(data);
						}						
					}else{
						$('#gest-error').html("Aucun aperçu");
					}
				});
			}
			
			function getFormadd(qstring) {
				$.get("include/view.php",{wht : "add",art : ""+qstring+""},function(data){
					if(data.length>0){
						$('#tab-right').load(data);
						
					}else{
						$('#gest-error').html("Aucun aperçu");
					}
				});
			}
			
			function getFormChange(qstring,qint) {
				$.get("include/view.php",{wht : "change",art : ""+qstring+"", artid : ""+qint+""},function(data){
					if(data.length>0){
						$('#tab-right').load(data);
						
					}else{
						$('#gest-error').html("Aucun aperçu");
					}
				});
			}
			
			function getthh(qstring){
				tb_show("",qstring+"&KeepThis=true&TB_iframe=true&height=500&width=650",null);
			}
			
			
			function handleSliderChange(e, ui)
			{
			  var maxScroll = $("#tab-left").attr("scrollWidth") -
			                  $("#tab-left").width();
			  $("#tab-left").animate({scrollLeft: ui.value *
			     (maxScroll / 100) }, 1000);
			}
			
			function handleSliderSlide(e, ui)
			{
			  var maxScroll = $("#tab-left").attr("scrollWidth") -
			                  $("#tab-left").width();
			  $("#tab-left").attr({scrollLeft: ui.value * (maxScroll / 100) });
			}

			function subForm(formulaire){
				alert(formulaire + "héhé");
				$("#"+formulaire+"").submit;
			}

			function GetParameters()
			{
				var arg = new Object();
				var href = document.location.href;
			
				if ( href.indexOf( "?") != -1)
				{
					var params = href.split( "?")[1];
					var param = params.split("&");
					
					for (var i = 0; i < param.length; ++i)
					{
						var name = param[i].split( "=")[0];
						var value = param[i].split( "=")[1];			
						arg[name] = value;
					}
				}
				return arg;
			}
			
			function getPage(qS){	
				var url = GetParameters();
				url["page"] = qS;
				if(url['interview'] == "undefined"){
					url['interview'] = '';
				}	
				if(url['year'] == "undefined"){
					url['year'] = '';
				}
				var loc = $("#rooturl").text() + "interviews/";	
				window.location.href = loc + '?interview=' + url['interview'] + '&year=' + url['year'] + '&page=' + url['page'] ;
				return false;
			}
			
			function getPage2(qS){	
				var url = GetParameters();
				url["page"] = qS;
				if(url['media'] == "undefined" || url['media'] == ""){
					url['media'] = '';
				}	
				if(url['pays'] == "undefined" || url['pays'] == ""){
					url['pays'] = '';
				}//alert(url['media']+'\n'+url['pays']);
				var loc = $("#rooturl").text() + "actualites/";	
				window.location.href = loc + '?pays=' + url['pays'] + '&media=' + url['media'] + '&page=' + url['page'] ;
				return false;
			}
			
			function getPage3(qS,href){	
				$.get("include/ajax.php",{loc : ""+href+"",page : ""+qS+""},function(data){
					if(data.length>0){
						$("#modal_box").css("display","block"); 
						$('#tab-left').load(data);
						$("#modal_box").css("display","none"); 	
					}else{
						$('#gest-error').html("Aucun aperçu");
					}
				});
			}
			
			function getUrl_pays(qS){
				var url = GetParameters();
				url["pays"] = qS;
				if(url['media'] == "undefined"){
					url['media'] = '';
				}
				var loc = $("#rooturl").text() +"actualites/";	
				window.location.href = loc + '?pays=' + url['pays'] + '&media=' + url['media'] ;
				return false;
			}
			
			function getUrl_media(qS){
				var url = GetParameters();
				url["media"] = qS;
				if(url['pays'] == "undefined"){
					url['pays'] = '';
				}
				var loc = $("#rooturl").text() + "actualites/";	
				window.location.href = loc + '?pays=' + url['pays'] + '&media=' + url['media'] ;
				return false;
			}
			
			function getSelected(qS) { 
				var selected = qS;
				var date = '';
				if (selected != "") {
					if (selected == "Bélier") {
					date = 'du 21 mars au 20 avril';
					}
					else 
					if (selected == "Taureau") {
					date = 'du 21 avril au 21 mai';
					}
					else 
					if (selected == "Gémeaux") {
					date = 'du 22 mai au 21 juin';
					}
					else 
					if (selected == "Cancer") {
					date = 'du 22 juin au 22 juillet';
					}
					else 
					if (selected == "Lion") {
					date = 'du 23 juillet au 23 août';
					}
					else 
					if (selected == "Vierge") {
					date = 'du 24 août au 23 septembre';
					}
					else 
					if (selected == "Balance") {
					date = 'du 24 septembre au 23 octobre';
					}
					else 
					if (selected == "Scorpion") {
					date = 'du 24 octobre au 22 novembre';
					}
					else 
					if (selected == "Sagittaire") {
					date = 'du  23 novembre au 21 décembre';
					}
					else 
					if (selected == "Capricorne") {
					date = 'du 22 décembre au 20 janvier';
					}
					else 
					if (selected == "Verseau") {
					date = 'du 21 janvier au 18 février';
					}
					else 
					if (selected == "Poissons") {
					date = 'du 19 février au 20 mars';
					}
				}
				$("#date_n_signe").attr("value", date); 
				$("#date_n_signe").attr("readonly", "readonly");
			}
			
			function lookup(inputString) {
				if(inputString.length == 0) {
					$('#suggestions').hide();
				} else {
					$.post("include/rpc.php", {queryString: ""+inputString+""}, function(data){
						if(data.length >0) {
							$('#suggestions').show();
							$('#autoSuggestionsList').html(data);
						}else{
							$('#suggestions').hide();
						}
					});
					
				}
			} 
			
			function fill(thisValue) {
				$('#inputString').val(thisValue);
				$('#suggestions').hide();
			}
			
			function chgStat(qS,qI){
				if(confirm("Vous êtes sur le point de changer le statut : \n Vos autres modifications ne seront pas sauvegardé.")){
					$.post("include/add.php", 
					{uStatut : ""+qS+"" ,
					name: "question" ,
					crea_upd : "",
					uId: ""+qI+"" 
					},
					function(data){
							viewArticle('question',qI);
						});
				}
			}
			
			function TriTbl(qstring,href){
				var selected  = $("#"+qstring+" option:selected").val();
				if(selected != ''){
					$.get("include/ajax.php",{loc : ""+href+"",tri : ""+selected+""},function(data){
					if(data.length>0){
						$("#modal_box").css("display","block"); 
						$('#tab-left').load(data);
						$("#modal_box").css("display","none"); 	
					}else{
						$('#gest-error').html("Aucun aperçu");
					}
				});
				}
			}

