
/***************************************************************************/
/*     PROGRAMMER     :  JVN                                               */
/*     SCRIPT NAME    :  js.js                                             */
/*     CREATED ON     :  04/MAY/2006                                       */
/*     MODIFIED ON    :  04/MAY/2006                                       */
/*                                                                         */
/*                                                                         */
/*                  js.js                                                  */
/***************************************************************************/
    /*----------------------------------------------------------------
    Description   :- function to validate an email id
    Programmer    :- JVN
    CREATED ON    :- 04/MAY/2006
    -------------------------------------------------------------------*/
          function isBadEmail(strg) {
            email_array = strg.split('@');
            if (email_array.length != 2) return true;
            if (email_array[1].split(".").length < 2) return true;
            if (email_array[1].split(".")[1].length < 1) return true;
            if (strg.indexOf('@') < 1) return true;
            if (strg.indexOf(' ') != -1) return true;
            if (email_array[1].indexOf('.') < 1) return true;
            if (strg.length < 5) return true;
            return false;
          }


    /*----------------------------------------------------------------
    Description   :- function to user registration
    Programmer    :- JVN
    CREATED ON    :- 04/MAY/2006
    -------------------------------------------------------------------*/
     function user_reg_form()
     {
            //user name
        if(document.frm_sign_up.text_first_name.value=='')
        {
            alert("Please Enter Your First Name!!");
            document.frm_sign_up.text_first_name.focus();
            return false;
        }
            if(document.frm_sign_up.text_last_name.value=='')
        {
            alert("Please Enter Your Last Name!!");
            document.frm_sign_up.text_last_name.focus();
            return false;
        }

           if(document.frm_sign_up.text_email.value=='')
        {
            alert("Please Enter Your Email Address!!");
            document.frm_sign_up.text_email.focus();
            return false;
        }
          if(isBadEmail(document.frm_sign_up.text_email.value))
        {
             alert("Invalid Email Id");
            document.frm_sign_up.text_email.focus();
            return false;
        }
             if(document.frm_sign_up.text_city.value=='')
        {
            alert("Please Enter Your City!!");
            document.frm_sign_up.text_city.focus();
            return false;
        }
        if(document.frm_sign_up.sel_country.value=='')
        {
            alert("Please Select country!!");
            document.frm_sign_up.sel_country.focus();
            return false;
        }
        if(document.frm_sign_up.text_user_name.value=='')
        {
            alert("Please Enter Your User Name!!");
            document.frm_sign_up.text_user_name.focus();
            return false;
        }
        if(document.frm_sign_up.text_password.value=='')
        {
            alert("Please Enter Password!!");
            document.frm_sign_up.text_password.focus();
            return false;
        }
          if(document.frm_sign_up.text_password_confirm.value=='')
        {
            alert("Please Enter ReType Password!!");
            document.frm_sign_up.text_password_confirm.focus();
            return false;
        }
          //confirm password
        if(document.frm_sign_up.text_password.value!=document.frm_sign_up.text_password_confirm.value)
        {
            alert("Please confirm your password");
            document.frm_sign_up.text_password_confirm.focus();
            return false;
        }
        return true;
     }

    /*----------------------------------------------------------------
    Description   :- function to tell a friend
    Programmer    :- Krn
    CREATED ON    :- 09/MAY/2006
    -------------------------------------------------------------------*/
     function tellafriend_form()
     {
            //user name
        if(document.frm_tellafriend.text_your_name.value=='')
        {
            alert("Please Enter Your Name!!");
            document.frm_tellafriend.text_your_name.focus();
            return false;
        }

           if(document.frm_tellafriend.text_your_email.value=='')
        {
            alert("Please Enter Your Email Address!!");
            document.frm_tellafriend.text_your_email.focus();
            return false;
        }
          if(isBadEmail(document.frm_tellafriend.text_your_email.value))
        {
             alert("Invalid Email Id");
            document.frm_tellafriend.text_your_email.focus();
            return false;
        }

        if(document.frm_tellafriend.text_email.value=='')
        {
            alert("Please Enter Email ID of your friend!!");
            document.frm_tellafriend.text_email.focus();
            return false;
        }

        if(isBadEmail(document.frm_tellafriend.text_email.value))
        {
             alert("Invalid Email Id");
            document.frm_tellafriend.text_email.focus();
            return false;
        }
        if(document.frm_tellafriend.comments.value=='')
        {
            alert("Please Enter Your comments!!");
            document.frm_tellafriend.comments.focus();
            return false;
        }

        return true;
     }
    /*----------------------------------------------------------------
    Description   :- function to user login
    Programmer    :- JVN
    CREATED ON    :- 04/MAY/2006
    -------------------------------------------------------------------*/
      function login_validate()
     {
            //user name
        if(document.frm_login.text_username.value=='')
        {
            alert("Please Enter Your User ID!!");
            document.frm_login.text_username.focus();
            return false;
        }
         //Password
          if(document.frm_login.text_password.value=='')
        {
            alert("Please Enter Your Password!!");
            document.frm_login.text_password.focus();
            return false;
        }
        return true;
     }

     /*----------------------------------------------------------------
    Description   :- function to user forgot_pass
    Programmer    :- JVN
    CREATED ON    :- 04/MAY/2006
    -------------------------------------------------------------------*/
    function forgot_pass()
     {
            //user name
        if(document.frm_forgot.txt_email.value=='')
        {
            alert("Please Enter Your Mail ID!!");
            document.frm_forgot.txt_email.focus();
            return false;
        }
          if(isBadEmail(document.frm_forgot.txt_email.value))
        {
             alert("Invalid Email Id");
            document.frm_forgot.txt_email.focus();
            return false;
        }
     return true;
    }

     /*----------------------------------------------------------------
    Description   :- function to user edit profile
    Programmer    :- JVN
    CREATED ON    :- 05/MAY/2006
    -------------------------------------------------------------------*/
     function change_profile_form()
     {
            //user name
        if(document.frm_change_profile.text_first_name.value=='')
        {
            alert("Please Enter Your First Name!!");
            document.frm_change_profile.text_first_name.focus();
            return false;
        }
            if(document.frm_change_profile.text_last_name.value=='')
        {
            alert("Please Enter Your Last Name!!");
            document.frm_change_profile.text_last_name.focus();
            return false;
        }

           if(document.frm_change_profile.text_email.value=='')
        {
            alert("Please Enter Your Email Address!!");
            document.frm_change_profile.text_email.focus();
            return false;
        }
          if(isBadEmail(document.frm_change_profile.text_email.value))
        {
             alert("Invalid Email Id");
            document.frm_change_profile.text_email.focus();
            return false;
        }
             if(document.frm_change_profile.text_city.value=='')
        {
            alert("Please Enter Your City!!");
            document.frm_change_profile.text_city.focus();
            return false;
        }
        if(document.frm_change_profile.sel_country.value=='')
        {
            alert("Please Select country!!");
            document.frm_change_profile.sel_country.focus();
            return false;
        }

        return true;
     }


     /*----------------------------------------------------------------
    Description   :- function to user edit password
    Programmer    :- JVN
    CREATED ON    :- 05/MAY/2006
    -------------------------------------------------------------------*/
     function change_password_form()
     {
            //user name
        if(document.frm_change_password.text_old_pass.value=='')
        {
            alert("Please Enter Your Old Password!!");
            document.frm_change_password.text_old_pass.focus();
            return false;
        }
         if(document.frm_change_password.text_new_pass.value=='')
        {
            alert("Please Enter New Password!!");
            document.frm_change_password.text_new_pass.focus();
            return false;
        }
          if(document.frm_change_password.text_confirm_pass.value=='')
        {
            alert("Please ReType Your New Password!!");
            document.frm_change_password.text_confirm_pass.focus();
            return false;
        }
          //confirm password
        if(document.frm_change_password.text_new_pass.value!=document.frm_change_password.text_confirm_pass.value)
        {
            alert("Please confirm your password");
            document.frm_change_password.text_confirm_pass.focus();
            return false;
        }

        return true;
    }


    /*----------------------------------------------------------------
    Description   :- function to add my gallery
    Programmer    :- JVN
    CREATED ON    :- 10/MAY/2006
    -------------------------------------------------------------------*/
     function add_gallery_form()
     {
            //user category
        if(document.frm_add_gallery.sel_category.value=='')
        {
            alert("Please Select Your Category!!");
            document.frm_add_gallery.sel_category.focus();
            return false;
        }
              //gallery name
        if(document.frm_add_gallery.text_name.value=='')
        {
            alert("Please Enter Your Gallery Name!!");
            document.frm_add_gallery.text_name.focus();
            return false;
        }

        return true;
    }
     /*----------------------------------------------------------------
    Description   :- function to add my images
    Programmer    :- JVN
    CREATED ON    :- 10/MAY/2006
    -------------------------------------------------------------------*/
     function add_images_form()
     {
            //user category
        if(document.frm_add_images.text_name.value=='')
        {
            alert("Please Enter Your Image Title!!");
            document.frm_add_images.text_name.focus();
            return false;
        }
              //gallery name
        if(document.frm_add_images.txt_photo_file.value=='')
        {
            alert("Please Choose Your Image!!");
            document.frm_add_images.txt_photo_file.focus();
            return false;
        }

        return true;
    }
    /*----------------------------------------------------------------
    Description   :- function to add my videos
    Programmer    :- JVN
    CREATED ON    :- 10/MAY/2006
    -------------------------------------------------------------------*/
     function add_video_form()
     {
            //user category
        if(document.frm_add_video.text_name.value=='')
        {
            alert("Please Enter Your Video Title!!");
            document.frm_add_video.text_name.focus();
            return false;
        }
              //gallery name
        if(document.frm_add_video.txt_video_file.value=='')
        {
            alert("Please Choose Your Video!!");
            document.frm_add_video.txt_video_file.focus();
            return false;
        }

        return true;
    }

     /*----------------------------------------------------------------
    Description   :- function to ecard validate
    Programmer    :- JVN
    CREATED ON    :- 15/MAY/2006
    -------------------------------------------------------------------*/
     function ecard_validate()
     {
            //user category
        if(document.frm_ecard.text_to.value=='')
        {
            alert("Please Enter Email ids!!");
            document.frm_ecard.text_to.focus();
            return false;
        }

        var temp_mail_arr = document.frm_ecard.text_to.value.split(",");

          for (i=0; i<temp_mail_arr.length; i++)
           {
            if(isBadEmail(temp_mail_arr[i]))
                {
             alert("Invalid Email Id");
            document.frm_ecard.text_to.focus();
            return false;
                }

           }

              //gallery name
        if(document.frm_ecard.texta_msg.value=='')
        {
            alert("Please Type Your Messages!!");
            document.frm_ecard.texta_msg.focus();
            return false;
        }

        return true;
    }

    /*----------------------------------------------------------------
    Description   :- function to confirm the deletion of a record
    Programmer    :- JVN
    Last Modified :- 17/May/2006
    -------------------------------------------------------------------*/
    function deleteGalleryconfirm(page,name,id,userid)
    {
        if(confirm("Are you sure you want to delete this " + name + "?\nIf 'OK' all the information associated with this " + name + " will be removed from the system.\nYou cannot UNDO this process."))
                        window.location = page + "?id=" + id + "&name=" + name + "&userid=" + userid;
    }

    /*----------------------------------------------------------------
    Description   :- function to add my links
    Programmer    :- JVN
    CREATED ON    :- 17/MAY/2006
    -------------------------------------------------------------------*/
     function my_links_form()
     {
            //link name
        if(document.frm_my_links.text_link_name.value=='')
        {
            alert("Please Enter Your Link Name!!");
            document.frm_my_links.text_link_name.focus();
            return false;
        }
              //url
        if(document.frm_my_links.text_url.value=='')
        {
            alert("Please Add Your Url!!");
            document.frm_my_links.text_url.focus();
            return false;
        }
                      //url
        if(document.frm_my_links.text_url.value=='')
        {
            alert("Please Add Your Url!!");
            document.frm_my_links.text_url.focus();
            return false;
        }

        return true;
    }
    /*----------------------------------------------------------------
    Description   :- function to new category
    Programmer    :- JVN
    CREATED ON    :- 18/MAY/2006
    -------------------------------------------------------------------*/
     function new_category_form()
     {
            //link name
        if(document.frm_new_category.text_cat_name.value=='')
        {
            alert("Please Enter Your Category Name!!");
            document.frm_new_category.text_cat_name.focus();
            return false;
        }
        return true;
    }
    /*----------------------------------------------------------------
    Description   :- function to post new blog post
    Programmer    :- JVN
    CREATED ON    :- 20/MAY/2006
    -------------------------------------------------------------------*/
     function my_post_form()
     {
            //post title
        if(document.frm_my_post.text_title.value=='')
        {
            alert("Please Enter Your Blog Post Title!!");
            document.frm_my_post.text_title.focus();
            return false;
        }
          //post category
          if(document.frm_my_post.sel_category.value=='')
        {
            alert("Please Select Your Category!!");
            document.frm_my_post.sel_category.focus();
            return false;
        }
           //post comment status
          if(document.frm_my_post.Sel_Comment_status.value=='')
        {
            alert("Please Select Your Comment Status!!");
            document.frm_my_post.Sel_Comment_status.focus();
            return false;
        }

        return true;
    }

    /*----------------------------------------------------------------
    Description   :- function to validate the attachment add my post page
    Programmer    :- JVN
    Last Modified :- 20/May/2006
    -------------------------------------------------------------------*/
    function image_attachment_validate()
    {
            if(document.frm_my_post.txt_image.value=='')
        {
                alert("Please choose the image file");
            document.frm_my_post.txt_image.focus();
            return false;
        }
        document.frm_my_post.mode.value  = "images";
        document.frm_my_post.submit();
    }
    /*----------------------------------------------------------------
    Description   :- function to remove an attachment from add my post page
    Programmer    :- JVN
    Last Modified :- 20/May/2006
    -------------------------------------------------------------------*/
    function remove_image_attachment(attachment)
    {
            if(confirm("Are you sure you want to remove this image?"))
        {
                document.frm_my_post.mode.value = "remove";
            document.frm_my_post.attachmentname.value = attachment;
            document.frm_my_post.submit();
        }
        return false;
    }

    /*----------------------------------------------------------------
    Description   :- function to post new comments
    Programmer    :- JVN
    CREATED ON    :- 20/MAY/2006
    -------------------------------------------------------------------*/
     function frm_comments_validate_1()
     {
            //post title
        if(document.frm_comments_1.texta_comments.value=='')
        {
            alert("Please Type Your Comments!!");
            document.frm_comments_1.texta_comments.focus();
            return false;
        }
         if(document.frm_comments_1.txtNumber.value=='')
        {
            alert("Please Type Verification Code!!");
            document.frm_comments_1.txtNumber.focus();
            return false;
        }

        return true;
    }
    /*----------------------------------------------------------------
    Description   :- function to post new comments
    Programmer    :- JVN
    CREATED ON    :- 20/MAY/2006
    -------------------------------------------------------------------*/
     function frm_comments_validate_2()
     {
            //post title
        if(document.frm_comments_2.text_username.value=='')
        {
            alert("Please Enter Your Name!!");
            document.frm_comments_2.text_username.focus();
            return false;
        }
          if(document.frm_comments_2.text_email.value=='')
        {
            alert("Please Enter Your Email!!");
            document.frm_comments_2.text_email.focus();
            return false;
        }
            if(isBadEmail(document.frm_comments_2.text_email.value))
        {
             alert("Invalid Email Id");
            document.frm_comments_2.text_email.focus();
            return false;
        }
             if(document.frm_comments_2.texta_comments.value=='')
        {
            alert("Please Enter Your Comments!!");
            document.frm_comments_2.texta_comments.focus();
            return false;
        }
         if(document.frm_comments_2.txtNumber.value=='')
        {
            alert("Please Type Verification Code!!");
            document.frm_comments_2.txtNumber.focus();
            return false;
        }

        return true;
    }
     /*----------------------------------------------------------------
    Description   :- function open popup window rating
    Programmer    :- JVN
    CREATED ON    :- 23/MAY/2006
    -------------------------------------------------------------------*/
    function open_popup_window(page)
    {
    window.open(page,'','status=no,location=no,directories=no,menubar=no,toolbar=no,scrollbars=yes,height=200,width=235,resizable=no,top=40,left=200,screenX=600,screenY=400');
    }

    /*----------------------------------------------------------------
    Description   :- function to post new comments
    Programmer    :- JVN
    CREATED ON    :- 20/MAY/2006
    -------------------------------------------------------------------*/
     function rate_validate()
     {
            //post title
        if(document.frm_vote.sel_vote.value=='')
        {
            alert("Please Select Your Rate!!");
            document.frm_vote.sel_vote.focus();
            return false;
        }

        return true;
    }
    /*----------------------------------------------------------------
    Description   :- function to post new comments
    Programmer    :- JVN
    CREATED ON    :- 20/MAY/2006
    -------------------------------------------------------------------*/
     function  comments_validate()
     {
            //post title
        if(document.frm_comments.texta_comments.value=='')
        {
            alert("Please Type Your Comments!!");
            document.frm_comments.texta_comments.focus();
            return false;
        }

        return true;
    }
     /*----------------------------------------------------------------
    Description   :- function to site manage validate
    Programmer    :- JVN
    CREATED ON    :- 26/MAY/2006
    -------------------------------------------------------------------*/
     function  site_manage_validate()
     {
        var strsearch        =  document.frm_my_site.header_title.value ;
        var        cad = strsearch.replace(/ /g,"");
            //post title
        if(cad=='')
        {
            alert("Please Enter Your Site Title!!");
            document.frm_my_site.header_title.focus();
            return false;
        }

        return true;
    }

     /*----------------------------------------------------------------
    Description   :- function to post new comments
    Programmer    :- JVN
    CREATED ON    :- 20/MAY/2006
    -------------------------------------------------------------------*/
     function  add_blog_roll_form()
     {

          var  Blogroll =  document.frm_blogroll.text_rollblog_name.value;
          var newroll = Blogroll.replace(/ /g,"");
            //post title
        if(newroll=='')
        {
            alert("Please Type Your Blog Roll Name!!");
            document.frm_blogroll.text_rollblog_name.focus();
            return false;
        }

         var  Blogroll_url =  document.frm_blogroll.text_rollblog_url.value;
          var newrollurl = Blogroll_url.replace(/ /g,"");
            //post title
        if(newrollurl=='')
        {
            alert("Please Type Your Blog Roll Url!!");
            document.frm_blogroll.text_rollblog_url.focus();
            return false;
        }

        return true;
    }
