﻿function stripAccent(str){
    var s=str;

    var rExps=[ /[\xC0-\xC2]/g, /[\xE0-\xE2]/g,
    /[\xC8-\xCA]/g, /[\xE8-\xEB]/g,
    /[\xCC-\xCE]/g, /[\xEC-\xEE]/g,
    /[\xD2-\xD4]/g, /[\xF2-\xF4]/g,
    /[\xD9-\xDB]/g, /[\xF9-\xFB]/g ];

    var repChar=['A','a','E','e','I','i','O','o','U','u'];

    for(var i=0; i<rExps.length; i++)
    s=s.replace(rExps[i],repChar[i]);

    return s;
}

function toPaypal(){
    alert("Il est très important de cliquer sur le bouton ''Retour sur le site de Planeq'' à la fin du processus d'achat Paypal pour compléter votre commande correctement.");
    return clearPaypal();
}

function clearPaypal(){
    var ib = document.getElementById("first_name");
    if (ib && ib.value){
        ib.value = stripAccent(ib.value);
    }
    ib = document.getElementById("last_name");
    if (ib && ib.value){
        ib.value = stripAccent(ib.value);
    }
    ib = document.getElementById("address1");
    if (ib && ib.value){
        ib.value = stripAccent(ib.value);
    }
    ib = document.getElementById("address2");
    if (ib && ib.value){
        ib.value = stripAccent(ib.value);
    }
    ib = document.getElementById("city");
    if (ib && ib.value){
        ib.value = stripAccent(ib.value);
    }
    ib = document.getElementById("zip");
    if (ib && ib.value){
        ib.value = stripAccent(ib.value);
    }
    ib = document.getElementById("email");
    if (ib && ib.value){
        ib.value = stripAccent(ib.value);
    }
    return true;
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}