var secure_url="https://www.reportfordoc.com";
//var secure_url="http://server/php/rfd";
function loginFrm_validation(frm) 
{   
    var username      =    $('username').value;    
    var password     =    $('password').value;
    
    $('usernameErr').innerHTML = '';
    $('passwordErr').innerHTML = '';
    
    if(trim(username) == '')
    {
        $('usernameErr').innerHTML    = '( Username required! )';
        $('username').focus();
        return false;
    }    
    else if(trim(password) == '')
    {
        $('passwordErr').innerHTML    = '( Password required! )';
        $('password').focus();
        return false;
    }
    else
    {           
        var pars     = Form.serialize( frm ); 
        var url = 'check_doctor_loginDetails.php';      
        var myAjax = new Ajax.Request( url, {method: 'post', parameters: pars, onLoading: showLoadDoctorLogin, onComplete: showResponseDoctorLogin} );
    }    
} 
function showLoadDoctorLogin () 
{

}
function showResponseDoctorLogin (originalRequest) 
{
    result=trim(originalRequest.responseText);    
    //alert(result);
    if(result=="true")
    {           
        window.location="doctors_panel.php";
    }    
    else
    {
        document.getElementById('loginMsg').innerHTML=result;
        return false;
    }
}


function validateCategory()
{
      var category      =    $('category').value;
      if( trim(category) == '' )
      {
        $('catErr').innerHTML    = '( Category required! )';
        return false;
      }
      return true;
}


function validate_Canceling_reason_frm()
{
      var source_title      =    $('source_title').value;
      
      $('source_titleErr').innerHTML ="";
      
      if( trim(source_title) == '' )
      {
        $('source_titleErr').innerHTML    = '( Canceling reason cannot be blank! )';
        $('source_title').value="";
        $('source_title').focus();
        return false;
      }
      return true;
}


function validate_cancel_subscription_frm()
{
      var canceling_reason      =    $('canceling_reason').value;
      var other_canceling_reason=    $('other_canceling_reason').value;
      
      $('canceling_reason_ERR').innerHTML ="";
      
      if(canceling_reason=='')
      {
        $('canceling_reason_ERR').innerHTML    = '( Please select the canceling reason! )';        
        $('canceling_reason').focus();
        return false;
      }
      else if( trim(canceling_reason) == '5' && other_canceling_reason=='If other, please specify')
      {
        $('canceling_reason_ERR').innerHTML    = '( Enter the other canceling reason! )';        
        $('other_canceling_reason').focus();
        return false;
      }
      return true;
}

function validate_Referral_reason_frm()
{
      var source_title      =    $('source_title').value;
      
      $('source_titleErr').innerHTML ="";
      
      if( trim(source_title) == '' )
      {
        $('source_titleErr').innerHTML    = '( Referral reason cannot be blank! )';
        $('source_title').value="";
        $('source_title').focus();
        return false;
      }
      return true;
}


function validateDemoCode()
{
      var demo_code      =    $('demo_code').value;
      if( trim(demo_code) == '' )
      {
        $('demo_codeErr').innerHTML    = '( Demo Code required! )';
        $('demo_code').focus();
        return false;
      }
      else
      {
        if(demo_code.length!=16)      
        {   
            $('demo_codeErr').innerHTML   = '( Demo code should be equal to 16 digits! )';
            $('demo_code').focus();
            return false;
        }  
      }
      return true;
}

function validateAdminSettings()
{
    var printing_company_email      =    $('printing_company_email').value;
    if( trim(printing_company_email) == '' )
    {
        $('printing_company_emailErr').innerHTML    = '( Email address required! )';
        $('printing_company_email').focus();
        return false;
    }
    else
    {
        if( !validateEmail(printing_company_email) )
        {
            $('printing_company_emailErr').innerHTML = '( Email address is invalid ! )';
            $('printing_company_email').focus();            
            return false;
        }
    }    
    return true;
}

function isSpaceKey(evt)
{
 var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode == 32)
    return false;

 return true;
}

function isValidText_for_OthersTextBoxes(id,txt)  // not being used anywhere 
{
    document.getElementById(id).onfocus = function()
    {  
        if(this.value == txt) this.value = "";  
    };  
    document.getElementById(id).onblur = function()
    {  
        if(this.value == "") this.value = txt;  
    };  
}

function OthersBoxManager(current_id,id_to_match,other_boxID,container_textBoxId)  
{   
    if(current_id==id_to_match)
    {
        document.getElementById(other_boxID).style.display='inline';    
        document.getElementById(container_textBoxId).focus();
    }          
    else
    {
        document.getElementById(other_boxID).style.display='none';    
    }
}


function validateSelectCategory()
{
    var catID= $('mainCategory').value;
    if(catID==0)
    {
        $('mainCategoryErr').innerHTML    = '( Select Main Category! )';
        return false;
    }
    $('mainCategoryErr').innerHTML = '';
    return true;
}

function validateSelect_FaqType()
{
    var faq_type= $('faq_Category').value;
    if(faq_type=='')
    {
        $('faqType_Err').innerHTML    = '( Select FAQ Type! )';
        return false;
    }
    $('faqType_Err').innerHTML = '';
    return true;
}

function validateSubCategory()
{
    var title      =    $('title').value;    
    var categroyID     =    $('mainCategory').value;
    
    $('mainCategoryErr').innerHTML = '';
    $('titleErr').innerHTML = '';
    
    if(categroyID==0)
    {        
        $('mainCategoryErr').innerHTML    = '( Select Main Category! )';
        return false;
    }    
    
    if(trim(title) == '')
    {
        $('titleErr').innerHTML    = '( Title required! )';
        $('title').focus();
        return false;
    }
    
    return true;     
}                                

function validateMetropolitanArea()
{
    var title      =    $('title').value;    
    var countryID     =    $('mainCountry').value;
    
    $('mainCountryErr').innerHTML = '';
    $('titleErr').innerHTML = '';
    
    if(countryID==0)
    {        
        $('mainCountryErr').innerHTML    = '( Select Country! )';
        return false;
    }    
    
    if(trim(title) == '')
    {
        $('titleErr').innerHTML    = '( Title required! )';
        $('title').focus();
        return false;
    }
    
    return true;     
}


function validateContent()
{
    var page_title   =    $('page_title').value;
    //var page_body    =    $('page_body').value;

    if(trim(page_title) == '')
    {
        $('page_titleErr').innerHTML    = '( Page Title required! )';
        $('page_title').focus();
        return false;
    }

    var s = FCKeditorAPI.GetInstance('page_body') ;    
    if(s.GetXHTML()==""||s.GetXHTML()==null)
    {
        $('page_bodyErr').innerHTML    = '( Page Body required! )';
        return false;        
    }    
    
    return true;
}

function validateFaqContent()
{
    var faq_Category   =    $('faq_Category').value;
    //var faq_question    =    $('faq_question').value;
    //var faq_answer    =    $('faq_answer').value;    
    
    
    $('faq_CategoryErr').innerHTML="";
    $('faq_questionErr').innerHTML="";
    $('faq_answerErr').innerHTML="";

    if(trim(faq_Category) == '')
    {
        $('faq_CategoryErr').innerHTML    = '( Select category! )';
        $('faq_Category').focus();
        return false;
    }

    var s1 = FCKeditorAPI.GetInstance('faq_question');    
    
    var s2 = FCKeditorAPI.GetInstance('faq_answer');
         
    if(s1.GetXHTML()==""||s1.GetXHTML()==null||s1.GetXHTML()=="<br />")
    {
        $('faq_questionErr').innerHTML    = '( Question required! )';
        return false;        
    }    
        
   
    if(s2.GetXHTML()==""||s2.GetXHTML()==null||s2.GetXHTML()=="<br />")
    {
        $('faq_answerErr').innerHTML    = '( Answer required! )';
        return false;        
    }    
    
    return true;
}  

function validateEmailContent()
{
    var email_subject   =    $('email_subject').value;
    var email_content    =    $('email_content').value;
    
    $('email_subjectErr').innerHTML="";
    $('email_contentErr').innerHTML="";

    if(trim(email_subject) == '')
    {
        $('email_subjectErr').innerHTML    = '( Subject required! )';
        $('email_subject').value="";
        $('email_subject').focus();
        return false;
    }

    var s = FCKeditorAPI.GetInstance('email_content') ;  
    if(s.GetXHTML()==""||s.GetXHTML()==null||s.GetXHTML()=="<br />")
    {           
        $('email_contentErr').innerHTML    = '( Email content required! )';
        $('email_content').focus();
        return false;        
    }  
    
    return true;
}




function validate_member() 
{   
    var username        =    $('username').value;
    var pass1        =    $('password').value;
    var pass2        =    $('re_password').value;
    var email        =    $('email').value;
    var re_email        =    $('re_email').value;    
    var fname        =    $('fname').value;
    var lname        =    $('lname').value;    
    var country        =    $('country').value;      
    var address        =    $('address').value;
    var city        =    $('city').value;  
    var state        =    $('state').value;  
    var zip        =    $('zip').value;  
    var office_phone_area        =    $('office_phone_area').value; 
    var office_phone_number        =    $('office_phone_number').value; 
    
    var main_specialties_category        =    $('main_specialties_category').value;  
    var sub_specialties_category        =    $('sub_specialties_category').value;  
    var metroplitan_area        =    $('metroplitan_area').value;  
    var reference_source        =    $('reference_source').value;  
    var other_reference_source  = $('other_reference_source').value;    
    var signupcode_div_value = document.getElementById('signupcode_div').style.display;
    
    
    
    
    $('usernameErr').innerHTML='';
    $('passErr').innerHTML='';
    $('re_passErr').innerHTML='';
    $('emailErr').innerHTML='';
    $('re_emailErr').innerHTML='';   
    $('fnameErr').innerHTML='';
    $('lnameErr').innerHTML='';
    $('countryErr').innerHTML='';
    $('addressErr').innerHTML='';
    $('cityErr').innerHTML='';    
    $('stateErr').innerHTML='';    
    $('zipErr').innerHTML='';  
    $('officePhoneNumberErr').innerHTML='';     
    $('main_specialties_categoryErr').innerHTML='';  
    $('specialtiesErr').innerHTML='';  
    $('metroplitan_areaErr').innerHTML='';  
    $('reference_sourceErr').innerHTML='';  
    $('signup_codeErr').innerHTML='';
    
    
    //var flag         =    1;
    
    if( trim (username) == '' )
    {
        $('usernameErr').innerHTML   = '( Username required! )';
        $('username').focus();
        //flag = 0 ;
        return false;
    }
    
    if( trim (pass1) == '' )
    {
        $('passErr').innerHTML   = '( Password required! )';
        $('password').focus();
        //flag = 0 ;
        return false;
    }
    else if(pass1.length<=4)      
    {   
        $('passErr').innerHTML   = '( Password should be grater than 4 digits! )';
        $('password').focus();   
        //flag = 0 ;
        return false;       
    }
    else if( trim (pass2) == '' )
    {
        $('re_passErr').innerHTML   = '( Reenter password required! )';
        $('re_password').focus();
        //flag = 0 ;
        return false;
    }
    else if( trim (pass1) != '' && trim (pass2) != '' )
    {
        if(trim (pass1)!=trim (pass2))
        {
            $('re_passErr').innerHTML   = '( Password not match with reentered password! )';
            $('re_password').focus(); 
            //flag = 0 ;
            return false;
        }
    }
    
    if(trim(email)  == '' )
    {
        $('emailErr').innerHTML = '( Email address required! )';
        $('email').focus();
        //flag = 0 ;
        return false;
    }
    else
    {
        if( !validateEmail(email) )
        {
            $('emailErr').innerHTML = '( Email address is invalid ! )';
            $('email').focus();
            //flag = 0 ;
            return false;
        }
    }
    
    if(trim(re_email)  == '' )
    {
        $('re_emailErr').innerHTML = '( Reenter Email address required! )';
        $('re_email').focus();
        //flag = 0 ;
        return false;
    }
    else
    {   
        if( !validateEmail(re_email) )
        {
            $('re_emailErr').innerHTML = '( Reenter Email address is invalid ! )';
            $('re_email').focus();
            //flag = 0 ;
            return false;
        }
    }
    
    if(trim (email)!=trim (re_email))
    {
        $('re_emailErr').innerHTML   = '( Email not match with reentered email! )';
        $('re_email').focus();
        //flag = 0 ;
        return false;
    }
    
    
    if(trim(fname)  == '' )
    {
        $('fnameErr').innerHTML = '( First Name required! )';
        $('fname').focus();
        //flag = 0 ;
        return false;
    }
    if(trim(lname)  == '' )
    {
        $('lnameErr').innerHTML = '( Last Name required! )';
        $('lname').focus();
        //flag = 0 ;
        return false;
    }
    
    if(trim(country)  == '' )
    {
        $('countryErr').innerHTML = '( Country required! )';
        $('country').focus();
        //flag = 0 ;
        return false;
    }
    
    if(trim(address)  == '' )
    {
        $('addressErr').innerHTML = '( Address required! )';
        $('address').focus();
        //flag = 0 ;
        return false;
    }
    
    if(trim(city)  == '' )
    {
        $('cityErr').innerHTML = '( City required! )';
        $('city').focus();
        flag = 0 ;
    }
    
    if(trim(state)  == '' )
    {
        $('stateErr').innerHTML = '( State required! )';
        $('state').focus();
        //flag = 0 ;
        return false;
    }
    
    if(trim(zip)  == '' )
    {
        $('zipErr').innerHTML = '( Zip required! )';
        $('zip').focus();
        //flag = 0 ;
        return false;
    }
    
    if(trim(office_phone_area)  == '' || trim(office_phone_number)=='' )
    {
        $('officePhoneNumberErr').innerHTML = '( Office phone number required! )';
        //flag = 0 ;
        return false;
    }
    
    if(trim(main_specialties_category)  == '' )
    {
        $('main_specialties_categoryErr').innerHTML = '( Specialty Category required! )';
        //flag = 0 ;
        return false;
    }
    
    if(trim(sub_specialties_category)  == '' )
    {
        $('specialtiesErr').innerHTML = '( Specialty required! )';
        //flag = 0 ;
        return false;
    }
    
    /*if(trim(metroplitan_area)  == '' )
    {
        $('metroplitan_areaErr').innerHTML = '( Metropolitan area required! )';
        //flag = 0 ;
        return false;
    } */
    
    if(trim(reference_source)  == '' )
    {
        $('reference_sourceErr').innerHTML = '( How doctor learned about us required! )';
        //flag = 0 ;
        return false;
    }
    
    if(trim(reference_source)  == '7' )   
    {
        if(trim(other_reference_source)=='' || trim(other_reference_source)=='If other, please specify')
        {
            $('reference_sourceErr').innerHTML = '( If other, please specify ! )';
            //flag = 0 ;
            return false; 
        }    
    }
    
    if(signupcode_div_value=='inline')
    {
        var signup_code  = $('signup_code').value;        
        if(trim(signup_code)=="" || trim(signup_code)=="Please enter it here")
        {               
            $('signup_codeErr').innerHTML   = '( Signup code required! )';
            $('signup_code').focus();            
            return false;                    
        }
        else if(trim(signup_code).length>"20" || trim(signup_code)=="Please enter it here")
        {               
            $('signup_codeErr').innerHTML   = '( Invalid Signup code! )';
            $('signup_code').focus();            
            return false;                    
        }   
    }
    
    
    return true;
    /*if( flag == 1 )
        return true;
    else 
        return false;*/
}

function validate_update_email() 
{   
    var newEmail        =    $('newEmail').value;
    var re_newEmail     =    $('re_newEmail').value;
    
      
    $('newEmailErr').innerHTML='';
    $('re_newEmailErr').innerHTML='';
    
    var flag         =    1;
    
    if(trim(newEmail)  == '' )
    {
        $('newEmailErr').innerHTML = '( New email required! )';
        $('newEmail').focus();
        flag = 0 ;
    }
    else
    {
        if( !validateEmail(newEmail) )
        {
            $('newEmailErr').innerHTML = '( Email address is invalid ! )';
            $('newEmail').focus();  
            flag = 0 ;
        }
    }                        
    
    if(trim(re_newEmail)  == '' )
    {
        $('re_newEmailErr').innerHTML = '( Confirm New email required! )';        
        flag = 0 ;
    }
    else
    {
        if( !validateEmail(re_newEmail) )
        {
            $('re_newEmailErr').innerHTML = '( Email address is invalid ! )';            
            flag = 0 ;
        }
    }                           
    
    if( trim(newEmail)  != '' && trim(re_newEmail)  != '')      
    {
        if( trim(newEmail) != trim(re_newEmail) )
        {
            $('re_newEmailErr').innerHTML = '( Email Not match with confirm email! )';            
            flag = 0 ;    
        }
    }
    
    
    if( flag == 1 )
        return true;
    else 
        return false;
}

function validate_update_password() 
{   
    var old_password        =    $('old_password').value;
    var new_password        =    $('new_password').value;
    var confirm_new_password=    $('confirm_new_password').value;
    
      
    $('old_passwordErr').innerHTML='';
    $('new_passwordErr').innerHTML='';    
    $('confirm_new_passwordErr').innerHTML='';    
    
    var flag         =    1;
    
    if(trim(old_password)  == '' )
    {
        $('old_passwordErr').innerHTML = '( Old password required! )';
        $('old_password').focus();
        flag = 0 ;
    }
    else
    {   
        if(old_password.length<=4)
        {
            $('old_passwordErr').innerHTML   = '( Password should be grater than 4 digits! )';
            flag = 0 ;
        }    
    }
    
    if(trim(new_password)  == '' )
    {
        $('new_passwordErr').innerHTML = '( New password required! )';
        flag = 0 ;
    }
    else
    {   
        if(new_password.length<=4)
        {
            $('new_passwordErr').innerHTML   = '( Password should be grater than 4 digits! )';
            flag = 0 ;
        }    
    }
    
    if(trim(confirm_new_password)  == '' )
    {
        $('confirm_new_passwordErr').innerHTML = '( Confirm password required! )';
        flag = 0 ;
    }
    else
    {   
        if(confirm_new_password.length<=4)
        {
            $('confirm_new_passwordErr').innerHTML   = '( Password should be grater than 4 digits! )';
            flag = 0 ;
        }    
    }
    
    if( trim(new_password) != '' && trim(confirm_new_password) != '' )
    {
        if( trim(new_password) != trim(confirm_new_password))
        {
            $('confirm_new_passwordErr').innerHTML   = '( New Password not match with confirm password! )';
            flag = 0 ;
        }
    }
    
    if( flag == 1 )
        return true;
    else 
        return false;
}

function validate_update_member() 
{   
    var fname        =    $('fname').value;
    var lname        =    $('lname').value;    
    var country      =    $('country').value;      
    var address      =    $('address').value;
    var city         =    $('city').value;  
    var state        =    $('state').value;  
    var zip          =    $('zip').value;  
    var office_phone_area        =    $('office_phone_area').value; 
    var office_phone_number        =    $('office_phone_number').value;     
    var main_specialties_category        =    $('main_specialties_category').value;  
    var sub_specialties_category        =    $('sub_specialties_category').value;  
    var metroplitan_area        =    $('metroplitan_area').value;  
    var reference_source        =    $('reference_source').value;  
      
    $('fnameErr').innerHTML='';
    $('lnameErr').innerHTML='';
    $('countryErr').innerHTML='';
    $('addressErr').innerHTML='';
    $('cityErr').innerHTML='';    
    $('stateErr').innerHTML='';    
    $('zipErr').innerHTML='';  
    $('officePhoneNumberErr').innerHTML='';     
    $('main_specialties_categoryErr').innerHTML='';  
    $('specialtiesErr').innerHTML='';  
    $('metroplitan_areaErr').innerHTML='';  
    $('reference_sourceErr').innerHTML='';  
    
    
    var flag         =    1;
    
    if(trim(fname)  == '' )
    {
        $('fnameErr').innerHTML = '( First Name required! )';
        flag = 0 ;
    }
    if(trim(lname)  == '' )
    {
        $('lnameErr').innerHTML = '( Last Name required! )';
        flag = 0 ;
    }
    
    if(trim(country)  == '' )
    {
        $('countryErr').innerHTML = '( Country required! )';
        flag = 0 ;
    }
    
    if(trim(address)  == '' )
    {
        $('addressErr').innerHTML = '( Address required! )';
        flag = 0 ;
    }
    
    if(trim(city)  == '' )
    {
        $('cityErr').innerHTML = '( City required! )';
        flag = 0 ;
    }
    
    if(trim(state)  == '' )
    {
        $('stateErr').innerHTML = '( State required! )';
        flag = 0 ;
    }
    
    if(trim(zip)  == '' )
    {
        $('zipErr').innerHTML = '( Zip required! )';
        flag = 0 ;
    }
    
    if(trim(office_phone_area)  == '' || trim(office_phone_number)=='' )
    {
        $('officePhoneNumberErr').innerHTML = '( Office phone number required! )';
        flag = 0 ;
    }
    
    if(trim(main_specialties_category)  == '' )
    {
        $('main_specialties_categoryErr').innerHTML = '( Specialty Category required! )';
        flag = 0 ;
    }
    
    if(trim(sub_specialties_category)  == '' )
    {
        $('specialtiesErr').innerHTML = '( Specialty required! )';
        flag = 0 ;
    }
    
    /*if(trim(metroplitan_area)  == '' )
    {
        $('metroplitan_areaErr').innerHTML = '( Metropolitan area required! )';
        flag = 0 ;   
    }*/
    
    if(trim(reference_source)  == '' )
    {
        $('reference_sourceErr').innerHTML = '( How doctor learned about us required! )';
        flag = 0 ;
    }
            
    if( flag == 1 )
        return true;
    else 
        return false; 
}

function validate_member_admin() 
{   
    var username        =    $('username').value;
    var pass1        =    $('password').value;    
    var email        =    $('email').value;    
    var fname        =    $('fname').value;
    var lname        =    $('lname').value;    
    var country        =    $('country').value;      
    var address        =    $('address').value;
    var city        =    $('city').value;  
    var state        =    $('state').value;  
    var zip        =    $('zip').value;  
    var office_phone_area        =    $('office_phone_area').value; 
    var office_phone_number        =    $('office_phone_number').value; 
    
    var main_specialties_category        =    $('main_specialties_category').value;  
    var sub_specialties_category        =    $('sub_specialties_category').value;  
    var metroplitan_area        =    $('metroplitan_area').value;  
    var reference_source        =    $('reference_source').value;  
    
    
    
    $('usernameErr').innerHTML='';
    $('passErr').innerHTML='';    
    $('emailErr').innerHTML='';    
    $('fnameErr').innerHTML='';
    $('lnameErr').innerHTML='';
    $('countryErr').innerHTML='';
    $('addressErr').innerHTML='';
    $('cityErr').innerHTML='';    
    $('stateErr').innerHTML='';    
    $('zipErr').innerHTML='';  
    $('officePhoneNumberErr').innerHTML='';     
    $('main_specialties_categoryErr').innerHTML='';  
    $('specialtiesErr').innerHTML='';  
    $('metroplitan_areaErr').innerHTML='';  
    $('reference_sourceErr').innerHTML='';  
    
    
    var flag         =    1;
    
    if( trim (username) == '' )
    {
        $('usernameErr').innerHTML   = '( Username required! )';
        flag = 0 ;
    }
    
    if( trim (pass1) == '' )
    {
        $('passErr').innerHTML   = '( Password required! )';
        flag = 0 ;
    }
    else
    {   
        if(pass1.length<=4)
        {
            $('passErr').innerHTML   = '( Password should be grater than 4 digits! )';
            flag = 0 ;
        }    
    }
    
    
    
    if(trim(email)  == '' )
    {
        $('emailErr').innerHTML = '( Email address required! )';
        flag = 0 ;
    }
    else
    {
        if( !validateEmail(email) )
        {
            $('emailErr').innerHTML = '( Email address is invalid ! )';
            flag = 0 ;
        }
    }
    
    if(trim(fname)  == '' )
    {
        $('fnameErr').innerHTML = '( First Name required! )';
        flag = 0 ;
    }
    if(trim(lname)  == '' )
    {
        $('lnameErr').innerHTML = '( Last Name required! )';
        flag = 0 ;
    }
    
    if(trim(country)  == '' )
    {
        $('countryErr').innerHTML = '( Country required! )';
        flag = 0 ;
    }
    
    if(trim(address)  == '' )
    {
        $('addressErr').innerHTML = '( Address required! )';
        flag = 0 ;
    }
    
    if(trim(city)  == '' )
    {
        $('cityErr').innerHTML = '( City required! )';
        flag = 0 ;
    }
    
    if(trim(state)  == '' )
    {
        $('stateErr').innerHTML = '( State required! )';
        flag = 0 ;
    }
    
    if(trim(zip)  == '' )
    {
        $('zipErr').innerHTML = '( Zip required! )';
        flag = 0 ;
    }
    
    if(trim(office_phone_area)  == '' || trim(office_phone_number)=='' )
    {
        $('officePhoneNumberErr').innerHTML = '( Office phone number required! )';
        flag = 0 ;
    }
    
    if(trim(main_specialties_category)  == '' )
    {
        $('main_specialties_categoryErr').innerHTML = '( Specialty Category required! )';
        flag = 0 ;
    }
    
    if(trim(sub_specialties_category)  == '' )
    {
        $('specialtiesErr').innerHTML = '( Specialty required! )';
        flag = 0 ;
    }
    
    if(trim(metroplitan_area)  == '' )
    {
        $('metroplitan_areaErr').innerHTML = '( Metropolitan area required! )';
        flag = 0 ;
    }
    
    if(trim(reference_source)  == '' )
    {
        $('reference_sourceErr').innerHTML = '( How doctor learned about us required! )';
        flag = 0 ;
    }
            
    if( flag == 1 )
        return true;
    else 
        return false;
}

function validate_update_member_admin() 
{   
    var pass1        =    $('password').value;    
    var email        =    $('email').value;    
    var fname        =    $('fname').value;
    var lname        =    $('lname').value;    
    var country      =    $('country').value;      
    var address      =    $('address').value;
    var city         =    $('city').value;  
    var state        =    $('state').value;  
    var zip          =    $('zip').value;  
    var office_phone_area        =    $('office_phone_area').value; 
    var office_phone_number        =    $('office_phone_number').value;     
    var main_specialties_category        =    $('main_specialties_category').value;  
    var sub_specialties_category        =    $('sub_specialties_category').value;  
    var metroplitan_area        =    $('metroplitan_area').value;  
    var reference_source        =    $('reference_source').value;  
      
    
    $('passErr').innerHTML='';    
    $('emailErr').innerHTML='';  
    $('fnameErr').innerHTML='';
    $('lnameErr').innerHTML='';
    $('countryErr').innerHTML='';
    $('addressErr').innerHTML='';
    $('cityErr').innerHTML='';    
    $('stateErr').innerHTML='';    
    $('zipErr').innerHTML='';  
    $('officePhoneNumberErr').innerHTML='';     
    $('main_specialties_categoryErr').innerHTML='';  
    $('specialtiesErr').innerHTML='';  
    $('metroplitan_areaErr').innerHTML='';  
    $('reference_sourceErr').innerHTML='';  
    
    
    var flag         =    1;
    
    if( trim (pass1) == '' )
    {
        $('passErr').innerHTML   = '( Password required! )';
        flag = 0 ;
    }
    else
    {   
        if(pass1.length<=4)
        {
            $('passErr').innerHTML   = '( Password should be grater than 4 digits! )';
            flag = 0 ;
        }    
    }
    
    
    
    if(trim(email)  == '' )
    {
        $('emailErr').innerHTML = '( Email address required! )';
        flag = 0 ;
    }
    else
    {
        if( !validateEmail(email) )
        {
            $('emailErr').innerHTML = '( Email address is invalid ! )';
            flag = 0 ;
        }
    }
    
    if(trim(fname)  == '' )
    {
        $('fnameErr').innerHTML = '( First Name required! )';
        flag = 0 ;
    }
    if(trim(lname)  == '' )
    {
        $('lnameErr').innerHTML = '( Last Name required! )';
        flag = 0 ;
    }
    
    if(trim(country)  == '' )
    {
        $('countryErr').innerHTML = '( Country required! )';
        flag = 0 ;
    }
    
    if(trim(address)  == '' )
    {
        $('addressErr').innerHTML = '( Address required! )';
        flag = 0 ;
    }
    
    if(trim(city)  == '' )
    {
        $('cityErr').innerHTML = '( City required! )';
        flag = 0 ;
    }
    
    if(trim(state)  == '' )
    {
        $('stateErr').innerHTML = '( State required! )';
        flag = 0 ;
    }
    
    if(trim(zip)  == '' )
    {
        $('zipErr').innerHTML = '( Zip required! )';
        flag = 0 ;
    }
    
    if(trim(office_phone_area)  == '' || trim(office_phone_number)=='' )
    {
        $('officePhoneNumberErr').innerHTML = '( Office phone number required! )';
        flag = 0 ;
    }
    
    if(trim(main_specialties_category)  == '' )
    {
        $('main_specialties_categoryErr').innerHTML = '( Specialty Category required! )';
        flag = 0 ;
    }
    
    if(trim(sub_specialties_category)  == '' )
    {
        $('specialtiesErr').innerHTML = '( Specialty required! )';
        flag = 0 ;
    }
    
    if(trim(metroplitan_area)  == '' )
    {
        $('metroplitan_areaErr').innerHTML = '( Metropolitan area required! )';
        flag = 0 ;
    }
    
    if(trim(reference_source)  == '' )
    {
        $('reference_sourceErr').innerHTML = '( How doctor learned about us required! )';
        flag = 0 ;
    }
            
    if( flag == 1 )
        return true;
    else 
        return false;
}






//Validation for INVITE CODE checking STARTS here....
function checkCode() 
{   
    var part1=document.getElementById('part1').value;
    var part2=document.getElementById('part2').value;
    var part3=document.getElementById('part3').value;
    var part4=document.getElementById('part4').value;
    
    
    if( trim(part1)=="" || part1.length!="4" )
    {           
        document.getElementById('checkErr').innerHTML="Please enter 16 digits Invite code!";
        document.getElementById('part1').focus();
        document.getElementById('part1').value = document.getElementById('part1').value; 
    }
    else if( trim(part2)=="" || part2.length!="4" )
    {           
        document.getElementById('checkErr').innerHTML="Please enter 16 digits Invite code!";
        document.getElementById('part2').focus();
        document.getElementById('part2').value = document.getElementById('part2').value;  
    }
    else if( trim(part3)=="" || part3.length!="4" )
    {           
        document.getElementById('checkErr').innerHTML="Please enter 16 digits Invite code!";        
        document.getElementById('part3').focus();
        document.getElementById('part3').value = document.getElementById('part3').value;  
    }
    else if( trim(part4)=="" || part4.length!="4")
    {           
        document.getElementById('checkErr').innerHTML="Please enter 16 digits Invite code!";
        document.getElementById('part4').focus();
        document.getElementById('part4').value = document.getElementById('part4').value;  
    }    
    else
    {           
        document.getElementById('checkErr').innerHTML="";
        var icode=document.getElementById('part1').value+document.getElementById('part2').value+document.getElementById('part3').value+document.getElementById('part4').value;
        var url = 'check_invite_code.php?ic='+icode;      
        var myAjax = new Ajax.Request( url, {method: 'get', onLoading: showLoad, onComplete: showResponse} );
    }
} 
function showLoad () 
{

}
function showResponse (originalRequest) 
{
    /*result=trim(originalRequest.responseText);    
    if(result=="true")
    {
        document.getElementById('checkErr').innerHTML="";
        window.location="survey.php";
    }
    else if(result=="Invite code not match with our database!")
    {
        document.getElementById('checkErr').innerHTML="";
        window.location="surveyLogin.php";
    }
    else
    {
        document.getElementById('checkErr').innerHTML=result;
    }*/
    
    result_data=trim(originalRequest.responseText);        
    stateobj =result_data.split("*****");            
    if(stateobj.length>1)
    {
        var result=stateobj[0];
        if(result=="true")
        {
            var redirect_status=stateobj[1];
            document.getElementById('checkErr').innerHTML="";        
            if(redirect_status=="0" || redirect_status=="2")
            {
                window.location=secure_url+"/survey.php";
            }
            else
            {
                window.location=secure_url+"/survey_step1.php";    
            }
        }
        else if(result=="Invite code not match with our database!")
        {           
            document.getElementById('checkErr').innerHTML="";        
            //document.getElementById('ajaxloader').style.display='none';
            window.location="surveyLogin.php";
        }
        else if(result=="Invite code has been expired!")
        {   
            document.getElementById('checkErr').innerHTML=result;        
        }        
        else
        {
            document.getElementById('ajaxloader').style.display='none';
            document.getElementById('checkErr').innerHTML=result;        
        }
    }
    
}
//Validation for INVITE CODE checking ENDS here...

function surveyStep1_validation()
{ 
    var patient_reference   =    $('patient_reference').value;         
    var other_patient_refernce   =    $('other_patient_refernce').value;         
    var answer1   =    $('answer1').value;    
    var answer2   =    $('answer2').value;    
    var answer3   =    $('answer3').value;    
    var answer4   =    $('answer4').value;    
    var answer5   =    $('answer5').value;
    var answer6   =    $('answer6').value;
    var answer7   =    $('answer7').value;    
    
    $('patient_reference_ERR').innerHTML="";
    $('answer1_ERR').innerHTML="";
    $('answer2_ERR').innerHTML="";
    $('answer3_ERR').innerHTML="";
    $('answer4_ERR').innerHTML="";
    $('answer5_ERR').innerHTML="";
    $('answer6_ERR').innerHTML="";
    $('answer7_ERR').innerHTML="";

    if(trim(patient_reference) == '0' || trim(patient_reference) == '' || trim(patient_reference) == 'blank')
    {
        $('patient_reference_ERR').innerHTML    = '( Please answer this question ! )';                   
        $('patient_reference').focus();
        return false;
    }
    else if(trim(patient_reference) == '9' && (trim(other_patient_refernce)=="If other, please specify" || trim(other_patient_refernce)==""))
    {
        $('patient_reference_ERR').innerHTML    = '( If other, please specify ! )';                   
        $('other_patient_refernce').focus();
        return false;    
    }
    else if(trim(answer1) == '0' || trim(answer1) == '')
    {
        $('answer1_ERR').innerHTML    = '( Please answer this question! )';        
        $('answer1').value='0';        
        $('patient_reference').focus();
        return false;
    }
    else if(trim(answer2) == '0' || trim(answer2) == '')
    {
        $('answer2_ERR').innerHTML    = '( Please answer this question! )';
        $('answer2').value='0';        
        $('patient_reference').focus();
        return false;
    }
    else if(trim(answer3) == '0' || trim(answer3) == '')
    {
        $('answer3_ERR').innerHTML    = '( Please answer this question! )';
        $('answer3').value='0';        
        $('patient_reference').focus();
        return false;
    }
    else if(trim(answer4) == '0' || trim(answer4) == '')
    {
        $('answer4_ERR').innerHTML    = '( Please answer this question! )';
        $('answer4').value='0';        
        $('patient_reference').focus();
        return false;
    }
    else if(trim(answer5) == '0' || trim(answer5) == '')
    {
        $('answer5_ERR').innerHTML    = '( Please answer this question! )';
        $('answer5').value='0';        
        $('patient_reference').focus();
        return false;
    }
    else if(trim(answer6) == '0' || trim(answer6) == '')
    {
        $('answer6_ERR').innerHTML    = '( Please answer this question! )';
        $('answer6').value='0';        
        return false;
    }
    else if(trim(answer7) == '0' || trim(answer7) == '')
    {
        $('answer7_ERR').innerHTML    = '( Please answer this question! )';
        $('answer7').value='0';        
        return false;
    }
    else
    {
        return true;
    }
}

function surveyStep1_no_validation()
{ 
    var patient_reference   =    $('patient_reference').value;         
    var other_patient_refernce   =    $('other_patient_refernce').value;  
    
    $('patient_reference_ERR').innerHTML="";  

    if(trim(patient_reference) == '0' || trim(patient_reference) == '' || trim(patient_reference) == 'blank')
    {
        $('patient_reference_ERR').innerHTML    = '( Please answer this question ! )';                   
        $('patient_reference').focus();
        return false;
    }
    else if(trim(patient_reference) == '9' && (trim(other_patient_refernce)=="If other, please specify" || trim(other_patient_refernce)==""))
    {
        $('patient_reference_ERR').innerHTML    = '( If other, please specify ! )';                   
        $('other_patient_refernce').focus();
        return false;    
    }    
    else
    {
        return true;
    }
}

function surveyStep2_validation()
{       
    var answer9   =    $('answer9').value;    
    var answer10   =    $('answer10').value;    
    var answer11   =    $('answer11').value;    
    var answer12   =    $('answer12').value;    
    var answer13   =    $('answer13').value;
    var answer14   =    $('answer14').value;
    
    var dontknow9  =    $('dontknow9').checked;    
    var dontknow10  =    $('dontknow10').checked;
    var dontknow11  =    $('dontknow11').checked;
    var dontknow12  =    $('dontknow12').checked;
    var dontknow13  =    $('dontknow13').checked;
    var dontknow14  =    $('dontknow14').checked;
    
    $('answer9_ERR').innerHTML="";
    $('answer10_ERR').innerHTML="";
    $('answer11_ERR').innerHTML="";
    $('answer12_ERR').innerHTML="";
    $('answer13_ERR').innerHTML="";
    $('answer14_ERR').innerHTML="";    

    if(dontknow9==false)
    {
        if(trim(answer9) == '0' || trim(answer9) == '')
        {
            $('answer9_ERR').innerHTML    = '( Please answer this question! )';        
            $('answer9').value='0';        
            $('dontknow9').focus();
            return false;
        }
    }
    
    if(dontknow10==false)
    {
        if( trim(answer10) == '0' || trim(answer10) == '')
        {
            $('answer10_ERR').innerHTML    = '( Please answer this question! )';
            $('answer10').value='0'; 
            $('dontknow10').focus();        
            return false;
        }
    }
    
    if(dontknow11==false)
    {
        if(trim(answer11) == '0' || trim(answer11) == '')
        {
            $('answer11_ERR').innerHTML    = '( Please answer this question! )';
            $('answer11').value='0';        
            $('dontknow11').focus(); 
            return false;
        }
    }
    
    if(dontknow12==false)
    {
        if(trim(answer12) == '0' || trim(answer12) == '')
        {
            $('answer12_ERR').innerHTML    = '( Please answer this question! )';
            $('answer12').value='0';   
            $('dontknow12').focus();      
            return false;
        }
    }
    
    if(dontknow13==false)
    {
        if(trim(answer13) == '0' || trim(answer13) == '')
        {
            $('answer13_ERR').innerHTML    = '( Please answer this question! )';
            $('answer13').value='0';  
            $('dontknow13').focus();       
            return false;
        }
    }
    
    
    if(dontknow14==false)
    {
        if(trim(answer14) == '0' || trim(answer14) == '')
        {
            $('answer14_ERR').innerHTML    = '( Please answer this question! )';
            $('answer14').value='0';        
            $('dontknow14').focus(); 
            return false;
        }
    }
    
    return true;    
}


function surveyStep3_validation()
{       
    var answer15   =    $('answer15').value;    
    var answer16   =    $('answer16').value;    
    /*var answer17   =    $('answer17').value;    
    var answer18   =    $('answer18').value;    
    var answer19   =    $('answer19').value;
    var answer20   =    $('answer20').value;*/
    
    $('answer15_ERR').innerHTML="";
    $('answer16_ERR').innerHTML="";
    /*$('answer17_ERR').innerHTML="";
    $('answer18_ERR').innerHTML="";
    $('answer19_ERR').innerHTML="";
    $('answer20_ERR').innerHTML="";*/

    if(trim(answer15) == '')
    {
        $('answer15_ERR').innerHTML    = '( Information required! )';
        $('answer15').focus();
        return false;
    }
    else if(trim(answer15) > 200)
    {
        $('answer15_ERR').innerHTML    = '( Please enter less than 200 minutes! )';
        $('answer15').focus();
        return false;
    }
    else if(trim(answer16) == '')
    {
        $('answer16_ERR').innerHTML    = '( Information required! )';
        $('answer16').focus();
        return false;
    }
    else if(trim(answer16) > 200)
    {
        $('answer16_ERR').innerHTML    = '( Please enter less than 200 minutes! )';
        $('answer16').focus();
        return false;
    }
    /*else if(trim(answer17) == '')
    {
        $('answer17_ERR').innerHTML    = '( Information required! )';
        $('answer17').focus();
        return false;
    }
    else if(trim(answer18) == '')
    {
        $('answer18_ERR').innerHTML    = '( Information required! )';
        $('answer18').focus();
        return false;
    }
    else if(trim(answer19) == '')
    {
        $('answer19_ERR').innerHTML    = '( Information required! )';
        $('answer19').focus();
        return false;
    }
    else if(trim(answer20) == '')
    {
        $('answer20_ERR').innerHTML    = '( Information required! )';
        $('answer20').focus();
        return false;
    }*/
    else
    {
        return true;
    }
}

function surveyStep4_validation()
{       
    /*var age_Month   =    $('age_Month').value;
    var age_Day   =    $('age_Day').value;     
    var age_Year   =    $('age_Year').value;
    
    var visit_Month   =    $('visit_Month').value;
    var visit_Day   =    $('visit_Day').value;     
    var visit_Year   =    $('visit_Year').value; */   
    
    var family_income   =    $('family_income').value;  
    var education_level =  $('education_level').value;  
    
    
    
    var ethic = $('ethic').value; 
    var email = $('email').value;  
    var conf_email = $('conf_email').value;
    
           
    /*$('dobErr').innerHTML="";
    $('visit_dateErr').innerHTML="";   */
    $('family_incomeErr').innerHTML="";
    $('education_levelErr').innerHTML="";
    $('ethicErr').innerHTML="";
    $('emailErr').innerHTML="";
    $('conf_emailErr').innerHTML="";
    
    /*if(trim(age_Month) == '')
    {
        $('dobErr').innerHTML    = '( Please select month! )';
        $('age_Month').focus();
        return false;
    }
    else if(trim(age_Day) == '')
    {
        $('dobErr').innerHTML    = '( Please select day! )';
        $('age_Day').focus();
        return false;
    }
    else if(trim(age_Year) == '')
    {
        $('dobErr').innerHTML    = '( Please select year! )';
        $('age_Year').focus();
        return false;
    }
    else if(trim(visit_Month) == '')
    {
        $('visit_dateErr').innerHTML    = '( Please select month! )';
        $('visit_Month').focus();
        return false;
    }
    else if(trim(visit_Day) == '')
    {
        $('visit_dateErr').innerHTML    = '( Please select day! )';
        $('visit_Day').focus();
        return false;
    }
    else if(trim(visit_Year) == '')
    {
        $('visit_dateErr').innerHTML    = '( Please select year! )';
        $('visit_Year').focus();
        return false;
    }*/
    
    if(trim(family_income) == '')
    {
        $('family_incomeErr').innerHTML    = '( Please select yearly family income range! )';
        $('family_income').focus();
        return false;
    }
    else if(trim(education_level) == '')
    {
        $('education_levelErr').innerHTML    = '( Please select highest level of education! )';
        $('education_level').focus();
        return false;
    }
    else if(trim(ethic) == '')
    {
        $('ethicErr').innerHTML    = '( Please select race/ethnic! )';
        $('ethic').focus();
        return false;
    }     
    
    if(trim(email) != '')
    {    
        if(false==validateEmail(trim(email)))
        {
            $('emailErr').innerHTML    = '( Please enter valid email! )';
            $('email').focus();    
            return false;
        }
        if(trim(conf_email)=='')
        {
            $('conf_emailErr').innerHTML    = '( Please enter confirm email! )';
            $('conf_email').focus();    
            return false;    
        }
    }    
    
    if(trim(conf_email)!='')
    {   
        if(false==validateEmail(trim(conf_email)))
        {
            $('conf_emailErr').innerHTML    = '( Please enter valid confirm email! )';
            $('conf_email').focus();    
            return false;
        }   
        if(trim(email)=='')
        {
            $('emailErr').innerHTML    = '( Please enter email! )';
            $('email').focus();    
            return false;    
        }     
    }
    
    if( trim(email) != '' || trim(conf_email) != '' )
    {
        if(trim(email)!= trim(conf_email))
        {
            $('conf_emailErr').innerHTML    = '( Email not match with confirm email! )';
            $('conf_email').focus();   
            return false;    
        }   
    }
    
    return true;
}

function contactusFrm_validation()
{   
    var fullname   =    $('fullname').value;      
    var email = $('email').value;  
    var message = $('message').value;
    
    $('fullnameErr').innerHTML="";
    $('emailErr').innerHTML="";
    $('messageErr').innerHTML="";
    
    if(trim(fullname) == '')
    {
        $('fullnameErr').innerHTML    = '( Enter your full name! )';
        $('fullname').focus();
        return false;
    }
    
    if(trim(email)=='')
    {
        $('emailErr').innerHTML    = '( Enter Email! )';
        $('email').focus();    
        return false;    
    }
    else if(trim(email) != '')
    {    
        if(false==validateEmail(trim(email)))
        {
            $('emailErr').innerHTML    = '( Enter Valid Email! )';
            $('email').focus();    
            return false;
        }        
    }
    
    if(trim(message)=='')
    {
        $('messageErr').innerHTML    = '( Enter Message! )';
        $('message').focus();    
        return false;    
    }    
    return true;
}

function subscribeFrm_validation()
{          
    var subscribe_email = $('subscribe_email').value;          
    
    $('subscribe_emailErr').innerHTML="";                      
    
    if(trim(subscribe_email)=='')
    {
        $('subscribe_emailErr').innerHTML    = '( Enter Email! )';
        $('subscribe_email').focus();    
        return false;    
    }
    else if(trim(subscribe_email) != '')
    {    
        if(false==validateEmail(trim(subscribe_email)))
        {
            $('subscribe_emailErr').innerHTML    = '( Enter Valid Email! )';
            $('subscribe_email').focus();    
            return false;
        }        
    }
    return true;
}

function forgot_pwdFrm_validation()
{   
    var username = $('username').value;          
    var email = $('email').value;          
    
    $('usernameErr').innerHTML="";  
    $('emailErr').innerHTML=""; 
    
    if(trim(username)=='')
    {
        $('usernameErr').innerHTML    = '( Enter Username! )';
        $('username').focus();    
        return false;    
    }
    
    if(trim(email)=='')
    {
        $('emailErr').innerHTML    = '( Enter Email! )';
        $('email').focus();    
        return false;    
    }
    else if(trim(email) != '')
    {    
        if(false==validateEmail(trim(email)))
        {
            $('emailErr').innerHTML    = '( Enter Valid Email! )';
            $('email').focus();    
            return false;
        }        
    }
    return true;
}




//################################################################################
//Use : This function is used to validate the String according to a type
//Arguments 
//str: string to validate
//type: type of string
//#################################################################################
function validateString(str, type)
{
    //var entityStr = EntitiesToText("&#192;&#193;&#194;&#195;&#196;&#197;&#198;&#199;&#200;&#201;&#202;&#203;&#204;&#205;&#206;&#207;&#208;&#209;&#210;&#211;&#212;&#213;&#214;&#217;&#218;&#219;&#220;&#221;&#224;&#225; &#226;&#227;&#228;&#229;&#231;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#241;&#242;&#243;&#244;&#245;&#246;&#249;&#250;&#251;&#252;&#253;&#255;&#256;&#257;&#258;&#259;&#260;&#261;&#262;&#263;&#264;&#265;&#266;&#267;&#268;&#269;&#270;&#271;&#272;&#273;&#274;&#275;&#276;&#277;&#278;&#279;&#280;&#281;&#282;&#283;&#284;&#285;&#286;&#287;&#288;&#289;&#290;&#291;&#292;&#293;&#294;&#295;&#296;&#297;&#298;&#299;&#300;&#301;&#302;&#303;&#304;&#305;&#306;&#307;&#308;&#309;&#310;&#311;&#312;&#313;&#314;&#315;&#316;&#317;&#318;&#319;&#320;&#321;&#322;&#323;&#324;&#325;&#326;&#327;&#328;&#329;&#330;&#331;&#332;&#333;&#334;&#335;&#336;&#337;&#338;&#339;&#340;&#341;&#342;&#343;&#344;&#345;&#346;&#347;&#348;&#349;&#350;&#351;&#352;&#353;&#354;&#355;&#356;&#357;&#358;&#359;&#360;&#361;&#362;&#363;&#364;&#365;&#366;&#367;&#368;&#369;&#370;&#371;&#372;&#373;&#374;&#375;&#376;&#377;&#378;&#379;&#380;&#381;&#382;&#383;");
    //alert(entityStr);
    if(type == "strspace")                //Only Characters and Spaces are allowed
        reg = "^[A-Za-z\\s]*$";
    
    if(type == "str")                    //Only Characters are allowed
        reg = "^[A-Za-z]*$";
    
    if(type == "strnumspace")            //Only Characters, number and Spaces are allowed
        reg = "^[A-Za-z0-9\\s]*$";
    
    if(type == "strnum")                //Only Characters and numbers are allowed
        reg = "^[A-Za-z0-9]*$";
    
    if(type == "userid")                //Only Characters and Numbers are allowed but first letter should be character
        reg = "^[A-Za-z]+[A-Za-z0-9]*$";
    
    if(type == "numspace")                //Only Characters and Spaces are allowed
        reg = "^[0-9\\s]*$";
    
    if(type == "num")                    //Only Numbers are allowed
        reg = "^[0-9]*$";
    
    if(type == "spacebetween")            //Only Spaces are there in Between
        reg = "[\\s]+";
    
    if(type == "email")                    //Valid Email ID a@b.c
        reg = "^(([a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9])|([a-zA-Z0-9]))@(([a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9])|([a-zA-Z]))\\.(([a-zA-Z][a-zA-Z\\.]*[a-zA-Z])|([a-zA-Z]))$";
    
    if(type == "telephone")                //Valid Telephone Number     + (91) (120) 3054300
        reg = "^((\\+{0,1}([0-9\\s\\-\\.])*[0-9]+))$";
    
    if(type == "weburl")                //Valid Web URL
        reg = "^(www\\.){1}(([a-zA-Z0-9][\\w\\.\\-]*[a-zA-Z0-9])|([a-zA-Z]))\\.(([a-zA-Z][a-zA-Z\\.]*[a-zA-Z])|([a-zA-Z]))$";

    if(type == "strnumspacedot")        //Only Characters, number, spaces and dot are allowed
        reg = "^[A-Za-z0-9\\s\\.]*$";
    
    if(type == "address")
        reg = "^[A-Za-z0-9\\s\\.&\-\/:\\\\]*$";
    
    //alert(reg);
    str = trim(str);
    var myReg = new RegExp(reg);
    return str.match(myReg);
}

//#########################################################################################
// Use : this function allow to insert only digits into the text box
// Arguments : event on the text box element of the form to which this function is associated
//#########################################################################################

function onlyDigits(e)
{
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if(String.fromCharCode(whichCode) != ' ' && String.fromCharCode(whichCode) >= 0 && String.fromCharCode(whichCode) <= 9)
        return true;
    return false;
}       

//Function to trim the space in the left side of the string
function ltrim ( s )
{
    return s.replace( /^\s*/, "" );
}

//Function to trim the space in the right side of the string
function rtrim ( s )
{
    return s.replace( /\s*$/, "" );
}

//Function to trim the space in the  string
function trim(s)
{
    var temp = s;
       return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}

// Function to change the focus of the textbox when it reach to its maxlength.
function changefocus( original, destination )
{
    if (original.getAttribute && original.value.length==original.getAttribute("maxlength"))
        destination.focus();
}

//Function to test string passed as argument is integer or not
function isInteger(s)
{
    var i;
    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function changefocus( original, destination )
{
    if (original.value.length==original.getAttribute("maxlength"))
    {
        destination.focus();
    }
}


function validateEmail(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
    {
      return true;
    }
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
        var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
        if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}


function ajaxpage(url, c_id)
{
    var page_request = false 
    if (window.XMLHttpRequest)     // if Mozilla, Safari etc
    {
        page_request = new XMLHttpRequest()
    }
    else if (window.ActiveXObject) // if IE
    {
        try
        {
            page_request = new ActiveXObject("Msxml2.XMLHTTP")            
        }
        catch (e)
        {
            try
            {
                page_request = new ActiveXObject("Microsoft.XMLHTTP")                
            }
            catch (e){}
        }
    }
    else
        return false 
            

    page_request.onreadystatechange=function()
    {
        loadpage(page_request, c_id)
    }


    anticache=(url.indexOf("?")!=-1) ? "&"+new Date().getTime() : "?"+new Date().getTime()

    page_request.open('GET', url+anticache, true)

    page_request.send(null)

}
 
function loadpage(page_request, c_id)
{
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    {
        document.getElementById(c_id).innerHTML=page_request.responseText
    }
}

//Examples How to call the following functions:
//removeAllOptions(document.formx.month);
//addOption(document.formx.month, "", "[Month]");
//addOption(document.formx.month, "01", "January");

function removeAllOptions(selectbox)
{
    var i;
    for(i=selectbox.options.length-1;i>=0;i--)
    {
        //selectbox.options.remove(i);
        selectbox.remove(i);
    }
}

function addOption(selectbox, value, text )
{
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;

    selectbox.options.add(optn);
}

function addOption_selected(selectbox, value, text )
{
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    optn.selected=true;
    selectbox.options.add(optn);
}        

function displayHideId(id)
{
    if(document.getElementById(id).style.display == 'none')
    {
       document.getElementById(id).style.display = 'inline'; 
    }
    else if(document.getElementById(id).style.display == 'inline')
    {
       document.getElementById(id).style.display = 'none'; 
    }    
}

function divManager(show_id,hide_id)
{       
    if(document.getElementById(hide_id).style.display == 'inline')
    {
       document.getElementById(hide_id).style.display = 'none'; 
    }
    
    if(document.getElementById(show_id).style.display == 'none')
    {
       document.getElementById(show_id).style.display = 'inline'; 
    }    
        
}


//code used for Doctor Details Confirmation STARTS here...     TEMPORARY BLOCK SO... DON'T DELETE THIS CODE
/*function DoctorDetailsConfirmation(msg)
{   
    
    if(confirm(msg))
    {   
        var confirm_value='yes';              
    }
    else        
    {
        var confirm_value='no';               
    }
    var url = 'update_survey_status.php?con='+confirm_value;
    var myAjax = new Ajax.Request( url, {method: 'get', onLoading: showLoadDoctorDetailsConfirmation, onComplete: showResponseDoctorDetailsConfirmation} );
    
}*/  

function showLoadDoctorDetailsConfirmation () 
{
}

function showResponseDoctorDetailsConfirmation (originalRequest) 
{
    result=trim(originalRequest.responseText);        
    switch(result)
    {
        case '1':
            window.location=secure_url+"/survey_step1.php";
            break;
        case '2':
            window.location=secure_url+"/confirm_doctor.php";
            //window.location="doctorsSearch.php";
            break;
    }    
}

function confirmDoctorFrm_validation()
{       
    var confirm_value=getCheckedValue(document.confirmDoctorFrm.confirm_doctor_details);          
    var url = 'update_survey_status.php?con='+confirm_value;
    var myAjax = new Ajax.Request( url, {method: 'get', onLoading: showLoadDoctorDetailsConfirmation, onComplete: showResponseDoctorDetailsConfirmation} );    
}
//code used for Doctor Details Confirmation ENDS here... 

function mapConfirmDoctorFrm_validation()
{   
    var confirm_value=getCheckedValue(document.mapConfirmDoctorFrm.DoctorID_to_map);        
    if(confirm_value=="")
    {
        $('search_next_ERR').innerHTML="Please select doctor to confirm!";
        return false;
    }
    else
    {
        $('search_next_ERR').innerHTML="";
        return true;    
    }
}

function getCheckedValue(radioObj) 
{
    if(!radioObj)
        return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
        if(radioObj.checked)
            return radioObj.value;
        else
            return "";
    for(var i = 0; i < radioLength; i++) {
        if(radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}




    





















function validateMenuCategory()
{
      var title      =    $('title').value;
      /*var description      =    $('description').value;*/
      
      //      $('showMessage').innerHTML = '';
      if(trim(title) == '')
      {
        $('titleErr').innerHTML    = '( Title required! )';
        return false;
      }
      /*if(trim(description) == '')
      {
        $('descErr').innerHTML    = '( Descritpion required! )';
        return false;
      }*/
      return true;
}




function Validate_Commercialfrm()
{
    var indicative_bid_date      =    $('indicative_bid_date').value;    
    var final_bid_date     =    $('final_bid_date').value;
    
    $('indicative_bid_dateErr').innerHTML = '';
    $('final_bid_dateErr').innerHTML = '';
    
    if(trim(indicative_bid_date) == '')
    {
        $('indicative_bid_dateErr').innerHTML    = '( Indicative Bid Date required! )';
        return false;
    }
    
    if(trim(final_bid_date) == '')
    {
        $('final_bid_dateErr').innerHTML    = '( Final Bid Date required! )';
        return false;
    }
    
    return true;
}

function Validate_Residentialfrm()
{
    var indicative_bid_date      =    $('indicative_bid_date').value;    
    var final_bid_date     =    $('final_bid_date').value;
    
    $('indicative_bid_dateErr').innerHTML = '';
    $('final_bid_dateErr').innerHTML = '';
    
    if(trim(indicative_bid_date) == '')
    {
        $('indicative_bid_dateErr').innerHTML    = '( Indicative Bid Date required! )';
        return false;
    }
    
    if(trim(final_bid_date) == '')
    {
        $('final_bid_dateErr').innerHTML    = '( Final Bid Date required! )';
        return false;
    }
    
    return true;
}

function validateTransactionCategory()
{   
    var label      =    $('label').value;
    var classification  =  $('classification').value;
    var location      =    $('location').value;        
    var menuID     =    $('mainMenu').value;

    $('mainMenuErr').innerHTML = '';
    $('labelErr').innerHTML = '';
    $('classificationErr').innerHTML = '';
    $('locationErr').innerHTML = '';    

    if(menuID==0)
    {        
        $('mainMenuErr').innerHTML    = '( Select Transaction Type! )';
        return false;
    }    

    if(trim(label) == '')
    {
        $('labelErr').innerHTML    = '( Label required! )';
        return false;
    }
    
    if(trim(classification) == '')
    {
        $('classificationErr').innerHTML    = '( Classification required! )';
        return false;
    }
    
    if(trim(location) == '')
    {
        $('locationErr').innerHTML    = '( Location required! )';
        return false;
    }

    return true; 
}

function validateAboutUsCategory()
{
    var menuID     =    $('mainMenu').value;
    var name   =    $('name').value;    
    var title      =    $('title').value;
    
    $('mainMenuErr').innerHTML = '';    
    $('name_headingErr').innerHTML = '';
    $('titleErr').innerHTML = '';
    

    if(menuID==0)
    {        
        $('mainMenuErr').innerHTML    = '( Select About Us Type! )';
        return false;
    }    

    if(trim(name_heading) == '')
    {
        $('name_headingErr').innerHTML    = '( Name / Heading required! )';
        return false;
    }
    
    if(trim(title) == '')
    {
        $('titleErr').innerHTML    = '( Title required! )';
        return false;
    }
    
    return true;
}

function validateServices()
{
    var menuID     =    $('mainMenu').value;
    var label   =    $('label').value;        
    
    $('mainMenuErr').innerHTML = '';    
    $('labelErr').innerHTML = '';        

    if(menuID==0)
    {        
        $('mainMenuErr').innerHTML    = '( Select About Us Type! )';
        return false;
    }    

    if(trim(label) == '')
    {
        $('labelErr').innerHTML    = '( Label required! )';
        return false;
    }
    
    return true;
}

function validateMissionTeam()
{   
    
    var name   = $('name').value;    
    var title  = $('title').value;
    var email  = $('email').value;
    
    $('nameErr').innerHTML = '';
    $('titleErr').innerHTML = '';
    $('emailErr').innerHTML = '';

    if(trim(name) == '')
    {
        $('nameErr').innerHTML    = '( Name required! )';
        return false;
    }
    
    if(trim(title) == '')
    {
        $('titleErr').innerHTML    = '( Title required! )';
        return false;
    }
    
    if(trim(email) == '')
    {
        $('emailErr').innerHTML    = '( Email required! )';
        return false;
    }
    else
    {
        if(false==validateEmail(email))
        {
            $('emailErr').innerHTML    = '( Enter Valid Email! )';
            return false;
        }
    }
    
    return true;
}

/*function show_content ( url ) 
{   
    var myAjax = new Ajax.Request( url, {method: 'get', onSuccess: function(transport){
      var response = transport.responseText || "no response text";
      //$('testdiv').innerHTML=  response;  
      var data     =    response.split('***');
      var emp_id =  data[0];
      var name_heading =  data[1];
      var emp_title =  data[2];
      var emp_desc =  data[3];
      var emp_image =  data[4];
      $('name_heading_id').innerHTML=name_heading;
      var image_str = "<img src=admin/"+emp_image+" width=100 height=100 style='filter:alpha(opacity=100);-moz-opacity:1.0; opacity:1.0;'>";        
      $('imageid').innerHTML= image_str;       
      $('emp_title_id').innerHTML= emp_title;       
      $('emp_desc_id').innerHTML= emp_desc;             
      //alert("Success! \n\n" + response);
      //$('imageid').innerHTML=emp_image;
    },
    onFailure: function(){ alert('Something went wrong...') } } );
}

Effect.OpenUp = function(element) {
     element = $(element);
     new Effect.BlindDown(element, arguments[1] || {});
 }

 Effect.CloseDown = function(element) {
     element = $(element);
     new Effect.BlindUp(element, arguments[1] || {});
 }

 Effect.Combo = function(element) {
     element = $(element);
     if(element.style.display == 'none') { 
         new Effect.OpenUp(element, arguments[1] || {});  
     }else { 
          new Effect.CloseDown(element, arguments[1] || {}); 
     }
 } */

 
function myscroller(element)
{
    element = $(element);     
    //alert(element.innerHTML);
    document.getElementById('movecontent').innerHTML=element.innerHTML;    
    
    /*var  scroll = {    
        top: function(event) { new Effect.ScrollTo('top'); },
        bottom: function(event) 
        {
            
            new Effect.ScrollTo('footer'); 
        }
    }    
    scroll.top();*/
    new Effect.ScrollTo('top'); 
}



/*function show_content1 ( url ) 
{   
    var myAjax = new Ajax.Request( url, {method: 'get', onLoading: tabLoad, onComplete: tabResponse } );
}

function tabLoad () 
{
    //$('tabLoad').style.display = 'block';
}
function tabResponse (originalRequest) {
    var    resp    =    originalRequest.responseText;
    $('testdiv').innerHTML=  resp;
    
    
    var data     =    resp.split('**');
    var newData =  data[0];
       $('fNm').value='';
    //alert(data[1]);
    //alert(resp);
    
    $('tabLoad').style.display = 'none';
    $('tabDetail').innerHTML = newData;
    $('FID').value         =    data[1];    
    $('F_TYPE').value    =    data[2];
    $('ftype').value    =   data[1];
    //$('Title').value    =    data[2];
    $('searchTabs').innerHTML=  data[3];
    $('searchLabel').innerHTML=  data[4];
    
}*/

//Function to check Multiple checkbox on single click.
// Method of calling onClick = "Javascript:checkAll(document.from.fieldName, this.checked );" 
function checkAll( field , val )
{
	if( val == true )
    {
        if( field.length )
		{
			for(i=0; i<field.length; i++)
			{
				field[i].checked = true; 
			}
		}
		else if( field )
		{
			field.checked = true;
		}

    }
    else
    {
        if( field.length )
		{
			for(i=0; i<field.length; i++)
			{
				field[i].checked = false;
			}
		}
		else if ( field )
		{
			field.checked = false;
		}
    }
}

//Function to show error Message on the Span WHen validation error occur.
function errMsg( divID , value , msg ,className )
{
    if( trim ( value )  == '' || trim( value ) == 0)
    {
        $(divID).innerHTML = msg; 
    }
    else
    {
        $(divID).innerHTML = '';
    }
}

//function change class will change the classs of the input box

//Function to show error Message on the Span WHen validation error occur.
function changeClass( eleID , spanID,  value , msg )
{
    var app          =    navigator.appName;
    var IE           =  'Microsoft Internet Explorer';
    var FF           =  'Netscape';
    if( trim ( value )  == '' || trim( value ) == 0)
    {
        if( app == FF )
            $(eleID).setAttribute('class','inputbox-error');
        else if( app == IE )
            $(eleID).setAttribute('className','inputbox-error');
        else
            $(spanID).innerHTML = msg; 
    }
    else
    {
        if( app == FF )
            $(eleID).setAttribute('class','inputbox');
        else if( app == IE )
            $(eleID).setAttribute('className','inputbox');
        else
            $(spanID).innerHTML = '';
    }
}


function validateCombo( divID, comboID , msg )
{
    var combo    =     $(comboID);
    if( combo.selectedIndex == 0 || combo.selectedIndex == -1 )
    {
        $(divID).innerHTML = msg;
    }
    else
    {
        $(divID).innerHTML = '';
    }
}





/////////////////////////////////////////////////////////////////////////////


function validate_basic_firm()
{
    
    var area     =     $('areaID').selectedIndex;
    var catID    =     $('categoryID');
    var cat      =     $('category');
    var comp     =     $('company').value;
    var addr     =     $('address').value;
    var city     =     $('city').value;
    var state    =     $('state').value;
    var zip      =     $('postalCode').value;
    var flag     =     true;
    if(area == 0 )
    {
        $('areaErr').innerHTML = '( Area required ! )';
        flag  = false;
    }
    if( catID.options.length == 0 )
    {
        $('catErr').innerHTML = '( Category required ! )';
        flag  = false;
    }
    if( cat.options.length == 0 )
    {
        $('catErr').innerHTML = '( Cannot select all category ! )';
        flag  = false;
    }
    if( trim( comp ) == '' )
    {
        $('compErr').innerHTML = '( Company required ! )';
        flag  = false;
    }
    if( trim( addr ) == '' )
    {
        $('addrErr').innerHTML = '( Address required ! )';
        flag  = false;
    }
    if( trim( city ) == '' )
    {
        $('cityErr').innerHTML = '( City required ! )';
        flag  = false;
    }
    if( trim( state ) == '' )
    {
        $('stateErr').innerHTML = '( State required ! )';
        flag  = false;
    }
	if( trim( zip ) == '' )
    {
        $('postalCodeErr').innerHTML = '( Postal Code required ! )';
        flag  = false;
    }
    if( flag )
    {
        for( i=0; i<catID.options.length; i++ )
        {
            catID.options[i].selected = true;
        }
        return true;
    }
    else
    {
        return false;
    }
}

function validate_moderate_basic_firm()
{
    if ( validate_basic_firm() ) 
    {
        if ( trim ( $('adminComment').value ) == '' )
        {
            $('commentErr').innerHTML = 'Your comment required';
            return false;
        }
        else
        {
            return true;
        }
    }
}

function validate_featured_firm()
{
    
    var areaID   =     $('areaID');
    var catID    =     $('categoryID');
    var cat      =     $('category');
    var area     =     $('area');
    
    var flag     =     true;
    if(areaID.options.length == 0 )
    {
        $('areaErr').innerHTML = '( Area required ! )';
        flag  = false;
    }
    if( catID.options.length == 0 )
    {
        $('catErr').innerHTML = '( Category required ! )';
        flag  = false;
    }
    if( cat.options.length == 0 )
    {
        $('catErr').innerHTML = '( Cannot select all category ! )';
        flag  = false;
    }
    else if( catID.options.length > 0 )
    {
       $('catErr').innerHTML = '';
    }
    if( area.options.length == 0 )
    {
        $('areaErr').innerHTML = '( Cannot select all area ! )';
        flag  = false;
    }
    else if( areaID.options.length > 0 )
    {
       $('areaErr').innerHTML = '';
    }
    if( flag )
    {
        for( i=0; i<catID.options.length; i++ )
        {
            catID.options[i].selected = true;
        }
        for( i=0; i<areaID.options.length; i++ )
        {
            areaID.options[i].selected = true;
        }
        return true;
    }
    else
    {
        return false;
    }
}


 
function validateLogin ( ) 
{    
    var loginID      =    $('chk_loginID').value;
    var pass1        =    $('chk_password').value;
    var flag         =    1;
    var app          =    navigator.appName;
    var IE           =  'Microsoft Internet Explorer';
    var FF           =  'Netscape';
    if( trim(loginID) == '' )
    {
        if( app == FF )
            $('chk_loginID').setAttribute('class','inputbox-error');
        else if( app == IE )
            $('chk_loginID').setAttribute('className','inputbox-error');
        else
            $('chk_loginErr').innerHTML = '( loginID required )';
        flag = 0 ;
    }
    if( trim (pass1) == '' )
    {
        if( app == FF )
            $('chk_password').setAttribute('class','inputbox-error');
        else if ( app == IE )
            $('chk_password').setAttribute('className','inputbox-error');
        else
            $('chk_passErr').innerHTML   = '( Password required! )';
        flag = 0 ;
    }
   
    if( flag == 1 )
        return true;
    else 
        return false;
} 



function validateArea()
{
      var area      =    $('area').value;
      if( trim(area) == '' )
      {
        $('areaErr').innerHTML    = '( Area required! )';
        return false;
      }
      return true;
}

function validateTitle()
{
      var title      =    $('title').value;
      var desc      =     $('desc').value;
      $('showMessage').innerHTML = '';
      if(trim(title) == '')
      {
        $('titleErr').innerHTML    = '( Title required! )';
        $('descErr').innerHTML    = '';
        return false;
      }
      if(trim(desc) == '')
      {
        $('titleErr').innerHTML    = '';
        $('descErr').innerHTML    = '( Description required! )';
        return false;
      }
      return true;
}

function validateTaxForm()
{
      var title     =    $('title').value;
      var desc      =     $('desc').value;
      var pdfFile   =     $('frmProductImage').value;
      $('showMessage').innerHTML = '';

      if(trim(title) == '')
      {
        $('titleErr').innerHTML    = '( Title required! )';
        $('descErr').innerHTML    = '';
        return false;
      }

      if(trim(desc) == '')
      {
        $('titleErr').innerHTML    = '';
        $('descErr').innerHTML    = '( Description required! )';
        return false;
      }
      
      if(trim(pdfFile) == '')
      {
        $('fileErr').innerHTML    = '';
        $('fileErr').innerHTML    = '( File required! )';
        return false;
      }
      return true;
}

function enable_disable(val)
{
    var list  = document.forms['form'].elements['listingType']; 
    var chk1  = $('jobPosting');
    var chk2  = $('classified');
    var chk3  = $('profOpp');
    
    if( val == 1  )
    {
        list[0].disabled = true;
        list[1].disabled = true;
        chk1.disabled = true;
        chk2.disabled = true;
        chk3.disabled = true;
    }
    else if ( val == 2 )
    {
        list[0].disabled = false;
        list[1].disabled = false;
        chk1.disabled = false;
        chk2.disabled = false;
        chk3.disabled = false;
    }
}





function changePassword()
{
    var oldPass  =     $('oldPassword').value;
    var newPass  =     $('newPassword').value;
    var confPass =     $('confPassword').value;
    var flag     =     true;
    var app      =     navigator.appName;
    var IE       =    'Microsoft Internet Explorer';
    var FF       =    'Netscape';
    
    if( trim( oldPass ) == '' )
    {
        if( app == FF )
            $('oldPassword').setAttribute('class','inputbox-error');
        else if ( app == IE )
            $('oldPassword').setAttribute('className','inputbox-error');
        else
            $('oldErr').innerHTML = '( Current password required ! )';
        flag  = false;
    }
    if( trim( newPass ) == '' )
    {
        if( app == FF )
            $('newPassword').setAttribute('class','inputbox-error');
        else if ( app == IE )
            $('newPassword').setAttribute('className','inputbox-error');
        else
            $('newErr').innerHTML = '( New password required ! )';
        flag  = false;
    }
    if( trim( confPass ) == '' )
    {
        if( app == FF )
            $('confPassword').setAttribute('class','inputbox-error');
        else if ( app == IE )
            $('confPassword').setAttribute('className','inputbox-error');
        else
            $('confErr').innerHTML = '( Confirm password required ! )';
        flag  = false;
    }
    if( trim( newPass ) !=  trim( confPass ) )
    {
        if( app == FF )
            $('confPassword').setAttribute('class','inputbox-error');
        else if ( app == IE )
            $('confPassword').setAttribute('className','inputbox-error');
        else
            $('confErr').innerHTML = '( Confirm password doesnot match ! )';
        flag  = false;
    }
    if( flag )
    {
        return true;
    }
    else
    {
        return false;
    }
}






function showWindow(URL,ID)
{
  win = new Window( { className: 'spread', url: URL, title: "Email Form", width:100, height:400, destroyOnClose: true, recenterAuto:false } ); 
  win.showCenter();
}


function showJobDesc(URL,jobTitle)
{
  //alert(URL);
  win = new Window( { className: 'spread', url: URL, title: "Accounting Job Section", width:200, height:500, destroyOnClose: true, recenterAuto:false } ); 
  win.showCenter();
}

function showClassifiedDesc(URL,jobTitle)
{
  //alert(URL);
  win = new Window( { className: 'spread', url: URL, title: "Classifieds Section", width:200, height:500, destroyOnClose: true, recenterAuto:false } ); 
  win.showCenter();
}

function checkNewsletterForm() 
{    
    var fName        =    $('firstname').value;
    var email        =    $('email').value;
    if(trim(fName)  == '')
    {
        alert('First Name required!');
        $('firstname').focus();
        return false;
    }
    if(trim(email)  == '')
    {
        alert('Email address required!');
        $('email').focus();
        return false;
    }
    if( trim(email) != '')
    {
        if( !validateEmail(email) )
        {
            alert('Email address is invalid !');
            $('email').focus();
            return false;
        }
    }
    return true;
}

function checkEnquiryForm() 
{ 
    var name        =    document.getElementById('name').value;
    var email       =    document.getElementById('email').value;
    var message     =    document.getElementById('message').value; 
    document.getElementById('emailspan').style.display = 'none';
    if(trim(name)  == '')
    {
        document.getElementById('namespan').style.display = '';
        document.getElementById('name').focus();
        return false;
    }
    else
    {
        document.getElementById('namespan').style.display = 'none';
    }
    
    if(trim(email)  == '')
    {
        document.getElementById('emailspan').style.display = '';
        document.getElementById('email').focus();
        return false;
    }

    if( trim(email) != '')
    {
        if( !validateEmail(email) )
        {
            document.getElementById('emailspan').style.display = '';
            document.getElementById('emailspan').innerHTML = '<label class="error">(Email address is invalid!)<label>';
            document.getElementById('email').focus();
            return false;
        }
    }
    else
    {
        //document.getElementById('emailspan').innerHTML = '';
        document.getElementById('emailspan').style.display = 'none';
    }
    
    if(trim(message)  == '')
    {
        document.getElementById('messagespan').style.display = '';
        document.getElementById('message').focus();
        return false;
    }
    else
    {
        document.getElementById('messagespan').style.display = '';
    }
    return true;
}


function phone_counter( URL, phoneNo, phoneExt )
{
     var phExt  = '';
     if( phoneExt != '' )
     {
        phExt = '( '+ phoneExt +' )';
     }
     phoneNo  =   phoneNo + phExt;
     if( phoneNo == '' )
     {
        phoneNo = 'N.A';
     }
     $('phone').innerHTML = phoneNo;
     
     var myAjax = new Ajax.Request( URL, { method: 'get', onLoading: load, onComplete: response } );
}

function load()
{

}

function response (originalRequest) {
    var    resp    =    originalRequest.responseText;
}

//made by viney goel on 16 july to validate job posting form
function validateJobPostingForm()
{
    var cat     =     $('cat').value;
    var title   =     $('title').value;
    var desc    =       $('desc').value;
    var flag    =     true;
    var app     =    navigator.appName;
    var IE      =  'Microsoft Internet Explorer';
    var FF      =  'Netscape';
   
    if( trim(cat) == 0 )
    {
        if( app == FF )
        {
            $('cat').setAttribute('class','inputbox-error'); 
            $('categoryErr').innerHTML = '( Category required ! )';
        }
        else if ( app == IE )
        {
            $('cat').setAttribute('className','inputbox-error');
            $('categoryErr').innerHTML = '( Category required ! )';
        }
        else
        {
            $('categoryErr').innerHTML = '( Category required ! )';
        }
        flag  = 0;
    }
    else
    {
        $('categoryErr').innerHTML = '';
    }
     
    
    if( trim( title ) == '' )
    {
        if( app == FF )
        {
            $('title').setAttribute('class','inputbox-error');
            $('titleErr').innerHTML = '( Title required ! )';
        }
        else if ( app == IE )
        {
            $('title').setAttribute('className','inputbox-error');
            $('titleErr').innerHTML = '( Title required ! )';
        }
        else
            $('titleErr').innerHTML = '( Title required ! )';
            flag  = false;
    }
    else
    {
        $('titleErr').innerHTML = '';
    }
    
    if( trim( desc ) == '' )
    {
        if( app == FF )
        {
            $('desc').setAttribute('class','inputbox-error');
            $('descErr').innerHTML = '( Description required ! )';
        }
        else if ( app == IE )
        {
            $('desc').setAttribute('className','inputbox-error');
            $('descErr').innerHTML = '( Description required ! )';
        }
        else
            $('descErr').innerHTML = '( Description required ! )';
        flag  = false;
    }
    else
    {
            $('descErr').innerHTML = '';
    }
    
    if( flag )
    {
        return true;
    }
    else
    {
        return false;
    }
}


function validateRequestAccountant()
{
    var cat     =     $('categoryID').selectedIndex;
    var name    =     $('name').value;
    var email   =     $('emailID').value;
    var desc    =     $('comment').value;
    var flag    =     true;
    var app     =     navigator.appName;
    var IE      =     'Microsoft Internet Explorer';
    var FF      =     'Netscape';
   
    
    
    if(trim(name)  == '' )
    {
        if( app == FF )
            $('name').setAttribute('class','inputbox-error'); 
        else if ( app == IE )
            $('name').setAttribute('className','inputbox-error');
        else
            $('nameErr').innerHTML = '( Email required ! )';
        flag  = 0;
    }
     
    if(trim(email)  == '' )
    {
        if( app == FF )
            $('emailID').setAttribute('class','inputbox-error'); 
        else if ( app == IE )
            $('emailID').setAttribute('className','inputbox-error');
        else
            $('emailErr').innerHTML = '( Email required ! )';
        flag  = 0;
    }
    
    if( trim(email) != '')
    {
        if( !validateEmail(email) )
        {
            if( app == FF )
                $('emailID').setAttribute('class','inputbox-error'); 
            else if ( app == IE )
                $('emailID').setAttribute('className','inputbox-error');
            else
                $('emailErr').innerHTML = '( Invalid Email ! )';
            flag = 0 ;
        }
    }
    
    if( cat == 0 )
    {
        if( app == FF )
            $('categoryID').setAttribute('class','inputbox-error'); 
        else if ( app == IE )
        {
            $('categoryID').setAttribute('className','inputbox-error');
            $('categoryErr').innerHTML = '( Required ! )';
        }
        else
            $('categoryErr').innerHTML = '( Category required ! )';
        flag  = 0;
    }

    if( trim( desc ) == '' )
    {
        if( app == FF )
            $('comment').setAttribute('class','inputbox-error');
        else if ( app == IE )
            $('comment').setAttribute('className','inputbox-error');
        else
            $('commentErr').innerHTML = '( Comment required ! )';
            flag  = false;
    }
    
    if( flag )
    {
        return true;
    }
    else
    {
        return false;
    }
}

function search_validation( )
{
	var areaID  =    document.getElementById('area').selectedIndex;
	var catID   =    document.getElementById('category').selectedIndex;
	if( areaID == 0 && catID == 0 )
	{
		alert('Please select area or category');
		return false;
	}
	return true;
}

function statsWindow(url)
{
	var newpopup  = window.open(url,'newpopupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=800,height=400,screenX=50,screenY=50,top=50,left=50');
	newpopup.focus();
}

function view_counter ( url ) 
{	
	var myAjax = new Ajax.Request( url, {method: 'get', onLoading: tabLoad, onComplete: tabResponse} );
}

function tabLoad () 
{

}
function tabResponse (originalRequest) 
{
	var	URL		=	trim(originalRequest.responseText);
	if( URL != '' )
	{
		window.open( URL );
	}
}

function validatePass()
{
    var oldPass  =     $('oldPassword').value;
    var newPass  =     $('newPassword').value;
    var confPass =     $('confPassword').value;
    var flag     =     true;
    
    if( trim( oldPass ) == '' )
    {
        
        $('oldPassErr').innerHTML = '( Current password required ! )';
        flag  = false;
    }
	else
	{
		$('oldPassErr').innerHTML = '';
	}
    if( trim( newPass ) == '' )
    {
        $('newPassErr').innerHTML = '( New password required ! )';
        flag  = false;
    }
	else
	{
		$('newPassErr').innerHTML = '';
	}
    if( trim( confPass ) == '' )
    {
        $('confPassErr').innerHTML = '( Confirm password required ! )';
        flag  = false;
    }
	else
	{
		$('confPassErr').innerHTML = '';
	}
    if( trim( newPass ) !=  trim( confPass ) )
    {
        $('confPassErr').innerHTML = '( Confirm password doesnot match ! )';
        flag  = false;
    }
	else
	{
		$('confPassErr').innerHTML = '';
	}
    if( flag )
    {
        return true;
    }
    else
    {
        return false;
    }
}