function CDMScript(filename, path) {

	this.path = path;

	this.filename = filename;

}

function CDMScriptManager(name) {

	this.name = name;

	this.scriptCollection = new Array();

}	

CDMScriptManager.prototype = {								

	load: function(scriptPath, continueLoadOnConflict) {

		if(continueLoadOnConflict == 'undefined')

			continueLoadOnConflict = false;



		if(scriptPath == undefined) {

			document.write('<scr' + 'ipt><!-- Path is required to load "' + scriptPath + '" --></scr' + 'ipt>');

			return false;

		}



		var scriptFilename = this.getFilenameFromPath(scriptPath);				

		var isLoaded = this.isLoaded(scriptFilename);



		if(isLoaded != null)

			document.write('<scr' + 'ipt><!-- Warning: "'+scriptFilename+'" has been previously loaded. --></scr' + 'ipt>');

		

		if(isLoaded == null || continueLoadOnConflict) {										

			this.scriptCollection.push(new CDMScript(scriptFilename, scriptPath));



			document.write('<scr' + 'ipt type="text/javascript" src="' + scriptPath + '"></scr' + 'ipt>');

			

			return true;					

		}

		return false;

	},

	isLoaded: function(scriptFilename) {

		for(i=0;i<this.scriptCollection.length;i++) {

			if(this.scriptCollection[i].filename == scriptFilename) {

				return this.scriptCollection[i];

			}

		}

		return null;

	},

	getFilenameFromPath: function(path) {

		var regex = new RegExp(/([^\/\\]+)$/);

		var result = regex.exec(path);

		if (result == null)

			return null;

		else

			return result[0];

	},

	getLoadedScripts: function() {

		return this.scriptCollection;

	},

	getQuickInfo: function() {

		var result = '';

		for(i=0;i<this.scriptCollection.length;i++) {

			result += this.scriptCollection[i].path;

			result += (i != this.scriptCollection.length - 1) ? ', ' : '';

		}

		return result;

	}

}

var CDMScriptManager = new CDMScriptManager('CDM Script Manager');





/*******************************************************/



function hide_d(theTable){document.getElementById(theTable).style.display = 'none';}

function show_d(theTable){	document.getElementById(theTable).style.display = 'block';}




function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";

	//make image transparent
	changeOpac(0, imageid);

	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;

	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}


var cole='#F4F4F4';
function addElement(theValue,myDiv,text,styl) {
  var imgadddel='';
  var ni = document.getElementById(myDiv);
  var numi = document.getElementById(theValue);
  var num = (document.getElementById(theValue).value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = theValue+num+'Div';
  newdiv.setAttribute('id',divIdName);
/*  if(cole=='#F4F4F4'){cole='#CCCCCC'}else{cole='#F4F4F4'}*/
newdiv.style.opacity = 0;
if(!styl) newdiv.style.backgroundColor = cole;


if(styl==1){
var imgadddel="<img style='cursor:pointer;' src='/images/add16x16.png' title='add a new anser' onclick=\"addElement('numxxx','ajax_d','<input name=tx[]>',1);\" /><img style='cursor:pointer;' src='/images/delete16x16.png' title='Delete this anser' onclick=\"destroy_it('"+divIdName+"');\" />";
 }
  newdiv.innerHTML = text+'  '+imgadddel;
  ni.appendChild(newdiv);
opacity(divIdName,0,100, 500);
if(!styl) setTimeout("ready_x();",1000);

 }

function removeElement(divNum) {
/*var el = document.getElementById('myDiv');
el.parentNode.removeChild(divNum);*/
opacity(divNum,100,1, 500)
setTimeout("hide_d('"+divNum+"');",500);
}

function destroy_it(div){
opacity(div,100,1, 500)
setTimeout("hide_d('"+div+"');",500);
getData('http://www.urorbit-tools.com/blank_page.php',div)	
}
