function changeDisplay(id, action)
{
	if (action == 'the_same')
	{
		document.getElementById(id).style.display 		= 'none';
	} else {
    	document.getElementById(id).style.display 		= 'block'; 
	}
}


function domains(action)
{
	if ( action == "add" )
	{
		document.getElementById('btn_addDomain').style.display = 'none';
		document.getElementById('tbl_addDomain').style.display = 'block';
	}
	
	if ( action == "cancel" )
	{
		document.getElementById('btn_addDomain').style.display = 'block';
		document.getElementById('tbl_addDomain').style.display = 'none';

		document.getElementById('new_addDomain').style.display 		= 'block';
		document.getElementById('found_addDomain').style.display 	= 'none';
		document.addDomain.searchDomain.value						= '';
		document.addDomain.verify.disabled 							= false;
	}
	
	if ( action == "verify" )
	{
		document.addDomain.verify.disabled = true;

		searchDomain 	= document.addDomain.searchDomain.value
    	searchDomainExt = document.addDomain.searchDomainExt[ document.addDomain.searchDomainExt.selectedIndex ].value
    	
		var params= 'searchDomain=' + searchDomain + '&searchDomainExt=' + searchDomainExt;
		
        var xhr = createXMLHttpRequest( );
        xhr.open("POST", "_verify_domain.php", true);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
        xhr.setRequestHeader("Content-length", params.length);
        xhr.setRequestHeader("Connection", "close");
    
        xhr.onreadystatechange = function( ) 
        {
            if (xhr.readyState == 4) 
            {
                if (xhr.status == 200) 
                {
                	numeDomeniu 	= searchDomain + '.' + searchDomainExt;
                	
                	if (parseInt(xhr.responseText) == 0)
                	{
                		document.getElementById('new_addDomain').style.display 		= 'none';
                		document.getElementById('found_addDomain').style.display 	= 'block';
                		document.getElementById('found_domain').innerHTML 			= numeDomeniu;

                		document.addDomain.searchDomain_hidden.value	 = searchDomain;
                		document.addDomain.searchDomainExt_hidden.value  = searchDomainExt;

                		document.addDomain.submit()
                	}
                	
                	if (parseInt(xhr.responseText) == -1)
                	{
	                	document.getElementById('message_addDomain').innerHTML = 'Domeniul ' + numeDomeniu + ' este indisponibil, incercati altul:';
	                	document.addDomain.submit.disabled = false;
	                	//alert('nu i liber');
                	}
                    //alert(xhr.responseText);
                    //document.getElementById('sample_front_hidden').value 	= xhr.responseText;
                }
            }
        }
        xhr.send(params);
	}
	
	return false;
}

function updateOS(targ, textLink, selObj)
{
	eval(targ  + ".location='" + textLink + "" + selObj.options[selObj.selectedIndex].value + "'");
}

function CheckAndSubmit()
{
	if ( document.getElementById('i_have_read').checked == false )
	{
		alert('Comanda se poate finaliza doar dupa bifarea casutei \nde deasupra butonului "Confirm comanda"');
		return false
	} else {
		document.registerForm.submit();
		return false;
	}
	
}