function load_domenii()
{
	//------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------
	
	var domeniu = document.getElementById("domeniu").value;
	
	var c = document.getElementById("f_verifica_domeniu").getElementsByTagName('input');
		
	//------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------
	
	tlds = '';
	
    for (var i = 0; i < c.length; i++) 
	{
        if (c[i].type == 'checkbox') 
		{
			if(c[i].checked == true)
			{
				//----------------------				
	
				tlds += '&tld[]=' + c[i].value;
				
				//----------------------
				
				c[i].checked = false;
			}
        }
    }
		
	//----------------------
	
	if(domeniu == "" || domeniu == "Va rugam introduceti domeniu (ex. nshost)")
	{
		$("#domeniu").css("background-color","#ffd8de");
		
		$("#domeniu").val("Va rugam introduceti domeniu (ex. nshost)");
		
		return false;
	}
	else if(validare_domeniu(domeniu) == false) 
	{
		$("#domeniu").css("background-color","#ffd8de");
		
		$("#domeniu").val("Va rugam introduceti domeniu valid");
		
		return false;
	}
	else if(tlds == "")
	{	
		alert("Va rugam bifati una din extensiile de mai jos!");
		return false;
	}
	else
	{
		$("#domeniu").css("background-color","white");
		
		$('#rezultat_domenii').fadeIn('1200');
		
		//----------------------	
		
		var url_complet = 'ajax/domenii/verifica_domeniu.php?domeniu=' + encodeURI(domeniu) + '&tld=' + encodeURI(tlds);
			
		$.ajax({
		  url: url_complet,
		  cache: false,
		  success: function(html){
			$("#rezultat_domenii").html(html);
		  }
		});	
		
				
		//------------------------------------------------------------------------------------------------
		//------------------------------------------------------------------------------------------------
		//------------------------------------------------------------------------------------------------
		
		return false;
	}
	
	//----------------------
}

//----------------------	
//----------------------	
//----------------------

function verifica_domeniu_content()
{
	var nume_dom = document.getElementById("nume_domeniu").value;
	
	if(nume_dom == '') return false;	
}

//----------------------

function validare_domeniu(value)
{			
	var strValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	
	var strChar;
	
	var blnResult = true;

	//---

	if (value.length == 0) return false;
	
	//---

	for (i = 0; i < value.length && blnResult == true; i++)
	{
		strChar = value.charAt(i);
		
		if(strValidChars.indexOf(strChar) == -1)
		{
			return false;
		}
	}
	
	//---
}

//------

function scris_casuta_domeniu(value) 
{
	if (value == 'Va rugam introduceti domeniu (ex. nshost)' || value == 'Va rugam introduceti domeniu valid')
	{
		document.getElementById("domeniu").value = '';			
	}
}

//------

function status_domeniu(domeniu, tld, i, selectat)
{
	var status_div = '#status' + i;
	
	$(document).ready(function html(){
	
	//---
	
	$('#status' + i).empty(); 
	
		var url_complet = 'ajax/domenii/check_domeniu.php?domeniu=' + encodeURI(domeniu) + '&tld=' + encodeURI(tld) + '&selectat=' + selectat + '&i=' + i;
				
		//---
		
		$(status_div).fadeIn(400).html('<img src="img/loading.gif" />');
		
		//---	
			
		$.ajax({
		  url: url_complet,
		  cache: false,
		  success: function(html){
			$(status_div).html(html);
			return true;
		  }
		});	
		
		//---	
		
	});	
}


//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------

function rezultat_cos()
{	
	//--------
	
	var div_cos = '#rezultat_cos';
	
	var url_complet_1 = 'ajax/domenii/status_cos.php';		
		
	$.ajax({
	  url: url_complet_1,
	  cache: false,
	  success: function(html){
		$(div_cos).html(html);
	  }
	});	
}

//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------

function add_session_domain(extensie, domeniu)
{
	var extensie;
	
	var id_checkbox = extensie + '_1';
	
	var checkbox = document.getElementById(extensie + '_1');
	
	//---
	
	if(checkbox.checked == true)
	{
		var url = 'ajax/domenii/add_session_extension.php?checked=da&domeniu=' + domeniu + '&ext=' + extensie;
	}
	else
	{
		var url = 'ajax/domenii/add_session_extension.php?checked=nu&domeniu=' + domeniu + '&ext=' + extensie;
	}
	
	//---
	
	$.ajax({
	  url: url,
	  cache: false
	});	
}

//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------

function verificare_rand(status_verificare, tld, selectat_sus, i, domeniu, pret_domeniu, currency)
{
	//---
	
	var id_checkbox = tld + '_1';
	
	//---
	
	var div_checkbox = document.getElementById('checkbox_' + i);
	var div_comanda = document.getElementById('comanda_' + i);
	var rand_domenii = 'rand_domenii_' + i;
			
	//------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------
		
	if(status_verificare == 'da')
	{
		//---
		
		div_checkbox.innerHTML = '<input type="checkbox" name="tlds[]" id="' + id_checkbox + '" value="' + id_checkbox + '" onclick="add_session_domain(\'' + tld +'\', \'' + domeniu +'\'); rezultat_cos();" />';
		
		//---
		
		div_comanda.innerHTML = '<table cellpadding="0" cellspacing="0" id="tabel_inside"><tr><td width="24"><img src="img/yes_1.jpg" /></td><td align="left">' + pret_domeniu + ' - ' + currency + '</td></tr></table>';
	}
	else
	{
		//---
		
		document.getElementById(rand_domenii).style.background = '#ffd2d2';
		
		//---	
	
		div_checkbox.innerHTML = '<img src="img/no.gif" />';
		
		//---
		
		div_comanda.innerHTML = '<a href="http://www.' + domeniu + tld + '" target="_blank">www</a> - <a href="#" onclick="window.open(\'https://clienti.nshost.ro/whois-clienti.php?domain=' + domeniu + tld + '\',\'whois\',\'width=500,height=400,scrollbars=yes\');return false">whois</a>';
	}
	
	//------------------------------------------------------------------------------------------------
	
	if(selectat_sus == 'da')
	{
		if(status_verificare == 'da')
		{
			document.getElementById(tld + '_1').checked = true;
						
			rezultat_cos();
		}
		else
		{
			rezultat_cos();
		}
	}	
	
	//------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------
}

//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------

function expand_domenii()
{
	var div = document.getElementById("expand").style.display;
	
	if(div == 'none')
	{
		document.getElementById("expand").style.display = 'block';
		document.getElementById('expand_semn').src = 'img/domenii/minus.jpg';
	}
	else if(div == '')
	{
		document.getElementById("expand").style.display = 'block';	
		document.getElementById('expand_semn').src = 'img/domenii/minus.jpg';
	}
	else
	{
		document.getElementById("expand").style.display = 'none';
		document.getElementById('expand_semn').src = 'img/domenii/plus.jpg';
	}
}

//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------

function show_hint(hint, id)
{
	$('#hint_' + id).fadeIn(400).html(hint);
}
