	// JavaScript Document
	/*
	# eLuminous Technologies - Copyright (C)  http://eluminoustechnologies.com 
	# This code is written by eLuminous Technologies, Its a sole property of 
	# eLuminous Technologies and cant be used / modified without license.  
	# Any changes/ alterations, illegal uses, unlawful distribution, copying is strictly
	# prohibhited 
	# Name: form_validator.js
	# Usage: included the file to validate the contents of the form. ( WRITE USAGE DETAILS ) 
	# Created : Rupal Pinge & Sham Shriwastav (30-05-2007)
	# Update  : 30-05-2007 Sham Shriwastav 
	# Status  : open
	# Purpose : make javascript code seprate from other coding
	*/
	
	function checkPhone(cnt_id)
	{  
   //var phone =trim(document.getElementById(cnt_id).value);
   	var phone=trim(cnt_id.value);
    var len  =phone.length;
   
    var str_accept ="0123456789+-(),";
    if (phone != "")
    {
     	if(phone <= 0)
     	{
      		alert("Please enter valid phone number / land line number."); 
			cnt_id.focus();
			cnt_id.style.border="1px solid #FF0000";
		    return false; 
     	} 
  		else if (len < 6)
     	{ 
      		alert ("Please enter minimum 6 digits for phone number / land line number."); 
			cnt_id.focus();
			cnt_id.style.border="1px solid #FF0000";
      		return false;
  		}
  		else if (phone.charAt(0) == "-" || phone.charAt(0) == "(" || phone.charAt(0) == ")"  || phone.charAt(0) == ",")  
  		{ 
    		alert ( "Please enter the proper phone number / land line number.");  
			cnt_id.focus();
			cnt_id.style.border="1px solid #FF0000";
			   return false; 
   		}
  		else
     	{
      		for(j=0;j<len;j++)
      		{
         		current_char = phone.charAt(j);
         		if(str_accept.indexOf(current_char) == -1)
              	{  
               		alert( "Please enter the proper phone number / land line number.");  
					cnt_id.focus();
					cnt_id.style.border="1px solid #FF0000";
               		return false; 
              	}
          	}  
   		}     
   		return true;// final return for the phone validate 
   	} 
 }
 
 	function checkMobile(cnt_id)
	{  
   //var phone =trim(document.getElementById(cnt_id).value);
   	var phone=trim(cnt_id.value);
    var len  =phone.length;
   
    var str_accept ="0123456789+-(),";
    if (phone != "")
    {
     	if(phone <= 0)
     	{
      		alert("Please enter valid mobile number."); 
			cnt_id.focus();
			cnt_id.style.border="1px solid #FF0000";
		    return false; 
     	} 
  		else if (len < 10)
     	{ 
      		alert ("Please enter minimum 10 digits for mobile number."); 
			cnt_id.focus();
			cnt_id.style.border="1px solid #FF0000";
      		return false;
  		}
  		else if (phone.charAt(0) == "-" || phone.charAt(0) == "(" || phone.charAt(0) == ")" || phone.charAt(0) == ",")  
  		{ 
    		alert ( "Please enter the proper mobile number.");  
			cnt_id.focus();
			cnt_id.style.border="1px solid #FF0000";
			   return false; 
   		}
  		else
     	{
      		for(j=0;j<len;j++)
      		{
         		current_char = phone.charAt(j);
         		if(str_accept.indexOf(current_char) == -1)
              	{  
               		alert( "Please enter the proper mobile number.");  
					cnt_id.focus();
					cnt_id.style.border="1px solid #FF0000";
               		return false; 
              	}
          	}  
   		}     
   		return true;// final return for the phone validate 
   	} 
 }
 
 
 
 
	function isFilled(str){ return (str != ""); }

	function isEmail(string) { return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1); }

 	//function isDigital(str)	{ return(parseInt(str,10)==(str*1)); /*return(parseFloat(str,10)==(str*1));*/ }

 	function isPhone(val) { 	var re = /^(\$?\d+\$?|\$?\d+\.\d+\$?)$/; return (re.test(val)); }
	//function isCurrency(val) { 	var re = /^(\$?\d+\$?|\$?\d+\.\d+\$?)$/; return (re.test(val)); }
	
	function chkhtaccess(string)
	{
		for(var ivA = 0; ivA <string.length; ivA++)
		{
			var testval = string.charCodeAt(ivA);
			if( !( (testval >= 65 && testval <= 90)  || (testval >= 97 && testval <= 122 ) || testval == 45 || testval == 95  || (testval >= 48 && testval <= 57 ) ) )
			{
				return false;
			}
		 
		}
		return true;		
	}
	
	function isInteger (s)
	{
		  var i;
			
		  if (isEmpty(s))
		  if (isInteger.arguments.length == 1) return 0;
		  else return (isInteger.arguments[1] == true);
	
		  for (i = 0; i < s.length; i++)
		  {
			 var c = s.charAt(i);
	
			 if (!isDigit(c)) return false;
		  }
	
		  return true;
	}
	function isEmpty(s)
	{
		  return ((s == null) || (s.length == 0))
	}
	
	function isDigit (c)
	{
		return ((c >= "0") && (c <= "9"))
	}
	
	
	
	
	
	
function validate(req,email,digits,currs)
{
	var field, i;
	var req_len = parseInt(req.length);
	var email_len = parseInt(email.length);
	var digits_len = parseInt(digits.length);
	var currs_len = parseInt(currs.length);
	
	for (i=0;i<req_len;i++)
	{
			var field = document.getElementById(req[i]);
			if (field)
			{
				field.style.border="1px solid #CCCCCC";
				if ((field.type == 'checkbox')||(field.type == 'radio'))
				{
					var field = document.getElementsByName(req[i]);
					var chk = false;
					for(l=0;l<field.length;l++)
					{
						if (field[l].checked) chk = true;
					}
					if (!chk) 
					{
						//alert("Field '" + field[0].title + "' is required to be checked correctly before successful submission.");
						//alert ("Please select " + field[0].title+"." );
						alert (field[0].title);
						field[0].style.border="1px solid #FF0000";
						return false; 
						break;
					}
				}
				else
				{
					if (!isFilled(trim(field.value)))
						{
						//alert("Field '" + field.title + "' is required to be filled in before successful submission.");
						//alert ("Please fill " + field.title+"." );
						alert (field.title);
						field.value="";
						field.focus();
						field.style.border="1px solid #FF0000";
						return false;
						// break;
						}
				}
			}
			else
				alert(req[i] + " does not exist" );		
	}


		for (i=0;i<email_len;i++)
		{
			var field = document.getElementById(email[i]);
			field.style.border="1px solid #CCCCCC";
			if (!isEmail(trim(field.value)))
			 {
				//alert("Field '" + field.title + "' is required to be filled in with valid email addresses before successful submission.");
				alert("Please fill valid email addresses.");
				field.style.border="1px solid #FF0000";
				field.focus();
				return false;
				break;
			}
		}

		for (i=0;i<digits_len;i++)
		{

			var field = document.getElementById(digits[i]);
				field.style.border="1px solid #CCCCCC";
			if ( field.value !="")
			{
					if(isNaN(field.value)==true)
						{ 
							alert("Please fill valid numeric value.");
							field.style.border="1px solid #FF0000";
							field.focus();
							return false;
							break;
						} 
				
				/*if (!isDigital(trim(field.value))) 
				{
					//alert("Field " + field.title + " is required to be filled in only with digits (0-9) and decimal point before successful submission.");
					//alert("Please fill only digits(0-9) and decimal point in "+field.title + ".");
					alert("Please fill in valid numeric value.");
					field.style.border="1px solid #FF0000";
					field.focus();
					return false;
					break;
				}	*/
			}
		}

		for (i=0;i<currs_len;i++)	{

			var field = document.getElementById(currs[i]);
				field.style.border="1px solid #CCCCCC";
			if (!isCurrency(trim(field.value))) {

				//alert("Field " + field.title + " is required to be filled in only with digits (0-9) a decimal point, or a dollar sign before successful submission.");
				alert("Please fill only digits(0-9) and decimal point in "+field.title + ".");
				field.style.border="1px solid #FF0000";
				field.focus();
				return false;
				break;

			}}










		return true;
}
	
	
//-- trim functions
// Removes Leading whitespaces
  function LTrim( value )
			{
				var re = /\s*((\S+\s*)*)/;
				return value.replace(re, "$1");
				
			}

// Removes ending whitespaces
		function RTrim( value )
			{
				var re = /((\s*\S+)*)\s*/;
				return value.replace(re, "$1");
				
			}

// Removes leading and ending whitespaces
	function trim( value ) 
		{
			return LTrim(RTrim(value));
		}

// Script by hscripts.com 
function checkDomain(nname)
{
var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw');

var mai = nname;
var val = true;

var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,dot);
var ext = mai.substring(dot,mai.length);
//alert(ext);
if(dot>2 && dot<57)
{
	for(var i=0; i<arr.length; i++)
	{
	  if(ext == arr[i])
	  {
	 	val = true;
		break;
	  }	
	  else
	  {
	 	val = false;
	  }
	}
	if(val == false)
	{
	  	 alert("Your domain extension "+ext+" is not correct");
		 return false;
	}
	else
	{
		for(var j=0; j<dname.length; j++)
		{
		  var dh = dname.charAt(j);
		  var hh = dh.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
		  {
			 if((j==0 || j==dname.length-1) && hh == 45)	
		  	 {
		 	  	 alert("Domain name should not begin are end with '-'");
			      return false;
		 	 }
		  }
		else	{
		  	 alert("Your domain name should not have special characters");
			 return false;
		  }
		}
	}
}
else    
{
	 alert("Invalid Domain name");
	 return false;
}	

return true;
}
// Script by hscripts.com 		


// function to check valid ip address
// Original:  Jay Bienvenu 
// Web Site:  http://www.bienvenu.net 
	
function verifyIP (IPvalue) {
	errorString = "";
	theName = "IPaddress";
	
	var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
	var ipArray = IPvalue.match(ipPattern);
	
	if (IPvalue == "0.0.0.0")
	errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
	else if (IPvalue == "255.255.255.255")
	errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
	if (ipArray == null)
	errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
	else {
		for (i = 0; i < 5; i++) {
			thisSegment = ipArray[i];
			if (thisSegment > 255) {
				errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
				i = 5;
			}
			if ((i == 0) && (thisSegment > 255)) {
				errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
				i = 5;
			}
		}
	}
	extensionLength = 3;
	if (errorString != "")
	alert (errorString);
}	

//Function to check valid numeric value
function isDigital(str)		{ return(parseInt(str,10)==(str*1)); /*return(parseFloat(str,10)==(str*1));*/ }

function isFloat(str) {return(parseFloat(str,10)==(str*1));}

function isAlpha(string) 	
	{ 
		for(var ivA = 0; ivA <string.length; ivA++)
		{	
			var testval = string.charCodeAt(ivA);
			if( !( (testval >= 65 && testval <= 90)  || (testval >= 97 && testval <= 122 ) ) )
			{
				return false;
			}
		 }
		 return true;
	}
	
function show_err_border(cnt_id)			//function to change the border color to red
{
	document.getElementById(cnt_id).style.border="1px solid #FF0000";	
}

function validate_imgfile(str_id, error_msg)
{
	var filename =document.getElementById(str_id).value;
	dotindex=filename.lastIndexOf(".")+1;
	extension = filename.substring(dotindex);
	extension = extension.toLowerCase();
	if( extension == "gif" || extension == "jpeg" || extension == "jpg" || extension == "png")
	{ return true; }
	else
	{
		alert(error_msg);
		show_err_border(str_id);
		return false;
	}
}

function phoneCheck(cnt_id,allowed_didits,for_elem)
{  
	
  	var phone	=trim(cnt_id.value);
    var len		=phone.length;
   
    var str_accept ="0123456789+-() ";
    if (phone != "")
    {
	    if (phone <= 0)
	    {
	    	//alert ("Please fill the proper phone number."); 
	    	alert ("Please fill the proper "+for_elem+".");
	    	return false;	
	    }	
		else if (len < 6)
	    {	
	    	//alert ("Please fill minimum 6 digits for phone number."); 
	    	alert ("Please fill minimum "+allowed_didits+" digits for "+for_elem+".");
	    	return false;
		}
		else if (phone.charAt(0) == "-" || phone.charAt(0) == "(" || phone.charAt(0) == ")" )  
		{ 
		 	//alert ( "Please fill the proper phone number.");  
		 	alert ("Please fill the proper "+for_elem+".");
		 	return false; 
		 }
		else
	    {
		    for(j=0;j<len;j++)
		    {
		       current_char = phone.charAt(j);
		      
		       if(str_accept.indexOf(current_char) == -1)
	           	 {  
	           	 	alert ("Please fill the proper "+for_elem+".");
	           	 	//alert ( "Please fill the proper phone number.");  
	           	 	return false; 
	           	 }
	          
		        }  
			}     
	 	return true;// final return for the phone validate 
 	 } 
 }	
 
 // check the url for validation 
function checkUrl(field, error_msg)
{
	//-- field is object
  	/* This is the main function which was used in crocads... */
	theUrl=field.value;
	//if(theUrl.match(/^(http)\:\/\/\w+([\.\-]\w+)*\.\w{2,4}(\:\d+)*([\/\.\-\?\&\%\#]\w+)*\/?$/i)) 
	if(theUrl.match(/http:\/\/[A-Za-z0-9_\.\[\]\?-]{3,}\.[A-Za-z]{3}/))
		{
		   //alert("valid address.");
			return true;
		} 
	 else 
		{
			//alert("Wrong address.");
			alert(error_msg);
			field.style.border="1px solid #FF0000";
			field.focus();
			return false;
		}
		
	return true;
}

function validate_date_now(greater_date, obj_FDate, error_msg, chk_cond)
	{
		 //clear_error_border();
		  var month = new Array();
			  month['01'] = "January";
			  month['02'] = "February";
			  month['03'] = "March";
			  month['04'] = "April";
			  month['05'] = "May";
			  month['06'] = "June";
			  month['07'] = "July";
			  month['08'] = "August";
			  month['09'] = "September";
			  month['10'] = "October";
			  month['11'] = "November";
			  month['12'] = "December";
		 
		 
		 if(obj_FDate.value != "")
		 {
		 	var nowDate =greater_date; // current date
			
			// -- get from date time stamp.
			  arr_nowDate = nowDate.split("-");
			  //alert(arr_fd[0]);
			  var strMonthnowDate = month[arr_nowDate[0]];
			 // alert(strMonthfd);
			  var mynowDate = new Date(strMonthnowDate+' '+arr_nowDate[2]+', '+arr_nowDate[1]+' 00:00:00');
			  var timestampnowDate = mynowDate.getTime()/1000.0;
			  //alert(strMonthfd+' '+arr_fd[2]+', '+arr_fd[1]+' 00:00:00 ======== ' + timestampFD);
			  
			  
			  // -- get from date time stamp.
			  arr_fd = obj_FDate.value.split("-");
			  //alert(arr_fd[0]);
			  var strMonthfd = month[arr_fd[0]];
			 // alert(strMonthfd);
			  var myDate = new Date(strMonthfd+' '+arr_fd[2]+', '+arr_fd[1]+' 00:00:00');
			  var timestampFD = myDate.getTime()/1000.0;
			  
			  //alert(strMonthfd+' '+arr_fd[2]+', '+arr_fd[1]+' 00:00:00 ======== ' + timestampFD);
			  
			 if(chk_cond == 'isgreater')
			 {
				// compare the time stamp so that rewuested date is not greater than current date	
				 if( timestampnowDate < timestampFD)
				  {
					   alert(error_msg)
					   return false;
				  }
			 }
			 else if(chk_cond == 'isless')
			 {
				// compare the time stamp so that rewuested date is not greater than current date	
				 if( timestampnowDate > timestampFD)
				  {
					   alert(error_msg)
					   return false;
				  }
			 }
			  
			  
		 }
		 return true;
	}
	
function usernameCheck (cnt_id)
{ 
	var str_username = trim(document.getElementById(cnt_id).value);
	
	var len = document.getElementById(cnt_id).value.length;
	for(j=0;j<len;j++)
    {
       current_char = str_username.charAt(j);
      
       var testval = str_username.charCodeAt(j);
		if( !( (testval >= 65 && testval <= 90)  || (testval >= 97 && testval <= 122 ) || (testval >= 48 && testval <= 57) ) )
		{
			if (current_char != "-" && current_char != "_" )
			{	
				alert ("Please fill proper Username.");
				//alert ("Please fill proper username.");
				show_err_border(cnt_id)
				return false;
			}	
		}
    }  
	return true; 
}

function isAlphaDigit(string)
	{
		for(var ivA = 0; ivA <string.length; ivA++)
		{
			var testval = string.charCodeAt(ivA);
			if( !( (testval >= 65 && testval <= 90)  || (testval >= 97 && testval <= 122 )|| (testval >= 48 && testval <= 57 ) ) )
			{
				return false;
			}
		 
		}
		return true;		
	}

