function validateEmail(email){
	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	str = email;
	if(str.match(emailRegEx)){
		return true;
	}
	else{
		return false;
	}
}
function CharNumeric(value,least,last){
	var CharNumRegxp = /^[0-9a-zA-Zs]+$/;
	str = value;
	len=value.length;
	if(str.match(CharNumRegxp)){
		if(len>=least && len<=last)
			return true;
		else 
			return false;
	}
	else{
		return false;
	}
}
function Numeric(value,least,last){
	var NumRegxp = /^[0-9a]+$/;
	str = value;
	len=value.length;
	if(str.match(NumRegxp)){
		if(len>=least && len<=last)
			return true;
		else 
			return false;
	}
	else{
		return false;
	}
}
function explodeArray(item,delimiter) { 
	tempArray=new Array(1); 
	var Count=0; 
	var tempString=new String(item); 
	
	while (tempString.indexOf(delimiter)>0) { 
	tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter)); 
	tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
	Count=Count+1 
	} 
	
	tempArray[Count]=tempString; 
	return tempArray; 
} 
function in_array(needle,haystack) {
	var bool = false;
	for (var i=0; i<haystack.length; i++) {
	  if (haystack[i]==needle) {
	   bool=true;
	  }
	}
	return bool;
} 
function validate(frm_Source)	{
	check=0;
	for(i=0;i < eval(frm_Source).getElementsByTagName('INPUT').length; i++){
		obj = eval(frm_Source).getElementsByTagName('INPUT')[i];
		if(obj.type=='text' || obj.type=='password' || obj.type=='radio') {
			if(obj.getAttribute('required')==1  && check<1){
				///////////////////////////////////////////Check for Security
				if(obj.getAttribute('xType')=='secure')	{
					if(obj.value=='' || obj.value!=document.getElementById('fld_Secure_Code').value)	{
						alert(obj.getAttribute('msg'));
						obj.focus();
						check++;
						return false;
					}////
				}//////////End of if////////End of Security
				///////////////////////////////////////////////Check fot Not Security
				else if(obj.type=='radio' && !obj.checked)	{
					alert(obj.length);
				}
				else	{
					//////////////////////////////////////////Check Empty
					if(obj.value=='' )	{
						msg=obj.getAttribute('msg');
						alert(msg);
						obj.focus();
						check++;
						return false;	
					}////////////////////////////////
					////////////////////////////////////////Check Repeat
					else if(obj.getAttribute('xType')!='' )	{
						pieces=explodeArray(obj.getAttribute('xType'),'|');
						type=pieces[0];
						compare=pieces[1];
						nextcompare=pieces[2];
						if(type=='Repeat')	{
							if(obj.value!=document.getElementById(compare).value)	{
								alert('Repeat');
								obj.focus();
								check++;
								return false;
							}//if
						}//if
						else if(type=='CharNum')	{
							if(!CharNumeric(obj.value,compare,nextcompare))	{
								alert('Please Enter Only Numbers and Characters');
								obj.focus();
								check++;
								return false;
							}//if
						}//if
						else if(type=='Numeric')	{
							if(!Numeric(obj.value,compare,nextcompare))	{
								alert('Please Enter Only Numbers');
								obj.focus();
								check++;
								return false;
							}//if
						}//if
					}//else if
				}///////////////////////////////////////////////end else
			}/////////////////////end if required
			else if(obj.getAttribute('required')!=1  && obj.value!='' && check<1){
				if(obj.getAttribute('xType')!='')	{
					if(obj.getAttribute('xType')=='Email')	{
						if(!validateEmail(obj.value))	{
							msg=obj.getAttribute('msg');
							alert(msg);
							obj.focus();
							check++;
							return false;
						}///if
					}//if
				}///if
			}//////else if
		}//////////////////text and password
	}///////////////////////Input
	//for(i=0;i < eval(frm_Source).all.tags( 'SELECT' ).length; i++){
	for(i=0;i < eval(frm_Source).getElementsByTagName('SELECT').length; i++){
		//obj = eval(frm_Source).all.tags( 'SELECT' )[i];
		obj = eval(frm_Source).getElementsByTagName('SELECT')[i];
		//if(obj.required==1 &&  obj.value==0 && check<1){
		if(obj.getAttribute('required')==1 &&  obj.value==0 && check<1){
				//alert(obj.msg);
				alert(obj.getAttribute('msg'));
				obj.focus();
				check++;
				return false;
		}
	}
	//for(i=0;i < eval(frm_Source).all.tags( 'TEXTAREA' ).length; i++){
	for(i=0;i < eval(frm_Source).getElementsByTagName('TEXTAREA').length; i++){
		//obj = eval(frm_Source).all.tags( 'TEXTAREA' )[i];
		obj = eval(frm_Source).getElementsByTagName('TEXTAREA')[i];
		//if(obj.required==1 &&  obj.value=='' && check<1){
		if(obj.getAttribute('required')==1 &&  obj.value=='' && check<1){
				//alert(obj.msg);
				alert(obj.getAttribute('msg'));
				obj.focus();
				check++;
				return false;
		}
	}
	return true;
}
function exchangeImage(image)	{
	alert(image.id);
}	
function makevisible(cur,which)	{
 	if(which==0)	{	
		cur.filters.alpha.opacity=100;
	}
	else	{
		cur.filters.alpha.opacity=30;
	}
}
function ceateIfrmae(name,id,parent)	{
	     var iframe;
        if(!id)
        {
            id = '';
        }
        if(document.all) // for IE
        {
            iframe = document.createElement('<iframe id="'+id+'" name="'+name+'">');
        }
        else // for FF
        {
            iframe = document.createElement('iframe');
            iframe.id = id;
            iframe.name = name;
        }
        iframe.width = '100';
        iframe.height = '30';
        //iframe.style.display = 'none';
        iframe.scrolling = 'no';
        iframe.src = 'about:blank';
        document.frm_Create.appendChild(iframe);

        return iframe;
}