function eid(ename){
	var e_name = document.getElementById(ename);
	return e_name;
}

function getTab(tabid){
	var tabs = document.getElementById('tabs').getElementsByTagName('a');
	for (var i=0; i < tabs.length; i++) {
		tabs[i].style.backgroundColor = '#F4F4F5';
		var tabname = tabs[i].name;
		document.getElementById('div-'+tabname).style.display = "none";
	}
	document.getElementById('tab_'+tabid).style.backgroundColor = "#ffffff";
	document.getElementById('div-'+tabid).style.display = "block";
}


function changeTab(catid,planid){

	var boxes = document.getElementById(catid).getElementsByTagName("div");
	var tabs = document.getElementById(catid + '_tabs').getElementsByTagName('a');

	for (var b=0; b < boxes.length; b++) {
		clasname = /main_box_holder/g;
		if(clasname.test(boxes[b].className)){
			var boxname = boxes[b].id;
			document.getElementById(boxname).style.display = "none";
		}
	}

	eid(planid).style.display = "block";

	for (var e=0; e < tabs.length; e++) {
		tabs[e].className = "active";
		tabs[e].parentNode.className = "active";
		if(tabs[e].id == "tab_"+planid){
			tabs[e].className = "selected";
			tabs[e].parentNode.className = "selected";
		}
	}
}


// JAVASCRIPT DROPDOWN

// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id){
	// cancel close timer
	mcancelclosetime();
	eid('d_mainbox').innerHTML = "-------";

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
}

// close showed layer
function mclose(){
	if(ddmenuitem)ddmenuitem.style.visibility = 'hidden';
	eid('d_mainbox').innerHTML = eid('srch_tld').value;
}

// go close timer
function mclosetime(){
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime(){
	if(closetimer)	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;

function getDomExt(tld){
	eid('srch_tld').value = "."+ tld;
	eid('d_mainbox').innerHTML = "."+ tld;
}

function submit_domain(){
	if(eid('srch_domain').value != ""){
		var chk_domain = /^([-a-z0-9]+)$/i;
		if(chk_domain.test(eid('srch_domain').value)){
			//eid('srch_domain').value;
			//eid('srch_tld').value;
			//var sURL = unescape("http://billing.ns1.bg/order/orderwiz.php?new_domain="+ eid('srch_domain').value +"&new_tld_extension="+ eid('srch_tld').value +"&submit_domain=register&v=2&aid=&c_code=&submit=1");
			//window.location.replace( sURL );
			document.forms.domain_submit.submit(); //document.domain_submit.submit();
		}else{
			alert("Домейнът може да съдържа само:\nЛатински букви от A до Z, цифри от 0 до 9\nи имволът -");
		}
	}else{
		alert("Моля въведете домейн");
	}
}

function getDomExt2(tld){
	eid('srch_tld2').value = "."+ tld;
	eid('d_mainbox2').innerHTML = "."+ tld;
}

function submit_domain2(){
	if(eid('srch_domain2').value != ""){
		var chk_domain = /^([-a-z0-9]+)$/i;
		if(chk_domain.test(eid('srch_domain2').value)){
			//eid('srch_domain').value;
			//eid('srch_tld').value;
			//var sURL = unescape("http://billing.ns1.bg/order/orderwiz.php?new_domain="+ eid('srch_domain').value +"&new_tld_extension="+ eid('srch_tld').value +"&submit_domain=register&v=2&aid=&c_code=&submit=1");
			//window.location.replace( sURL );
			document.forms.domain_submit2.submit(); //document.domain_submit.submit();
		}else{
			alert("Домейнът може да съдържа само:\nЛатински букви от A до Z, цифри от 0 до 9\nи имволът -");
		}
	}else{
		alert("Моля въведете домейн");
	}
}


