	// JavaScript Document
		//Trim Functions
		function ltrim(str) { 
			for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
			return str.substring(k, str.length);
		}
		function rtrim(str) {
			for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
			return str.substring(0,j+1);
		}
		function trim(str) {
			return ltrim(rtrim(str));
		}
		function isAlphaNumeric(val){
			if (val.match(/^[a-zA-Z0-9]+$/))
			{
			return true;
			}
			else
			{
			return false;
			} 
		}
		function isWhitespace(charToCheck) {
			var whitespaceChars = " \t\n\r\f";
			return (whitespaceChars.indexOf(charToCheck) != -1);
		}
		//End Trim Functions
		//Email Validation
		function __fncCheckEMail(email, strMessage){
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (filter.test(email)){
				testres = true
				return(testres)
			}else{
				//alert(strMessage);
				testres=false
				return(testres)
			}
		}
		// Accept numbers only
		function numbersonly(myfield, e, dec){ 
				var key;
				var keychar;
				
				if (window.event)
					 key = window.event.keyCode;
				else if (e)
					 key = e.which;
				else
					 return true;
				keychar = String.fromCharCode(key);
				/*
				if(val && keychar == '.'){
					if(val.split(".").length > 1){
						return false;
					}
				}
				*/
				// control keys
				if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
					 return true;
				
				// numbers
				else if ((("0123456789").indexOf(keychar) > -1))
					 return true;
				
				// decimal point jump
				else if ((dec) && (keychar == "."))
					 {
					 myfield.form.elements[dec].focus();
					 return false;
					 }
				else
					 return false;
		}
			
		function __fncFillCategory(cboCountry, cboState, sDefaultCountry){
			var sDefaultCountry, sDefault, sCountry, sId
			var selectOption = -1;
			cboCountry.options.length=0
			for (i=0;i<sCountryString.split("|").length;i++){
				sCountry = sCountryString.split("|")[i];
				sId = sCountryString_id.split("|")[i];
				if (sDefaultCountry == sCountry){
					sDefault = true;
					if (navigator.appName == "Microsoft Internet Explorer")	{
						cboState.focus();
					}
				}	else{
					sDefault = false;
				}
				if (sDefault)	{
					var oo = new Option(sCountry,sId,sDefault,sDefault);
					oo.setAttribute("selected", "true");
					cboCountry.options[i] = oo;
					selectOption = i;
				}	else {
					cboCountry.options[i] = new Option(sCountryString.split("|")[i], sId);
				}
			}
			if (selectOption > -1){
				cboCountry.selectedIndex = selectOption;
			}
		}
		
		function __fncFillSubCategory(cboCountry, cboState, sDefaultState){
			var sDefaultState, sState, sDefault, sId
			var selectOption = -1;
			cboState.options.length=0
			for (i=0;i<sStateArray[cboCountry.selectedIndex].split("|").length;i++)	{
				sState = sStateArray[cboCountry.selectedIndex].split("|")[i];
				sId = sStateArray_id[cboCountry.selectedIndex].split("|")[i];
				if (sDefaultState == sId)	{
					sDefault=true;
					selectOption = i;
					if (navigator.appName=="Microsoft Internet Explorer"){cboState.focus();}
				}	else {
					sDefault=false;
				}
				if (sDefault){
					var oo = new Option(sState,sId,sDefault,sDefault);
					oo.setAttribute("selected", "true");
					cboState.options[i] = oo;	
				} else {
					cboState.options[i]=new Option(sState,sId);
				}
			}
			if (selectOption > -1){
				cboState.selectedIndex = selectOption;
			}
		}
		
		//Display Message
		function __fncDisplayMessage(id){
				document.getElementById(id).style.display = 'block';
		}
		function __fncHideMessage(id){
				document.getElementById(id).style.display = 'none';
		}
		/**
	* Insert text at position
	*/
	function fncInsert_text(text, spaces, popup){
		var textarea;
		
		if (!popup){
			textarea = document.getElementById('txtDescription');
		}
		/*else
		{
			textarea = opener.document.forms[form_name].elements[text_name];
		}
		*/
		if (spaces){
			text = ' ' + text + ' ';
		}
	
	if (!isNaN(textarea.selectionStart)){
			var sel_start = textarea.selectionStart;
			var sel_end = textarea.selectionEnd;
	
			mozWrap(textarea, text, '')
			textarea.selectionStart = sel_start + text.length;
			textarea.selectionEnd = sel_end + text.length;
		}	else if (textarea.createTextRange && textarea.caretPos){
			if (baseHeight != textarea.caretPos.boundingHeight) {
				textarea.focus();
				storeCaret(textarea);
			}
			var caret_pos = textarea.caretPos;
			caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
		}	else {
			textarea.value = textarea.value + text;
		}
	
		if (!popup) {
			textarea.focus();
		}
	
	}
	function mozWrap(txtarea, open, close){
		var selLength = txtarea.textLength;
		var selStart = txtarea.selectionStart;
		var selEnd = txtarea.selectionEnd;
		var scrollTop = txtarea.scrollTop;
	
		if (selEnd == 1 || selEnd == 2) {
			selEnd = selLength;
		}
	
		var s1 = (txtarea.value).substring(0,selStart);
		var s2 = (txtarea.value).substring(selStart, selEnd)
		var s3 = (txtarea.value).substring(selEnd, selLength);
	
		txtarea.value = s1 + open + s2 + close + s3;
		txtarea.selectionStart = selEnd + open.length + close.length;
		txtarea.selectionEnd = txtarea.selectionStart;
		txtarea.focus();
		txtarea.scrollTop = scrollTop;
		return;
	}
	/*********************/
	function fncGetCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}
	//Password Length
	var pass_strength_phrases = {
    0: 'Very Weak',
    10: 'Very Weak',
    20: 'Weak',
    30: 'Weak',
    40: 'Weak',
    50: 'OK',
    60: 'OK',
    70: 'Strong',
    80: 'Strong',
    90: 'Very Strong',
    100: 'Very Strong'
	};
function getPasswordStrength(pw){
	var pwlength=(pw.length);
	if(pwlength>5)pwlength=5;
		var numnumeric=pw.replace(/[0-9]/g,"");
		var numeric=(pw.length-numnumeric.length);
		if(numeric>3)numeric=3;
		var symbols=pw.replace(/\W/g,"");
		var numsymbols=(pw.length-symbols.length);
		if(numsymbols>3)numsymbols=3;
		var numupper=pw.replace(/[A-Z]/g,"");
		var upper=(pw.length-numupper.length);
		if(upper>3)upper=3;
		var pwstrength=((pwlength*10)-20)+(numeric*10)+(numsymbols*15)+(upper*10);
		if(pwstrength<0){
			pwstrength=0}if(pwstrength>100){pwstrength=100
		}
		return pwstrength
	}
	function updatePasswordStrength_new(pwbox,pwdiv,divorderlist){
			var bpb=""+pwbox.value;
			var pwstrength=getPasswordStrength(bpb);
			var bars=(parseInt(pwstrength/10)*10);
			
			var pwdivEl=document.getElementById(pwdiv);
			if(!pwdivEl){
				alert('Password Strength Display Element Missing')
			}
			var divlist=pwdivEl.getElementsByTagName('div');
			var maindiv=divlist[0].getElementsByTagName('div');
			maindiv[0].className='pass_bar_base pass_bar_'+bars;
			var txtdivnum=1;
			if(divorderlist&&divorderlist.text>-1){
				txtdivnum=divorderlist.text;
			}
			var txtdiv=divlist[txtdivnum];
			if(txtdiv && self.pass_strength_phrases){
				txtdiv.innerHTML=pass_strength_phrases[bars];
			}
		}
		function updatePasswordStrength(pwbox,pwdiv,divorderlist){
			var bpb=""+pwbox.value;
			var pwstrength=getPasswordStrength(bpb);
			var bars=(parseInt(pwstrength/10)*10);
			var pwdivEl=document.getElementById(pwdiv);
			if(!pwdivEl){
				alert('Password Strength Display Element Missing')
			}
			var divlist=pwdivEl.getElementsByTagName('div');
			var imgdivnum=0;
			var txtdivnum=1;
			if(divorderlist&&divorderlist.text>-1){
				txtdivnum=divorderlist.text
			}
			if(divorderlist&&divorderlist.image>-1){
				imgdivnum=divorderlist.image
			}
			var imgdiv=divlist[imgdivnum];
			imgdiv.id='ui-passbar-'+bars;
			var txtdiv=divlist[txtdivnum];
			if(txtdiv&&self.pass_strength_phrases){
				txtdiv.innerHTML=pass_strength_phrases[bars]
			}
		}
		
	//End Password Streangth
	//Add to Wtach List
	function __fncAddToWatchList(id, type, repondid){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		var poststr = "id=" + encodeURI( id )+
		"&type=" + encodeURI( type );
		makePOSTRequest_01('posts.php?action=savewatchlist', poststr, repondid);
	}
	
	//Show User Profile area
	function __fncMyprofileDetails(repondid){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		var poststr = '';
		makePOSTRequest_01('posts.php?action=showprofile', poststr, repondid);
	}
	
	//Show Edit User Profile
	function __fncEditprofilDetails(repondid){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		var poststr = '';
		makePOSTRequest_01('posts.php?action=editprofile', poststr, repondid);
	}
	
	//Show User's Change Password Area
	function __fncChangeUserPassword(repondid){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		var poststr = '';
		makePOSTRequest_01('posts.php?action=changeuserpassword', poststr, repondid);
	}
	
	//Show User Photo Edit Area
	function __fncEditPhoto(repondid){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		var poststr = '';
		makePOSTRequest_01('posts.php?action=edituserphoto', poststr, repondid);
	}
	//Show User Photo Edit Area
	function __fncShowUserClubHoldings(repondid){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		var poststr = '';
		makePOSTRequest_01('posts.php?action=showuserclubholdings', poststr, repondid);
	}
	// Add CV details to Table
	function __fncUpdateCV(repondid){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		var poststr = '';
		makePOSTRequest_01('posts.php?action=showcvdetails', poststr, repondid);
	}
	// Calculator Functions
	function __fncCalcuatePresent(){
		var poststr = "txtFutureValue=" + encodeURI( document.getElementById('txtFutureValue').value )+
		"&txtPeriod=" + encodeURI( document.getElementById('txtPeriod').value )+
		"&txtPeriodPerYear=" + encodeURI ( document.getElementById('txtPeriodPerYear').value )+
		"&txtAnnualRate=" + encodeURI( document.getElementById('txtAnnualRate').value )+
		"&txtWhat2Do=" + encodeURI( 'PRESENTVALUE' );
		__fncCalculatorPresentVal('divContent', poststr);
	}
	function __fncCalcuateFuture(){
		var poststr = "txtFutureValue=" + encodeURI( document.getElementById('txtFutureValue').value )+
		"&txtPeriod=" + encodeURI( document.getElementById('txtPeriod').value )+
		"&txtPeriodPerYear=" + encodeURI ( document.getElementById('txtPeriodPerYear').value )+
		"&txtAnnualRate=" + encodeURI( document.getElementById('txtAnnualRate').value )+
		"&txtWhat2Do=" + encodeURI( 'FUTUREVALUE' );
		__fncCalculatorFutureVal('divContent', poststr);
	}
	function __fncCalcuateInterest(){
		var poststr = "txtFutureValue=" + encodeURI( document.getElementById('txtFutureValue').value )+
		"&txtPeriod=" + encodeURI( document.getElementById('txtPeriod').value )+
		"&txtPeriodPerYear=" + encodeURI ( document.getElementById('txtPeriodPerYear').value )+
		"&txtPresentValue=" + encodeURI( document.getElementById('txtPresentValue').value )+
		"&txtWhat2Do=" + encodeURI( 'INTERESTVALUE' );
		__fncCalculatorInterestVal('divContent', poststr);
	}
	function __fncCalcuateBondPrieceInterest(){
		theFStr = '1000';
		if (!isPositiveNumber(theFStr)) {
			return false;
		}
		theCRStr = document.getElementById('txtAnnualCouponRate').value;
		if (!isPositiveNumber(theCRStr)) {
			return false;
		}
		theRStr = document.getElementById('txtYieldToMaturity').value;
		if (!isPositiveNumber(theRStr)) {
			return false;
		}
		theMStr = document.getElementById('txtMaturityYears').value ;
		if (!isPositiveNumber(theMStr)) {
			return false;
		}
		theF = parseFloat(theFStr);
		theCR = parseFloat(theCRStr);
		theR = parseFloat(theRStr);
		theM = parseInt(theMStr);
		var theB = (theCR*theF/200)*((1-Math.pow(1 + theR/200,-2*theM))/(theR/200))+theF/Math.pow(1+theR/200,2*theM);
		
		//form.MInput.value = "" + Math.round(theM);
		var val = "" + Math.round(theB*100)/100;
		
		var poststr = "txtAnnualCouponRate=" + encodeURI( document.getElementById('txtAnnualCouponRate').value )+
		"&txtMaturityYears=" + encodeURI( document.getElementById('txtMaturityYears').value )+
		"&txtYieldToMaturity=" + encodeURI ( document.getElementById('txtYieldToMaturity').value )+
		"&val=" + encodeURI ( val )+
		"&txtWhat2Do=" + encodeURI( 'BONDVALUE' );
		__fncCalculatorBondPrice('divContent', poststr);
	}
	
	function __fncCalcuateZScore(){
		var poststr = "TA=" + encodeURI( document.getElementById('TA').value )+
		"&WC=" + encodeURI( document.getElementById('WC').value )+
		"&RE=" + encodeURI ( document.getElementById('RE').value )+
		"&EBIT=" + encodeURI ( document.getElementById('EBIT').value )+
		"&MVE=" + encodeURI ( document.getElementById('MVE').value )+
		"&TL=" + encodeURI ( document.getElementById('TL').value )+
		"&S=" + encodeURI ( document.getElementById('S').value )+
		"&txtWhat2Do=" + encodeURI( 'Z_SCORECALC' );
		__fncZScore('divContent', poststr);
	}
	//						
	function __fncCalculatorPresentVal(repondid, poststr){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		//var poststr = '';
		makePOSTRequest_01('calculatorfunctions.php?action=showpresentvalue', poststr, repondid);
	}
	function __fncCalculatorFutureVal(repondid, poststr){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		makePOSTRequest_01('calculatorfunctions.php?action=showfutuevalue', poststr, repondid);
	}
	function __fncCalculatorInterestVal(repondid, poststr){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		makePOSTRequest_01('calculatorfunctions.php?action=interestvalue', poststr, repondid);
	}
	
	function __fncCalculatorBondPrice(repondid, poststr){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		makePOSTRequest_01('calculatorfunctions.php?action=bondvalue', poststr, repondid);
	}
	function __fncZScore(repondid, poststr){
		document.getElementById(repondid).innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		makePOSTRequest_01('calculatorfunctions.php?action=zscore', poststr, repondid);
	}
	// End calculator functions 
	/******Date Difference************/
	function compareDates(startDate,endDate){
		var point1=0;var point2=0;
		var arrDate1 = startDate.split("-");
		var useDate1 = new Date(arrDate1[2], arrDate1[1]-1, arrDate1[0]);
		var arrDate2 = endDate.split("-");
		var useDate2 = new Date(arrDate2[2], arrDate2[1]-1, arrDate2[0]);
		var day1=arrDate1[2];
		var month1=arrDate1[1]-1;
		var year1=arrDate1[0];
		var day2=arrDate2[2];
		var month2=arrDate2[1]-1;
		var year2=arrDate2[0];
		if(year1>year2) point1++; else if(year1<year2) point2++; else {point1++;point2++;}
		if(month1>month2 && point1>0) point1++; else if(month1<month2 && point2>0) point2++; else {point1++;point2++;}
		if(day1>day2 && point1>1) point1++; else if(day1<day2 && point2>1) point2++; else {point1++;point2++;}
		
		if(point1>point2) return 0;
		else if(point1<=point2 ) return 1;
	}
	
	function __fncivitePeople(code,club){
		if(club==1){
			if(document.getElementById('cboclub').value=='0'){
				alert('Please Select Club Name.');
				return;
			}
		}
		if(document.getElementById('emails').value==''){
			alert('Please Enter E-mail.');
			return;
		}
		document.getElementById('repondid').innerHTML = 'Please wait ...<img src="images/wait.gif">';  
		if(club==1){
			var poststr = "code=" + encodeURI(code)+
			"&mails=" + encodeURI(document.getElementById('emails').value)+
			"&cboclub=" + encodeURI(document.getElementById('cboclub').value);
		}else{
			var poststr = "code=" + encodeURI(code)+
			"&mails=" + encodeURI(document.getElementById('emails').value);
		}
		makePOSTRequest_01('posts.php?action=INVITE', poststr ,'repondid');
	}
	/* Bullet in Board Function*/
	function __fncAddtoBulletinBoard(strId, strType, divId){
		var poststr = "strId=" + encodeURI( strId )+
		"&strType=" + encodeURI( strType );
		makePOSTRequest_01('./../posts.php?action=addToBulletinBoard', poststr, divId);
	}
	
	
	 function isPositiveNumber(inputStr) {
		for (var i = 0; i < inputStr.length; i++) {
			var oneChar = inputStr.substring(i,i+1);
			if (((oneChar >= "0") && (oneChar <= "9")) || (oneChar == ".")) {
			
			} else {
				alert("Please make sure that only numbers are input.");
				return false;
			} 
		}
		return true;
	 }
	 
	 function isNegativeNumber(inputStr) {
		if (inputStr.length < 2) {
			alert("Please input a negative number.");
			return false;
		}
		var oneChar = inputStr.substring(0,1);
		if (oneChar != '-') {
			alert("Please make sure that only negative numbers are input.");
			return false;
		}
		for (var i = 1; i < inputStr.length; i++) {
			oneChar = inputStr.substring(i,i+1);
			if (((oneChar >= "0") && (oneChar <= "9")) || (oneChar == ".")) {
			
			} else {
				alert("Please make sure that only numbers are input.");
				return false;
			} 
		}
		return true;
	 }