// JavaScript Document

function dgClass(){
	this.highLightMenu=function(Obj, classN){
		$(Obj).className=classN;
	}	
	
	
			var ResponsWritePlace;
		var LoadedContent;
		var loaderDIVObjVar

		this.CreateAJAXRequest=function(url,rPlace,pars,lContent,loaderDIVObj){
		
		ResponsWritePlace=rPlace;
		LoadedContent=lContent;
		pars=pars+"&killCache="+new Date().getTime();
		ajaxURL=url;
		loaderDIVObjVar=""
		
		
		if(loaderDIVObj!=undefined){
			if($(loaderDIVObj)){
				Element.show(loaderDIVObj);
				loaderDIVObjVar=loaderDIVObj;
			}
		}
		else{
			if($('loadingDIV')){
				Element.show("loadingDIV")
			}
			
			///new style
			if($('loaderIndicator')){
				Element.show("loaderIndicator")
			}
		}
		

		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars, 
				onSuccess: CallSucess,
				onFailure:CallError,
				onComplete: showResponse
			}
		);
	}
	
	function CallSucess(){
		//alert('success')
	}
		
	function CallError(){
		alert('Your Request Failed \n --------  '+ajaxURL);
	}
	
	
		function showResponse(originalRequest){
		
		//this checking it is normal MASTER PAGES Request or lightbox submition? 
		//First one is normal MASTER PAGES AJAX Request
		///remove already available(prevoius loaded) element
		if(ResponsWritePlace!="noPrintRequired" || LoadedContent!="NoContent"){
	
			///remove already available(prevoius loaded) element
			if($(LoadedContent)){Element.remove($(LoadedContent));}
			
				//put returned XML in the Container
				info = "<div class='clearFloat' id="+LoadedContent+">" + originalRequest.responseText + "</div>";
				
				new Insertion.Before($(ResponsWritePlace), info);//this enable javascript in loaded page
				
				
				if(LoadedContent=="lbContent"){//problem for FireFox 
					$('lightbox').className = "done";
				}

				
				if(loaderDIVObjVar!=""){
					if($(loaderDIVObjVar)){
						Element.hide(loaderDIVObjVar)
						loaderDIVObjVar="";
					}
				}
				else{
					if($('loadingDIV')){
						Element.hide("loadingDIV")
					}
					
					///new style
					if($('loaderIndicator')){
						Element.hide("loaderIndicator")
					}
				}


		}//if end
		//Lightbox control after request over
		else{
				
				if(loaderDIVObjVar!=""){
					Element.hide(loaderDIVObjVar)
					loaderDIVObjVar="";
				}
				else{
					if($('loadingDIV')){
						Element.hide("loadingDIV")
					}
					
					///new style
					if($('loaderIndicator')){
						Element.hide("loaderIndicator")
					}
				}
			


				
				//$('responseText').value=originalRequest.responseText;
				//alert(originalRequest.responseText);
				//return false;
				//for avoiding responsetext's string conversion pblm that I stored into hidden TEXT Box
				var cutResponse= new Array();

				if($('responseText')){//if obj available
					$('responseText').value=originalRequest.responseText;
					cutResponse=$('responseText').value.split('+++');
					$('responseText').value=cutResponse[0];
				}
				///---------------------After mail Sending--------------------------------------
				if(cutResponse[0]=="MailSent"){
					
					Effect.Appear(cutResponse[2]);
					$(cutResponse[3]).innerHTML='<img src="../assets/images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <strong> '+cutResponse[5]+'</strong>';
					Form.enable(cutResponse[1]);
					Form.reset(cutResponse[1]);
					
					if(cutResponse[6]=="STARTDOWNLOAD"){
						Element.hide(cutResponse[2]);
						$(cutResponse[3]).innerHTML='';
						//alert($("downLoadStaringStatus")) ///this is image Id embeded with Message
								//dgClassMain.CreateAJAXRequest("../inc/downloadfiles.php",'noPrintRequired','action=downloadFiles&fileCodes='+cutResponse[5],'NoContent',"downLoadStaringStatus");
						location.href="../training/after-sent.php?action=downloadFiles&fileCodes="+cutResponse[7]+"&returnURL="+cutResponse[9]+"&m="+cutResponse[5];
						//alert(URL);
						//window.setTimeout(function (a,b) {Element.hide("downLoadStaringStatus");location.href="../inc/downloadfiles.php?action=downloadFiles&fileCodes="+cutResponse[7];},2000);
						
						
					}
					
					if(cutResponse[6]=="REDIRECT"){
						
						window.setTimeout(function (a,b) {location.href=cutResponse[7];},5000);
						
					}
					//alert(cutResponse[9])
					/*if(cutResponse[8]=="REDIRECT"){
							
						window.setTimeout(function (a,b) {location.href=cutResponse[9];},9000);
							
					}*/
					
				}
				else if(cutResponse[0]=="WrongSecurityCode"){
					Effect.Appear("messageBox");
					$('messageWriterTD').innerHTML='<span style="font-weight:bold;"> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> '+cutResponse[3]+' </span>'
					Form.enable(cutResponse[1]);
					$(cutResponse[2]).focus();
					$(cutResponse[2]).className='redBorder';
					
				}
			}//else end 
		} // show response function end
		
		
		
				this.validateForm=function(formObj,fields,URL,action,messageTable,submitType,loadIndicator){

			if($('messageBox')){
				$('messageBox').style.display="none";
			}

			cutFieldParams=fields.split(',');
			
			compareFieldBool=false;compareFieldFirstVal="";ErrorCount=0;
			
			//reseting
			for(i=0;i<cutFieldParams.length;i++){
				getValidType=cutFieldParams[i].split("##");
				eval("document."+formObj+"."+getValidType[0]).className="";
			}
			
			for(i=0;i<cutFieldParams.length;i++){
				getValidType=cutFieldParams[i].split("##");
				if(getValidType[1]=="text"){//blank as text
					if(Trim(eval("document."+formObj+"."+getValidType[0]+".value"))=="" || Trim(eval("document."+formObj+"."+getValidType[0]+".value"))=="First Name" || Trim(eval("document."+formObj+"."+getValidType[0]+".value"))=="Last Name" ){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
					}
					if(getValidType[0]=="uname" && eval("document."+formObj+"."+getValidType[0]+".value")!=""){
						var illegalChars = /\W/;
						if (eval("document."+formObj+"."+getValidType[0]+".value").length < 5) {
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							ErrorCount++;
						} else if (illegalChars.test(eval("document."+formObj+"."+getValidType[0]+".value")))  {
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							ErrorCount++;
						}
					}
				}
				else if(getValidType[1]=="compare"){//compare password
					if(eval("document."+formObj+"."+getValidType[0]+".value")==""){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
							$(getValidType[0]+'Label').innerHTML="Password required.";
							$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
					}
					else if(eval("document."+formObj+"."+getValidType[0]+".value").length<6){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
							$(getValidType[0]+'Label').innerHTML="Password should be Minimum 6 characters.";
							$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
						}
					else if(eval("document."+formObj+".password.value")!=eval("document."+formObj+".confirmPassword.value")){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
							$(getValidType[0]+'Label').innerHTML="Password mismatch";
							$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
					}
					else{
						if($(getValidType[0]+'Label')){
							$(getValidType[0]+'Label').innerHTML="";
							$(getValidType[0]+'Label').className="grayTextForLabel";
						}
					}
					
				}
				else if(getValidType[1]=="email"){//email validation
					
					if(eval("document."+formObj+"."+getValidType[0]+".value")==""){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Email ID required";
								$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
					}
					else if(!emailValidation(eval("document."+formObj+"."+getValidType[0]+".value"))){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Valid Email ID required";
								$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
					}
					else{
						if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
						}
					}
				}
				else if(getValidType[1]=="select"){//select box validation
					if(eval("document."+formObj+"."+getValidType[0]+".selectedIndex")==0){
						eval("document."+formObj+"."+getValidType[0]).className="redBorderSelect";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Select from dropdown";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}						
					}
				}
				else if(getValidType[1]=="num"){//numerical validation
					if(eval("document."+formObj+"."+getValidType[0]+".value")==""){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else if(isNaN(eval("document."+formObj+"."+getValidType[0]+".value"))){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should be numerical value";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}//else if
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}						
					}
				}//else if email blank
				else if(getValidType[1]=="notblankEmail"){//numerical validation
					if(eval("document."+formObj+"."+getValidType[0]+".value")!=""){
						if(!emailValidation(eval("document."+formObj+"."+getValidType[0]+".value"))){
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Please enter a valid email Address";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							
							ErrorCount++;
						}
						else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
						}
					}
				}//else if 
				else if(getValidType[1]=="File"){//FILE
				
					if(eval("document."+formObj+"."+getValidType[0]+".value")==""){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else{
						
						if(!checkExtension(eval("document."+formObj+"."+getValidType[0]))){
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Accept only '"+ $(getValidType[0]).accept +"' ";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							ErrorCount++;
						}
						else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
						}
						
					}
				}
				else if(getValidType[1]=="notblankFile"){//FILE extension validation if not mandatory
					if(eval("document."+formObj+"."+getValidType[0]+".value")!=""){
						if(!checkExtension(eval("document."+formObj+"."+getValidType[0]))){
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Accept only '"+ $(getValidType[0]).accept +"' ";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							ErrorCount++;

						}
						else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
						}
					}
					
				}
				else if(getValidType[1]=="date"){
					if (isDate(eval("document."+formObj+"."+getValidType[0]+".value"))==false){
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Enter a valid Date";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							ErrorCount++;
					}
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
					}
	
				}//end of date
				////*This validating List box Multiple Selection required*/
				else if(getValidType[1]=="list"){
						countSel=0;
						for(var j=0; j<eval("document."+formObj+"."+getValidType[0]+".length"); j++) {
							if(eval("document."+formObj+"."+getValidType[0])[j].selected == true){
								countSel++;
							}
						}
						if(countSel<1){
							eval("document."+formObj+"."+getValidType[0]).className="redBorderSelect";
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML="Select one or more item from list box";
									$(getValidType[0]+'Label').className="mandatoryStar";
								}
								ErrorCount++;
						}
						else if(countSel==1 && eval("document."+formObj+"."+getValidType[0])[0].value=="-1"){
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML=eval("document."+formObj+"."+getValidType[0])[0].text.replace(/--/gi, "");
									$(getValidType[0]+'Label').className="mandatoryStar";
								}
								ErrorCount++;
						}
						else{
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML="";
									$(getValidType[0]+'Label').className="grayTextForLabel";
								}						
						}
				}
				////*End of ListBox Validation*/
								////*End of checkBox Validation*/
				else if(getValidType[1]=="check"){
					countChked=0;
						for(var j=0; j<eval("document."+formObj+"."+getValidType[0]+".length"); j++) {
							if(eval("document."+formObj+"."+getValidType[0])[j].checked == true){
								countChked++;
							}
						}	
						if(countChked<1){
							
								//eval("document."+formObj+"."+getValidType[0]+"DIV").className="redBorderSelect";
								$(getValidType[0]+"DIV").className="redBorder";
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML="Check one or more items";
									$(getValidType[0]+'Label').className="mandatoryStar";
								}
								ErrorCount++;
						}
						else{
								$(getValidType[0]+"DIV").className="";
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML="";
									$(getValidType[0]+'Label').className="grayTextForLabel";
								}						
						}
				}
				
				else if(getValidType[1]=="captcha") {
					if(Trim(eval("document."+formObj+"."+getValidType[0]+".value"))=="" ){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Security code should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
					}
				
				}
				

				
				/****************************************************************************************/
				/*--- START WYSIWYG----*/
				/* XXXX Very Important for this VALIDATION " TinyMCE WYSIWYG " required. Otherwise error occure  */
				/***************************************************************************************/
				else if(getValidType[1]=="WISIWYG"){
					 
					 if (tinyMCE.getContent(getValidType[0]) == null || tinyMCE.getContent(getValidType[0]) == "") ///This function contain in tiny_mce.js
					 {
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							ErrorCount++;
					 }
					 else {
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
					 }
				}
				/**************/
				/* ** END WYSIWYG***  */
				/******************/
				

			}///for
			if(ErrorCount>0){
				if(messageTable=="loginMessage" ){
					
					Effect.Appear("loginMessage");
					$('loginMessageWriterTd').innerHTML='<span><img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"> Username / Password missing</span>'
				}
				else if(messageTable=="fPErrorMessage"){
					Effect.Appear("fPErrorMessage");
					$('fPErrorMessageWriter').innerHTML='<span><img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"> E-mail Id field missing</span>'
					}
					else if(messageTable=='messageBoxR'){
					$('messageWriterTDR').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> Error! Please fill all mandatory<span class="mandatoryStar" >*</span> </span>'
					Effect.Appear("messageBoxR");
				}
				
				else if($('messageBox')){
					Effect.Appear("messageBox");
					$('messageWriterTD').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> Error! Please fill all mandatory fields marked as <span class="mandatoryStar" >*<span> </span>'
				}
				
				
			}//if
			else{
				
				
				if(messageTable=="loginMessage" ){
					$('loginMessage').style.display="none";
				}
				else if(messageTable=="fPErrorMessage"){
					$('fPErrorMessage').style.display="none";
					}
				else if($('messageBox')){
					$('messageBox').style.display="none";
				}
				else if($('messageBoxR')){
					$('messageBoxR').style.display="none";
				}
				
				if(submitType=="MULTIPART"){
					Form.enable(formObj);
					$(formObj).action=URL+"?action="+action;
					$(formObj).submit();	
					Form.disable(formObj);
					if($('submitBtn')){
						$('submitBtn').disabled=true;	
					}
				}
				else{
					if (formObj=="registrationForm" || formObj=="newsletterForm" || formObj=="referFriendForm" || formObj=="feedbackForm" ||  formObj=="communityForm"|| formObj=="mailForm"){
						Form.disable(formObj);
					}
					
					ObjToClose="";
					dgClassMain.CreateAJAXRequest(URL,'noPrintRequired','action='+action+'&ObjIdToClose='+ObjToClose+'&'+Form.serialize(formObj),'NoContent',loadIndicator);
				}
			}//else
		}//Validate function
		
		function emailValidation(ObjValue){
				cutEmailAt=ObjValue.split("@");
				cutEmailDot=ObjValue.split(".");
				if(cutEmailAt.length<2 || cutEmailAt.length>2 ){
					return false;
				}
				else if(cutEmailDot.length<2){
					return false;
				}
				else{
					return true; 
				}
		}
		
 		 //extension checking Added on 20th Nov 2007
		function checkExtension(Obj){
				cutAcceptEXT=Obj.accept.split(",");
				dot=Obj.value.lastIndexOf("."); 
				fileNamelength=Obj.value.length
				var extension = Obj.value.substr(dot+1,fileNamelength); 
				checkRightExtension=false;
				for(j=0;j<cutAcceptEXT.length;j++){
					if (Trim(cutAcceptEXT[j])==extension){
						checkRightExtension=true;	
					}
				}
				return checkRightExtension;
		}
		
			//Date Validation
			var dtCh= "/"; ///dd/mm/yyyy
			var minYear=1994;
			
			var now = new Date( );
			yy = now.getFullYear();
			mm = now.getMonth()+1;     // integer, 0..11
			dd = now.getDate();
			
			var maxYear=yy;
			
			function isInteger(s){
				var i;
				for (i = 0; i < s.length; i++){   
					// Check that current character is number.
					var c = s.charAt(i);
					if (((c < "0") || (c > "9"))) return false;
				}
				// All characters are numbers.
				return true;
			}
			
			function stripCharsInBag(s, bag){
				var i;
				var returnString = "";
				// Search through string's characters one by one.
				// If character is not in bag, append to returnString.
				for (i = 0; i < s.length; i++){   
					var c = s.charAt(i);
					if (bag.indexOf(c) == -1) returnString += c;
				}
				return returnString;
			}
			
			function daysInFebruary (year){
				// February has 29 days in any year evenly divisible by four,
				// EXCEPT for centurial years which are not also divisible by 400.
				return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
			}
			function DaysArray(n) {
				for (var i = 1; i <= n; i++) {
					this[i] = 31
					if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
					if (i==2) {this[i] = 29}
			   } 
			   return this
			}
			
			function isDate(dtStr){
				var daysInMonth = DaysArray(12)
				var pos1=dtStr.indexOf(dtCh)
				var pos2=dtStr.indexOf(dtCh,pos1+1)
				var strMonth=dtStr.substring(pos1+1,pos2)
				var strDay=dtStr.substring(0,pos1)
				var strYear=dtStr.substring(pos2+1)
				strYr=strYear
				if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
				if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
				for (var i = 1; i <= 3; i++) {
					if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
				}
				month=parseInt(strMonth)
				day=parseInt(strDay)
				year=parseInt(strYr)
				
				
				
				if (pos1==-1 || pos2==-1){
					//alert("The date format should be : dd/mm/yyyy")
					return false
				}
				if (strMonth.length<1 || month<1 || month>12){
					//alert("Please enter a valid month")
					return false
				}
				if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
					//alert("Please enter a valid day")
					return false
				}
				if (strYear.length != 4 || year==0 || year<minYear || year>maxYear ){
					//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
					return false
				}
				
				if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
					//alert("Please enter a valid date")
					return false
				}
				
				if(year==yy){
					if (month>mm || day>dd){
						//alert("Please enter a valid date")
						return false
					}
				}
				
			return true
			}
			
			/*****Triming space of Given text*****/
			function Trim(s) 
			   {
				// Remove leading spaces and carriage returns
				while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
				 { s = s.substring(1,s.length); }
				 
				// Remove trailing spaces and carriage returns
			 while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
				 { s = s.substring(0,s.length-1); }
				 
				 
				return s;
			   }
			/**********/
			
			
							//textarea Character Counter
		this.textareaCounter=function(textAreaObj, count, limiterPrintObj) {
			var text = $(textAreaObj).value;
			var len = text.length;
			if(len > count){
					text = text.substring(0,count);
					$(textAreaObj).value =text;
					return false;
			}
			if($(limiterPrintObj)){
				$(limiterPrintObj).innerHTML=count-len;	
			}
			//document.myform.limit.value = count-len;		
		}
		//textArea Character counter end


}

dgClassMain= new dgClass();