/* Get XMLHttpRequest
------------------------------------------------------------------------------*/
function createXhrObject()
{
    if (window.XMLHttpRequest)
        return new XMLHttpRequest();
 
    if (window.ActiveXObject)
    {
        var names = [
            "Msxml2.XMLHTTP.6.0",
            "Msxml2.XMLHTTP.3.0",
            "Msxml2.XMLHTTP",
            "Microsoft.XMLHTTP"
        ];
        for(var i in names)
        {
            try{ return new ActiveXObject(names[i]); }
            catch(e){}
        }
    }
    return null; // non supporte
}
/****************************
Ajout a la selection en AJAX
*****************************/

function getCartUpsellingMsg(url) {
	if (url == null){
		return false;
	}
	var xhr = createXhrObject();
	if (xhr) {
		xhr.open("GET", url, true);
		xhr.send(null);

		xhr.onreadystatechange=function()
     	{
	        if (xhr.readyState == 4) /* 4 : etat "complete" */
	        {
	           if (xhr.status == 200) /* 200 : code HTTP pour OK */
	           {
	              /*
	              	Traitement de la reponse.
	              */
	              var responseAjaxText = xhr.responseText;
	              document.getElementById("francoGiftMsg").innerHTML = responseAjaxText;
	           }
	        }
     	}
	}
}


/**
 * function permettant de soumettre le formulaire
 * newletter de la popin homepage en ajax
 **/
function submitPopinNewsletter(valid) {
	this.in_form = 'newsletter_inscription';
	this.form = $(this.in_form);
	var url = this.form.readAttribute("action");
	url = url +"?valid="+valid; // no need to validate form (first call)
	var formSerialize = this.form.serialize();
	new Ajax.Updater('formPopinNewsletter', url, {
		parameters :formSerialize, evalScripts:true
	});
}

/* EOF
------------------------------------------------------------------------------*/