  // OrdiBat Web Site methods - Ben Jay May 2003 
  var siteTag = 'fr1'; 
  var siteLinkRoot = 'http://www.batteriesdordinateur.com.fr/fr1/'; 
  var siteSecRoot = 'https://shop.stormserv.com/fr1/'; 
  var siteServRoot = 'http://shop.stormserv.com/fr1/'; 
 
  // include urchin web analysis: 
  document.write('<script src="/' + siteTag + '/__utm.js"></script>'); 
 
  // #########################################################/ 
  // check the email address is reasonable: 
 
  function checkEmail(email) 
  { 
    if(!isValidEmail(email)) 
    { 
      alert('Cette adresse e-mail n\u2019est pas valide. \n Elle devrait ressembler \u00e0 : \n\n votrenom@votreentreprise.com\n\nSans espaces. Veuillez recommencer.'); 
      return false; 
    } 
    return true; 
  } 
 
  // #########################################################/ 
  // check the email address is reasonable: 
 
  function isValidEmail(email) 
  { 
    if(isblank(email)) 
      return false; 
 
    email = email.toLowerCase(); 
 
    //  check for one '@': 
    var sections = email.split('@'); 
    if(sections.length != 2) 
      return false; 
 
    // now split into sections on '.': 
    var username = sections[0].split('.'); 
    var domain = sections[1].split('.'); 
    if(domain.length < 2) 
      return false; 
 
    // check the username: 
    for(var i = 0; i < username.length; i++) 
      if(!isValidEmailSection(username[i])) 
        return false; 
 
    // check the domain: 
    for(var i = 0; i < domain.length; i++) 
      if(!isValidEmailSection(domain[i])) 
        return false; 
 
    return true; 
  } 
 
  // #########################################################/ 
  // check this section of an email address is valid 
  // a-z 0-9 - . _ 
 
  function isValidEmailSection(sec) 
  { 
    if(sec.length < 1) 
      return false; 
 
    for(var i = 0; i < sec.length; i++) 
    { 
      var cc = sec.charCodeAt(i); 
      if( ((cc < 97) || (cc > 122)) && 
          ((cc < 48) || (cc > 57)) && 
          ((cc < 45) || (cc > 46)) && 
          (cc != 95) ) 
  	  return false; 
    } 
    return true; 
  } 
 
  // #########################################################/ 
 
  function showCountryList(start, selected) 
  { 
    document.writeln('<SELECT ' + start + '>'); 
 
    var countries = [ 'FR','France', 
'DE','Allemagne', 
'AT','Autriche', 
'BE','Belgique', 
'DK','Danemark', 
'ES','Espagne', 
'FI','Finlande', 
'GR','Gr&egrave;ce', 
'IE','Irlande', 
'IT','Italie', 
'LU','Luxembourg', 
'NO','Norv&egrave;ge', 
'NL','Pays-Bas', 
'PT','Portugal', 
'CZ','R&eacute;publique tch&egrave;que', 
'GB','Royaume-Uni', 
'SK','Slovaquie', 
'SE','Su&egrave;de' ]; 
 
    for(var i = 0; i < countries.length; i = i+2) 
    { 
      var html = '<OPTION value="' + countries[i] + '"'; 
      if(countries[i] == selected) 
        html += ' selected'; 
      html += '>' + countries[i+1] + '</OPTION>'; 
      document.writeln(html); 
    } 
    document.writeln('</SELECT>'); 
  } 
 
  // #########################################################/ 
 
  function showYearList(start, selected, full) 
  { 
//    var currentYear = 2004;  
    var currentYear = (new Date()).getFullYear(); 
 
    document.writeln('<SELECT ' + start + '>'); 
    var maxYear = currentYear + 10; 
    if(full) 
    { 
      maxYear = currentYear + 1; 
      currentYear = currentYear - 5; 
      if(selected == ' ') 
        document.writeln('<OPTION value=" " selected> </OPTION>'); 
      else 
        document.writeln('<OPTION value=" "> </OPTION>'); 
    } 
 
    for(var i = currentYear; i < maxYear; i++) 
    { 
      var html = '<OPTION value="' + i + '"'; 
      if(i == selected) 
        html += ' selected'; 
      html += '>' + i + '</OPTION>'; 
      document.writeln(html); 
    } 
    document.writeln('</SELECT>'); 
  } 
 
  // #########################################################/ 
 
  function showMonthList(start, selected, full) 
  { 
    document.writeln('<SELECT ' + start + '>'); 
 
    var list = [' ',' ', '01','01', '02','02', '03','03', '04','04', '05','05', '06','06', '07','07', '08','08', '09','09', '10','10', '11','11', '12','12']; 
    var start = 2; 
    var end = list.length -2; 
    if(full) 
      start = start - 2; 
 
    for(var i = start; i <= end; i = i+2) 
    { 
      var html = '<OPTION value="' + list[i] + '"'; 
      if(list[i] == selected) 
        html += ' selected'; 
      html += '>' + list[i+1] + '</OPTION>'; 
      document.writeln(html); 
    } 
    document.writeln('</SELECT>'); 
  } 
 
  // #########################################################/ 
  // function call, embedded within notes etc in the database: 
 
  function pl(linkOb, linkValue) 
  { 
//    linkOb.href='/fr1/e/Page.Filler?_page=b/plink&ps=' + linkValue; 
    if(linkValue) 
      linkOb.href=siteLinkRoot + 'b/plink.html?ps=' + linkValue;   
  } 
 
  // #########################################################/ 
  // if a number ends with .0, remove it 
 
  function trimdp(str) 
  { 
    if(str.lastIndexOf('.0') == str.length -2) 
      str = str.substring(0, str.length -2); 
 
    document.write(str); 
  } 
 
  // #########################################################/ 
 
  function magnitude(str) 
  { 
    num = str.valueOf(); 
 
    if(num > 999) 
    { 
      num = num / 1000; 
      str = num.toString() + "K"; 
    } 
    else if(num > 999999) 
    { 
      num = num / 1000000; 
      str = num.toString() + "M"; 
    } 
 
    document.write(str); 
  } 
 
  // #########################################################/ 
  // check there is a value: 
 
  function isblank(str) 
  { 
    for(var i = 0; i < str.length; i++) 
    { 
      var ch = str.charAt(i); 
      if((ch != ' ') && (ch != '\n') && (ch != '\t')) 
        return false; 
    } 
    return true; 
  } 
 
  // #########################################################/ 
  // check there is a value: 
 
  function validCardNo(val, min, max) 
  { 
    var count = 0; 
    for(var i = 0; i < val.length; i++) 
    { 
      var ch = val.charAt(i); 
      if((ch == '0') || (ch == '1')|| (ch == '2') || (ch == '3') || (ch == '4') ||  
         (ch == '5') || (ch == '6') || (ch == '7') || (ch == '8') || (ch == '9')) 
        count++; 
      else if(ch != ' ') 
        return false; 
    } 
 
    if((count.valueOf() < min) || ((count.valueOf() > max) && (max > -1))) 
      return false; 
 
    return true; 
  } 
 
  // #########################################################/ 
 
  function showHelp(helpTopic) 
  { 
    var win = window.open(siteServRoot + 'e/Page.Filler?_page=help/' + helpTopic, '_help','status=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes, width=650, height=400'); 
    win.focus(); 
    return false; 
  } 
 
  // #########################################################/ 
 
  function stockMessage(level, order, central) 
  { 
    if(level > 0) 
      document.write('En stock maintenant'); 
    else if(order > 0) 
      document.write('<b>Commande en cours</b><br>(disponible prochainement)'); 
    else if(central > 0) 
      document.write('<b>Sur demande</b><br>(disponible sous 8 jours)'); 
    else 
      document.write('<b>Command&eacute; sur demande</b><br>(disponibilit&eacute; inconnue)'); 
  } 
 
  // #########################################################/ 
 
  function report(ob) 
  { 
    reportN(ob, 20); 
  } 
 
  // #########################################################/ 
 
  function reportN(ob, num) 
  { 
    mes = ''; 
    i = 0; 
    for(a in ob) 
    { 
      mes += "[" + a + " : " + ob[a] + "]\n"; 
      i++; 
      if(i > num) 
      { 
        alert(mes); 
        i = 0; 
        mes = ""; 
      } 
    } 
    alert(mes); 
  } 
 
  // #########################################################/ 
 
  var promos = new Object(); 
  promos.numbers = [ 1,2,5,6 ]; 
  promos.imgSrc = [ 'unibat.gif','xdrive.gif','sleeves.gif','phones.gif' ]; 
  promos.imgAlt = [ 'Vie longue Batterie de Portable Universelle Externe.','Disque Dur Externe. Firewire et USB2. Espace Suppl&eacute;mentaire de 60GB!','Sacoche pour Ordinateur Portable. Doux et Rembourr&eacute;. Convient pour les 12, 14, 15 et 17 pouces.','T&eacute;l&eacute;phones Skype sans fil. Plus besoin d&#39;&eacute;couteur. Avec Skype, appelez de n&#39;importe o&ugrave;!' ]; 
  promos.prodLocator = [ '58570','61579','61583','85798' ]; 
  promos.prodLink = [ 'b/ubp0767b.html','b/ehd0060g.html','b/bag0017b.html','b/voi0001a.html' ]; 
  var promoCount = 0; 
  var promoPsList = []; 
  var promoRepeats=0; 
  
  // #########################################################/    
  function getPromoUrl(i) 
  { 
    var url=promos.prodLink[i];  
    if(url == '') 
      return url; 
 
    if(url.indexOf('http')<0) 
      url=siteLinkRoot+url; 
    return url;   
  } 
  // #########################################################/  
  function writePromo(ps)  
  {  
	if(promos.numbers.length == 0)  
		return;  
  
	// pick 1 as i the first time, then randomise it: 
	var i = 0; 
	if(promoCount > 0) 
	  i = Math.round((Math.random()*promos.numbers.length)-0.5); 
 
 	var url=getPromoUrl(i); 
   	if(url != '') 
          document.write('<A id="promolink'+ps+'" href="'+url+ '">');  
	document.write('<IMG id="promoimg'+ps+'" src="/fr1/i/promo/' + promos.imgSrc[i] + '" height="61" width="200" border="0" alt="' + promos.imgAlt[i] + '">');  
	if(url != '')   
		document.write('</A>');  
	promoCount++; 
	promoPsList[promoPsList.length] = ps; 
  }  
  
  // #########################################################/  
  function startPromos() 
  { 
return; 
    if(promoPsList.length > 0) 
      setInterval('changePromos()', 6000); 
  } 
  // #########################################################/  
  function changePromos() 
  { 
	if(promoRepeats++>20) 
	  return; 
	for(n in promoPsList) 
	{ 
	  var ps = promoPsList[n]; 
	  var i = Math.round((Math.random()*promos.numbers.length)-0.5); 
  	  var el = document.getElementById('promoimg'+ps); 
	  if(el) 
	  { 
	    el.src='/fr1/i/promo/' + promos.imgSrc[i]; 
	    el.alt=promos.imgAlt[i]; 
	  } 
  	  el = document.getElementById('promolink'+ps); 
	  if(el) 
	    el.href=getPromoUrl(i);  
	} 
  } 
 
  // #########################################################/  
  function writePromos(xPrices)  
  {  
	if(promos.numbers.length == 0)  
		return;  
  
	document.write('Offres exeptionnelles sur les accessoires pour l&#39;achat d&#39;une batterie ou d&#39;un adaptateur:<br>'); 
	for(var i=0;i<promos.numbers.length;i++)  
	{  
   	  var url=getPromoUrl(i); 
   	  if(url != '') 
            document.write('<A href="'+url+ '">');   
		document.write('<IMG id="promoimg'+i+'" src="/fr1/i/promo/' + promos.imgSrc[i] + '" height="61" width="200" border="0" alt="' + promos.imgAlt[i] + '">');  
		if(url != '')  
			document.write('</A>');  
	}  
 
	if(xPrices) 
	{ 
		for(var i=0;i<promos.numbers.length;i++)  
		{  
			if(xPrices['x'+promos.prodLocator[i]])  
				document.write('<div id="promotext'+i+'" style="position: absolute; top: 0px; left: 0px;"><a href="javascript:order('+promos.prodLocator[i]+');">seulement '+xPrices['x'+promos.prodLocator[i]]+'! &nbsp;&nbsp;&bull; COMMANDE</a></div>');  
		}  
	} 
  }  
  
  // #########################################################/ 
  function arrangePromoText() 
  { 
	if(promos.numbers.length == 0)  
		return;  
 
	for(var i=0;i<promos.numbers.length;i++)  
	{  
		if(document.getElementById('promotext'+i)) 
		{ 
	    		document.getElementById('promotext'+i).style.top = document.getElementById('promoimg'+i).offsetTop+61; 
    			document.getElementById('promotext'+i).style.left = document.getElementById('promoimg'+i).offsetLeft+20; 
		} 
	} 
  } 
 
  // #########################################################/ 
 
  function writeBsi() 
  { 
    var src = ' '; 
    if(src.length > 1) 
      document.writeln('<br><img style="float: right; margin-right: 20px;" src="/fr1/i/logos/' + src + '>'); 
  } 
 
  // #########################################################/  
  // check if the servlets have been able to set a Cookie, direct them to an error page if blocked. 
  function cookieCheck() 
  {     
    if(document.cookie.length < 1 && document.location.pathname.indexOf('/e/') != -1 && document.location.search.indexOf('cookies') == -1) 
      document.location = siteLinkRoot + 'info/cookies.html?returl=' + escape(document.location); 
//      document.location = '/fr1/info/cookies.html?returl=' + escape(document.location); 
  } 
  cookieCheck(); 
 
  // #########################################################/  
  // reload the page which sent them to the Cookie error page. 
  function cookieContinue() 
  { 
    var i = document.location.search.indexOf('returl='); 
    var j = document.location.search.indexOf('&', i); 
    if(j < 0) 
      j = document.location.search.length; 
 
    if(i < 0 || i+7 == j) 
      document.location = 'http://www.batteriesdordinateur.com.fr/'; 
    else 
      document.location = unescape(unescape(document.location.search.substring(i+7, j))); 
  } 
 
  // #########################################################/  
  //-------------------------------------------- 
  // link when moving between servers. Using the Urchin monitor to transfer tracking data. If we stop using Urchin, can simply remove the inner utm function call. 
  function svrLink(url) 
  { 
    __utmLinker(url); 
  } 
 
  //-------------------------------------------- 
 
//  function order() 
//  { 
//    svrLink(siteLinkRoot + 'e/Shopping.Cart'); 
//  } 
 
  //-------------------------------------------- 
 
  function order(locator, pno) 
  { 
    if(typeof(locator) == "undefined") 
      svrLink(siteServRoot + 'e/Shopping.Cart'); 
    else //if(typeof(pno) == "undefined") 
      svrLink(siteServRoot + 'e/Shopping.Cart?_action=add&p_surrogate=' + locator);  
//    else 
//      svrLink(siteServRoot + 'e/Shopping.Cart?_action=add&p_surrogate=' + locator + '&part_number=' + escape(pno.toUpperCase()));  
  } 
 
  //-------------------------------------------- 
 
  function secLink(page) 
  { 
    svrLink(siteSecRoot + page); 
  } 
 
  //------------------------------------------- 
  // page, can include a ?. Current search string and xtra will be appended to the end of the page url. 
  // to use xtra, a non empty page must be give. do not include leading ? or & in the xtra string. 
 
  function pageView(page, xtra)   
  {   
    // if a specific page has been provided, log that:   
    if(typeof(page) != "undefined" && page.length > 0)   
//      urchinTracker(addSearch(page, xtra));   
      urchinTracker(page);   
   
    // is this a page filler call, if so, log the page:   
    var i = document.location.search.indexOf('_page=');   
    if(document.location.pathname.indexOf('Page.Filler') > 0 && i > 0)   
    {   
      var j = document.location.search.indexOf('&', i+6);   
      if(j > 0)   
        page = document.location.search.substring(i+6, j);   
      else   
        page = document.location.search.substring(i+6);   
//      urchinTracker(addSearch(document.location.pathname + '/' + page, xtra));   
      urchinTracker(document.location.pathname + '/' + page);   
    }   
   
    // else, let the tracker figure it out:   
    else   
      urchinTracker();   
  }   
   
  //-------------------------------------------   
  // adds the current locations search params to the specified url for logging, plus the xtra string. 
  // unused : should prevent it adding the _page param, and any Urchin params starting __utmxxxx 
 
  function addSearch(url, xtra) 
  { 
    var search = document.location.search; 
    if(typeof(xtra) != "undefined" && xtra.length > 0) 
    { 
      if(search.length == 0) 
        search = '?' + xtra; 
      else  
        search = search + '&' + xtra; 
    } 
    if(url.indexOf('?') > -1 && search.length > 0) 
    { 
//      alert(url + '&' + search.substring(1)); 
      return url + '&' + search.substring(1); 
    } 
    else 
    { 
//      alert(url + search); 
      return url + search; 
    }     
  } 
 
  //------------------------------------------- 
 
  function postForm(f) 
  { 
    __utmLinkPost(f); 
    f.submit(); 
  } 
 
  //------------------------------------------- 


