function checkDomain(nname)
{
var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name', '.asia',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw','.eu','.me','.rs');

var mai = nname;
var val = true;

var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,dot);
var ext = mai.substring(dot,mai.length);
//alert(ext);
	
if(dot>2 && dot<57)
{
	for(var i=0; i<arr.length; i++)
	{
	  if(ext == arr[i])
	  {
	 	val = true;
		break;
	  }	
	  else
	  {
	 	val = false;
	  }
	}
	if(val == false)
	{
	  	 alert("Your domain extension "+ext+" is not correct");
		 return false;
	}
	else
	{
		for(var j=0; j<dname.length; j++)
		{
		  var dh = dname.charAt(j);
		  var hh = dh.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46 && dh!='_')
		  {
			 if((j==0 || j==dname.length-1) && hh == 45)	
		  	 {
		 	  	 alert("Domain name should not begin are end with '-'");
			      return false;
		 	 }
		  }
		else	{
		  	 alert("Your domain name should not have special characters");
			 return false;
		  }
		}
	}
}

//Added by tsergiy - 15.04.2009

else if (dot <= 0)
{
	alert("Domain name you entered isn't valid");
	return false;
}

//End of tsergiy's adding

else
{
 alert("Your Domain name is too short/long");
 return false;
}	

return true;
}


function addOption (oListbox, text, value, isDefaultSelected, isSelected)
{
  var oOption = document.createElement("option");
  oOption.appendChild(document.createTextNode(text));
  oOption.setAttribute("value", value);

  if (isDefaultSelected) oOption.defaultSelected = true;
  else if (isSelected) oOption.selected = true;

  oListbox.appendChild(oOption);
}

function updateEncodeVersionSelect() {
	var module_name_select = document.getElementById('tlfModuleName');
	document.getElementById('tlfEncodeVersion').options.length = 0;
	
	software_selected = parseInt(module_name_select.options[module_name_select.selectedIndex].className);

	try {
  	var product_trial_period = parseInt($(module_name_select.options[module_name_select.selectedIndex]).attr("id"));
		
  	if (product_trial_period > 0) {
  		$("#product_trial_period").text(product_trial_period);
  		$("#product_trial_period_label_container").show();
  	}
  } catch (e) {
  	
  }
	
	if(software_selected) {
		document.getElementById("tlfDomain_container").style.display = "none";
	} else {
		document.getElementById("tlfDomain_container").style.display = "";
	}
	
	if(module_name_select.value == '-1') {
		document.getElementById("encodeVersionSelectTR").style.display = "none";
	} else {
		switch ( avail_encoded_versions[module_name_select.value] ) {
			case "all"	:
				addOption(document.getElementById('tlfEncodeVersion'), "Zend encoded version (Recommended)", 'zend', false, false);
				addOption(document.getElementById('tlfEncodeVersion'), "IonCube encoded version", 'ioncube', false, false);
				document.getElementById("encodeVersionSelectTR").style.display = "";
			break;
			
			case "zend":
				addOption(document.getElementById('tlfEncodeVersion'), "Zend encoded version (Recommended)", 'zend', false, false);
				document.getElementById("encodeVersionSelectTR").style.display = "";
			break;
			
			case "ioncube":
				addOption(document.getElementById('tlfEncodeVersion'), "IonCube encoded version", 'ioncube', false, false);
				document.getElementById("encodeVersionSelectTR").style.display = "";
			break;
			
			case "none":
			default:
				document.getElementById("encodeVersionSelectTR").style.display = "none";
			break;
		}
	}
}

function submit_special_trial_request_form() {
	$("#request_form_load_indicator").css("display", "inline");
	$("#special_trial_request_error_message").hide();
	
	$.post("account_trial_special.php", $("#special_trial_request").serialize(),
	    function(info_contents) {
					$("#request_form_load_indicator").css("display", "none");
					
					if (parseInt($.trim(info_contents)) == 1) {
						show_special_trial_request_info();
				  } else {
						$("#special_trial_request_error_message").show();
						$("#special_trial_request_error_message").html(info_contents);
					}
	    }
	);
}

function show_special_trial_request_info() {
	$("#special_trial_request_form").hide();
	//$("#show_special_trial_request_info_block").html(info_contents);
	$("#special_trial_request_result_block").slideDown("normal");
}

function show_special_trial_request_form() {
	$("#special_trial_request").get(0).reset();
	$("#special_trial_request_title").hide();
	$("#special_trial_request_result_block").hide();
	$("#special_trial_request_form").slideDown("normal");
}

function reset_trial_request_form() {
	$("#special_trial_request").get(0).reset();
}

