var height = 320;
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}


function jsMainFuns(){
			
			  
		 this.browser = navigator.appName; 
		 this.imgLst  = "";
		 this.imgParam = "";
		 var lengthMsg = "";	  
		 this.Forms = new Array("loginFrm" , "contactForm" );
		 this.openDiv = "";
		 this.height = 320;
		 this.allDialogs = [];
		 this.seq = 0;
		 this.dialog  = "";
		 
		 this.chkFroms = function(){ 
					if( document.getElementById(this.Forms[0]) ){
								if( document.all )document.getElementById(this.Forms[0]).attachEvent("onsubmit" ,chkLoginForm );
								else document.getElementById(this.Forms[0]).addEventListener('submit' ,chkLoginForm, false); 
							}
					if( document.getElementById(this.Forms[1]) ){
								if( document.all )document.getElementById(this.Forms[1]).attachEvent("onsubmit" ,checkContactUsForm );
								else document.getElementById(this.Forms[1]).addEventListener('submit' ,checkContactUsForm, false); 
							}

			}
				
			this.checkTextField = function(textObj , length){ 
   			    lengthMsg = "";
				if(textObj.value == ""){textObj.focus();return false;}
				else if(textObj.value == " "){textObj.focus();return false;}
				else if(textObj.value.length < length){
						lengthMsg = "The desired data should be more than ("+length+") character(s)";
						textObj.focus();return false;
				 }
				return true;
				}	
				
	     this.errorInForm	 = function ( errMsg , action , e){
			 		try{e.preventDefault();}catch(ex){}
					if( lengthMsg == "" )alert(errMsg);
					else alert(lengthMsg);
					return false;
					}	
	
	   this.include = function(file){
		   		
				script =  document.createElement('script');
				script.src = file;
				script.type = 'text/javascript';
				document.getElementsByTagName("head").item(0).appendChild(script);
				}
				
				
		this.deleteRow = function ( e ){
					
				targetEl = (e.srcElement)?e.srcElement:e.target	
			 	index    =  targetEl.parentNode.parentNode.rowIndex;
				tbl      = targetEl.parentNode.parentNode.parentNode.parentNode  ; 
				tbl.deleteRow(index);	
				
					}	
		//---------------------------------
		
		this.chkAllBoxs = function ( frmName , chk , chkName ){
					FORM = document.getElementById(frmName);
					for( i = 0; i < FORM.elements.length ; i++)if(FORM.elements[i].name == chkName)FORM.elements[i].checked = chk; 
				}
	   this.refreshList = function ( ){
					if( document.getElementById("oneNewsFileUpdate") )refreshNewsOneFileCell();
					
				}
				
		this.Ajax = function(){
				 this.time = new Date();
				 try{ this.xmlHttp=new XMLHttpRequest();}
				 catch (e){  try{this.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
				 			 }catch (e){ try{this.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
							 			 }catch (e){
										 alert("Your browser does not support AJAX!");
												   return false;   
												}
										}
						  }
			} // ajax function 	
		
		this.showPageDetails= function (show){	
					display = ( show == true )?"block":"none";
					document.getElementById("pageDetail").style.display = display;
				}
		
		this.createWait =	  function(options) {
			  options = $.extend({title: "Image Details ",modal:true,fixed: false}, options || {});
			  this.dialog = new Boxy('<div style="width:520px; height:400px; padding-top:50px" align="center" id="innerDt" ><img src="imgs/lightbox-ico-loading.gif" /></div>', options);
			this.allDialogs.push(this.dialog);
			 return true; 
		  }
		 this.loadMemberTypeList = function(selObj){
			
			if(selObj.value == 2)document.getElementById("membersType[]").style.display = "block"; 
			else document.getElementById("membersType[]").style.display = "none"; 
			
			} 
		this.fadOut = function(imgObj , percent){
					per =  (percent / 100);
					if(document.all){imgObj.style.filter='Alpha(opacity="'+percent+'")';}
					else imgObj.style.opacity = per;
					}	
		  
		this.fadIn = function(imgObj, percent){
					per =  (percent / 100);
					if(document.all){imgObj.style.filter='Alpha(opacity="'+percent+'")';}
					else imgObj.style.opacity = per;
					}	
		
		this.checkemail = function (x)
			{
			if(x.value == ""){x.focus();return false;}
			if(x.value.indexOf("@") == -1){x.focus();return false;}
			if(x.value.indexOf(".") == -1){x.focus(); return false;}
			if(x.value.indexOf("@") == 0) {x.focus();return false;}
			if(x.value.indexOf(".") == 0){x.focus(); return false;}
			return true;
			}
		this.searchKey = function ( param ){
			window.location = "?"+param+document.getElementById("srchtxt").value;
			}

		this.submitSearch = function (e , param)
			{
				var code ;
				if(!e) var e = window.event;
				if(e.keyCode) code= e.keyCode;
				else if(e.which) code = e.which;
				var character =  String.fromCharCode(code);
				if(code==13){
					this.searchKey(param)	
						}
		   }
		  this.clearField = function() {
			  		fieldValue = document.getElementById("srchtxt").value.trim();
			  		if( fieldValue == "Search" )document.getElementById("srchtxt").value = "";
					}
		  
		  this.resetField = function() {
			  		fieldValue = document.getElementById("srchtxt").value.trim();
					if( fieldValue == "" )document.getElementById("srchtxt").value = " Search ";
					}
		
	}  
