var root;
var scripts = document.getElementsByTagName("script");
var i = scripts.length;
while (i--) {
	var match = scripts[i].src.match(/(^|.*\/)gadget\/select\.js$/);
	if (match) {
		root = match[1];
		break;
	}
}

var now = new Date();
var rnd = Math.floor(Math.random() * 100000);
var divid = "almighty_" + now.getTime().toString() + rnd.toString();

var divtag = '<div id="' + divid + '"></div>';
document.write(divtag);

var paramList = "gadget=select&divid=" + divid
	+ "&items=" + encodeURIComponent(almighty_gadget_items) 
;

if(typeof almighty_gadget_width != "undefined"){
	paramList = paramList + "&width=" + almighty_gadget_width;
}
if(typeof almighty_gadget_height != "undefined"){
	paramList = paramList + "&height=" + almighty_gadget_height;
}
if(typeof almighty_gadget_text_color != "undefined"){
	paramList = paramList + "&tc=" + almighty_gadget_text_color;
}
if(typeof almighty_gadget_background_color != "undefined"){
	paramList = paramList + "&bg=" + almighty_gadget_background_color;
}
if(typeof almighty_gadget_border_color != "undefined"){
	paramList = paramList + "&bc=" + almighty_gadget_border_color;
}
if(typeof almighty_gadget_link_color != "undefined"){
	paramList = paramList + "&lc=" + almighty_gadget_link_color;
}
if(typeof almighty_gadget_template_no != "undefined"){
	paramList = paramList + "&tn=" + almighty_gadget_template_no;
}
var url = root + "gadget.php?" + paramList;

var script = document.createElement( 'script' );

script.src   = url;
script.type  = 'text/javascript';
script.defer = true;
script.async = true;
script.charset = "utf-8";

document.getElementsByTagName( "head" )[ 0 ].appendChild( script );


