
// JScript File 

 function validate()
    {  
       //Name
       var checkName;
        checkName=document.getElementById("ucInfotechSendRightEnquiry_txtName").value;
         
       if((Trim(checkName).length) == 0)
       {
             alert("Please enter name");
	         document.getElementById("ucInfotechSendRightEnquiry_txtName").focus();
	         return false;       
       }
       else if(!CheckValid(document.getElementById('ucInfotechSendRightEnquiry_txtName').value,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&_. "))
       {
            alert("Please enter a valid name");
		    document.getElementById("ucInfotechSendRightEnquiry_txtName").focus();
	         return false;       
       }
         
        //Description               
        if(document.getElementById("ucInfotechSendRightEnquiry_txtDesignation").value=="")
        {
            alert("Please enter designation");
	        document.getElementById("ucInfotechSendRightEnquiry_txtDesignation").focus();
	        return false;
        }
	else if (document.getElementById("ucInfotechSendRightEnquiry_txtDesignation").value.length > 200)
        {		
            alert("Designation should not be more than 200 characters");
            document.getElementById("ucInfotechSendRightEnquiry_txtDesignation").focus();
            return false;
        } 

        
        //Company 
        if(document.getElementById("ucInfotechSendRightEnquiry_txtCompany").value=="")
        {
            alert("Please enter company");
	        document.getElementById("ucInfotechSendRightEnquiry_txtCompany").focus();
	        return false;
        }                
        else if (document.getElementById("ucInfotechSendRightEnquiry_txtCompany").value.length > 200)
        {		
            alert("Company name should not be more than 200 characters");
            document.getElementById("ucInfotechSendRightEnquiry_txtCompany").focus();
            return false;
        } 
        
        
        //Address 
        if(document.getElementById("ucInfotechSendRightEnquiry_txtAddress").value=="")
        {
            alert("Please enter address");
	        document.getElementById("ucInfotechSendRightEnquiry_txtAddress").focus();
	        return false;
        }                
        else if (document.getElementById("ucInfotechSendRightEnquiry_txtAddress").value.length > 400)
        {		
            alert("Address should not be more than 400 characters");
            document.getElementById("ucInfotechSendRightEnquiry_txtAddress").focus();
            return false;
        } 
            
        
        //City 
        if(document.getElementById("ucInfotechSendRightEnquiry_txtCity").value=="")
        {
            alert("Please enter city");
	        document.getElementById("ucInfotechSendRightEnquiry_txtCity").focus();
	        return false;
        }                
        else if (document.getElementById("ucInfotechSendRightEnquiry_txtCity").value.length > 100)
        {		
            alert("City should not be more than 100 characters");
            document.getElementById("ucInfotechSendRightEnquiry_txtCity").focus();
            return false;
        }  
        else if(!CheckValid(document.getElementById('ucInfotechSendRightEnquiry_txtCity').value,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. "))
       {
            alert("Please enter a valid city");
		    document.getElementById("ucInfotechSendRightEnquiry_txtCity").focus();
	         return false;       
       }
         //Pin
        if(document.getElementById("ucInfotechSendRightEnquiry_txtPin").value=="")
        {
            alert("Please enter pincode");
	        document.getElementById("ucInfotechSendRightEnquiry_txtPin").focus();
	        return false;
        }
        if (document.getElementById("ucInfotechSendRightEnquiry_txtPin").value.length > 20)
        {		
            alert("Pin should not be more than 20 characters");
            document.getElementById("ucInfotechSendRightEnquiry_txtPin").focus();
            return false;
        }  
        if(!CheckValid(document.getElementById('ucInfotechSendRightEnquiry_txtPin').value,"0123456789"))
        {
	        alert("Please enter valid pincode");
		    document.getElementById("ucInfotechSendRightEnquiry_txtPin").focus();
            return false;       
         }
         
         //Country
//         if(document.getElementById("ucInfotechSendRightEnquiry_txtCountry").value=="")
//        {
//            alert("Please Enter Country");
//	        document.getElementById("ucInfotechSendRightEnquiry_txtCountry").focus();
//	        return false;
//        }
//         if(!CheckValid(document.getElementById("ucInfotechSendRightEnquiry_txtCountry").value,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "))
//        {
//            alert('Enter valid Country.');
//            document.getElementById("ucInfotechSendRightEnquiry_txtCountry").focus();
//            return false;
//        } 

          if(document.getElementById("ucInfotechSendRightEnquiry_ddlcountry").value=="0")
            {
                alert("Please select country");
	            document.getElementById("ucInfotechSendRightEnquiry_ddlcountry").focus();
	            return false;
            }
        
          //Email
         if(document.getElementById("ucInfotechSendRightEnquiry_txtEmail").value=="")
        {
            alert("Please enter e-mail id");
	        document.getElementById("ucInfotechSendRightEnquiry_txtEmail").focus();
	        return false;
        }
         if(!IsValidEmail(document.getElementById("ucInfotechSendRightEnquiry_txtEmail").value))
        {
            alert('Enter valid e-mail id and try again.');
            document.getElementById("ucInfotechSendRightEnquiry_txtEmail").focus();
            return false;
        } 
        
        //Telophone 
        if(document.getElementById("ucInfotechSendRightEnquiry_txtTelephone").value=="")
        {
            alert("Please enter contact number");
	        document.getElementById("ucInfotechSendRightEnquiry_txtTelephone").focus();
	        return false;
        }
        if(!CheckValid(document.getElementById("ucInfotechSendRightEnquiry_txtTelephone").value,"+-0123456789"))
        {
            alert('Please enter valid contact number');
            document.getElementById("ucInfotechSendRightEnquiry_txtTelephone").focus();
            return false;
        }
        
        
        //Fax
        if(document.getElementById("ucInfotechSendRightEnquiry_txtFax").value!="")
        {
//            alert("Please Enter Fax No.");
//	        document.getElementById("ucInfotechSendRightEnquiry_txtFax").focus();
//	        return false;
       
        if(!CheckValid(document.getElementById("ucInfotechSendRightEnquiry_txtFax").value,"+-0123456789"))
        {
            alert('Please enter valid fax no.');
            document.getElementById("ucInfotechSendRightEnquiry_txtFax").focus();
            return false;
        }
        }
//        else if (document.getElementById("ucInfotechSendRightEnquiry_txtFax").value.length < 10)
//        {		
//            alert("Fax No. should not be less than 10 digits");
//            document.getElementById("ucInfotechSendRightEnquiry_txtFax").focus();
//            return false;
//        } 
        
       
        
        
        //Query
        if(document.getElementById("ucInfotechSendRightEnquiry_txtQuery").value=="")
        {
            alert("Please enter query");
	        document.getElementById("ucInfotechSendRightEnquiry_txtQuery").focus();
	        return false;
        }
        if (document.getElementById("ucInfotechSendRightEnquiry_txtQuery").value.length > 400)
        {		
            alert("Query should not be more than 400 characters");
            document.getElementById("ucInfotechSendRightEnquiry_txtQuery").focus();
            return false;
        }  
        if(CheckValid(document.getElementById('ucInfotechSendRightEnquiry_txtQuery').value," "))
        {
	        alert("Please enter valid query");
		    document.getElementById("ucInfotechSendRightEnquiry_txtQuery").focus();
            return false;       
         } 
        
       
       return true;     
     }
     
     
     
function IsValidEmail(stremail,empty)
    {
     if(stremail=='' && empty)
            return true;
     var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
     return filter.test(stremail);
    }
     
     
     
function CheckValid(chars,validchars)
    {   
        var blnresult=true;
        for(var i=0;i<chars.length&&blnresult==true;i++)
            {
                 var cchar=chars.charAt(i);
                 if(validchars.indexOf(cchar)==-1)
                    {
                        blnresult=false;
                    }
        
            }
         return blnresult;
     }
    
    function ClearAll()
    {    
        document.getElementById("ucInfotechSendRightEnquiry_lblMessage").value="";        
         document.getElementById("ucInfotechSendRightEnquiry_txtName").value="";          
         document.getElementById("ucInfotechSendRightEnquiry_txtDesignation").value="";
         document.getElementById("ucInfotechSendRightEnquiry_txtCompany").value=""; 
         document.getElementById("ucInfotechSendRightEnquiry_txtAddress").value="";
         document.getElementById("ucInfotechSendRightEnquiry_txtCity").value="";
         document.getElementById("ucInfotechSendRightEnquiry_txtPin").value="";
//       document.getElementById("ucInfotechSendRightEnquiry_txtCountry").value="";
         document.getElementById("ucInfotechSendRightEnquiry_ddlcountry").value="0";
         document.getElementById("ucInfotechSendRightEnquiry_txtEmail").value="";          
         document.getElementById("ucInfotechSendRightEnquiry_txtTelephone").value="";
         document.getElementById("ucInfotechSendRightEnquiry_txtFax").value="";          
         document.getElementById("ucInfotechSendRightEnquiry_txtQuery").value="";
         document.getElementById("ucInfotechSendRightEnquiry_txtName").focus(); 
          document.getElementById("ucInfotechSendRightEnquiry_lblMessage").innerHTML="";   
         return false;     
    }
    
function textkey1Counter(maxlimit) 
   {   
   if(document.getElementById("ucInfotechSendRightEnquiry_txtAddress").value.length > maxlimit)
   {
        alert('Address should not be more than 400 characters');
        return false;
   }
   if(document.getElementById("ucInfotechSendRightEnquiry_txtQuery").value.length > maxlimit)
   {
        alert('Query should not be more than 400 characters');
        return false;
   }
//    var field=document.getElementById("ucInfotechSendRightEnquiry_txtAddress");
//    if (field.value.length > maxlimit) 
//    field.value = field.value.substring(0, maxlimit); 
   }

function LTrim(str)
	{
		var whitespace = new String(" \t\n\r");
		var s = new String(str);

		if (whitespace.indexOf(s.charAt(0)) != -1) 
		{
			var j=0, i = s.length;
			while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
				j++;
			s = s.substring(j, i);
		}
		return s;
	}
	function RTrim(str)
	{
		var whitespace = new String(" \t\n\r");
		var s = new String(str);
		if (whitespace.indexOf(s.charAt(s.length-1)) != -1) 
		{

			var i = s.length - 1;       
			while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
			i--;
			s = s.substring(0, i+1);
		}
		return s;
	}
	function Trim(str)
	{
		return RTrim(LTrim(str));
	}













function downBrochures(nav,aadnav)
{
 show = window.open('brochures.asp?NAV='+nav+'&AADNAV='+aadnav, 'Show', 'height=250,width=450,resizeble=0 ,scrollbars=0,status=0,screenX=280,screenY=30')
}

function downWhitepaper(nav,aadnav)
{
 show = window.open('whitepaper.asp?NAV='+nav+'&AADNAV='+aadnav, 'Show', 'height=250,width=450,resizeble=0 ,scrollbars=0,status=0,screenX=280,screenY=30')
}

function downDemo(nav,aadnav)
{
 show = window.open('demo.asp?NAV='+nav+'&AADNAV='+aadnav, 'Show', 'height=250,width=450,resizeble=0 ,scrollbars=0,status=0,screenX=280,screenY=30')
}

function downDemoGlobal(nav,aadnav)
{
 show = window.open('demoglobal.asp?NAV='+nav+'&AADNAV='+aadnav, 'Show', 'height=250,width=450,resizeble=0 ,scrollbars=0,status=0,screenX=280,screenY=30')
}




function isDate(day,month,year) {
        if ((day < 1)||(day > 31)) return false;
        if ((month < 1)||(month > 12)) return false;
        if (((((month == 4)||(month == 6))||(month == 9))||(month == 11))&&(day > 30)) return false;
        if (month == 2) {
                 if (((year % 4 == 0)&&(year % 100 != 0))||(year % 400 == 0)) 
                        {if (day > 29) return false;}
                else
                        {if (day > 28) return false;}
        }
        return true;
}

function isEmail(item) 
{
	var l = item.length;
	var at = item.indexOf("@");
	var dot = item.indexOf(".",at+1);
	if (((at < 1)||(dot <= at+1))||(dot == l-1)) 
		return false;
	return true;
}

function error(item, text) {
        if (flag) return;
        flag = true;
        window.alert(text);
        item.focus();
}

function isFilled(item) {
 if ((item==null)||(item==""))
	{
		return false;
	}
	else
	{
		var filled = false;
		var i = 0;
		for (i = 0; i < item.length; i++)
		{
			if (item.charAt(i) != " ")
			{
				filled = true;
			}
		}
		return filled;
	}		
}

function isNumber(itemvalue) {
        if (!Number(itemvalue))
                return false;
        return true;
}        

function isBlankNum(itemvalue){
		if ((itemvalue=="")||(itemvalue==null))
			return true;
		else 
			return isNumber(itemvalue);
}

function isftDate(fday,fmonth,fyear,tday,tmonth,tyear) {
  	var fromDate = new Date(), toDate = new Date();
	fromDate.setDate(fday);
	fromDate.setMonth(fmonth-1);
	fromDate.setYear(fyear);
	toDate.setDate(tday);
	toDate.setMonth(tmonth-1);
	toDate.setYear(tyear);
	if (fromDate.getTime() > toDate.getTime()) return false;
	return true;
}



