function Browser(){
			var ua = navigator.userAgent.toLowerCase(); 
			this.Gecko = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
			this.Safari = (ua.indexOf('safari') != - 1);
			this.IE = (ua.indexOf('msie') != -1 && !this.Opera && (ua.indexOf('webtv') == -1) ); 
			this.Firefox = ( (ua.indexOf('firebird/') != -1) || (ua.indexOf('firefox/') != -1) );
			this.IECompatible = ( (ua.indexOf('msie') != -1) && !this.IE);
			this.NSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.NS && !this.Mozilla);
			this.geckoVersion = ( (this.Gecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
			this.equivalentMozilla = ( (this.Gecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
			this.versionMinor = parseFloat(navigator.appVersion); 
			if (this.Gecko && !this.Mozilla) this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
			else if (this.Mozilla) this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
			else if (this.IE && this.versionMinor >= 4) this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
			else if (this.Safari) this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
			this.versionMajor = parseInt(this.versionMinor); 
			this.DOM1 = (document.getElementById);
			this.DOM2Event = (document.addEventListener && document.removeEventListener);
			this.mode = document.compatMode ? document.compatMode : 'BackCompat';
			this.Win = (ua.indexOf('win') != -1);
			this.Mac = (ua.indexOf('mac') != -1);
			this.NS6up = (this.NS && this.versionMajor >= 6);
			this.NS7up = (this.NS && this.versionMajor >= 7);
			this.IE4 = (this.IE && this.versionMajor == 4);
			this.IE5 = (this.IE && this.versionMajor == 5);
			this.IE55 = (this.IE && this.versionMinor == 5.5);
			this.IE5up = (this.IE && this.versionMajor >= 5);
			this.IE6x = (this.IE && this.versionMajor == 6);
			this.IE6up = (this.IE && this.versionMajor >= 6);
		}
		var is = new Browser();
	
		
		function attrType(){
			this.onlyLetterChk = "false";
			this.onlyNumberChk = "false";
			this.onlyEmailChk = "false";
			this.noPunctuationChk = "false";
			this.toLowerChr = "false";
			this.toUpperChr = "false";
			this.noEnterChrChk = "false";
			this.descriptionText = "";
			this.minLngth = 0;
			this.necessaryField = "false";
			this.maxLngth = 0;
			this.optArea = "false";
			this.sameArea = "";
			this.slctBox = "false";
			this.rdnChkControl = "false";
			this.noOnlyNumber = "false";
			this.groupId = "";	
			}
		
		
		var ATTR;
		function MagicFormCheck(MyName, formID, lang){
			this._name=MyName;
			
			this._lang="TR";
			if (lang){
				this._lang=lang;
			}
			
			if (formID) {
				this.formID=formID;
			}
			else{
				this.formID;	
			}
						
			this._myForm = document.forms[formID];	
			this._myObjAttr;	
			
			this.selectArr=[];
			this.customCheckArr = [];
			this.customAttributeArr = [];
			this.groupId = "";
			
		}
		
		
	MagicFormCheck.prototype.returnMessage=function (label,m,pA) {
			messageTxt=this.repl(MESSAGES[m],'{LABEL}',label);	
			if (pA) {
				pA+='';
				pArray=pA.split('|');
				for (k=0;k<=pArray.length-1;k++) {
					kk=k+1;
					messageTxt=this.repl(messageTxt,'{PARAMETER'+kk+'}', pArray[k]);
				}
			}
			alert(messageTxt);
		}
		
		MagicFormCheck.prototype.repl=function(mainString,str1,str2) {
			tmpA=mainString.split(str1);
			tmpStr='';
			for (j=0;j<=tmpA.length-1;j++) {
				if (j<tmpA.length-1) {
					tmpStr+=tmpA[j]+str2;
				}else{
					tmpStr+=tmpA[j];
				}
			}
			return tmpStr;
		}
		
		

		// textboxlara attributeler yaziliyo
		MagicFormCheck.prototype.activeElementAttributeRead = function(_name, _id){
			_myObj = this._myForm.elements[_name];

			
			if (_myObj.length > 0 && (_myObj[0].type == "radio" || _myObj[0].type == "checkbox")){
				_myObj = _myObj[0];						
			}
			
			this._myObjAttr = new attrType;
			if ( _myObj.getAttribute("MC_toUpperChr")){ this._myObjAttr.toUpperChr = _myObj.getAttribute("MC_toUpperChr")}			
			if ( _myObj.getAttribute("MC_toLowerChr")){ this._myObjAttr.toLowerChr = _myObj.getAttribute("MC_toLowerChr")}			
			if ( _myObj.getAttribute("MC_onlyLetterChk")){ this._myObjAttr.onlyLetterChk = _myObj.getAttribute("MC_onlyLetterChk")}			
			if ( _myObj.getAttribute("MC_onlyNumberChk")){ this._myObjAttr.onlyNumberChk = _myObj.getAttribute("MC_onlyNumberChk")}					
			if ( _myObj.getAttribute("MC_onlyEmailChk")){ this._myObjAttr.onlyEmailChk = _myObj.getAttribute("MC_onlyEmailChk")}			
			if ( _myObj.getAttribute("MC_noPunctuationChk")){ this._myObjAttr.noPunctuationChk = _myObj.getAttribute("MC_noPunctuationChk")}			
			if ( _myObj.getAttribute("MC_noEnterChrChk")){ this._myObjAttr.noEnterChrChk = _myObj.getAttribute("MC_noEnterChrChk")}
			if ( _myObj.getAttribute("MC_descriptionText")){ this._myObjAttr.descriptionText = _myObj.getAttribute("MC_descriptionText")}			
			if ( _myObj.getAttribute("MC_minLngth")){ this._myObjAttr.minLngth = parseInt(_myObj.getAttribute("MC_minLngth"))}
			if ( _myObj.getAttribute("MC_maxLngth")){ this._myObjAttr.maxLngth = parseInt(_myObj.getAttribute("MC_maxLngth"))}
			if ( _myObj.getAttribute("MC_necessaryField")){ this._myObjAttr.necessaryField = _myObj.getAttribute("MC_necessaryField")}
			if ( _myObj.getAttribute("MC_optArea")){ this._myObjAttr.optArea = _myObj.getAttribute("MC_optArea")}
			if ( _myObj.getAttribute("MC_sameArea")){ this._myObjAttr.sameArea = _myObj.getAttribute("MC_sameArea")}
			if ( _myObj.getAttribute("MC_slctBox")){ this._myObjAttr.slctBox = _myObj.getAttribute("MC_slctBox")}	
			if ( _myObj.getAttribute("MC_rdnChkControl")){ this._myObjAttr.rdnChkControl = _myObj.getAttribute("MC_rdnChkControl")}
			if ( _myObj.getAttribute("MC_noOnlyNumber")){ this._myObjAttr.noOnlyNumber = _myObj.getAttribute("MC_noOnlyNumber")}
			if ( _myObj.getAttribute("MC_groupId")){ this._myObjAttr.groupId = _myObj.getAttribute("MC_groupId")}
						
			
			_myObj.ATTR = this._myObjAttr
			
			_myObj.onkeypress=this.keyPressFunctions;		
		}
		
		
		MagicFormCheck.prototype.keyPressFunctions=function(e) {
			var keyCode = (is.IE) ? event.keyCode : e.which;
				
			// LETTER CONTROL START
			if (this.ATTR.onlyLetterChk == "true"){		
				if (keyCode > 47 && keyCode<58){return false;}
			}			
			// LETTER CONTROL END		
			
			// NUMBER CONTROL START
			if (this.ATTR.onlyNumberChk == "true"){		
				if ((keyCode<48 || keyCode>57)&&keyCode!=8&&keyCode!=0) {return false;}
			}			
			// NUMBER CONTROL END
						
			// MAIL CONTROL START
			if (this.ATTR.onlyEmailChk == "true"){	
				var mailInvalidChars=" !#/*{[()]},;^><\\?+:`|";	
				if (keyCode>127) {
					return false;
				}
				for (i=0;i<=mailInvalidChars.length-1;i++) {
					if (keyCode==mailInvalidChars.charCodeAt(i)) {
						return false;
					}
				}
			}			
			// MAIL CONTROL END
			
			// PUNCTIATION CONTROL START
			if (this.ATTR.noPunctuationChk == "true"){		
				var puncInvalidChars=" !#/*.-=&%*'@{[()]},;^><\\?+:`|";			
				if (keyCode>127) {
					return false;
				}
				for (i=0;i<=puncInvalidChars.length-1;i++) {
					if (keyCode==puncInvalidChars.charCodeAt(i)) {
						return false;
					}
				}

			}			
			// PUNCTIATION CONTROL END
						
			// NO ENTER CHRACTER CONTROL START
			if (this.ATTR.noEnterChrChk != "false"){		
				var customInvalidChars=this.ATTR.noEnterChrChk;			
				if (keyCode>127) {
					return false;
				}
				for (i=0;i<=customInvalidChars.length-1;i++) {
					if (keyCode==customInvalidChars.charCodeAt(i)) {
						return false;
					}
				}

			}			
			// NO ENTER CHRACTER  CONTROL END
									
			/*
			Upper ve Lower islemleri en asagida yapilmalidir.
			*/
			
			// UPPER CASE CONTROL START
			if (this.ATTR.toUpperChr=="true"){
				var keyMap = {
					'ý': 'I',
					'ð': 'Ð',
					'ü': 'Ü',
					'þ': 'Þ',
					'i': 'Ý',
					'ö': 'Ö',
					'ç': 'Ç'
				 };
				 
				if (keyCode > 32) {
					var mychar = String.fromCharCode(keyCode);
					var mappedChar = keyMap[mychar];
					
					if (mappedChar) {
						this.value += mappedChar;
					} else {
						this.value += mychar.toUpperCase();
					}
					
					return false;
				}
			}			
			// UPPER CASE CONTROL END
			
			// LOWER CASE CONTROL START
			if (this.ATTR.toLowerChr == "true"){			
				var keyMap = {
					'I': 'i',
					'Ð': 'ð',
					'Ü': 'ü',
					'Þ': 'þ',
					'Ý': 'i',
					'Ö': 'ö',
					'Ç': 'ç'
				 };
				 
				if (keyCode > 32) {
					var mychar = String.fromCharCode(keyCode);
					var mappedChar = keyMap[mychar];
					
					if (mappedChar) {
						this.value += mappedChar;
					} else {
						this.value += mychar.toLowerCase();
					}
					
					return false;
				}
			}			
			// LOWER CASE CONTROL END			
		}
				
		MagicFormCheck.prototype.checkFormFunctions=function(_name, _id) {
					
			_myObj = this._myForm.elements[_name];	
			
			if (_myObj.length > 0 && (_myObj[0].type == "radio" || _myObj[0].type == "checkbox")){
				_myChkRadioGroup = _myObj;
				_myObj = _myObj[0];	
									
			}
			
			if ((this.groupId != "") && this.groupId != _myObj.ATTR.groupId){
				return true;
			}
			
			_err=true;
			
			// optional en ustte olmali
			// OPTIONAL CHECK START
			if(_myObj.ATTR.optArea == "true"){
				if(_myObj.value.length==0){return true;}
			}		
			// OPTIONAL CHECK END
			
			// MAIL CHECK START
			if(_myObj.ATTR.onlyEmailChk == "true"){
				
				if ( !(this.funcMailCheck(_myObj.value)) ){
				
					this.returnMessage(_myObj.ATTR.descriptionText,5);
					_myObj.focus();
					_myObj.className += " ERR_FIELD";
					_err=false;
					return false;
				}
			}		
			// MAIL CHECK END
						
			// MINLENGTH CHECK START
			if(_myObj.ATTR.minLngth > 0){
				if ( !(this.funcMinLength(_myObj.value, _myObj.ATTR.minLngth)) ){
					this.returnMessage(_myObj.ATTR.descriptionText, 3, _myObj.ATTR.minLngth);
					_myObj.focus();
					_myObj.className += " ERR_FIELD";
					_err=false;
					return false;
				}
			}		
			// MINLENGTH CHECK END
						
			// MAXLENGTH CHECK START
			if(_myObj.ATTR.maxLngth > 0){
				if ( !(this.funcMaxLength(_myObj.value, _myObj.ATTR.maxLngth)) ){
					this.returnMessage(_myObj.ATTR.descriptionText, 2, _myObj.ATTR.maxLngth);
					_myObj.focus();
					_myObj.className += " ERR_FIELD";
					_err=false;
					return false;
				}
			}		
			// MAXLENGTH CHECK END
			

			// NECESSARY CHECK START
			if(_myObj.ATTR.necessaryField == "true"){
				if ( !(this.funcNecessary(_myObj.value)) ){
					this.returnMessage(_myObj.ATTR.descriptionText, 6);
					_myObj.focus();
					_myObj.className += " ERR_FIELD";
					_err=false;
					return false;
				}
			}		
			// NECESSARY CHECK END
			
			// SAME AREA CHECK START
			if(_myObj.ATTR.sameArea != ""){
				if ( !(this.funcSameArea(_myObj.value, _myObj.ATTR.sameArea)) ){
					this.returnMessage(_myObj.ATTR.descriptionText, 9);
					_myObj.focus();
					_myObj.className += " ERR_FIELD";
					_err=false;
					return false;
				}
			}		
			// SAME AREA CHECK END
			
			// SELECT CHECK START
			if(_myObj.ATTR.slctBox == "true"){

				if ( !(this.funcSelectBox(_myObj)) ){					
					this.returnMessage(_myObj.ATTR.descriptionText, 1);
					_myObj.focus();
					_myObj.className += " ERR_FIELD";
					_err=false;
					return false;
				}
			}		
			// SELECT CHECK END
			
			
			// RADIO CHECKBOX CHECK START
			if(_myObj.ATTR.rdnChkControl == "true"){
				if ( !(this.funcrdnChkControl(_myChkRadioGroup)) ){			
					this.returnMessage(_myObj.ATTR.descriptionText, 6);
					_err=false;
					return false;
				}
			}		
			// RADIO CHECKBOX CHECK END
			
			
			// NOONLYNUMBER CHECK START
			if(_myObj.ATTR.noOnlyNumber == "true"){
				if ( !(this.funcNoOnlyNumber(_myObj)) ){			
					this.returnMessage(_myObj.ATTR.descriptionText, 8);
					_err=false;
					return false;
				}
			}		
			// NOONLYNUMBER CHECK END
			
	

			return _err;			
		}
		
		
		
		MagicFormCheck.prototype.funcNoOnlyNumber=function(objInput) {		
			var _InvalidChars="1234567890";
	
			_myObj = objInput
			_myValue = _myObj.value;
		
			_noOnlyNumber = 0;
				
			if (_myValue.length>0){
				for (l=0;l<_myValue.length;l++){
							
					for (u=0;u<_InvalidChars.length;u++){	
						if (_myValue.substr(l,1) == _InvalidChars.substr(u,1)){
							_noOnlyNumber++;
						}		
					}	
					
				}
				
				if (_noOnlyNumber==_myValue.length) {
						return false;
				}
			}
			return true;			
		}
		
		MagicFormCheck.prototype.funcrdnChkControl=function(objInput) {		
			var temp=false;
			//alert(objInput.length)
			for (boxes=0;boxes<=objInput.length-1;boxes++) {
				if (objInput[boxes].checked==true) {
					temp=true;
					break;
				}
			}
			return temp;
		}
		
		MagicFormCheck.prototype.funcSelectBox=function(objInput) {		
			_mySelbox = objInput.options.selectedIndex;
			if (objInput.options[_mySelbox].value == ""){
				return false;
			}
			return true;			
			/*if(_mySelbox < 1){
				return false;
			}
			return true;
			*/
		}
				
		MagicFormCheck.prototype.funcSameArea=function(objInput,sameArea) {		
			_myObjTmp = this._myForm.elements[sameArea];
			_myObjV = _myObjTmp.value
			if(objInput != _myObjV){
				return false;
			}
			return true;
		}
		
		MagicFormCheck.prototype.funcMaxLength=function(objInput,charLength) {		
			if (objInput.length > charLength){
				return false;
			}
			return true;
		}
		
		MagicFormCheck.prototype.funcNecessary=function(objInput) {		
			if (objInput.length == 0){
				return false;
			}
			return true;
		}
		
		MagicFormCheck.prototype.funcMinLength=function(objInput,charLength) {			
			if (objInput.length < charLength){
				return false;
			}
			return true;
		}
		
		MagicFormCheck.prototype.funcMailCheck=function(objInput) {
			TmpStr=objInput;
			
				if (TmpStr==""){ return false;}
				else{
					var i, atPos, atPos2, InvalidChars=" üÜðÐýþÞÝçÇöÖ!#/*{[()]}";
			
					for (i=0; i<InvalidChars.length; i++)
						if (TmpStr.indexOf(InvalidChars.charAt(i)) != -1) {
							return false;
						}
					atPos = TmpStr.indexOf("@");
					atPos1 = TmpStr.indexOf(".");
					atPos2 = TmpStr.indexOf("@", atPos+1);
					
					if ((atPos < 1) || (atPos1 < 1) || (atPos2 != -1)) {
						return false;
					} else{
							atPos3=new Array;
							atPos3 = TmpStr.split("@");
							
							atPos4=new Array;
							atPos4 = atPos3[1].split(".");
			
							if(atPos4[1].length<2 || atPos4[0].length<1) {
								return false;
							}
			
						return true;
					}
					return true;
				}
				
	}
	
	
	MagicFormCheck.prototype.addCustomCheck = function(runFunctionName){
		this.customCheckArr.push(runFunctionName);
	}
	
	
	
	MagicFormCheck.prototype.changeAttribute = function(_name, attrName, attrValue){
		_myObj = this._myForm.elements[_name];
		if (_myObj.length > 0 && (_myObj[0].type == "radio" || _myObj[0].type == "checkbox")){
				_myObj = _myObj[0];				
		}
		
		_myObj.setAttribute(attrName, attrValue);
		
		this.activeElementAttributeRead(_name);		
	}
	
	MagicFormCheck.prototype.inActivate = function(_name){
		_myObj = this._myForm.elements[_name];
		
		_myObj.setAttribute("MC_toUpperChr", "false");
		_myObj.setAttribute("MC_toLowerChr", "false");
		_myObj.setAttribute("MC_onlyLetterChk", "false");
		_myObj.setAttribute("MC_onlyNumberChk", "false");
		_myObj.setAttribute("MC_onlyEmailChk", "false");
		_myObj.setAttribute("MC_noPunctuationChk", "false");
		_myObj.setAttribute("MC_noEnterChrChk", "false");
		_myObj.setAttribute("MC_descriptionText", "");
		_myObj.setAttribute("MC_minLngth", "0");
		_myObj.setAttribute("MC_maxLngth", "0");
		_myObj.setAttribute("MC_necessaryField", "false");
		_myObj.setAttribute("MC_optArea", "false");
		_myObj.setAttribute("MC_sameArea", "");
		_myObj.setAttribute("MC_slctBox", "false");
		_myObj.setAttribute("MC_rdnChkControl", "false");
		_myObj.setAttribute("MC_noOnlyNumber", "false");
		_myObj.setAttribute("MC_groupId", "");
		
		
		this.activeElementAttributeRead(_name);		
		
	}
	
	
		MagicFormCheck.prototype.initiate = function(){
			for (i=0;i<this._myForm.elements.length;i++){
				
				if ((this._myForm.elements[i].type != "submit") && (this._myForm.elements[i].type != "button")  && (this._myForm.elements[i].type != "")){
					if ((this._myForm.elements[i].type == "radio") || this._myForm.elements[i].type == "checkbox"){
						isThere=0;
						for (j=0;j<this.selectArr.length;j++){
							if (this.selectArr[j][0]==this._myForm.elements[i].name){ 
								isThere=1;
								break;
							}
						}
						
						if (isThere==0){
							var tmpAtr = [];
							tmpAtr[0]=this._myForm.elements[i].name;
							tmpAtr[1]=0;
							this.selectArr.push(tmpAtr);
							this.activeElementAttributeRead(this._myForm.elements[i].name,this._myForm.elements[i].id);
						}
					}
					else{
						this.activeElementAttributeRead(this._myForm.elements[i].name,this._myForm.elements[i].id);
					}
				}
			}
		}
				
		MagicFormCheck.prototype.checkForm = function(groupId){	
		_statu=false;		
		this.groupId = (groupId) ? groupId :  "";

		for (k=0;k<this.selectArr.length;k++){
			this.selectArr[k][1]=0;
		}
		
			for (i=0;i<this._myForm.elements.length;i++){
			
				if ((this._myForm.elements[i].type != "submit") && (this._myForm.elements[i].type != "button")  && (this._myForm.elements[i].type != "") ){
					if (this._myForm.elements[i].type == "radio" || this._myForm.elements[i].type == "checkbox"){
						for (j=0;j<this.selectArr.length;j++){
							if ((this.selectArr[j][0]==this._myForm.elements[i].name) && (this.selectArr[j][1]==0)){						
								this.selectArr[j][1]=1;
								_statu = (this.checkFormFunctions(this.selectArr[j][0],this.selectArr[j][0]))
								//break;
							}
						}
					}
					else{
					_statu = (this.checkFormFunctions(this._myForm.elements[i].name,this._myForm.elements[i].id))
					}
					if ( !_statu ){return _statu}
				}
			}
			
			for (i=0;i<this.customCheckArr.length;i++){
				_statu = eval(this.customCheckArr[i]);
			}
			return _statu;
		}