function get(id){
	return document.getElementById(id);
}




function checkContactForm(){
	var err = '';

	if(!get('mr').checked && !get('mr2').checked && !get('mr3').checked){
		err+="La civilité est obligatoire.\n";
	}

	if(!get('nom').value) err+= "Le nom est obligatoire.\n";

	if(!get('prenom').value) err+= "Le prénom est obligatoire.\n";

	if(!get('societe').value) err+= "La société est obligatoire.\n";

	if(!get('fonction').value) err+= "La fonction est obligatoire.\n";


        if (!get('email').value && !get('telephone').value) err+="Merci de renseigné au moins l'un des deux champs suivant : 'Téléphone', 'email'.\n";

	if(get('email').value) {
            if(!isEmail(get('email').value)) err+= "Le champs \"Email\" n'est pas correctement renseigné.\n";
	}

	if(!get('messages').value) err+= "Le message est obligatoire.\n";

        if(!get('secure').value) err+= "Le code de sécurité est obligatoire.\n";

	if(err) alert(err);
	else {
            get('contact').value='contact';
            get('formDevis').submit();
        }
}

function checkDevisForm(){
	var err = '';

	if(!get('mr').checked && !get('mr2').checked && !get('mr3').checked){
		err+="La civilité est obligatoire.\n";
	}

	if(!get('nom').value) err+= "Le nom est obligatoire.\n";

	if(!get('prenom').value) err+= "Le prénom est obligatoire.\n";

	if(!get('societe').value) err+= "La société est obligatoire.\n";

	if(!get('fonction').value) err+= "La fonction est obligatoire.\n";


        if (!get('email').value && !get('telephone').value) err+="Merci de renseigné au moins l'un des deux champs suivant : 'Téléphone', 'email'.\n";

	if(get('email').value) {
            if(!isEmail(get('email').value)) err+= "Le champs 'Email' n'est pas correctement renseigné.\n";
	}

	if(!get('secure').value) err+= "Le code de sécurité est obligatoire.\n";

	if(err) alert(err);
	else {
            get('devis').value='devis';
            get('formDevis').submit();
        }
}

function checkRapel (){
    var err = '';

	if(!get('civilite1').checked && !get('civilite2').checked && !get('civilite3').checked){
		err+="La civilité est obligatoire.\n";
	}

        if (!get('name').value || get('name').value=='Votre nom') err+="Le nom est obligatoire.\n";

        if (!get('phone').value || get('phone').value=='Votre numéro de téléphone') err+="Le téléphone est obligatoire.\n";

        if(err) alert(err);
	else {
            get('rappel').value='rappel';
            get('form').submit();
        }
}


// returns true if the string is a valid email
function isEmail(str){
	var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
	return re.test(str);
}

// returns true if the string only contains characters 0-9 and is not null
function isNumeric(str){
	var re = /[\D]/g
	if (re.test(str)) return false;
	return true;
}


function getDim(){

    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;

    if (self.innerHeight) {	// all except Explorer
        if(document.documentElement.clientWidth){
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){
        pageWidth = xScroll;
    } else {
        pageWidth = windowWidth;
    }

    return [pageWidth,pageHeight];
}
