// JavaScript Document

var accueilNumber= 1; //  variable globale pour le choix de la page (_onefiles/../frameset.html) d'accueil par d&eacute;fault

function SetScreenLoadingMode()
	{
	document.getElementById("waitforloading").style.visibility =  "visible";
	document.getElementById("frameweboose").style.visibility =  "hidden";
	}
function ExecuteOnSearch()
{	
	//alert("maintenance : execute on search asked");
	var lookupValue = document.form.qTemp.value;
	if (lookupValue=="")
	{
		alert("merci de préciser votre recherche... // Please, enter the query before...");
	}
	else
	{
		document.getElementById("frameweboose").style.visibility =  "hidden";
		//document.getElementById("cse-search-results").style.visibility =  "hidden";		
		
		//a variable that will hold the index number of the selected radio button
		var theoneIsChecked = 0;
		//alert("document.formSearch.sitesearch.length = "+document.formSearch.sitesearch.length);
		for (i=0;i<10;i++) //i<document.formSearch.sitesearch.length
		{
			if(document.formSearch.sitesearch[i] == null)
			{//alert(document.formSearch.sitesearch[i]);
				break;
			}
			//alert("i = "+i);
			if (document.formSearch.sitesearch[i].checked==true)
			{
				theoneIsChecked=i
			//alert("i = "+i+" ; document.formSearch.sitesearch[i].checked = "+document.formSearch.sitesearch[i].checked +" ; theoneIsChecked = "+theoneIsChecked);
			}
		}
		// get Safe value
		var safe = "off";
		if (document.form.safe.checked==1) 
		{safe = "on";}
		
		// Si Autres moteur de recherche de site web (1): 		
		if(theoneIsChecked!=null)
		{
			if (theoneIsChecked ==5 && lookupValue.indexOf("site:weboose.com")==-1)
			{
					lookupValue = lookupValue + " site:weboose.com";
					//alert("lookupValue.indexOf : non trouvé ! ; modification lookupValue = "+lookupValue);			
			}				
			if (theoneIsChecked ==1 && lookupValue.indexOf(":en")==-1 )
			{
					lookupValue = ":en " +lookupValue ;
					//alert("lookupValue.indexOf : non trouvé ! ; modification lookupValue = "+lookupValue);			
			}				
		}		
		
		//like SetScreenLoadingMode
		//var escapeLookupValue = escape(lookupValue);	
		
		// FIN Si Autres moteur de recherche de site web (1) 
		
		// ALL WEB SITE SEARCH or  Weboose SEARCH
		if (theoneIsChecked == 1 || theoneIsChecked == 5 || theoneIsChecked == 0) // Seeks
		{
			
			if (theoneIsChecked == 0) // Imminent
			{
				openMainFrame();	
				document.formSearchImminent.q.value = UTF8_tool.encodeFromANSI(lookupValue);
				document.formSearchImminent.submit();	
			}
			else
			{
				openMainFrame();			
				document.formSearchSeeks.q.value = UTF8_tool.encodeFromANSI(lookupValue); 
				
				//alert(	"escapeLookupValue = "+escapeLookupValue+" ; UTF8_tool.encodeFromANSI(lookupValue) = "+UTF8_tool.encodeFromANSI(lookupValue));		
				if (safe=="off"){document.formSearchSeeks.safe.value = "off";} else {document.formSearchSeeks.safe.value = "none";} 
				document.formSearchSeeks.engines.value = "";
				document.formSearchSeeks.rpp.value = "";
				document.formSearchSeeks.submit();	
			}
		}
		/*
		if (theoneIsChecked == 0) // google (fr) search
		{
			openMainFrame();
			document.formSearchGoogle.q.value = lookupValue; 
			//alert(	"escapeLookupValue = "+escapeLookupValue+" ; UTF8_tool.encodeFromANSI(lookupValue) = "+UTF8_tool.encodeFromANSI(lookupValue));		
			if (safe=="off"){document.formSearchGoogle.safe.value = "off";} else {document.formSearchGoogle.safe.value = "none";} 
			document.formSearchGoogle.submit();	
		}
		*/
		// IMAGE SEARCH
		else if (theoneIsChecked == 2)
		{
			openMainFrame();
			
			// -------------------- Codes si google image -----------------
			//document.formSearchImage.q.value = lookupValue;
			//if (safe=="off"){document.formSearchImage.safe.value = "off";} else {document.formSearchImage.safe.value = "none";} 
			//document.formSearchImage.submit();
			
			// -------------------- Codes si aol image -----------------			
			document.formSearchAolImage.query.value = UTF8_tool.encodeFromANSI(lookupValue);
			if (safe=="off"){document.formSearchAolImage.safe.value = "off";} else {document.formSearchAolImage.safe.value = "none";} 			
			document.formSearchAolImage.submit();			
			  
		}			
		// VIDEO SEARCH
		else if (theoneIsChecked == 3)  
		{
			openMainFrame();
			// -------------------- Codes si zuula video -----------------
			
			//if (safe=="off"){document.formSearchVideo.sson.value = "off";} else {document.formSearchVideo.sson.value = "on";} 
			//document.formSearchVideo.st.value = UTF8_tool.encodeFromANSI(lookupValue);
			//document.formSearchVideo.submit();
			
			// -------------------- Codes si Blinkx -----------------
			//if (safe=="off"){document.formSearchBlinkx.safefilter.value = "off";} else {document.formSearchBlinkx.safefilter.value = "on";}
			//document.formSearchBlinkx.action = "http://www.blinkx.com/videos/"+lookupValue; 
			//document.formSearchBlinkx.submit();	
			
			// -------------------- Codes si Yahoovideo -----------------
			
			document.formSearchYahooVideo.p.value = UTF8_tool.encodeFromANSI(lookupValue); 
			document.formSearchYahooVideo.submit();	
			
			// -------------------- Codes si seeks video -----------------
			
			//if (safe=="off"){document.formSearchSeeks.safe.value = "off";} else {document.formSearchSeeks.safe.value = "none";}
			//document.formSearchSeeks.q.value = UTF8_tool.encodeFromANSI(lookupValue); 
			//document.formSearchSeeks.engines.value = "youtube,dailymotion";
			//document.formSearchSeeks.rpp.value = "40";
			//document.formSearchSeeks.submit();	
		
			// -------------------- Codes si google video (NEW VERSION) -----------------
			//if (safe=="off"){document.formSearchVideo.safe.value = "off";} else {document.formSearchVideo.safe.value = "none";} 
			//document.formSearchVideo.q.value = UTF8_tool.encodeFromANSI(lookupValue);
			//document.formSearchVideo.submit();
			// -------------------- Codes si autres moteurs video (OLD VERSION) -----------------
			// specific to video (3 levels of safe prevention)
			// OLD with GOOGLE VIDEO : if (safe=="off"){safe="none";} document.formSearchVideo.q.value = UTF8_tool.encodeFromANSI(lookupValue);
			// OLD with TRUVEO : document.formSearchVideo.query.value = lookupValue; //truveo.com
			// OLD with GOOGLE VIDEO OR TRUVEO - document.formSearchVideo.safe.value = safe;
		}
		
		// MUSIC SEARCH
		else if (theoneIsChecked == 4)
		{			
			openMainFrame();
			lookupValue = UTF8_tool.encodeFromANSI(lookupValue);
			
			document.formSearchMusique2.q.value = lookupValue;
			// music2
			//document.formSearchMusique2.submit();
			//javascript:popitup(document.formSearchMusique2.action+'?q='+lookupValue+'&uni='+document.formSearchMusique2.uni.value,800,670,'no','yes','yes','musicme');
			
			//music1
			//document.formSearchMusique.action = document.formSearchMusique.action + escape(lookupValue) ;
			//document.formSearchMusique.submit();
			javascript:popitup(document.formSearchMusique.action+escape(lookupValue),570,700,'no','yes','yes','deezer');
		}
			// PEOPLE SEARCH
		else if (theoneIsChecked == 6)
		{
			openMainFrame();
			document.formSearchPeople.action = "http://www.123people.fr/s/"+lookupValue; //lookupValue ;
			//if (safe=="off"){document.formSearchImage.safe.value = "off";} else {document.formSearchImage.safe.value = "none";} 
			document.formSearchPeople.submit();	
		}		
			// SHOPPING SEARCH
		else if (theoneIsChecked == 7)
		{
			openMainFrame();
			document.formSearchShopping.q.value = UTF8_tool.encodeFromANSI(lookupValue); //lookupValue ;
			//if (safe=="off"){document.formSearchImage.safe.value = "off";} else {document.formSearchImage.safe.value = "none";} 
			document.formSearchShopping.submit();	
		}	
		else if (theoneIsChecked == 8)
		{
			// GOOGLE MAP
			//openMainFrame();
			//document.formSearchGoogleMap.q.value = UTF8_tool.encodeFromANSI(lookupValue); //lookupValue ;			
			//document.formSearchGoogleMap.submit();	
			
			// MAPPY
			openMainFrame();
			document.formSearchMappy.d.value = UTF8_tool.encodeFromANSI(lookupValue); //lookupValue ;			
			document.formSearchMappy.submit();	
		}	
	}
}

function openMainFrame(page)
{
	//alert("maintenance : openMainFrame asked");
	//change the height of the regular frame to let enough place to display the frame instead of the query results to be display
		
	document.getElementById("waitforloading").style.visibility =  "visible";//"visible"
	var mainFrame = document.getElementById('frameweboose');
	mainFrame.style.display = "block";
	document.getElementById("frameweboose").style.visibility =  "visible";
	document.getElementById("waitforloading").style.visibility =  "hidden";//"visible"
}

function closeMainFrame()
{
	document.getElementById("waitforloading").style.visibility =  "hidden";//"visible"	
	document.getElementById("frameweboose").style.visibility =  "hidden";	
	//change the height of the regular frame to let enough place for the query results to be display	
	var mainFrame = document.getElementById('frameweboose');
	mainFrame.style.display = "none";
	mainFrame.height = "0";
	
	if ((navigator.appName=='Microsoft Internet Explorer') &&
    (parseInt(navigator.appVersion)>=4))
  	{  // iexplore
    		// set the onglet src to null in order to help to reload the query without the param "rechercher" while clicking on one of the onglets	
			var query="" ;//= "&page="+page;
			query = query+"&q="+document.form.qTemp.value;
			query = query+"&safe="
			query += (document.form.safe.checked==1)?"on":"off";
			
			var linkplansite = document.getElementById("plansite");				
			linkplansite.href ="index.html?"+query;
			linkplansite.target="_top";
			linkplansite.onClick="";	
				
			var onglet0 = document.getElementById("onglet0");				
			onglet0.href ="index.html?"+query+"&page=0";
			onglet0.target="_top";
			onglet0.onClick="";		
	
			var onglet1 = document.getElementById("onglet1");				
			onglet1.href ="index.html?"+query+"&page=1";
			onglet1.target="_top";
			onglet1.onClick="";				
				/*	
			var onglet2 = document.getElementById("onglet2");				
			onglet2.href ="index.html?"+query+"&page=2";
			onglet2.target="_top";
			onglet2.onClick="";
			*/
			
			var onglet3 = document.getElementById("onglet3");				
			onglet3.href ="index.html?"+query+"&page=3";
			onglet3.target="_top";
			onglet3.onClick="";
		
  	}
 	 else{}  // Firefox
	//document.getElementById("cse-search-results").style.visibility =  "visible";
	ResizeFrames();
}
function ResizeFrames()
{
	//alert("maintenance : ResizeFrames asked");
	var mainFrame = document.getElementById('frameweboose');
	var searchDiv = document.getElementById('cse-search-results');
	var searchAreaHeight = 0;
	var clientHeight = document.body.clientHeight;
	var maxheight = screen.height; 
	if ((navigator.appName=='Microsoft Internet Explorer') &&
    (parseInt(navigator.appVersion)>=4))
  	{		//internet explorer
	searchAreaHeight = 115;
	if (maxheight<1000)
		{
			mainFrame.height =  (clientHeight-searchAreaHeight>0)?clientHeight-searchAreaHeight:(68/100)*maxheight;//"100%";			
			searchDiv.style.height =(clientHeight-searchAreaHeight>0)?clientHeight-searchAreaHeight: (71/100)*maxheight; 
		}
		else
		{
			mainFrame.height = (clientHeight-searchAreaHeight>0)?clientHeight-searchAreaHeight:(74/100)*maxheight;//"100%";			
			searchDiv.style.height =(clientHeight-searchAreaHeight>0)?clientHeight-searchAreaHeight: (75/100)*maxheight;  
		}		
	}
	else   //firefox
	{
	searchAreaHeight = 120;
	if (maxheight<1000)
		{
			mainFrame.height = (clientHeight-searchAreaHeight>0)?clientHeight-searchAreaHeight:(67/100)*maxheight;//"100%";
			searchDiv.style.height = (clientHeight-searchAreaHeight>0)?clientHeight-searchAreaHeight: (69/100)*maxheight; // 550 
		}
		else
		{
			mainFrame.height =(clientHeight-searchAreaHeight>0)?clientHeight-searchAreaHeight: (77/100)*maxheight;//"100%";
			searchDiv.style.height = (clientHeight-searchAreaHeight>0)?clientHeight-searchAreaHeight: (74/100)*maxheight; // 550 
		}	
	}
		
}
function CheckId(i)
{
document.formSearch.sitesearch[i].checked=1;
}
function ExecuteOnUnLoad()
{
	SetScreenLoadingMode();
}
	//,"_onefiles/style/MagentaTab_LeftCorner.gif"
	//,"_onefiles/style/MagentaTab_Middle.gif"
	//,"_onefiles/style/MagentaTab_RightCorner.gif"
MM_preloadImages(	
	"images/banner_green.gif"
	,"images/banner_blue.gif"
	,"images/banner_purple.gif"			
	,"_onefiles/style/PurpleTab_LeftCorner.gif"
	,"_onefiles/style/PurpleTab_Middle.gif"
	,"_onefiles/style/PurpleTab_RightCorner.gif"	
	,"_onefiles/style/GreenTab_LeftCorner.gif"
	,"_onefiles/style/GreenTab_Middle.gif"
	,"_onefiles/style/GreenTab_RightCorner.gif"		
	,"_onefiles/style/BlueTab_LeftCorner.gif"
	,"_onefiles/style/BlueTab_Middle.gif"
	,"_onefiles/style/BlueTab_RightCorner.gif"			
	,"_onefiles/style/RolloverTab_LeftCorner.gif"
	,"_onefiles/style/RolloverTab_Middle.gif"
	,"_onefiles/style/RolloverTab_RightCorner.gif"
	,"_onefiles/style/RolloverTab.gif"
	,"_onefiles/style/RolloverPage_RightCorner.gif"
	,"_onefiles/style/RolloverPage_Body.gif"	
	);
function ExecuteOnLoad()
{
	//alert("maintenance : page ExecuteOnload asked");
	SetScreenLoadingMode();		
	var safe = getQueryString("safe");
	if (safe=="off" || safe =="none")
	//alert("safe"+safe);
	{document.form.safe.checked = 0;} // unchecked if explicitly noticed
	else
	{document.form.safe.checked = 1;}	
	if (parent.location.search.length>3) //means there is a filled query -- if not the following is not needed obviously...
	{
		//first time only:  check on the queryString if the q parameter is filled and though filled in the input text related		
		var lookupValue = getQueryString("q");	
		if (lookupValue !="" && lookupValue!=null )
		{		
			lookupValue = replaceAll(lookupValue,'+',' ');
			var qTemp = document.form.qTemp.value;
			if (qTemp=="")
			{			
				var unescapeLookupValue = "";
			
				if (lookupValue.indexOf("Ã")!=-1)// so need to be decoded
				{unescapeLookupValue = UTF8_tool.decodeToANSI(lookupValue);}
				else 
				{unescapeLookupValue = unescape(lookupValue);}			
 				document.form.qTemp.value = unescapeLookupValue;
			}
		}

		// SIMPLE SEARCH (Web & Weboose and not Video, Music, Artiste... )
		// check on the query to know if we are under a search process 
		var sa = "";
		sa = getQueryString("sa");	
		if (sa=="Rechercher")
		{	
			closeMainFrame();	
			return;
		}
		else  // first opening without any request
		{	
			//check prior if the Reloading of the main frame is needed (for instance while it occurs from a go back button - with IE only then we should'nt call 			this action
			var page = "";
			page = getQueryString("page");		
			
			if (page!="" && page!=null)
			{
				if (page>=0 || page<=100)
				{			
					document.getElementById("frameweboose").src="_onefiles/"+page+"/SectionFrameset.html";
				}					
				else
				{
					// si la destination contient les chaines "_onefiles/" et "/page"
					// alors on récupère le numero de l'onglet (v_onglet) et le numéro de la page (v_dest)
					//alert ("indexOf : "+page.indexOf("_onefiles/", 0)+ " - "+page.indexOf("/page", 0));
					
					var v_ongletIndexOf = page.indexOf("_onefiles/");
					var v_destIndexOf = page.indexOf("/page");
					var v_destIndexOf_end = page.indexOf(".htm");
					
					//alert("page = "+page+" - "+"v_ongletIndexOf = "+v_ongletIndexOf+" - "+"v_destIndexOf = "+v_destIndexOf+" - "+"v_destIndexOf_end = "+v_destIndexOf_end);
					
					if (v_ongletIndexOf>-1 && v_destIndexOf>-1 && v_destIndexOf_end>-1 )
					{						
						var v_onglet = page.substring(v_ongletIndexOf+10,v_ongletIndexOf+10+1);
						//alert ("v_onglet = "+v_onglet);	
						
						var v_dest = page.substring(v_destIndexOf+5,v_destIndexOf+5+(v_destIndexOf_end-v_destIndexOf-5));
						//alert ("v_dest = "+v_dest);					
						//alert ("newDestination = "+"_onefiles/"+v_onglet+"/SectionFrameset"+v_dest+".html");
						document.getElementById("frameweboose").src = "_onefiles/"+v_onglet+"/SectionFrameset"+v_dest+".html";						
					}						
					else if(page.indexOf("wordpress")>=0)
					{
					document.getElementById("frameweboose").src="_onefiles/1/SectionFramesetwordpress.html";
					}
					else if(page.indexOf("top-info")>=0 || page.indexOf("topinfo")>=0)
					{
					document.getElementById("frameweboose").src="_onefiles/1/SectionFramesetjournaltopinfos.html";
					}
					else if(page.indexOf("nibiru")>=0 || page.indexOf("elenin")>=0 || page.indexOf("planetx")>=0)
					{
					document.getElementById("frameweboose").src="_onefiles/1/SectionFramesetjournalnibiru.html";
					}
					else if(page.indexOf("besttwitters")>=0 || page.indexOf("bestwitters")>=0 || page.indexOf("bestwitter")>=0 || page.indexOf("besttwitter")>=0)
					{
					document.getElementById("frameweboose").src="_onefiles/1/SectionFramesetjournalbesttwitters.html";
					}
					else if(page.indexOf("bankster")>=0)
					{
					document.getElementById("frameweboose").src="_onefiles/1/SectionFramesetbanksters.html";
					}
					else if(page.indexOf("ploutocrat")>=0)
					{
					document.getElementById("frameweboose").src="_onefiles/1/SectionFramesetploutocratie.html";
					}
					else if(page.indexOf("asservissement")>=0)
					{
					document.getElementById("frameweboose").src="_onefiles/1/SectionFramesetAsservissement.html";
					}
					else if(page.indexOf("soleil")>=0 || page.indexOf("solaire")>=0 )
					{
					document.getElementById("frameweboose").src="_onefiles/1/SectionFramesetSoleil.html";
					}
					else if(page.indexOf("immo")>=0)
					{
					document.getElementById("frameweboose").src="_onefiles/1/SectionFramesetimmo.html";
					}
					else {document.getElementById("frameweboose").src = page;}// default				
				}	
			}
			else {document.getElementById("frameweboose").src="_onefiles/"+accueilNumber+"/SectionFrameset.html";}			
		}

	}
	else 
	{	
		// UNLOCK THE FOLLOWING Only if google is used for search		
		//document.getElementById("frameweboose").src="_onefiles/"+accueilNumber+"/SectionFrameset.html";
	}	

	openMainFrame(); 
	ResizeFrames();
	//alert("maintenance : page ExecuteOnload done");
}
