function show_cont()
{
	$('#fac_cont').hide();
	$('#am_cont').show()		
}

function show_fac_cont()
{

	$('#am_cont').hide();
	$('#fac_cont').show()		
}


function OnOver(TheId) {
	document.getElementById(TheId).style.background='#F4F4F4';
}

function OnOut(TheId) {
	document.getElementById(TheId).style.background='#FFFFFF';
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oLeft = o.offsetLeft ;           // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent ;   // Get parent object reference
		oLeft += oParent.offsetLeft; // Add parent left position
		o = oParent;
	}
	// Return left postion
	return oLeft;
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oTop = o.offsetTop       ;     // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent ; // Get parent object reference
		oTop += oParent.offsetTop; // Add parent top position
		o = oParent;
	}
	// Return top position
	return oTop;
}

function show_domain_help(id,short_text)
{
	
		var w = screen.width
		var left = getAbsoluteLeft(id);


		var top = getAbsoluteTop(id);
		var resp = document.getElementById('domain_helper');
		resp.style.top = top+0+'px';
		resp.style.left = left+17+'px';
		

		resp.innerHTML=short_text;
		document.getElementById('domain_helper').style.display='';
}

function hide_domain_help() {
	document.getElementById('domain_helper').style.display='none';
}


function close_domain_window(){
	//document.getElementById('domain_rezerv').style.display='none';
	
	//var ajax;
	
	new Effect.Shrink('domain_rezerv');
}

function change_domain(option){
	if(option==3){
		document.getElementById('domain_row').style.display = 'none';
	}
	else if(option==2){
		document.getElementById('domain_row').style.display = '';
		document.getElementById('have_domain').style.display = 'inline';
		document.getElementById('order_domain').style.display = 'none';
	}
	else if(option==1){
		document.getElementById('domain_row').style.display = '';
		document.getElementById('have_domain').style.display = 'none';
		document.getElementById('order_domain').style.display = 'inline';
	}
	
	err_row = document.getElementById('domain_error_row');
	if(err_row != null) err_row.style.display = 'none';


	if(option !=1 && !document.getElementById('hosting_select1').checked){
//		document.getElementById('add_to_cart').disabled = true;
		document.getElementById('add_to_cart').style.display = 'none';
	} else {
//		document.getElementById('add_to_cart').disabled = false;
		document.getElementById('add_to_cart').style.display = 'inline';
	}
}

function change_hosting(option){
	if(option==2){
		document.getElementById('hosting_row_1').style.display = 'none';
		document.getElementById('hosting_row_2').style.display = 'none';
	}
	else if(option==1){
		document.getElementById('hosting_row_1').style.display = '';
		document.getElementById('hosting_row_2').style.display = '';
	}

	if(option !=1 && !document.getElementById('domain_select1').checked){
//		document.getElementById('add_to_cart').disabled = true;
		document.getElementById('add_to_cart').style.display = 'none';
	} else {
//		document.getElementById('add_to_cart').disabled = false;
		document.getElementById('add_to_cart').style.display = 'inline';
	}
}

function select_domain(id,extension,name){
	
	
	//document.domain_form.button1.disabled=true;

	var ajax;

	//new Effect.Grow('domain_sel')

	document.getElementById('domain_sel').innerHTML = '<img src="/media/img/layout/loader.gif" style="margin-right:5px;"> va rugam asteptati ...';

	
	ajax =  new Ajax.Updater(
         'domain_sel',
         '/phpBIN/inc.sel-domain.php?type='+id+'&extension='+extension+'&name='+name,
         { method:'get'});


}

function sel_host(hosting){
	//alert(hosting.value);
}

function check_domain(){
	

	val = document.domain_form.domain_name.value;
	var c_value = document.getElementById('dom_select').options[document.getElementById('dom_select').selectedIndex].value;	
	var reg = /^[A-Za-z0-9]+([A-Za-z0-9\-]{0,61})+[A-Za-z0-9]$/;
	
	if(reg.test(val) == false) {
		alert('Numele domeniului ales este invalid.');
		return false;
	} else {
		document.getElementById('domain_rezerv').style.display = "block";
		

				$('#domain_rezerv').html('<img src="/media/img/layout/loader.gif" style="margin-right:5px;"> va rugam asteptati ...');
				
				rez = $.ajax({
						   type: "GET",
						   url: "/ajax/check-dom.php?",
						   data: "type="+val+"&ext="+c_value,
						   async: false
				}).responseText;
				
				$('#domain_rezerv').html(rez);
	
		
		
		return false;
		
	}

/*	
	for (var i=0; i < document.domain_form.domain.length; i++)
	{
		if (document.domain_form.domain[i].checked){
		  c_value = c_value + document.domain_form.domain[i].value + "+";
		}
	}	
*/	
}

function check_cart_item()
{
	rad = document.getElementById('domain_select1');
	inp = document.getElementById('the_domain_name');
	if(rad && rad.checked && inp){
		val = inp.value;
		var reg = /^[A-Za-z0-9]+([A-Za-z0-9\-]{0,61})+[A-Za-z0-9]$/;
		if (reg.test(val) == false) {
			alert('Numele domeniului ales este invalid.');
			return false;
		}
	}
	
	return true;
}


function check_login()
{	
	if (document.login.email.value=="" || document.login.email.value=="adresa@email") {
		alert("Va rugam adaugati adresa de e-mail pentru a continua.");
		document.login.email.focus();
		return false;
	}
	
	if (document.login.password.value=="") {
		alert("Va rugam adaugati parola pentru a continua.");
		document.login.password.focus();
		return false;
	}
	return true;
}

function disabled_off()
{
	document.domain_form.button1.disabled=false;
}


function domainPriceOver(TheId) {
	document.getElementById(TheId).style.border='1px solid #e40429';
	//document.getElementById(TheId).style.color='#FFFFFF';
}

function domainPriceOut(TheId) {
	document.getElementById(TheId).style.border='1px solid #EEEEEE';
	//document.getElementById(TheId).style.color='#e40429';
}

function check_order()
{
	if (document.getElementById('log_in_yes').checked) {
		if (document.order.email_cont.value=="" || document.order.email_cont.value=="-") {
			alert("Va rugam adaugati e-mail dvs pentru a continua.");
			document.order.email_cont.focus();
			return false;
		}

		if (document.order.password.value=="" || document.order.password.value=="-") {
			alert("Va rugam adaugati parola dvs pentru a continua.");
			document.order.password.focus();
			return false;
		}

	} else {
		if (document.order.name.value=="" || document.order.name.value=="-") {
			alert("Va rugam adaugati numele dvs pentru a continua.");
			document.order.name.focus();
			return false;
		}

		if (document.order.email.value=="" || document.order.email.value=="-") {
			alert("Va rugam adaugati e-mail dvs pentru a continua.");
			document.order.email.focus();
			return false;
		}
	
		if (document.order.phone.value=="" || document.order.phone.value=="-") {
			alert("Va rugam adaugati telefonul dvs pentru a continua.");
			document.order.phone.focus();
			return false;
		}	
	
		if (document.order.city.value=="" || document.order.city.value=="-") {
			alert("Va rugam adaugati orasul dvs pentru a continua.");
			document.order.city.focus();
			return false;
		}
	
		if (document.order.addr.value=="" || document.order.addr.value=="-") {
			alert("Va rugam adaugati adresa dvs pentru a continua.");
			document.order.addr.focus();
			return false;
		}
	
		if (document.order.code.value=="" || document.order.code.value=="-") {
			alert("Va rugam adaugati codul postal dvs pentru a continua.");
			document.order.code.focus();
			return false;
		}
	
		if (document.order.cf.value=="" || document.order.cf.value=="-") {
			alert("Va rugam adaugati codul fiscal sau CNP pentru persoane fizice pentru a continua.");
			document.order.cf.focus();
			return false;
		}	
	}
}

function check_voucher()
{
	if (document.order.voucher.value=="" || document.order.voucher.value=="-") {
		alert("Va rugam adaugati codul voucherului.");
		document.order.voucher.focus();
		return false;
	}
		
	return true;
}

function check_profile()
{
		if (document.profile.name.value=="" || document.profile.name.value=="-") {
			alert("Va rugam adaugati numele dvs pentru a continua.");
			document.profile.name.focus();
			return false;
		}

		if (document.profile.phone.value=="" || document.profile.phone.value=="-") {
			alert("Va rugam adaugati telefonul dvs pentru a continua.");
			document.profile.phone.focus();
			return false;
		}	
	
		if (document.profile.city.value=="" || document.profile.city.value=="-") {
			alert("Va rugam adaugati orasul dvs pentru a continua.");
			document.profile.city.focus();
			return false;
		}
	
		if (document.profile.addr.value=="" || document.profile.addr.value=="-") {
			alert("Va rugam adaugati adresa dvs pentru a continua.");
			document.profile.addr.focus();
			return false;
		}
	
		if (document.profile.code.value=="" || document.profile.code.value=="-") {
			alert("Va rugam adaugati codul postal dvs pentru a continua.");
			document.profile.code.focus();
			return false;
		}
	
		if (document.profile.cf.value=="" || document.profile.cf.value=="-") {
			alert("Va rugam adaugati codul fiscal sau CNP pentru persoane fizice pentru a continua.");
			document.profile.cf.focus();
			return false;
		}	
}

function clear_field(field,name)
{
		if(field.value==name){
			field.value="";
		}
}


function clear_domain(field,name)
{
		$('#domain_rezerv').html(" ");
		$('#domain_rezerv').hide();
		
		if(field.value==name){
			field.value="";
		}
}

