var browsername = navigator.appName;
var count = 0;
var flag = 0;
var partnerIdList;
var partnerIdLocal;
 
function setVar(partnerIdList, partnerId) 
	{
		partnerIdList = partnerIdList;
		partnerIdLocal = partnerId;
	}

var browserversion = parseInt(navigator.appVersion);
// Random Number for Double click
var randnum=new Date().getTime();

if (((browsername == "Netscape") && (browserversion >= 3)) ||
	((browsername == "Microsoft Internet Explorer") && (browserversion >= 4)))
{
	var clientbrowser = 1;
}
else
{
	var clientbrowser = -1;
}

function RenderPopup(windowsource, windowname, width,
	height, scrollbars, directories, location,
	menubar, status, toolbar, resizable) {
	var windowfeatures = 'width=' + width +
	',height=' + height + ',directories=' + directories +
	',location=' + location + ',menubar=' + menubar +
	',scrollbars=' + scrollbars + ',status=' + status +
	',toolbar=' + toolbar + ',resizable=' + resizable;
	flag = 1;
	var check = checkForPartnerId();
	if(count == 1 && check == true)
	{
	window.open(windowsource, windowname, windowfeatures);
}
	else if (check == false)
	{
		window.open(windowsource, windowname, windowfeatures);
	}
	count =1;
}


function goback() {
	history.back();
}

function ImageOver(ImageName, statustext) {
	if (clientbrowser == 1)
	{
	 	document[ImageName].src = eval(ImageName + "On.src");
		window.status = statustext;
	}
}

function ImageOut(ImageName) {
	if (clientbrowser == 1)
	{
		document[ImageName].src = eval(ImageName + "Off.src");
		window.status = '';
	}
}

// Random Number for Double click
var timeNow=new Date();
var randnum=timeNow.getTime();

// Livechat functions

	var enterCalled = false;
	function enterLivePerson(aname, gname, re, name) {
		enterCalled = true;
		window.name = "lp_parent";
		var url = "http://lastminute.client.liveperson.net/user.asp?aname=" + aname + "&gname=" + gname + "&RE=" + re + "&name=" + name;
		var hWnd = window.open(url,"live_person","width=300,height=350,resizable=yes,scrollbars=yes");
		if (hWnd != null) { if (hWnd.opener == null) { hWnd.opener = self; window.name = "home"; hWnd.location.href=url; } }
	}
				
	function popMe(aname, gname) {
		if (enterCalled == false) {
		var url = "http://lastminute.client.liveperson.net/clients/help/help.asp?aname=" + aname + "&gname=" + gname
			var hWnd = window.open(url,"pro_active","width=120,height=120,resizable=no,scrollbars=no");
			if (hWnd != null) { if (hWnd.opener == null) { hWnd.opener = self; window.name = "home"; hWnd.location.href=url; } }
		}
	}

function isValidEmail(emailAddress)
{   
   var atIndex     = emailAddress.indexOf('@')
   var dotIndex    = emailAddress.indexOf('.',atIndex)
   // check 0 < atIndex < dotindex < length
   if( (0 < atIndex) && (atIndex < dotIndex) && (dotIndex < emailAddress.length-1) )
   { 
           // first character is a letter and all other are not whitespace
      var firstChar = emailAddress.charAt(0)
      
      if( (firstChar>='a' && firstChar<='z') ||  
          (firstChar>='A' && firstChar<='Z') ||
          (firstChar>='0' && firstChar<='9') )
      { 
         for(var i=1;i<emailAddress.length;++i){
            if(emailAddress.charCodeAt(i) <= 0x20){
               if(emailAddress.charAt(i) == ' ')
                  alert("Votre adresse e-mail ne doit pas contenir d'espaces.");
               else 
                  alert("Votre adresse e-mail ne doit pas contenir les caractères \"" + emailAddress.charAt(i));
               return false;
            }    
         }
         return true;
          
      }
      alert("Le caractère \"" + firstChar + "\" de votre adresse e-mail est incorrect.");
   }
   alert("Veuillez inscrire votre adresse e-mail dans sa totalité.");
   return false;
}

function setCookie( name, value, expireAt, path, domain, secure ) {
  var theCookie = name + "=" + escape ( value ) +
  ( ( expireAt == null ) ? "" : ( "; expires=" + expireAt.toGMTString() ) ) +
  ( ( path == null ) ? "" : ( "; path=" + path ) ) +
  ( ( domain == null ) ? "" : ( "; domain=" + domain ) ) +
  ( ( secure == true ) ? "; secure" : "" );

  document.cookie = theCookie;
}

function getCookie( name ) {
  var cookLength = document.cookie.length;
  name += "=";
  var nameLength = name.length;
  var i = 0;
  while ( i < cookLength ) {
    var j = i + nameLength;
    if ( document.cookie.substring( i, j ) == name ) {
      return getCookieValue( j );
    }
    i = document.cookie.indexOf( " ", i ) + 1;
    if ( i == 0 ) break;
  }
  return null;
}

function getCookieValue( offset ) {
  var endstr = document.cookie.indexOf ( ";", offset );
  if ( endstr == -1 )
    endstr = document.cookie.length;
  return unescape( document.cookie.substring( offset, endstr ) );
}

function executeEveryTime() 
	{
		if(flag == 0)
			count = 1;
	}
	
function checkForPartnerId()
	{
		var check = false;
		var m =0;
		var k =0;
		partnerIdListString = new String(partnerIdList);
		while(k < partnerIdListString.length) 
		{  
			var returnStr = partnerIdListString.substr(0,partnerIdListString.indexOf(','))
			k = returnStr.length+1;
			partnerIdListString = partnerIdListString.substr(returnStr.length+1,partnerIdListString.length);
			if (returnStr == partnerIdLocal) {
				check = true;
				break;
			}
			else
			{
				check = false;
			}
		}
    return check;
}                                                                                                                                   