function changebg(id)
{
	document.getElementById(id).style.borderColor='#ccc';
}

function checkdel()
{
    var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
	var email = document.getElementById("email").value;

  if(email == "Vaša email adresa") {
    inlineMsg('email','Molimo unesite Vaš e-mail.',2);
    document.getElementById("email").style.borderColor='#3c78a7';
    setTimeout("changebg('email');",2500);
    return false;
  }
  if(!email.match(emailRegex)) {
    inlineMsg('email','Vaše e-mail informacije nisu pravilno unete.',2);
    document.getElementById("email").style.borderColor='#3c78a7';
    setTimeout("changebg('email');",2500);
    return false;
  }
  else{return true;}
  
}

function getXMLHTTP() { 
        var xmlhttp=false;    
        try{
            xmlhttp=new XMLHttpRequest();
        }
        catch(e)    {        
            try{            
                xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){
                try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e1){
                    xmlhttp=false;
                }
            }
        }
             
        return xmlhttp;
    }
    
function obrisi(path) { 
    if (checkdel() == true) {
var email = document.getElementById("email").value;
var captcha = document.getElementById("captcha").value;                
        var strURL=path+"brisanje.php?email="+email+"&captcha="+captcha;

        var req = getXMLHTTP();
        
        if (req) {
            
            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                    // only if "OK"
                    if (req.status == 200) {                        
                        document.getElementById('deleteform').innerHTML=req.responseText;   
                        document.getElementById('deleteform').innerHTML += '<img src="'+path+'loader.gif" style="margin:70px auto;"/>';
                        document.getElementById('deleteform').innerHTML += '<div style="margin:20px auto;">Molimo sačekajte...</div>';
						setTimeout("hide();", 3000);                      
                    } else {
                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }                
            }            
            req.open("GET", strURL, true);
            req.send(null);
			}        
    }
}
    function hide() {
		document.getElementById('deleteform').innerHTML = '<div style="margin:150px auto;">Poruka za brisanje je uspešno poslata...</div>';
		setTimeout("TINY.box.hide();", 1500);
    }

