
errorColor="#336699";
normalColor="";


    // @return test
function mailButon () {

    params=''
    if(document.mailForm.email.value!='') {
        if(document.mailForm.email.value==document.mailForm.email_copy.value) {
            if(document.mailForm.email.value.indexOf('@', 2)!=-1
                &&    document.mailForm.email.value.indexOf('.',4)) {
                document.mailForm.email.style.backgroundColor=normalColor;
                params+="email="+document.mailForm.email.value;
                if(document.mailForm.nume.value.length>2){
                    document.mailForm.nume.style.backgroundColor=normalColor;
                    params+="&nume=" + document.mailForm.nume.value;
                    if(document.mailForm.mesaj.value.length>2){
                        document.mailForm.mesaj.style.backgroundColor=normalColor;
                        params+="&mesaj=" +document.mailForm.mesaj.value;
                        if(document.mailForm.captcha.value.length==4) {
                            document.mailForm.captcha.style.backgroundColor=normalColor;
                            params+="&captcha=" + document.mailForm.captcha.value;
                            mailAjax(params);
                        }else document.mailForm.captcha.style.backgroundColor=errorColor;
                    }else document.mailForm.mesaj.style.backgroundColor=errorColor;
                }else document.mailForm.nume.style.backgroundColor=errorColor;
            }else document.mailForm.email.style.backgroundColor=errorColor;
        }else {
            document.mailForm.email.style.backgroundColor=errorColor;
            document.mailForm.email_copy.style.backgroundColor=errorColor;
        }
    } else document.mailForm.email.style.backgroundColor=errorColor;
}

function getLoadingScript() {
    script='Asteptati ...<noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="100" height="30" title="Asteptati"><param name="movie" value="objects/loading.swf" /><param name="quality" value="high" /><embed src="objects/loading.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"   type="application/x-shockwave-flash" width="100" height="30"></embed></object></noscript>';
    return script;
}


function mailAjax(params) {
    var xmlhttp;
	 document.getElementById("raspunsMail").innerHTML=getLoadingScript();
    if (window.ActiveXObject)
    {
        // code for IE6, IE5
        try {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
    }
    else if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {
        alert("Browserul nu suporta XMLHTTP!");
    }
    xmlhttp.onreadystatechange=function()
    {
       
        if(xmlhttp.readyState==4)
        {
            var response =xmlhttp.responseText;
            document.getElementById("raspunsMail").innerHTML=response;
            //document.mailForm.reset();
            divImg=document.getElementById("captchaImg");
			img=divImg.childNodes[0];
            divImg.removeChild(img);
            img= new Image();
            randomnumber=Math.floor(Math.random()*100000);
            img.src="php/captcha.php?tip=suportCod&cache="+randomnumber;
            divImg.appendChild(img);
        }
    }
	
    xmlhttp.open("GET","/php/administrare/suportMail.php?" + params);
    xmlhttp.send(null);
}