var WindowCam;
var WindowChat;
var WindowAdmCall;
var WindowCGV;
var WindowProgr;
var WindowEtapes;
var WindowLegendes;
var WindowLegendesTarifs;
var WindowRegions

function GetCookie(nom) {
  var cookieTrouve = false;
  var debut = 0;
  var fin = 0;
  var chaineDeCookie=document.cookie;
  var i=0;
  // EXAMINER LE COOKIE POUR LOCALISER nom
  while (i <=chaineDeCookie.length) {
    debut=i;
    fin=debut + nom.length;
    if (chaineDeCookie.substring(debut,fin) == nom) {
      cookieTrouve = true;
      if (chaineDeCookie.charAt(fin) == '=') { break; }
    }
    i++;
  }
  // nom A-T-IL ETE TROUVE ?
  if (cookieTrouve) {
    debut =fin+1;
    fin=document.cookie.indexOf(";",debut);
    if (document.cookie.charAt(debut-1) != '=') { return ""; } // rajouté par IDYLYK
	else {
	   if(fin<debut) { fin = document.cookie.length; }
       return document.cookie.substring(debut,fin); 
	}
    //else { return ""; } 
  }
  return "";
}


// * * * * * * * * * * * * * * * * * * * 
// Mon devis
function OpenWindow2(theURL,w,h,param) {
  WH = 0;
  if ((gNav=='E')&&(gSE=='M')) {
    // encore (!) un cas particulier pour 
	// internet explorer Mac
	if (WH == 0) {
      WH=window.open("","zoom sur",'width='+w+',height='+h+',scrollbars=yes,resizable=no,status=no,menubar=no,toolbar=no'+param);
	}
    WH.location = theURL; 
  }
  else {
	if (WH == 0) {
      WH = window.open(theURL,'','width='+w+',height='+h+',scrollbars=yes,resizable=no,status=no,menubar=no,toolbar=no'+param);
	}
    //WH.location = theURL; 
  }
}
// * * * * * * * * * * * * * * * * * * * 
// Clients en ligne
function OpenWindow3(theURL,w,h,param) {
  WH = 0;
  if ((gNav=='E')&&(gSE=='M')) {
    // encore (!) un cas particulier pour 
	// internet explorer Mac
	if (WH == 0) {
      WH=window.open("","zoom sur",'width='+w+',height='+h+',scrollbars=yes,resizable=yes,status=no,menubar=no,toolbar=no'+param);
	}
    WH.location = theURL; 
  }
  else {
	if (WH == 0) {
      WH = window.open(theURL,'','width='+w+',height='+h+',scrollbars=yes,resizable=yes,status=no,menubar=no,toolbar=no'+param);
	}
    //WH.location = theURL; 
  }
}
// * * * * * * * * * * * * * * * * * * * 


function OpenWindow(theURL,WH,nom,w,h,param) {
// ouverture de la petite fenêtre de preview webcam
  
  // ferme l'instance en cours
  if (GetCookie('visiobox') == '') { 
    if (WH != 0) {
      if (WH.closed) {
        WH = 0;
      }
    }
  }
  else {
   WH = 0;
  } 
 
  if ((gNav=='E')&&(gSE=='M')) {
    // encore un cas particulier pour cette merde mal développée
	// d'internet explorer Mac
	if (WH == 0) {
      WH=window.open("","zoom sur",'width='+w+',height='+h+',resizable=no,status=no,menubar=no,toolbar=no'+param);
	}
    WH.location = theURL; 
  }
  else {
	if (WH == 0) {
      WH = window.open(theURL,'','width='+w+',height='+h+',resizable=no,status=no,menubar=no,toolbar=no'+param);
	}
    //WH.location = theURL; 
  }
  WH.name = nom;
  return (WH);
}

function CloseWindow(WH) {
	if (WH != 0) {
      WH.close();
	}
}

function OpenWindowWC(theURL) {
  WindowCam = OpenWindow(theURL,WindowCam,'WindowCam',200,180);
}

function OpenWindowChat(theURL) {
  WindowChat = OpenWindow(theURL,WindowChat,'WindowChat',400,300);
}

function OpenWindowAdmCall2(theURL) {
  WindowAdmCall = OpenWindow(theURL,WindowAdmCall,'WindowAdmCall',640,480);
}

function OpenWindowAdmCall(theURL) {
  WindowAdmCall = OpenWindow(theURL,WindowAdmCall,'WindowAdmCall',400,300);
}

function OpenWindowCGV(theURL) {
  WindowCGV = OpenWindow(theURL,WindowCGV,'WindowCGV',300,380);
}

function OpenWindowProgress(theURL) {
  WindowProgr = OpenWindow(theURL,WindowProgr,'WindowProgr',400,150);
}

function OpenWindowEtapes(theURL) {
  WindowEtapes = OpenWindow(theURL,WindowEtapes,'WindowEtapes',600,270);
}

function OpenWindowLegendes(theURL) {
  WindowLegendes = OpenWindow(theURL,WindowLegendes,'WindowLegendes',300,150);
}

function OpenWindowLegendesTarifs(theURL) {
  WindowLegendesTarifs = OpenWindow(theURL,WindowLegendesTarifs,'WindowLegendesTarifs',300,80);
}

function OpenWindowRegions(theURL) {
  WindowRegions = OpenWindow(theURL,WindowRegions,'WindowRegions',600,250,',scrollbars=yes');
}


// ini
WindowCam = 0;
WindowChat = 0;
WindowAdmCall = 0;
WindowCGV = 0;
WindowProgr = 0;
// adm
WindowEtapes = 0;
WindowLegendes = 0;
WindowLegendesTarifs = 0;
WindowRegions = 0;
