﻿function ValidateRequestDetails()
        {
        if($('ctl00_ctl00_Main_Main_firstNameTxtBx').value == ""){
            alert('Please enter your name');
            $('ctl00_ctl00_Main_Main_firstNameTxtBx').focus();
            return false;
        }
        if(!CheckForSpecialChars($('ctl00_ctl00_Main_Main_firstNameTxtBx').value))
	    {
	        alert("Please enter a valid name");
	        $('ctl00_ctl00_Main_Main_firstNameTxtBx').focus();
	        return false; 
	    }
	    if(!isAlpha($('ctl00_ctl00_Main_Main_firstNameTxtBx').value))
	    {
	        alert("Please enter a valid name");
	        $('ctl00_ctl00_Main_Main_firstNameTxtBx').focus();
	        return false; 
	    }
        if($('ctl00_ctl00_Main_Main_professionalTxtBx').value == ""){
            alert('Please enter your professional title');
            $('ctl00_ctl00_Main_Main_professionalTxtBx').focus();
            return false;
        }
         if($('ctl00_ctl00_Main_Main_organizationTxtBx').value == ""){
            alert('Please enter your organization');
            $('ctl00_ctl00_Main_Main_organizationTxtBx').focus();
            return false;
        }
        if($('ctl00_ctl00_Main_Main_telephoneTxtBx').value == ""){
            alert('Please enter your phone number');
            $('ctl00_ctl00_Main_Main_telephoneTxtBx').focus();
            return false;
        }
        if (!isValidPhoneNum($('ctl00_ctl00_Main_Main_telephoneTxtBx').value)) 
        {
	        alert("Please enter a valid phone number");
	        document.getElementById('ctl00_ctl00_Main_Main_telephoneTxtBx').focus();
	        return false; 
	    }
	    
         if($('ctl00_ctl00_Main_Main_businessEmailTxtBx').value == ""){
            alert('Please enter your E-Mail');
            $('ctl00_ctl00_Main_Main_businessEmailTxtBx').focus();
            return false;
        }
        if (($('ctl00_ctl00_Main_Main_businessEmailTxtBx').value != "") && (!ValidateEmailAddress($('ctl00_ctl00_Main_Main_businessEmailTxtBx').value))) 
        {
	        alert("Please enter valid E-mail");
	        document.getElementById('ctl00_ctl00_Main_Main_businessEmailTxtBx').focus();
	        return false; 
	    }
         
       
        if($('ctl00_ctl00_Main_Main_cityTxtBx').value == ""){
            alert('Please enter your city');
            $('ctl00_ctl00_Main_Main_cityTxtBx').focus();
            return false;
        }
         if($('ctl00_ctl00_Main_Main_countryDdl').selectedIndex == 0){
            alert('Please select your country');
            $('ctl00_ctl00_Main_Main_countryDdl').focus();
            return false;
        }
          if($('ctl00_ctl00_Main_Main_hearDdl').selectedIndex == 0){
            alert('Please select how did you heard about PPM Studio ');
            $('ctl00_ctl00_Main_Main_hearDdl').focus();
            return false;
        }
        
        if($('ctl00_ctl00_Main_Main_areaOfInterestDdl').selectedIndex == -1){            
            alert('Please select Area of Interest');
            $('ctl00_ctl00_Main_Main_areaOfInterestDdl').focus();
            return false;
        }
        
        if($('ctl00_ctl00_Main_Main_sourceTxtBx').value == ""){
            alert('Please enter When do you wish to have a customized demo?');
            $('ctl00_ctl00_Main_Main_sourceTxtBx').focus();
            return false;
        }
        
        if($('ctl00_ctl00_Main_Main_functionalRdBtn').checked == false && $('ctl00_ctl00_Main_Main_pmToolsRdBtn').checked== false){
            alert('Please describe your interest in evaluating PPM Studio');
            $('ctl00_ctl00_Main_Main_functionalRdBtn').focus();
            return false;
        }
        
//         if($('tellAbtYes').checked == false && $('tellAbtNo').checked== false){
//            alert('We appreciate, if you can tell us more about you');
//            $('tellAbtYes').focus();
//            return false;
//        }
//        
//        if($('tellAbtYes').checked && $('ctl00_ctl00_Main_Main_OrgEmp').value!=""){
//          if(!isNum($('ctl00_ctl00_Main_Main_OrgEmp').value))
//            alert('Please enter valid number of employees');
//            $('ctl00_ctl00_Main_Main_OrgEmp').focus();
//            return false;
//        }
        
        
        
        return true;
        }
        function ValidateEmailAddress(sEmailAddress) {
        return((sEmailAddress.length > 0) && (sEmailAddress.indexOf("@") > 0) && (sEmailAddress.indexOf(".",sEmailAddress.indexOf("@")) > 0)); 
        }
        var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/ ;

        function CheckForSpecialChars(parm) {

            if(parm.search(mikExp) == -1) 
            {
                return true;
            }
            else 
            {
                return false;
            }
        }

        function isNum(parm) 
        {
            return isValid(parm,numb);
        }
        function isLower(parm) 
        {
            return isValid(parm,lwr);
        }
        function isUpper(parm) 
        {
            return isValid(parm,upr);
        }
        function isAlpha(parm) 
        {
            return isValid(parm,lwr+upr);
        }
        function isAlphanum(parm) 
        { 
            return isValid(parm,lwr+upr+numb);
        }
        function isValidPhoneNum(parm)
        {
            for (i=0; i<parm.length; i++) 
            {
                if (numb.indexOf(parm.charAt(i),0) == -1) 
                return false;
            }
            if(parm.indexOf("--",0) != -1)
                return false;
            if(parm.indexOf("++",0) != -1)
                return false;
                
            return true;
        }
        function isValid(parm,val) {
            for (i=0; i<parm.length; i++) 
            {
                if (val.indexOf(parm.charAt(i),0) == -1) 
                return false;
            }
                return true;
        }
        function ClearDetails(){
             $('ctl00_ctl00_Main_Main_firstNameTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_lastNameTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_businessEmailTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_mobileTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_telephoneTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_professionalTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_organizationTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_streetAdd1TxtBx').value = '';
             $('ctl00_ctl00_Main_Main_streetAdd2TxtBx').value = '';
             $('ctl00_ctl00_Main_Main_cityTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_cityTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_stateTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_zipCodeTxtBx').value = '';
             $('countryDdl').selectedIndex = 0;
             $('ctl00_ctl00_Main_Main_areaOfInterestDdl').selectedIndex = 0;             
             $('ctl00_ctl00_Main_Main_industryDdl').selectedIndex = 0;
             $('ctl00_ctl00_Main_Main_revenueDdl').selectedIndex = 0;
             $('ctl00_ctl00_Main_Main_itReqDdl').selectedIndex = 0;
             $('ctl00_ctl00_Main_Main_describesDdl').selectedIndex = 0;
             $('hearDdl').selectedIndex = 0;
             $('ctl00_ctl00_Main_Main_commentsTxtBx').value = '';
             $('ctl00_ctl00_Main_Main_firstNameTxtBx').focus();
             return false;
        }

function dummy(){
    event.cancelBubble = true;
    return true;
}

function OnTellUsClick(id){
     if(id == "tellAbtYes"){
        document.getElementById('yesTbl').style.display = "block";
        $('ctl00_ctl00_Main_Main_saveYesBtn').style.display = "block";
       $('ctl00_ctl00_Main_Main_saveBtn').style.display = "none";
        
     }else{
        document.getElementById('yesTbl').style.display = "none";
          $('ctl00_ctl00_Main_Main_saveYesBtn').style.display = "none";
       $('ctl00_ctl00_Main_Main_saveBtn').style.display = "block";
     }
}
