function generatePassword(a,elem) {
	var a;
	if(!a) { a == "8"; }
    var chars = "0123456789ABCDEFGHJKMNPQRTUVWXYZabcdefghjkmnpqrstuvwxyz";
	var pass = "";
	    for (x=0; x < a; x++){
			rand  = Math.random() * chars.length;
			genn = Math.round(rand);
			while (genn<=0){
              	   genn++;
       			}
		 pass+=chars.charAt(genn);
		}
	elem.value = pass;
}
function generateRandom(a,elem) {
	var a;
	if(!a) { a == "8"; }
    var chars = "123456789ABCDEFGHJKMNPQRTUVWXYZ";
	var pass = "";
	    for (x=0; x < a; x++){
			rand  = Math.random() * chars.length;
			genn = Math.round(rand);
			while (genn<=0){
              	   genn++;
       			}
		 pass+=chars.charAt(genn);
		}
	elem.value = pass;
}

function ScrollToElement(theElement){
	var selectedPosX = 0;
	var selectedPosY = 0;
	while(theElement != null){
		selectedPosX += theElement.offsetLeft;
		selectedPosY += theElement.offsetTop;
		theElement = theElement.offsetParent;
	}
	window.scrollTo(selectedPosX,selectedPosY);
}
function hideTips(Elem) {
	$(Elem).style.display = "none";
	return false;
}
function showTips(Elem) {
	$(Elem).style.display = "block";
	return false;
}
function toggleContent(ID) {
	var elem = $(ID);
	if (elem.style.display == 'none') {
		elem.style.display = 'block';
	} else {
		if (elem.style.display == 'block') {
			elem.style.display = 'none';
		}
	}
}

function reloadPage() {
	window.location.reload();
}
function GenRes() {
	if (document.location.hash) {
		var lookFor = '/res_type=';
		if (document.location.hash.indexOf(lookFor) > 0) {
			url = document.location.hash;
			var startPos = url.indexOf(lookFor)+lookFor.length;
			url = url.substr(startPos);
			if (url.indexOf('/') > -1) {
				curID = url.substr(0,url.indexOf('/'));
			} else {
				var curID = url;
			}
			var lookFor = '/res_message=';
			url = document.location.hash;
			var startPos = url.indexOf(lookFor)+lookFor.length;
			url = url.substr(startPos);
			if (url.indexOf('/') > -1) {
				resMes = url.substr(0,url.indexOf('/'));
			} else {
				var resMes = url;
			}
			var myResult = $('ajax_result');
			$('ajax_result').addClass(curID);
			$('ajax_result').innerHTML = urldecode(resMes);
			//alert('got here');
			var newURL = document.location.hash;
			newURL = newURL.replace('/res_type='+curID,'');
			newURL = newURL.replace('/res_message='+resMes,'');
			//alert(newURL);
			
			//if (newURL == '#') {
				//newURL = '';	
			//}
			document.location.hash = newURL;
		}
	}
}
function nellenSetActiveTab(ActiveItem,pre) {
	if (!ActiveItem) { ActiveItem = ''; }
	if (!pre) { pre = ''; }
	if ($('nellenTabset'+pre+'_'+ActiveItem)) {
		$('nellenTabset'+pre+'_'+ActiveItem).getParents('ul').each(function(par){
			par.getChildren('li').each(function(sib){
				var name = sib.get('id').replace('nellenTabset'+pre+'_','nellenTabsetDiv'+pre+'_');
				sib.removeEvents();
				sib.addEvents({
					click: function(){
						nellenSetActiveTab(name.replace('nellenTabsetDiv'+pre+'_',''),pre);
					}
				});
				sib.getChildren('a').each(function(el){ el.removeClass('current'); });
				if ($(name)) {
					$(name).set('styles',{'display':'none'});	
				}
			});
		});
		$('nellenTabset'+pre+'_'+ActiveItem).getChildren('a').each(function(el){ el.addClass('current') });
		$('nellenTabsetDiv'+pre+'_'+ActiveItem).set('styles',{'display':'block'});
	}
}

function HexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}
function HexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}
function HexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}
function cutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h}

