function GetCookie(name) { 
 var cname = name + "="; 
 var dc = document.cookie; 
 if (dc.length > 0) { 
 begin = dc.indexOf(cname); 
 if (begin != -1) { 
 begin += cname.length; 
 end = dc.indexOf(";", begin);
 if (end == -1) end = dc.length;
 return unescape(dc.substring(begin, end));
 } 
 }
 return null;
} // end GetCookie function

var expDays = .05; // days til cookie expires
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function SetCookie(name, value) { 
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : exp; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
	document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) + 
((domain == null) ? "" : ("; domain=" + domain)) + 
((secure == true) ? "; secure" : "");
}
  function chkSearchForm()
   {
	 q=false;
    var searchString = document.forms[0].elements[16].value;
	searchString = searchString.replace(/(^\s*)|(\s*$)/gi,"");
	var regex=/^[0-9A-Za-z]+$/;
	if (searchString == "")
	{
	ErrorFlag = true;
	}
	  for(m=0; m<searchString.length; m++)
	  {
	  ErrorFlag = false;
		if(regex.test(searchString.charAt(m)))
	    {
	    ErrorFlag = false;
        }
        if (searchString.charAt(m) == " ")
	    {
	    ErrorFlag = true;
        }
	  }
	if (ErrorFlag == true)
	{
	document.forms[0].elements[16].value = 'Rechercher';
	return true;
	}
	else if (ErrorFlag == false)
	{
	document.forms[0].elements[16].value
	document.forms[0].elements[16].value = document.forms[0].elements[16].value.replace(/(^\s*)|(\s*$)/gi,"");
	document.forms[0].elements[16].value = document.forms[0].elements[16].value.replace(/[ ]{2,}/gi," ");
	document.forms[0].elements[16].value = document.forms[0].elements[16].value.replace(/\n /,"\n");
	return true;
	}
  }
function clearField(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function resetField(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}
function pageStartUp()   {
dynamicFunctionCall('checkAutoRenew');
  }
var drSID ='27681';
///////////////////////////////////////////
//get cookie
///////////////////////////////////////////
function getCookieNoDecode(name) { 
  var arg = name + "="; 
  var alen = arg.length; 
  var clen = document.cookie.length; 
  var i = 0; 
  while (i < clen) { 
    var j = i + alen; 
    if (document.cookie.substring(i, j) == arg) 
      return getCookieValNoDecode (j); 
    i = document.cookie.indexOf(" ", i) + 1; 
    if (i == 0) break; 
  } 
return null; 
}

///////////////////////////////////////////
//needed for cookie stuff
///////////////////////////////////////////
function getCookieValNoDecode (offset) { 
  var endstr = document.cookie.indexOf(";", offset); 
  if (endstr == -1) 
    endstr = document.cookie.length; 
  return document.cookie.substring(offset, endstr); 
} 

///////////////////////////////////////////
//parse the grouped cookies
///////////////////////////////////////////
function parseCookieGroup(name,parameter) {
   var foundCookie = false;
   var str = getCookieNoDecode(name);
   if (str != null) {
     //str = unescape(str); the value is not double encoded, this step is not necessary
     strArray = str.split('&');  //array of name / value pairs for cookie.
     for (i=0;i<strArray.length;i++) {
       //strArray[i] contain name value pair
       nameValuePair = strArray[i].split('=');
       if (nameValuePair[0] == parameter) {
         foundCookie = true;
         str = nameValuePair[1];
       }
     }
   }
   if (!foundCookie) {
     str = getCookie(parameter);
   }
   // check for the local variable used for the cookie name
  return stripNull(str); 
}

///////////////////////////////////////////
// stripNull checks for double encoding in CookieVal
///////////////////////////////////////////
function stripNull(CookieVal) {
  if(CookieVal == null) {
    return '';
  }
  else {
    if (!/%\w{2}/.test(CookieVal)) {
      CookieVal = escape(CookieVal).replace(/\./g,'%2E').replace(/\//g,'%2F').replace(/\+/g,'%2B');
    }
    return CookieVal;
  }
}
if (parseCookieGroup('API_Cookie','API_API1') == '100') {
var expDate = new Date();
expDate.setTime(expDate.getTime() + 1000*60*60*24*60)
// name, value - session cookie
setCookie("drCJID",parseCookieGroup('API_Cookie','API_API2'),expDate,'/');
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
// France extended currency selector scripts
// set pageCUR to the site currency without CUR= in URL
var pageCUR = "EUR";
var curInURL = "0";
var urlNoCacheId = location.pathname + location.search.replace(/(&cache_id=)\d*/i, '');

// check for &CUR= in the url
if (location.href.toUpperCase().indexOf("CUR") != -1) {
  curInURL = "1";
}
function ChangeCurrency(thisCUR) {
  if (thisCUR == "text") {
    		document.getElementById('CHF_IMG_ID').style.display = 'none';
				document.getElementById('InfoTVA_ID').style.display = 'none';
		}
		
  if (thisCUR != 'text') {
  var fcName = 'Currency Drop Down Full ' + thisCUR;
  fc_click(fcName, 'ad'); 
// check for &CUR= in the url
if (curInURL == "1") {
  // change &CUR= if it is there
  location.href = urlNoCacheId.replace(/(cur=)\d*/i, '$1' + thisCUR);
} else {
  // add &CUR= to URL if its not there
  url = location.href + "&CUR=" + thisCUR;
  location.href = url;
  }
 }

}
function currencyDropdown() {
// set the current cur as default in the dropdown
  if (pageCUR == "text") {
    document.getElementById("CurrencyDropdown").options[0].selected = true;
  } else if (pageCUR == "CAD") {
    document.getElementById("CurrencyDropdown").options[1].selected = true;
  } else if (pageCUR == "CHF") {
    document.getElementById("CurrencyDropdown").options[2].selected = true;
  } else if (pageCUR == "EUR") {
    document.getElementById("CurrencyDropdown").options[3].selected = true;
  } else {
    document.getElementById("CurrencyDropdown").options[0].selected = true;
  }
}
function addListener(element,type,expression){if(window.addEventListener){element.addEventListener(type,expression,false)}else{element.attachEvent('on'+type,expression)}}
addListener(document,"click",function(){q=false});