function removeMenu(){
	
	var getAnchor = document.getElementById("step4");
		if(getAnchor){
		var nodes = getAnchor.childNodes;
		//alert(nodes.length);
		if(nodes.length > 1){
			getAnchor.removeChild(nodes[1]);
		}	
	}
}

function setStep(stepId, onColor) {
	// Get the step id
	var stepNumber = stepId.substr(4,1);
				
	for (i = 1; i <= 4; i++) {
		var step = document.getElementById("step" + i);
		if (i < stepNumber) {
			var doSomething = function(){
				if(this.id == "step1"){
					removeMenu();
					createDesignCategoriesScreen();
				}else if(this.id == "step2"){
					removeMenu();
					if(designCategoryTypeId){
						getDesigns(designCategoryTypeId);
					}else{
						var callBack = function(data){
							getDesigns(data);
						};
						AjaxService.getUserSettings("designCategoryTypeId", callBack);
					}
					
				}else if(this.id == "step3"){
					removeMenu();
					getPublicationSize(false);
				}
			};
			step.onclick = doSomething;
			step.style.cursor = "pointer";
			if(!isFireFox){
				step.style.cursor = "hand";	
			}			
			setClassName(step, "completedStep");
		} else if (step.id == stepId) {
			step.onclick = null;
			setClassName(step, "selectedStep");
 		} else {
 			step.onclick = null;
			setClassName(step, "deSelectedStep");
		}
	}

}
var menuItemPreviouslySelected = null;
function setMenuItems(menuItemId, setItem) {
	for (i = 1; i <= 9; i++) {
		var menuItem = document.getElementById("menuItem" + i);
		if (menuItem) {
			if (menuItem.id == menuItemId) {
				setClassName(menuItem, "clicked");
				if (setItem) {
					menuItemPreviouslySelected = menuItem;
				}
			} else {
				setClassName(menuItem, "deSelected");
			}
		}
	}
}
function createHeader(parent, id, text) {
	var headerColumn = document.createElement("div");
	headerColumn.innerHTML = text;
	headerColumn.id = id;
	headerColumn.onmouseover = function () {
		if (this.className == "deSelected" || this.className == "") {
			setClassName(this, "selected");
		}
	};
	headerColumn.onmouseout = function () {
		if (this.className == "selected") {
			setClassName(this, "deSelected");
		}
	};
	if(!isFireFox){
		headerColumn.style.cursor = "hand";	
	}	
	headerColumn.style.cursor = "pointer";
	parent.appendChild(headerColumn);
	return headerColumn;
} 
function createSimpleDiv(parent, id, type) {
	if (!type) {
		type = "div";
	}
	var simpleDiv = document.createElement(type);
	simpleDiv.id = id;
	parent.appendChild(simpleDiv);
	return simpleDiv;
}
var agt = navigator.userAgent.toLowerCase();
function getBrowser() {
	if (agt.indexOf("msie") != -1) {
		return "ie";
	}
	if (agt.indexOf("opera") != -1) {
		return "opera";
	}
	if (agt.indexOf("mozilla") != -1 || agt.indexOf("compatible") == -1) {
		return "mozilla";
	}
	return "mozilla";
}


//Get object from array by id
function getObject(dataArray, id) {
	for (i = 0; i < dataArray.length; i++) {
		if (dataArray[i].id) {
			if (dataArray[i].id == id) {
				return dataArray[i];
			}
		} else {
			if (dataArray[i].domainModelId) {
				if (dataArray[i].domainModelId == id) {
					return dataArray[i];
				}
			}
		}
	}
}

//Remove all child nodes from a parent 
function removeChildrenFromNode(node) {
	while (node.hasChildNodes()) {
		node.removeChild(node.firstChild);
	}
}
//Insert after
function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}

//Calculate mod of two numbers
function Mod(X, Y) {
	return X - Math.floor(X / Y) * Y;
}
//Encode URL for flash movie
function encodeURL(str) {
	str = str.substring(7, str.length); // 7 = length('http://')
	str2 = "";
	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) == "=") {
			str2 += "[";
		} else {
			if (str.charAt(i) == "?") {
				str2 += "(";
			} else {
				if (str.charAt(i) == "&") {
					str2 += ")";
				} else {
					str2 += str.charAt(i);
				}
			}
		}
	}
	return str2;
}
function flashInfo(str){
	alert(str);
}
function setClassName(element, className) {
	if ((agt.indexOf("mozilla") != -1 && agt.indexOf("spoofer") == -1 && agt.indexOf("compatible") == -1) || (agt.indexOf("opera") != -1)) {
		element.setAttribute("class", className);
	} else {
		element.setAttribute("className", className);
	}
}
function block() {
	var blocker = document.createElement("div");
	blocker.setAttribute("id", "blocker");
	blocker.style.height = "100%";
	blocker.style.width = "100%";
	blocker.style.top = "0";
	blocker.style.left = "0";
	blocker.style.background = "silver";
	blocker.style.position = "absolute";
	blocker.style.filter = "Alpha(opacity:50)";
	blocker.style.MozOpacity = "0.5";
	blocker.style.KhtmlOpacity = "0.5";
	blocker.style.opacity = "0.5";
	document.body.appendChild(blocker);
	return blocker;
}
function blockParent(o) {
	var blocker = document.createElement("div");
	blocker.setAttribute("id", "blocker");
	blocker.style.height = document.body.offsetHeight;
	blocker.style.width = document.body.offsetWidth;
	blocker.style.top = "0";
	blocker.style.left = "0";
	blocker.style.background = "silver";
	blocker.style.position = "absolute";
	blocker.style.filter = "Alpha(opacity:50)";
	blocker.style.MozOpacity = "0.5";
	blocker.style.KhtmlOpacity = "0.5";
	blocker.style.opacity = "0.5";
	document.getElementById(o).appendChild(blocker);
	return blocker;
}
function unBlock() {
	var blocker = document.getElementById("div");
	document.body.removeChild(blocker);
}

// Removes leading whitespaces
function LTrim(value) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim(value) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

function trimString(valueToTrim){
	if(valueToTrim) {
		return LTrim(RTrim(valueToTrim));
	}
	else return '';	
}

// Removes leading and ending whitespaces
function trim() {
	return LTrim(RTrim(value));
}
String.prototype.trim = function () {
	return LTrim(RTrim(this));
};
if (document.captureEvents && Event.KEYUP) {
  //remove this part if you do not need Netscape 4 to work
	document.captureEvents(Event.KEYUP);
}

//now create the event handler function to process the event
function getKeyPressed(e) {
	if (!e) {
    //if the browser did not pass the event information to the
    //function, we will have to obtain it from the event register
		if (window.event) {
      //Internet Explorer
			e = window.event;
		} else {
      //total failure, we have no way of referencing the event
			return;
		}
	}
	if (typeof (e.keyCode) == "number") {
    //DOM
		e = e.keyCode;
	} else {
		if (typeof (e.which) == "number") {
    //NS 4 compatible
			e = e.which;
		} else {
			if (typeof (e.charCode) == "number") {
    //also NS 6+, Mozilla 0.9+
				e = e.charCode;
			} else {
    //total failure, we have no way of obtaining the key code
				return;
			}
		}
	}
	return e;
}
//Create menu item
function createMenuItem(id, searchScreens, text, body, left, numberOfItems) {
	var menuItem = document.createElement("label");
	if (left == null) {
		left = 0;
	}
	menuItem.id = id;
	if(!isFireFox){
		menuItem.style.cursor = "hand";	
	}	
	menuItem.style.cursor = "pointer";
	menuItem.style.position = "absolute";
	menuItem.style.left = left + "px";
	menuItem.innerHTML = text;
	menuItem.onmouseover = function () {
		if (this.className == "deSelected" || this.className == "") {
			setClassName(this, "selected");
		}
	};
	menuItem.onmouseout = function () {
		if (this.className == "selected" || this.className == "") {
			setClassName(this, "deSelected");
		}
	};
	if (body) {
		function menuItemOnclick(){
			if (numberOfItems) {
				setSubMenuItems(id, numberOfItems);
			}
			searchScreens.body.scrollTop = 0;	
			searchScreens.body.innerHTML = body;
		}
		menuItem.onclick = menuItemOnclick;
	}
	searchScreens.menu.appendChild(menuItem);
	return menuItem;
}
function setSubMenuItems(subMenuItemId, numberOfItems) {
	for (i = 1; i <= numberOfItems; i++) {
		var subMenuItem = document.getElementById("subMenu" + i);
		if (subMenuItem) {
			if (subMenuItem.id == subMenuItemId) {
				setClassName(subMenuItem, "clicked");
			} else {
				setClassName(subMenuItem, "deSelected");
			}
		}
	}
}
//Write message to the screen body
function writeMsg(searchScreens, msg) {
	searchScreens.body.innerHTML = msg;
}
function createInputBox(helpName, parent, type, required, nameAtt, value) {
	var boxO = new Object();
	var boxHolder = document.createElement("div");
	//boxHolder.style.border = "1px black solid";
	boxHolder.style.position = "relative";
	boxHolder.style.height = "25px";
	var label = document.createElement("label");
	label.style.top = "4px";
	label.style.left = "0px";
	label.style.height = "20px";
	label.style.width = "140px";
	//label.style.border = "1px black solid";
	label.style.position = "absolute";
	var help = getHelp(helpName);
	var reqText = "";
	if (required) {
		reqText = "<span style=color:red>*</span>";
	}
	label.innerHTML = help.caption + " " + reqText;
	label.onmouseover = function () {
		showHelpPopup(helpName, this);
	};
	label.onmouseout = function () {
		hidePopup();
	};
		
	var inputDiv = document.createElement("div");
	inputDiv.style.top = "0px";
	inputDiv.style.left = "145px";
	inputDiv.style.position = "absolute";
	var input;
	var v = "";
	if(value){
		v = value;
	}	
	if (type == "textArea") {
		input = document.createElement("textarea");
		setClassName(input, "largeTextArea");
	} else if(type == "hidden"){
		if(nameAtt){
			if(isIE){
				input =  document.createElement("<input name='"+nameAtt+"'>");
			}else{
				input =  document.createElement("input");
				input.setAttribute("name", nameAtt);
			}
		}else{
			input =  document.createElement("input");
		}
		input.type = "hidden";
	}else if(type == "text"){
		if(nameAtt){
			if(isIE){
				input =  document.createElement("<input name='"+nameAtt+"' value='"+v+"'>");
			}else{
				input =  document.createElement("input");
				input.setAttribute("name", nameAtt);
				input.setAttribute("value", v);
				//alert(DWRUtil.toDescriptiveString(input, 1));
			}
		}else{
			input =  document.createElement("input");
		}
		input.type = "text";
		setClassName(input, "largeTextBox");
	}else if(type == "file"){
		if(nameAtt){
			if(isIE){
				input =  document.createElement("<input name='"+nameAtt+"'>");
			}else{
				input =  document.createElement("input");
				input.setAttribute("name", nameAtt);
			}
		}else{
			input =  document.createElement("input");
		}
		input.type = "file";
		setClassName(input, "largeFileBox");
	}else if(type == "checkbox"){
		if(nameAtt){
			if(isIE){
				input =  document.createElement("<input name='"+nameAtt+"'>");
			}else{
				input =  document.createElement("input");
				input.setAttribute("name", nameAtt);
			}
		}else{
			input =  document.createElement("input");
		}
		input.type = "checkbox";
	}else if(type == "password"){
		if(nameAtt){
			if(isIE){
				input =  document.createElement("<input name='"+nameAtt+"'>");
			}else{
				input =  document.createElement("input");
				input.setAttribute("name", nameAtt);
			}
		}else{
			input =  document.createElement("input");
		}
		input.type = "password";
		setClassName(input, "largeTextBox");
	}
	input.id = helpName;
	inputDiv.appendChild(input);
	boxHolder.appendChild(label);
	boxHolder.appendChild(inputDiv);
	parent.appendChild(boxHolder);
	boxO.inputDiv = inputDiv;
	boxO.holder = boxHolder;
	boxO.label = label;
	boxO.input = input;
	return boxO;
}
function createRadio(caption, id, parent, value, checked) {
	var radioO = new Object();
	var radioDiv = document.createElement("div");
	radioDiv.style.width = "60px";
	radioDiv.style.height = "20px";
	var radio;
	try {
		radio = document.createElement("<input id=\"" + id + "\" type=radio name=myradio " + checked + ">");
	}
	catch (err) {
		radio = document.createElement("input");
		radio.id = id;
		radio.setAttribute("type", "radio");
		radio.setAttribute("name", "myradio");
		if (checked == "checked") {
			radio.checked = true;
		}
	}
	radio.style.position = "absolute";
	radio.value = value;
	radio.id = id;
	var label = document.createElement("label");
	label.innerHTML = caption;
	label.style.position = "absolute";
	label.style.top = "4px";
	label.style.left = "20px";
	radioDiv.appendChild(radio);
	radioDiv.appendChild(label);
	parent.appendChild(radioDiv);
	radioDiv.onmouseover = function () {
		if(helpName && helpName == null){
		} else {
			showHelpPopup(id + "-radioHelp");
		}
		
	};
	
	radioDiv.onmouseout = function () {
		hidePopup();
	};
	radioDiv.radio = radio;
	radioDiv.label = label;
	radioO.radioDiv = radioDiv;
	radioO.radio = radio;
	return radioO;
}

function createLoadingMessage(parent){
		var loadingMessage = document.createElement("div");
		loadingMessage.style.position = "absolute";
		loadingMessage.style.left = "130px";
		loadingMessage.innerHTML = "loading...";
		parent.appendChild(loadingMessage);
		return loadingMessage;
}

function createSelectBox(helpName, parent, left, dual, top, options) {
	var o = new Object();
	var div = document.createElement("div");
	div.style.width = "400px";
	div.style.height = "25px";
	var label = document.createElement("label");
	var help = getHelp(helpName);
	label.innerHTML = help.caption;
	label.style.position = "absolute";
	label.onmouseover = function () {
		if (helpName == null)
		{
		}else {
			showHelpPopup(helpName);
		}		
	};
	label.onmouseout = function () {
		hidePopup();
	};
	div.appendChild(label);
	var select = document.createElement("select");
//	if(options){
//		for(i = 0; i < options.length; i++){
//			
//		}
//	}
	
	select.id = helpName;
	select.name = helpName;
	setClassName(select, "largeTextBox");
	select.style.position = "absolute";
	select.style.left = left + "px";
	if(top != null) {
		select.style.top = top + "px";
	}
	
	div.appendChild(select);
	if (dual) {
		var select2 = document.createElement("select");
		select2.id = helpName + "2";
		select2.name = helpName;
		select2.style.position = "absolute";
		o.select2 = select2;
		div.appendChild(select2);
		setClassName(select2, "largeTextBox");
	}
	parent.appendChild(div);
	o.label = label;
	o.select = select;
	o.holder = div;
	return o;
}
function createImage(source, scale, parent, id) {
	var imgData = new Image();
	imgData.id = "small-" + id;
	imgData.src = source;
	imgData.style.display = "block";
	if (imgData.width > 0 && getBrowser() == "ie") {
		var w = imgData.width;
		var h = imgData.height;
		imgData.width = w * scale;
		imgData.height = h * scale;
	}
	imgData.onload = function () {
		var w = this.width;
		var h = this.height;
		this.width = w * scale;
		this.height = h * scale;
	};
	//chekIfImageIsloaded(id);
	return imgData;
}
/*function chekIfImageIsloaded(id) {
	for (i = 0; i < document.images.length; i++) {
		if (document.images[i].id.indexOf("small-") != -1) {
		alert(document.images[i].complete)
			if (!document.images[i].complete) {
			
			}
		}
	}
}*/
function pausecomp(millis) {
	var date = new Date();
	var curDate = null;
	do {
		curDate = new Date();
	} while (curDate - date < millis);
}
//*************************************Position properties************************************************//
//********************************************************************************************************//
function createProperties(width, height, left, top, zIndex, position, textAlign, border) {
	var properties = new Object();
	properties.width = 0;
	properties.height = 0;
	properties.left = 0;
	properties.zIndex = 0;
	properties.position = "absolute";
	properties.textAlign = "left";
	properties.border = "";
	if (top != null) {
		properties.top = top;
	}
	if (width != null) {
		properties.width = width;
	}
	if (height != null) {
		properties.height = height;
	}
	if (top != null) {
		properties.top = top;
	}
	if (left != null) {
		properties.left = left;
	}
	if (zIndex != null) {
		properties.zIndex = zIndex;
	}
	if (position != null) {
		properties.position = position;
	}
	if (textAlign != null) {
		properties.textAlign = textAlign;
	}
	if (border != null) {
		properties.border = border;
	}
	return properties;
}
//*********************Submits a click***************************//
function submitOnReturn(o) {
	if(!isFireFox){
		if (event != null && event.keyCode == 13) {
			o.onclick();
		}
	}
}
//********************************************Create action***********************************************//
var selectedAction = null;
function createAction(id, helpName, properties, caption, icon, capLeftPosition) {
	var action = document.createElement("div");
	action.style.border = "1px black solid";
	if(!isFireFox){
		action.style.cursor = "hand";	
	}	
	action.style.cursor = "pointer";
	action.style.whiteSpace = "nowrap";
	action.id = id;

	var cap = document.createElement("div");
	cap.id = helpName + "Caption";
	//cap.style.border = "1px black solid"
	cap.style.position = "absolute";
	cap.style.top = "12px";
	if(capLeftPosition){
		cap.style.left = capLeftPosition + "px";
	}else{
		cap.style.left = "15px";	
	}
	
	
	action.appendChild(cap);
	var help = getHelp(helpName);
	if (caption != null) {
		cap.innerHTML = caption;
	} else {
		cap.innerHTML = help.caption;
	}
	action.caption = cap;
	action.onmouseover = function () {
		setClassName(cap, "selected");
		if (helpName == null)
		{
		}else {
			showHelpPopup(helpName);
		}
		
	};
	action.onmouseout = function () {
		setClassName(cap, "deSelected");
		hidePopup();
	};
	if (properties != null) {
	
		action.style.width = properties.width;
		action.style.height = properties.height;
		action.style.left = properties.left;
		action.style.top = properties.top;
		action.style.textAlign = properties.textAlign;
		action.style.zIndex = properties.zIndex;
		action.style.border = properties.border;
		action.style.position = properties.position;
	}
	
	if(icon){
		var imgIcon = document.createElement("img");
		imgIcon.src = icon;
		imgIcon.id = helpName + "Icon";
		imgIcon.style.position = "absolute";		
		imgIcon.onmouseover = action.onmouseover;
		imgIcon.onmouseout = action.onmouseout;
		imgIcon.onclick = action.onclick;
		action.appendChild(imgIcon);
		action.icon = imgIcon;
		//cap.style.left = "25px";
	}
	return action;
}
function createArrowPointer(horizontal, parent, top, left) {
	var arrowObject = new Object();
	var img = document.createElement("img");
	if (horizontal) {
		img.src = interfaceImagesPath + "/arrow.gif";
		arrowObject.src = img.src;
		arrowObject.overSrc = interfaceImagesPath + "/arrow-over.gif";
		img.width = "12";
		img.height = "13";
	} else {
		img.src = interfaceImagesPath + "/arrow-down.gif";
		arrowObject.src = img.src;
		arrowObject.overSrc = interfaceImagesPath + "/arrow-down-over.gif";
	}
	arrowObject.image = img;
	img.style.position = "absolute";
	img.style.top = top + "px";
	img.style.left = left + "px";
	if(!isFireFox){
		img.style.cursor = "hand";	
	}		
	img.style.cursor = "pointer";
	parent.appendChild(img);
	return arrowObject;
}
function getEmptyDiv(divName) {
	var div = document.getElementById(divName);
	if (div == null) {
		div = document.createElement("div");
		div.id = divName;
	} else {
		while (div.hasChildNodes()) {
			div.removeChild(div.childNodes[0]);
		}
	}
	return div;
}
function getInnerWindowSize() {
	var screen = new Object();
	screen.width = document.body.offsetWidth;
	screen.height = document.body.offsetHeight;
	return screen;
}
function getDivCoords(parent, offsetParent) {
	var el = parent;
	var coords = new Object();
	var x = el.offsetLeft;
	if (offsetParent==null) offsetParent = document.body;
	while ((el = el.offsetParent) != null) {
		x += el.offsetLeft;	
		if (el.offsetParent == offsetParent) {
			break;
		}		
	}
	el = parent;
	var y = el.offsetTop;
	while ((el = el.offsetParent) != null) {
		y += el.offsetTop;		
		if (el.offsetParent == offsetParent) {
			break;
		}		
	}
	coords.x = x;
	coords.y = y;
	return coords;
}
function setTransparency(div, opacity) {
	div.style.filter = "Alpha(opacity:" + opacity + ")";
	div.style.MozOpacity = opacity / 100;
	div.style.KhtmlOpacity = opacity / 100;
	div.style.opacity = opacity / 100;
}
function newWin(url, winname, width, height, top, left, opener, forceNormalWindow) {
	if (window.showModalDialog && !forceNormalWindow) {
		win = window.showModelessDialog(url, opener, "dialogHeight: " + height + "px; dialogWidth: " + width + "px; edge: Raised; center: yes; help: no; resizable: no; status: yes; scroll=no");
	} else {
		win = window.open(url, winname, "left=" + ((screen.width) / 2 - width / 2) + ",top=" + ((screen.height) / 2 - height / 2) + ",height=" + height + ",width=" + width + ",dependent=yes,directories=no,location=no,menubar=no,resizable=yes,scrollbars=no,status=yes");
	}
}
function isCreditCard(st) {
  // Encoding only works on cards with less than 19 digits
	if (st.length > 19) {
		return (false);
	}
	if (st == 0) {
		return (false);
	}
	sum = 0;
	mul = 1;
	l = st.length;
	for (i = 0; i < l; i++) {
		digit = st.substring(l - i - 1, l - i);
		tproduct = parseInt(digit, 10) * mul;
		if (tproduct >= 10) {
			sum += (tproduct % 10) + 1;
		} else {
			sum += tproduct;
		}
		if (mul == 1) {
			mul++;
		} else {
			mul--;
		}
	}
	if ((sum % 10) == 0) {
		return (true);
	} else {
		return (false);
	}
}

function dhtmlLoadScript(url, id) {
	if (document.getElementById(id)==null) {
	   var e = document.createElement("script");
	   e.id = id;
	   e.src = url;
	   e.type="text/javascript";
	   document.getElementsByTagName("head")[0].appendChild(e);
	}
}

function addStyleSheet(styleSheetUrl) {
	//alert("ADDING " + styleSheetUrl)
	if(document.createStyleSheet) {
		document.createStyleSheet(styleSheetUrl);
	} else {
		var styles = "@import url('" + styleSheetUrl + "');";
		var newSS=document.createElement('link');
		newSS.rel='stylesheet';
		newSS.href='data:text/css,'+escape(styles);
		document.getElementsByTagName("head")[0].appendChild(newSS);
	}
}

function EditableSelectBox(id, helpName, properties, icon) {
	var action = document.createElement("span");
	if(!isFireFox){
		action.style.cursor = "hand";	
	}	
	action.style.cursor = "pointer";
	action.style.whiteSpace = "nowrap";
	action.id = id;
	
	var value = document.createElement("input");
	value.style.position = "absolute";
	value.style.top = "4px";
	value.style.width = (properties.width - 25);
	value.style.height = "30px";	
	
	action.appendChild(value);
	var help = getHelp(helpName);
	
	action.value = value;
	action.onmouseover = function () {
		setClassName(value, "selectBoxEditable");
		if (helpName == null)
		{
		}else {
			showHelpPopup(helpName);
		}
		
	};
	action.onmouseout = function () {
		setClassName(value, "selectBoxDeselected");
		hidePopup();
	};
	
	action.style.width = properties.width;
	action.style.height = properties.height;
	action.style.left = properties.left;
	action.style.top = properties.top;
	action.style.textAlign = properties.textAlign;
	action.style.zIndex = properties.zIndex;
	action.style.border = properties.border;
	action.style.position = properties.position;
	
	var dropdown = document.createElement("div");
	dropdown.id = "dropdown" + id;
	dropdown.style.position = "absolute";
	dropdown.style.top = properties.height;
	dropdown.style.height = "100px";
//	dropdown.style.visible = 'hidden';
	
	action.appendChild(dropdown);
	
	if(icon){
		var imgIcon = document.createElement("img");
		imgIcon.src = icon;
		imgIcon.style.position = "absolute";		
		imgIcon.onmouseover = action.onmouseover;
		imgIcon.onmouseout = action.onmouseout;
		imgIcon.onclick = imgIconOnclick;
		function imgIconOnclick(){
			dropdown.visibility = "visible";
		}
		action.appendChild(imgIcon);
		value.style.left = "25px";
	}
	return action;
}

var numb = '0123456789';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
 
function isValid(parm,val) 
{
  if (parm == "") return false;
  for (var i=0; i<parm.length; i++) 
  {
    if (val.indexOf(parm.charAt(i),0) == -1) return false;
  }
  return true;
}

//return true even if 1 value matches
function containsValue(parm,val) 
{
  if (parm == "") return false;
  for (var i=0; i<parm.length; i++) 
  {
    if (val.indexOf(parm.charAt(i),0) != -1){return true;}
  }
  return false;
}

/*Format currency and add amount*/
function formatCurrency(amount, symbol) {
	var i = parseFloat(amount);
	var isNegative = i < 0;
	if (isNaN(i)) {
		i = 0;
	}
	var minus = "";
	if (i < 0) {
		i = i * -1;
	}
	i = Math.abs(i);
	i = parseInt((i + 0.005) * 100);
	i = i / 100;
	s = new String(i);
	if (s.indexOf(".") < 0) {
		s += ".00";
	}
	if (s.indexOf(".") == (s.length - 2)) {
		s += "0";
	}
	
	if(isNegative){
		return "-" + symbol + s;
	}else{
		return "&nbsp;" + symbol + s;	
	}
}
 
function isNum(parm) {return isValid(parm,numb);}
function isLower(parm) {return isValid(parm,lwr);}
function isUpper(parm) {return isValid(parm,upr);}
function isAlpha(parm) {return isValid(parm,lwr+upr);}
function isNumIncSpace(parm) {return isValid(parm,numb+' ');}
function isAlphaNum(parm) {return isValid(parm,lwr+upr+numb);}
function isAlphaNumSpl(parm) {return isValid(parm,lwr+upr+numb+'-'+'_'+'.');} // used to validate userName during regn.
function isAlphaNumIncSpace(parm) {return isValid(parm,lwr+upr+numb+' ');}
function isAlphaIncSpace(parm) {return isValid(parm,lwr+upr+' ');}
function isValidAddress(parm){return isValid(parm,lwr+upr+numb+'-'+'_'+'.'+'/'+':'+','+'#'+' '+"'")}; 
function containsAlpha(parm){return containsValue(parm,lwr+upr)};
