	// 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 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{0,3})[\)]?[\s]?[\-]?(\d{3})[\s]?[\-]?(\d{4})[\s]?[x]?(\d*)$/; return (re.test(val)); }
	//function isCurrency(val) { 	var re = /^(\$?\d+\$?|\$?\d+\.\d+\$?)$/; return (re.test(val)); }
	
	
	/* function from cios */
	function phoneCheck(cnt_id)
    {  

     var phone    = trim(document.getElementById(cnt_id).value);

     var len      = phone.length;

     var str_accept ="0123456789+-() ";

     if (phone != "")
     {

                if (phone <= 0)

                {

                        alert ("Please fill the proper phone number."); 
						
                        return false;      

                }      

                        else if (len < 6)

                {      

                        alert ("Please fill minimum 6 digits for phone number."); 
						
                        return false;

                        }

                        else if (phone.charAt(0) == "-" || phone.charAt(0) == "(" || phone.charAt(0) == ")" )  

                        { 

                                    alert ( "Please fill proper phone number.");  

                                    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 phone number.");

                                   return false; 

                        }

                      

                                }  

                                    }     

                        return true;// final return for the phone validate 

             } 

 }


	
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 #000000";
				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 #000000";
			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 in valid email addresses.");
				field.style.border="1px solid #FF0000";
				field.focus();
				return false;
				break;
			}
		}

		for (i=0;i<digits_len;i++)
		{
			//alert(digits[i]);
			var field = document.getElementById(digits[i]);
			if(field)
			{
				field.style.border="1px solid #000000";
			if (field.value !="")
			{
					if(isNaN(field.value)==true)
						{ 
						    title = field.title;
							alert(title);
							//alert("Please fill in valid numeric value for" + title);
							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 #000000";
			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);
}	
	


// check the url for validation 
function checkUrl(field)
{
	//-- 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("Please fill in valid URL.");
			field.style.border="1px solid #FF0000";
			field.focus();
			return false;
		}
		
	return true;
}	

//Function to check valid numeric value
function is_numeric(num)
	{
		var exp = new RegExp("^[0-9-.]*$","g");
		return exp.test(num);
	}
