/***************************************************************************/
/*     AUTHOR         :  PHP Dev Team, iFactor Solutions, India            */
/*	   CONTACT 		  :  support@ifactors.com www.ifactors.com			   */
/*     PROGRAMMER     :  DPT                                               */
/*     SCRIPT NAME    :  js.js					                           */
/*     CREATED ON     :  27/JAN/2005                                       */
/*     LAST MODIFIED  :  04/FEB/2005                                       */
/*     MODIFIED ON    :  16/FEB/2005                                       */
/*     MODIFIED BY    :  SDYA											   */
/*                                                                         */
/*     Java Script Functions For the Site                                  */
/***************************************************************************/

	//global variables
    var flag_ccemailid = 0;
    var flag_toemailid = 1;

    /*----------------------------------------------------------------
    Description   :- function to validate an email id
    Programmer    :- DPT
    Last Modified :- 31/JAN/2005
    -------------------------------------------------------------------*/
	  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 change the style on mouse over
    Programmer    :- DPT
    Last Modified :- 31/JAN/2005
    -------------------------------------------------------------------*/
    function pviiClassNew(obj, new_style)
    {
  		obj.className=new_style;
	}

    /*----------------------------------------------------------------
    Description   :- function to validate the login form
    Programmer    :- DPT
    Last Modified :- 31/JAN/2005
    -------------------------------------------------------------------*/
    function login_validate()
    {
        //user name
        if(document.frm_login.txt_username.value=='')
        {
            alert("Please enter your user name");
            document.frm_login.txt_username.focus();
            return false;
        }
        //password
        if(document.frm_login.txt_password.value=='')
        {
            alert("Please enter your password");
            document.frm_login.txt_password.focus();
            return false;
        }
        return true;
    }

    /*----------------------------------------------------------------
    Description   :- function to validate the change user info form
    Programmer    :- DPT
    Last Modified :- 31/JAN/2005
    -------------------------------------------------------------------*/
    function changeuserinfo_validate()
    {
        //user name
        if(document.frm_userinfo.txt_username.value=='')
        {
            alert("Please enter your user id");
            document.frm_userinfo.txt_username.focus();
            return false;
        }
        //first name
        if(document.frm_userinfo.txt_firstname.value=='')
        {
            alert("Please enter your first name");
            document.frm_userinfo.txt_firstname.focus();
            return false;
        }
        //emailid
        if(document.frm_userinfo.txt_emailid.value=='')
        {
            alert("Please enter your email id");
            document.frm_userinfo.txt_emailid.focus();
            return false;
        }
        return true;
    }

    /*----------------------------------------------------------------
    Description   :- function to validate change password form
    Programmer    :- DPT
    Last Modified :- 31/JAN/2005
    -------------------------------------------------------------------*/
    function changepassword_validate()
    {
		//old password
    	if(document.frm_password.txt_oldpassword.value=='')
        {
        	alert("Please enter your old password");
            document.frm_password.txt_oldpassword.focus();
            return false;
        }

		//new password
    	if(document.frm_password.txt_password.value=='')
        {
        	alert("Please enter your new password");
            document.frm_password.txt_password.focus();
            return false;
        }

		//retype password
    	if(document.frm_password.txt_repassword.value=='')
        {
        	alert("Please re-type your password");
            document.frm_password.txt_repassword.focus();
            return false;
        }

        //confirm password
        if(document.frm_password.txt_password.value!=document.frm_password.txt_repassword.value)
        {
			alert("Please confirm your password");
            document.frm_password.txt_repassword.focus();
            return false;
        }
    }

    /*----------------------------------------------------------------
    Description   :- function to validate the sign up step2
    Programmer    :- DPT
    Last Modified :- 31/JAN/2005
	Modified on   :- 16/FEB/2005
	Modified by   :- SDYA
    -------------------------------------------------------------------*/
    function signup2_validate()
    {
    	//first name
        if(document.frm_signup.txt_firstname.value=='')
        {
        	alert("Please enter the first name");
            document.frm_signup.txt_firstname.focus();
            return false;
        }

        //last name
        if(document.frm_signup.txt_lastname.value=='')
        {
        	alert("Please enter the last name");
            document.frm_signup.txt_lastname.focus();
            return false;
        }

        //city
        if(document.frm_signup.txt_city.value=='')
        {
        	alert("Please enter the city");
            document.frm_signup.txt_city.focus();
            return false;
        }

        //email
        if(document.frm_signup.txt_email.value=='')
        {
        	alert("Please enter your email id");
            document.frm_signup.txt_email.focus();
            return false;
        }

	   //line name
        if(document.frm_signup.txt_linename.value=='')
        {
        	alert("Please enter your line name ");
            document.frm_signup.txt_linename.focus();
            return false;
        }

        //crossing year
        if(document.frm_signup.cbo_crossingyear.value=='')
        {
        	alert("Please select your crossing year");
            document.frm_signup.cbo_crossingyear.focus();
            return false;
        }

		//photo
        if(document.frm_signup.txt_image.value=='')
        {
        	alert("Please upload your photo");
            document.frm_signup.txt_image.focus();
            return false;
        }

		//biography
        if(document.frm_signup.txta_biography.value=='')
        {
        	alert("Please enter your biography ");
            document.frm_signup.txta_biography.focus();
            return false;
        }

        /*preference
        if(document.frm_signup.cbo_preference.value=='')
        {
        	alert("Please choose your privacy preference");
            document.frm_signup.cbo_preference.focus();
            return false;
        } */

        //memberid
        if(document.frm_signup.txt_memberid.value=='')
        {
        	alert("Please enter the user name");
            document.frm_signup.txt_memberid.focus();
            return false;
        }

        //password
        if(document.frm_signup.txt_password.value=='')
        {
        	alert("Please enter your password");
            document.frm_signup.txt_password.focus();
            return false;
        }

        //re password
        if(document.frm_signup.txt_repassword.value=='')
        {
        	alert("Please confirm your password");
            document.frm_signup.txt_repassword.focus();
            return false;
        }

        //confirm password
        if(document.frm_signup.txt_repassword.value!=document.frm_signup.txt_password.value)
        {
        	alert("Please confirm your password");
            document.frm_signup.txt_repassword.focus();
            return false;
        }
    }

    /*----------------------------------------------------------------
    Description   :- function to validate the login form
    Programmer    :- DPT
    Last Modified :- 31/JAN/2005
    -------------------------------------------------------------------*/
    function signin_validate()
    {
        //user name
        if(document.frm_login.txt_username.value=='')
        {
            alert("Please enter your user name");
            document.frm_login.txt_username.focus();
            return false;
        }
        //password
        if(document.frm_login.txt_password.value=='')
        {
            alert("Please enter your password");
            document.frm_login.txt_password.focus();
            return false;
        }
        return true;
    }

    /*----------------------------------------------------------------
    Description   :- function to validate the my profile page
    Programmer    :- DPT
    Last Modified :- 02/FEB/2005
	Modified on   :- 16/FEB/2005
	Modified by   :- SDYA
    -------------------------------------------------------------------*/
    function my_profile_validate()
    {
    	//first name
        if(document.frm_signup.txt_firstname.value=='')
        {
        	alert("Please enter the first name");
            document.frm_signup.txt_firstname.focus();
            return false;
        }

        //last name
        if(document.frm_signup.txt_lastname.value=='')
        {
        	alert("Please enter the last name");
            document.frm_signup.txt_lastname.focus();
            return false;
        }

        //city
        if(document.frm_signup.txt_city.value=='')
        {
        	alert("Please enter the city");
            document.frm_signup.txt_city.focus();
            return false;
        }

        //email
        if(document.frm_signup.txt_email.value=='')
        {
        	alert("Please enter your email id");
            document.frm_signup.txt_email.focus();
            return false;
        }

	    //line name
        if(document.frm_signup.txt_linename.value=='')
        {
        	alert("Please enter your line name ");
            document.frm_signup.txt_linename.focus();
            return false;
        }

        //crossing year
        if(document.frm_signup.cbo_crossingyear.value=='')
        {
        	alert("Please select your crossing year");
            document.frm_signup.cbo_crossingyear.focus();
            return false;
        }

		/*//photo
        if(document.frm_signup.txt_image.value=='')
        {
        	alert("Please upload your photo");
            document.frm_signup.txt_image.focus();
            return false;
        }*/

		//biography
        if(document.frm_signup.txta_biography.value=='')
        {
        	alert("Please enter your biography ");
            document.frm_signup.txta_biography.focus();
            return false;
        }


    }

    /*----------------------------------------------------------------
    Description   :- function to validate the change user info form
    Programmer    :- DPT
    Last Modified :- 02/FEB/2005
    -------------------------------------------------------------------*/
    function changeuserinfo_validate()
    {
        //user name
        if(document.frm_userinfo.txt_username.value=='')
        {
            alert("Please enter your user id");
            document.frm_userinfo.txt_username.focus();
            return false;
        }
	}

    /*----------------------------------------------------------------
    Description   :- function to validate change password form
    Programmer    :- DPT
    Last Modified :- 02/FEB/2005
    -------------------------------------------------------------------*/
    function changepassword_validate()
    {
		//old password
    	if(document.frm_password.txt_oldpassword.value=='')
        {
        	alert("Please enter your old password");
            document.frm_password.txt_oldpassword.focus();
            return false;
        }

		//new password
    	if(document.frm_password.txt_password.value=='')
        {
        	alert("Please enter your new password");
            document.frm_password.txt_password.focus();
            return false;
        }

		//retype password
    	if(document.frm_password.txt_repassword.value=='')
        {
        	alert("Please re-type your password");
            document.frm_password.txt_repassword.focus();
            return false;
        }

        //confirm password
        if(document.frm_password.txt_password.value!=document.frm_password.txt_repassword.value)
        {
			alert("Please confirm your password");
            document.frm_password.txt_repassword.focus();
            return false;
        }
    }

    /*----------------------------------------------------------------
    Description   :- function to validate the forgot password form
    Programmer    :- DPT
    Last Modified :- 02/FEB/2005
    -------------------------------------------------------------------*/
    function forgotpassword_validate()
    {
    	//user name
        if(document.frm_forgotpassword.txt_username.value=='')
        {
        	alert("Please enter your user id");
            document.frm_forgotpassword.txt_username.focus();
            return false;
        }
        return true;
    }

    /*----------------------------------------------------------------
    Description   :- function to validate the guestbook page
    Programmer    :- DPT
    Last Modified :- 28/FEB/2005
    -------------------------------------------------------------------*/
	function guestbook_validate()
	{
			//	name of the guest
			if(document.frm_guestbook.txt_name.value=='')
			{
				alert("Please enter your name");
				document.frm_guestbook.txt_name.focus();
                return false;
			}
            //	emailid of the guest
			if(document.frm_guestbook.txt_emailid.value=='')
			{
				alert("Please enter your emailid");
				document.frm_guestbook.txt_emailid.focus();
                return false;
			}
            /*//	url of the guest
			if(document.frm_guestbook.txt_url.value=='')
			{
				alert("Please enter the url");
				document.frm_guestbook.txt_url.focus();
                return false;
			} */
            //	country of the guest
			if(document.frm_guestbook.list_country.value=='')
			{
				alert("Please select your country");
				document.frm_guestbook.list_country.focus();
                return false;
			}
            //	comments from the guest
			if(document.frm_guestbook.txta_comment.value=='')
			{
				alert("Please enter your comments");
				document.frm_guestbook.txta_comment.focus();
                return false;
			}
	}

    /*----------------------------------------------------------------
    Description   :- function to validate the forum page
    Programmer    :- DPT
    Last Modified :- 26/FEB/2005
    -------------------------------------------------------------------*/
    function forum_validate(member)
    {
    	//ask name only for nonmember
        if(!member)
        {
	        //  name
	        if(document.frm_forum.txt_name.value=='')
	        {
	            alert("Please enter your name");
	            document.frm_forum.txt_name.focus();
	            return false;
	        }
        }
        //  message
        if(document.frm_forum.txta_message.value=='')
        {
            alert("Please enter your message");
            document.frm_forum.txta_message.focus();
            return false;
        }
    }

    /*----------------------------------------------------------------
    Description   :- function to validate the post topic - forum page
    Programmer    :- DPT
    Last Modified :- 24/FEB/2005
    -------------------------------------------------------------------*/
	function  forumtopic_validate()
    {
        if(document.frm_forum.txt_name.value=='')
        {
            alert("Please enter the title of the topic");
            document.frm_forum.txt_name.focus();
            return false;
        }
    }

    /*----------------------------------------------------------------
    Description   :- function to validate  newsletter subscription form
    Programmer    :- DPT
    Last Modified :- 04/FEB/2005
    -------------------------------------------------------------------*/
    function subscribe_validate()
    {
    	if(document.frm.txt_emailid.value=='')
        {
        	alert("Please enter your email id");
            document.frm.txt_emailid.focus();
            return false;
        }
    }

	/*----------------------------------------------------------------
    Description   :- function to validate the postevent page
    Programmer    :- SDYA
    Last Modified :- 02/FEB/2005
    -------------------------------------------------------------------*/
	function postevent_validate()
	{
			//	title of the event
			if(document.frm_event.txt_name.value=='')
			{
				alert("Please enter the title of the event");
				document.frm_event.txt_name.focus();
                return false;
			}
			//	description of the event
			if(document.frm_event.txta_description.value=='')
			{
				alert("Please enter the description about the event");
				document.frm_event.txta_description.focus();
                return false;
			}
	}

	/*----------------------------------------------------------------
    Description   :- function to confirm the deletion of a record
    Programmer    :- SDYA
    Last Modified :- 02/FEB/2005
    -------------------------------------------------------------------*/
    function deleteconfirm(page,name,id)
    {
    	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."))
        	window.location = page + "?id=" + id + "&name=" + name;
    }

	/*----------------------------------------------------------------
    Description   :- function to validate the postclassified page
    Programmer    :- SDYA
    Last Modified :- 02/FEB/2005
    -------------------------------------------------------------------*/
	function postclassified_validate()
	{
			//	title of the classified
			if(document.frm_classified.txt_name.value=='')
			{
				alert("Please enter the title of the classified");
				document.frm_classified.txt_name.focus();
                return false;
			}
			//	description of the classified
			if(document.frm_classified.txta_description.value=='')
			{
				alert("Please enter the description about the classified");
				document.frm_classified.txta_description.focus();
                return false;
			}
	}

	/*----------------------------------------------------------------
    Description   :- function to show the calender in post classified edit page
    Programmer    :- SDYA
    Last Modified :- 02/FEB/2005
    -------------------------------------------------------------------*/
	function show_calendar()
	{
		   		gfPop.fStartPop(document.frm_classified.txt_date,Date);
	}

	/*----------------------------------------------------------------
    Description   :- function to validate the post jobs page
    Programmer    :- SDYA
    Last Modified :- 02/FEB/2005
    -------------------------------------------------------------------*/
	function postjobs_validate()
	{
			//	title of the job
			if(document.frm_jobs.txt_name.value=='')
			{
				alert("Please enter the title of the job.");
				document.frm_jobs.txt_name.focus();
                return false;
			}
            //	description of the job
			if(document.frm_jobs.txta_description.value=='')
			{
				alert("Please enter the description of the job.");
				document.frm_jobs.txta_description.focus();
                return false;
			}
            //	requirements of the job
			if(document.frm_jobs.txt_requirements.value=='')
			{
				alert("Please enter the requirements of the job.");
				document.frm_jobs.txt_requirements.focus();
                return false;
			}
            //	contact number of the job
			if(document.frm_jobs.txt_contactno.value=='')
			{
				alert("Please enter the contact number.");
				document.frm_jobs.txt_contactno.focus();
                return false;
			}
            //	city of the job
			if(document.frm_jobs.txt_city.value=='')
			{
				alert("Please enter the city.");
				document.frm_jobs.txt_city.focus();
                return false;
			}
            //	state of the job
			if(document.frm_jobs.txt_state.value=='')
			{
				alert("Please enter the state.");
				document.frm_jobs.txt_state.focus();
                return false;
			}
            //	country of the job
			if(document.frm_jobs.list_country.value=='')
			{
				alert("Please select the country .");
				document.frm_jobs.list_country.focus();
                return false;
			}
	}

    /*----------------------------------------------------------------
    Description   :- function to validate the photo page
    Programmer    :- SDYA
    Last Modified :- 03/FEB/2005
    -------------------------------------------------------------------*/
    function postphoto_validate(id)
    {
        // name
        if(document.frm_photo.txt_name.value=='')
        {
            alert("Please enter the name");
            document.frm_photo.txt_name.focus();
            return false;
        }
		if(id==undefined)
		{
			//image
			if(document.frm_photo.txt_image.value=='')
			{
				alert("Please upload the photo");
				document.frm_photo.txt_image.focus();
				return false;
			}
		}
    }

	/*----------------------------------------------------------------
    Description   :- function to validate the sendmessage page
    Programmer    :- SDYA
    Last Modified :- 04/FEB/2005
    -------------------------------------------------------------------*/
    function sendmessage_validate()
    {
		//subject
        if(document.frm_send.txt_subject.value=='')
        {
            alert("Please enter the subject ");
            document.frm_send.txt_subject.focus();
            return false;
        }
        //message content
        if(document.frm_send.txta_message.value=='')
        {
            alert("Please type the message content ");
            document.frm_send.txta_message.focus();
            return false;
        }
    }

    /*----------------------------------------------------------------
    Description   :- function to validate the contactus page
    Programmer    :- SDYA
    Last Modified :- 04/FEB/2005
    -------------------------------------------------------------------*/
    function contactus_validate()
    {
        //emailid
        if(document.frm_contact.txt_emailid.value=='')
        {
            alert("Please enter the emailid ");
            document.frm_contact.txt_emailid.focus();
            return false;
        }
        //subject
        if(document.frm_contact.txt_subject.value=='')
        {
            alert("Please enter the subject ");
            document.frm_contact.txt_subject.focus();
            return false;
        }
        //message content
        if(document.frm_contact.txta_message.value=='')
        {
            alert("Please type the message content ");
            document.frm_contact.txta_message.focus();
            return false;
        }

    }

    /*----------------------------------------------------------------
    Description   :- function to validate the make donations page
    Programmer    :- SDYA
    Last Modified :- 05/FEB/2005
    -------------------------------------------------------------------*/
	function makedonations_validate()
	{
			//	name
			if(document.frm_makedonations.txt_name.value=='')
			{
				alert("Please enter the name.");
				document.frm_makedonations.txt_name.focus();
                return false;
			}
            //	emailid
			if(document.frm_makedonations.txt_emailid.value=='')
			{
				alert("Please enter the email id.");
				document.frm_makedonations.txt_emailid.focus();
                return false;
			}
            //	city
			if(document.frm_makedonations.txt_city.value=='')
			{
				alert("Please enter the city.");
				document.frm_makedonations.txt_city.focus();
                return false;
			}
            //	amount
			if(document.frm_makedonations.txt_amount.value=='')
			{
				alert("Please enter teh amount .");
				document.frm_makedonations.txt_amount.focus();
                return false;
			}
	}

	/*----------------------------------------------------------------
    Description   :- function to validate the compose page
    Programmer    :- SDYA
    Last Modified :- 08/FEB/2005
    -------------------------------------------------------------------*/
    function composemessage_validate()
    {
		//touser name
        if(document.frm_send.txt_name.value=='')
        {
            alert("Please select the name ");
            document.frm_send.txt_name.focus();
            return false;
        }
		//subject
        if(document.frm_send.txt_subject.value=='')
        {
            alert("Please enter the subject ");
            document.frm_send.txt_subject.focus();
            return false;
        }
        //message content
        if(document.frm_send.txta_message.value=='')
        {
            alert("Please type the message content ");
            document.frm_send.txta_message.focus();
            return false;
        }
    }

	/*----------------------------------------------------------------
    Description   :- function to validate the apply job page
    Programmer    :- SDYA
    Last Modified :- 15/FEB/2005
    -------------------------------------------------------------------*/
    function jobapply_validate()
    {
        //letter
 		if(document.frm_jobapply.txta_letter.value=='')
        {
            alert("Please type the covering letter ");
            document.frm_jobapply.txta_letter.focus();
            return false;
        }
		//attachments
        if(document.frm_jobapply.txt_attachment.value=='')
        {
            alert("Please select your resume ");
            document.frm_jobapply.txt_attachment.focus();
            return false;
        }
    }

    /*----------------------------------------------------------------
    Description   :- function to show the subscribe for newsletter form
    Programmer    :- DPT
    Last Modified :- 04/FEB/2005
    -------------------------------------------------------------------*/
    function subscribe()
    {
        window.open('subscribe_newsletter.php', 'NewsletterSubscription', 'status=no,location=no,directories=no,menubar=yno,toolbar=no,scrollbars=yes,height=140,width=420,resizable=yes,top=150,left=150,screenX=150,screenY=150');
    }

	/*----------------------------------------------------------------
    Description   :- function to pop up a window to show a large image of a thumbnail
    Programmer    :- DPT
    Last Modified :- 03/MAY/2005
    -------------------------------------------------------------------*/
	function showimage(image,width,height)
	{
		height += 20;
		width += 20;
		//open window
		window.open('showimage.php?image='+image, 'PhiBetaSigma', 'status=no,location=no,directories=no,menubar=yno,toolbar=no,scrollbars=yes,height=' + height + ',width=' + width + ',resizable=yes,top=150,left=150,screenX=150,screenY=150');
	}