var ns4 = (document.layers)? true:false;         //NS 4
var ie4 = (document.all)? true:false;         //IE 4
var dom = (document.getElementById)? true:false;   //NS 6 ou IE 5
var nav = (document.layers);
var iex = (document.all);


function favoris(urlv)
{
	if ( navigator.appName != 'Microsoft Internet Explorer' )
	{
		window.sidebar.addPanel("Medonline",urlv,"");
	}
	else {
		window.external.AddFavorite(urlv,"Medonline");
	}
}

function SetDiv(ID,Content)
{
	
	if(Content!="<div class=\"text\"></div>"){
		if (dom)
		{
			if(document.getElementById(ID)){
			document.getElementById(ID).innerHTML = Content;}
			return;
		}
		else if (ie4)
		{
			document.all[ID].innerHTML = Content;
			return;
		}
		else if (ns4)
		{
			with (eval('document.'+ID+'.document'))
			{
				open();
				write(Content);
				close();
			}
			return;
		}
	}
}
function GetDiv(ID)
{
	if (dom)
	{
		return document.getElementById(ID).innerHTML ;
	}
	else if (ie4)
	{
		return document.all[ID].innerHTML ;
	}

}
function IsNumeric(strString)
{
	var strValidChars  = "0123456789";
	var strChar;
	var blnResult = true;
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}
function ShowDiv(divname)
{
	document.getElementById(divname).style.display=(document.getElementById(divname).style.display=='none' ? "block" : "none");
}
function IsString(strString)
{
	strString = strString.toUpperCase();
	var strValidChars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var strChar;
	var blnResult = true;
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		if (strValidChars.indexOf(strString.substr(i,1)) <0)
		{
			blnResult = false;
		}
	}
	return blnResult;
}
function IsStringNumeric(strString)
{
	strString = strString.toUpperCase();
	var strValidChars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	var strChar;
	var blnResult = true;

	for (i = 0; i <= strString.length && blnResult == true; i++)
	{
		strChar = strString.substr(i,1);
		//alert(strString.charAt(i));
		if (strValidChars.indexOf(strChar) <0)
		{
			blnResult = false;
		}
	}
	return blnResult;
}


function Appear(divname,tmm)
{
	window.setTimeout("document.getElementById('"+divname+"').style.visibility='hidden';",tmm);
}
function Disapear(divname)
{
	window.setTimeout("document.getElementById('"+divname+"').style.visibility='visible';",100);
}
function noaccent(varme)
{
	newvarme='';
	for(var i=0; i<varme.length;i++)
	{
		if(IsString(varme.substr(i,1))==true || IsNumeric(varme.substr(i,1))==true || varme.substr(i,1)==" " || varme.substr(i,1)=="-")
		{
			newvarme= newvarme+varme.substr(i,1);
		}
	}
	return newvarme;
}
function PSR_imprimer (DivName) {
	var PSR_f1 = null;
	var PSR_content=document.getElementById(DivName).parentNode.innerHTML;
	//GenerateStats
	var PSR_title="Impression";
	if (PSR_f1) {if(!PSR_f1.closed) PSR_f1.close();}
	PSR_f1 = window.open ('imprimer.html',"printit", "height=600,width=700,menubar=yes,scrollbars=yes,resizable=yes,,left=10,top=10"); ;
	PSR_f1.document.open();
	PSR_f1.document.write("<html><head><title>" + PSR_title + "</title><link href='includes/css/CssClasses.css' rel='stylesheet' type='text/css'>");
	PSR_f1.document.write("</head><body bgcolor='#ffffff' leftmargin='10' topmargin='10' marginheight='10' marginwidth='10'><table cellspacing=10 cellpadding=0 border=0><tr><td>"+PSR_content+"</td></tr></TABLE></body></html>");
	PSR_f1.document.close();
	//PSR_f1.document.getElementById(DivName).style.visibility='hidden';
	PSR_f1.focus();
	PSR_f1.location.reload();
	PSR_f1.print();
}

function updateLink_definition(tag,url,title)
{
	if(ie4)
	{
		document.links(tag).href=url;
		document.links(tag).title=title;
	}
	else{
		document.links[tag].href=url;
		document.links[tag].title=title;
	}
}
function VerificationEmail(str)
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
		return false
	}

	if (str.indexOf(" ")!=-1){
		return false
	}

	return true
}
default_rollover=0;
//flash interactions
function thisMovie(movieName) {
	// IE and Netscape refer to the movie object differently.
	// This function returns the appropriate syntax depending on the browser.
	if (navigator.appName.indexOf ("Microsoft") !=-1) {
		return window[movieName]
	}	else {
		return window.document[movieName]
	}
}

// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie) {
	if (typeof(theMovie) != "undefined") {
		return theMovie.PercentLoaded() == 100;
	} else {
		return false;
	}
}




function MM_controlShockwave(movieName,theFrame)
{
	var obj;
	if (obj=MM_findObj(movieName)) {
		if(obj){
			try{
				obj['GotoFrame'](theFrame);
				//obj['Play'](theFrame);
			}
			catch(e){
				
			}
		}
	}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
} 

function go(theFrame,movieName) {
	//alert(theFrame);
	if(ie4){
		if (movieIsLoaded(thisMovie(movieName))) {
				thisMovie(movieName).GotoFrame(theFrame);
				//thisMovie(movieName).Play();
		}
	}
	else{
		MM_controlShockwave(movieName,theFrame);
	}
}


function Display_error(elform,elem,type)
{
	if(type==0){
		elform.elements[elem].style.backgroundColor="#082e5f";
		elform.elements[elem].style.color="#ffffff";
		elform.elements[elem].style.border="#0a73b4 solid 1px";
	}
	else{
		elform.elements[elem].style.backgroundColor="#d41b1b";
		elform.elements[elem].style.color="#ffffff";
		elform.elements[elem].style.border="#ffffff solid 1px";
	}
}
function goFocus(msg,elform,elem)
{
	Display_error(elform,elem,1);
	if(msg=="")
	{
		elform.elements[elem].focus();
	}
}

function Goupdate(ref,dateof,gotopage)
{
	if(document.forms['reserv'+ref].elements['debut'].value=='' || (document.forms['reserv'+ref].elements['debut'].value!='' && document.forms['reserv'+ref].elements['fin'].value!=''))
	{
		document.forms['reserv'+ref].elements['fin'].value='';
		document.forms['reserv'+ref].elements['debut'].value=dateof;
	}
	else{
		
		document.forms['reserv'+ref].elements['fin'].value=dateof;
	}
		CallResults(gotopage+"&personnes="+document.forms['reserv'+ref].elements['personnes'].value+"&debut="+document.forms['reserv'+ref].elements['debut'].value+"&fin="+document.forms['reserv'+ref].elements['fin'].value,"display"+ref);
}
function Goupdate_option(ref,gotopage)
{
	//alert(gotopage);
	CallResults(gotopage+"&personnes="+document.forms['reserv'+ref].elements['personnes'].value+"&debut="+document.forms['reserv'+ref].elements['debut'].value+"&fin="+document.forms['reserv'+ref].elements['fin'].value,"display"+ref);
}
function Goupdate_personnes(ref,gotopage)
{
	//alert(gotopage);
	CallResults(gotopage+"&debut="+document.forms['reserv'+ref].elements['debut'].value+"&fin="+document.forms['reserv'+ref].elements['fin'].value,"display"+ref);
}





function PSR_Sendmail (DivName) {
	if(document.getElementById('sendtifriend').style.visibility=='visible')
	{
		Sendmailclose();
	}
	else{
	//var PSR_content= GetDiv(DivName);
	//GenerateStats
	//document.forms["mailtofriend"].elements["htmform"].value=PSR_content;
	//sendtifriend
	document.getElementById('sendtifriend').style.visibility='visible';
	document.getElementById('sendtifriend').style.top='190px';
	document.getElementById('sendtifriend').style.width='380px';
	document.getElementById('sendtifriend').style.height='200px';
	document.getElementById('sendtifriend').style.left=(Math.round(document.body.clientWidth/2)-190)+'px';
	}	
}
function Sendmailclose()
{
	document.getElementById('sendtifriend').style.visibility='hidden';
	document.getElementById('sendtifriend').style.width='0px';
	document.getElementById('sendtifriend').style.height='0px';
}

/*ajout vv pour blink ie*/

/*
* Le code suivant va apprendre la balise blink à IE
*/
if ( document.all )
{
	function blink_show()
	{
		blink_tags  = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'visible';
		}
		
		window.setTimeout( 'blink_hide()', 700 );
	}
	
	function blink_hide()
	{
		blink_tags  = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'hidden';
		}
		
		window.setTimeout( 'blink_show()', 250 );
	}
	
	window.onload = blink_show;
}