/* Functions in this file
 
		PrintLogo						20
		PrintHead						46
		PrintMenu						79
		newWindow						326
		showMap							333
		getObj							345
		colorText						369
		fourNumbers					382
		isNumber						393
		errorMessage				417
		bas									442				
		QueryString					473
		modQueryString			508
		createQueryString		561
		infoMsg							572
		winMsg							593
*/


//var baseurl='http://www.parisaquatique.org/';
var baseurl='/';

function newWindow(mypage) 
{
  win = window.open(mypage,"photo","status=yes,toolbar=no,directories=no,scrollbars=yes,width=800,height=600,resizable=yes,left=0,top=0");
  win.window.focus();
}

//-------------------------------------------------------------------
function showMap(mypage) 
{
	win = window.open(mypage, "map", "toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,directories=yes,location=yes,left=0,top=0")
	win.window.focus();
}

/*--------------------------------------------------------------------- 
  getObj() returns the requested object
-----------------------------------------------------------------------*/

var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name)
{
//alert('name = ' + name);
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
		this.value = document.getElementById(name).value;
  }
  else if (document.all)
  {
		this.obj = document.all[name];
		this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

/*------------------------------------------------------------
 colorText() changes the indicated text to the selected color
--------------------------------------------------------------*/
function colorText(txt, txtcolor)
{
		if (!DHTML) return;
//alert('txt = ' + txt);
		var x = new getObj(txt);
		x.style.color = txtcolor;
}
//--------------------------------------------

/*---------------------------------------------------------------
 fourNumbers() Limits the number of characters in field1 to 4
  then skips to field2
-----------------------------------------------------------------*/
function fourNumbers(field1, field2)
{
		var x = new getObj(field1);
		var letters=x.value.length + 1;
if(letters>4)
	{document.getElementById(field2).focus();}
}

/*---------------------------------------------------------
 isNumber() Verifies that the data in the field is numeric
-----------------------------------------------------------*/
function isNumber(fld)
{
  var parsed = true;
  var validchars = "0123456789";
    
  for (var i=0; i <fld.length; i++) 
  {
    var letter = fld.charAt(i);
    if (validchars.indexOf(letter) != -1)
    {
      continue;
    }
    else
    {
    	parsed = false;
    	break;
    }
  }
  return parsed;
}

/*---------------------------------------------------------------
  errorMessage opens a window and writes the error messages
-----------------------------------------------------------------*/
function errorMessage(errorField, errorFlag, Error_Msg1, Error_Msg2)
{
		var errorWin=window.open("errorpage.htm",'error_win', 'height=300, width=300, toolbar=yes, menubar=no, location=no scrollbar=yes');
    errorWin.document.write("<html>");
    errorWin.document.write("<b>" + "<font color = 'red'>");
		errorWin.document.write(Error_Msg1);
		errorWin.document.write("<br>");
    errorWin.document.write("</b>" + "</font>");
		for(i = 1; i <= errorFlag; i++)
		{
    	errorWin.document.write("<b>" + "<font color = 'red'>" + "&nbsp;&nbsp;&nbsp;");
			errorWin.document.write(errorField[i]);
    	errorWin.document.write("</font>" + "</b>" + "<br>");
		}
		errorWin.document.write("<br>");
		errorWin.document.write("<A href='javascript://' onclick='javascript:self.close()'>");
		errorWin.document.write(Error_Msg2 + "</A>");
    errorWin.document.write("</html>");
		errorWin.moveTo(0,0);
		errorWin.focus();
}

/*-------------------------------------------------------------------------------------
Writes the webmaster's email address at the bottom of the page
---------------------------------------------------------------------------------------*/
function bas()
{
document.write("<table width='600' align='center' background='images/bg_whole.gif'>");
document.write("	<tr>");
document.write("		<td align='center'>");
document.write("			<font size='2' face='Arial'>");
document.write("				<a href='mailto:postmaster@ahparis.com' target='principal' class='norm'>webmaster</a>");
document.write("			</font>");
document.write("		</td>");
document.write("	</tr>");
document.write("	<tr>");
document.write("		<td align='center' valign='bottom' class='petit'>");
document.write("				Ah Paris! provides short term apartment flat rentals for vacation or business travel to Paris");
document.write("		</td>");
document.write("	</tr>");
document.write("</table>");
document.write("<table width='600' align='center' background='images/bg_bot.gif'>");
document.write("	<tr>");
document.write("		<td align='center' height='2' valign='bottom'>");
document.write("			<br>");
document.write("		</td>");
document.write("	</tr>");
document.write("</table>");

}


/*--------------------------------------------------------------------------------
 QueryString returns the value associated with the key
----------------------------------------------------------------------------------*/

function QueryString(key)
{
	QueryString.keys = new Array();
	QueryString.values = new Array();
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	value = null;
	for (i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;
		}
	}

	for (i=0;i<QueryString.keys.length;i++)
	{
		if (QueryString.keys[i]==key)
		{
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}

/*-------------------------------------------------------------------------------
ModQueryString replaces the value in the "key" field with a new value
  if the key field doesn't exist, it creates a new field
---------------------------------------------------------------------------------*/

function modQueryString(key, modif)
{
	QueryString.keys = new Array();
	QueryString.values = new Array();
	var QString = "";
	//This gives you the query string
	var query = window.location.search.substring(1);
	//If there is no querystring, create a default query string
	if(query.length < 1)
	{
		query = createQueryString();
	}
	//This splits the query string on the symbol "&" creating an array of pairs "x=y" 
	var pairs = query.split("&");
	var value = null;
	for (var i=0;i<pairs.length;i++)
	{
		//Split the pairs into the key and it's value
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			//Create the array QueryString.keys
			QueryString.keys[QueryString.keys.length] = argname;
			//Create the corresponding key value array QueryString.values
			QueryString.values[QueryString.values.length] = value;
		}
	}

	for (i=0;i<QueryString.keys.length;i++)
	{
		//Find the index of the key
		if (QueryString.keys[i]==key)
		{
			//Replace the value with the modified value
			QueryString.values[i] = modif;
			break;
		}
	}
	//Recreate the query string
	QString = QueryString.keys[0] + "=" + QueryString.values[0];
	for (i = 1;i<QueryString.keys.length;i++)
	{
		QString = QString + "&" + QueryString.keys[i] + "=" + QueryString.values[i];
	}
	return QString;
}

/*--------------------------------------------------------
Creates a default QueryString
----------------------------------------------------------*/

function createQueryString()
{
	var QString = "lang=en&pageNo=1";
	return QString;
}

/*---------------------------------------------------------------
  InfoWindow opens a window and writes the member information
-----------------------------------------------------------------*/
info_win=0;
function infoMsg(LName, FName, tel, email,UN)
{
	 if(info_win!=0){info_win.close();};
	 //if(infoWin!=0){infoWin.close();}//document.innerHTML="";
		//var infoWin=window.open("memberinfo.html",'info_win', 'height=300, width=290, toolbar=yes, menubar=no, location=no scrollbar=yes');
		var infoWin=window.open("memberinfo.php?LName="+LName+"&FName="+FName+"&UN="+UN,'info_win', 'height=300, width=290, toolbar=yes, menubar=no, location=no scrollbar=yes');
    
    infoWin.document.write("<html>");
//    infoWin.document.write("<img src='pic/logo/pa.gif'><br><br>");
    infoWin.document.write("<img src='"+baseurl+"pic/trait_270x1_rouge.gif'><br>");
    infoWin.document.write("<b>" + "<font size='2' face='Arial' color='#ff0000'>");
    infoWin.document.write(FName + '&nbsp;' + LName);
    infoWin.document.write("</font><img src='"+baseurl+"pic/trait_270x1_rouge.gif'><br>");
//newtext =newtext0.replace(/%/g,"");
      	 
    infoWin.document.write("<br><img src='"+baseurl+"pic/page/memb/"+escape(LName)+"-"+escape(FName)+".jpg' width=200>");

    infoWin.document.write("<font size='2' face='Arial' color='#999999'>");
    infoWin.document.write("<br><br>téléphone : ");
    infoWin.document.write(tel);
    infoWin.document.write("<br>");

    infoWin.document.write("<a href='mailto:" + email + "' target='principal' class='lien'>" + email + "</a><br><br>");

    infoWin.document.write("<img src='"+baseurl+"pic/trait_270x1_rouge.gif'><br>");
    infoWin.document.write("<br>");
    infoWin.document.write("<a href='javascript://' onclick='javascript:self.close()'>");
    infoWin.document.write("<align=right>" + "<font size='1' face='Arial' color = '#999999'>");
    infoWin.document.write("fermer</a>");

    infoWin.document.write("</html>");
		infoWin.moveTo(0,0);
		infoWin.focus();
}



function winMsg(msg)
{
		alert(msg);
		var msgWin=window.open("succes.htm",'error_win', 'height=300, width=300, toolbar=yes, menubar=no, location=no scrollbar=yes');
    msgWin.document.write("<html>");
    msgWin.document.write("<font color = 'blue'><b>");
		msgWin.document.write(msg);
    msgWin.document.write("</b></font><br><br>");
		msgWin.document.write("<A href='javascript://' onclick='javascript:self.close()'>");
		msgWin.document.write("Cliquez ici pour fermer" + "</A>");
    msgWin.document.write("</html>");
		msgWin.moveTo(0,0);
		msgWin.focus();
}

