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 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) {
	document.getElementById(Elem).style.display = "none";
	return false;
}
function showTips(Elem) {
	document.getElementById(Elem).style.display = "block";
	return false;
}
function toggleContent(ID) {
	var elem = document.getElementById(ID);
	if (elem.style.display == 'none') {
		elem.style.display = 'block';
	} else {
		if (elem.style.display == 'block') {
			elem.style.display = 'none';
		}
	}
}
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);
			document.getElementById('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;
		}
	}
}
