var menuids=["sidebarmenu1"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas

function initsidebarmenu(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
    ultags[t].parentNode.getElementsByTagName("a")[0].className+=" subfolderstyle"
  if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
   ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item
  else //else if this is a sub level submenu (ul)
    ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.display="block"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.display="none"
    }
    }
  for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
  ultags[t].style.visibility="visible"
  ultags[t].style.display="none"
  }
  }
}

if (window.addEventListener)
window.addEventListener("load", initsidebarmenu, false)
else if (window.attachEvent)
window.attachEvent("onload", initsidebarmenu)


var abxs = window.location.hostname;
if (abxs == "localhost")
{
	var tb_pathToFile="http://"+abxs+"/eco-feb-11/check_domain_ajax.php";
	var tb_pathToFile_add="http://"+abxs+"/eco-feb-11/add_domain_ajax.php";
	var tb_rj_add="http://"+abxs+"/eco-feb-11/registrar_ajax.php";
	var tb_pathToImage="http://"+abxs+"/eco-feb-11/js/check_domain.gif";
} else {
	var tb_pathToFile="http://"+abxs+"/check_domain_ajax.php";
	var tb_pathToFile_add="http://"+abxs+"/add_domain_ajax.php";
	var tb_rj_add="http://"+abxs+"/registrar_ajax.php";
	var tb_pathToImage="http://"+abxs+"/js/check_domain.gif";
}

function createObjectxmax() {
var request_typexmax;
var browserxmax = navigator.appName;
if(browserxmax == "Microsoft Internet Explorer"){
request_typexmax = new ActiveXObject("Microsoft.XMLHTTP");
}else{	
request_typexmax = new XMLHttpRequest();
}
return request_typexmax;
}
var http = createObjectxmax();
var nocachealls = 0;
function check_ext() {
	// Optional: Show a waiting message in the layer with ID login_response
	document.getElementById('display_domain').innerHTML = "<img src='"+tb_pathToImage+"' border='0'>";	
	// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.	
	var option_a= encodeURI(document.getElementById("domain").value);
	var option_b= encodeURI(document.getElementById("ext").value);
	var option_c= encodeURI(document.getElementById("option").value);
	//var option_d1= encodeURI(document.getElementById("registrar1").value);
	
	radios = document.getElementsByName("registrar");
    for (i = 0; i < radios.length; i++) {
        if (radios[i].checked) {
			var option_d2 = radios[i].value;
		}
    }
	// Set te random number to add to URL request
	nocachealls = Math.random();
	// Pass the login variables like URL variable
	http.open('get', tb_pathToFile+'?option_aa='+option_a+'&option_bb='+option_b+'&option_cc='+option_c+'&option_dm='+option_d2+'&nocachealls='+nocachealls);
	http.onreadystatechange = insertReplyalls;
	http.send(null);
}
function insertReplyalls() {
	if(http.readyState == 4){
		var responsealls = http.responseText;
		//alert(responsealls);
		// else if login is ok show a message: "Site added+ site URL".
		document.getElementById('display_domain').innerHTML = ''+responsealls;
	}	
}

var nocachenhys = 0;
function add_cart_domain(domain, ext, sample) {	
	// Optional: Show a waiting message in the layer with ID login_response	
	document.getElementById('display_domainx').innerHTML = "<img src='"+tb_pathToImage+"' border='0'>";		
	nocachenhys = Math.random();
	// Pass the login variables like URL variable
	http.open('get', tb_pathToFile_add+'?option_aa='+domain+'&option_bb='+ext+'&option_cc='+sample+'&nocachenhys='+nocachenhys);
	http.onreadystatechange = insertReplynhys;
	http.send(null);
}
function insertReplynhys() {
	if(http.readyState == 4){
		var responsenhys = http.responseText;		
		jQuery(document).ready(function($) {
			jQuery.facebox(responsenhys);
		})
	}	
}

var nocachevbnc = 0;
function change_ext_option(type) {	
	// Optional: Show a waiting message in the layer with ID login_response	
	document.getElementById('extensions_open').innerHTML = "wait...";		
	nocachevbnc = Math.random();
	// Pass the login variables like URL variable
	http.open('get', tb_rj_add+'?ttype='+type+'&nocachevbnc='+nocachevbnc);
	http.onreadystatechange = insertReplyvbnc;
	http.send(null);
}
function insertReplyvbnc() {
	if(http.readyState == 4){
		var responsevbnc = http.responseText;
		document.getElementById('extensions_open').innerHTML = ""+responsevbnc;
	}	
}

function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}
