/******************************************

Module name : Js Function file

Parent module : None

Date created : 10th September 2008

Date last modified : 24th October 2007

Author :  Gulshan Verma

Last modified by : Gulshan Verma

Comments : The functions_js.js file contains various functions related to the web directory project.

******************************************/	



/******************************************

Function name : inviteValidator

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Sandeep Kumar

Last modified by : Sandeep Kumar

Comments : Function will return the true or error message after validating checkboxes

User instruction : inviteValidator(btnType)

******************************************/

function inviteValidator(formname)

{

	if(formname)

	{

		 var obj = document.getElementById(formname);

		 var error="", flagCheck=0;

		

		 var len = obj.elements.length; 

		 var  i=0;

		 for(i=0;i<len;i++) 

		 {

			  if(obj.elements[i].type=='checkbox')

			  {

				   //alert(obj.elements[i].checked);

				   if(obj.elements[i].checked)

				   {

						flagCheck = 1;

				        //return false;

				   }

				   

			  }

		 }

		 //alert(flagCheck);

		 //alert(flagCheck);

		 if(flagCheck == 1)

		 {

			document.getElementById('frmMultipleInvite').style.display = 'block';

			obj.submit();

			return false;

		 }

		 else

		 {

		 	 document.getElementById('emptyInviteList').innerHTML = '<div class="error">Please select at least one record.</div>';

			 return false;	

		 }

	}

	else

	{

		return false;

	}

}



/******************************************

Function name : inviteValidator

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Sandeep Kumar

Last modified by : Sandeep Kumar

Comments : Function will return the true or error message after validating checkboxes

User instruction : inviteValidator(btnType)

******************************************/

function validateContacts(formname)

{

	if(formname)

	{

		 var obj = document.getElementById(formname);

		 var error="", flagCheck=0;

		

		 var len = obj.elements.length; 

		 var  i=0;

		 for(i=0;i<len;i++) 

		 {

			  if(obj.elements[i].type=='checkbox')

			  {

				   //alert(obj.elements[i].checked);

				   if(obj.elements[i].checked)

				   {

						flagCheck = 1;

				        //return false;

				   }

				   

			  }

		 }

		 //alert(flagCheck);

		 //alert(flagCheck);

		 if(flagCheck == 1)

		 {

			//document.getElementById('frmMultipleInvite').style.display = 'block';

			obj.submit();

			return false;

		 }

		 else

		 {

		 	 document.getElementById('emptyInviteList').innerHTML = '<div class="error">Please select at least one record.</div>';

			 return false;	

		 }

	}

	else

	{

		return false;

	}

}



/**********************************COMMMOM ADMIN FUNCTION IS NEEDED FOR THE ADMIN LOGIN & LOGOUT & SETTINMG OF THE ADMIN ****************/

/*****************************

Function name : resetDate

Return type : none

Date created : 10 March 2007

Date last modified : 

Author : Prashant Bhardwaj

Last modified by :

Comments : This function is used to reset the date of a form

User instruction : resetDate()

************************************/

function resetDate()

{

 document.forms[0].frmDate.value = "From";

 document.forms[0].frmTodate.value = "To";

}



/*****************************

Function name : dateCompare

Return type : boolean

Date created : 19 March 2007

Date last modified : 

Author : Gulshan Verma

Last modified by :

Comments : This function is used to validate the date compare form and to date.[ From date should be less than to date. ]

User instruction : dateCompare(formname)

************************************/

function dateCompare(formname)

{

 var sliptdate = document.getElementById(formname).frmTodate.value.split("-");

    var FromDate  = document.getElementById(formname).frmDate.value.split("-");

 /*********************** From Date *****************/

 var TY = FromDate[0];  //Year

 var TM = FromDate[1];  //Month

 var TD = FromDate[2];  //Date

 /******************* To Date *********************/

 var sY=sliptdate[0];  //Year

 var sM=sliptdate[1];  //Month

 var sD=sliptdate[2];  //Date

   

 if(document.getElementById(formname).frmDate.value != 'From' && document.getElementById(formname).frmTodate.value != 'To')

 {

  if(sY<TY ) 

  {

   alert("'To' date should be greater than 'From' date.");

   return false;   

  }

  else if(sM==TM && sD<TD && sY==TY) 

  { 

   alert("'To' date should be greater than 'From' date.");

   return false;

  }

  else if(sM<TM && sY==TY) 

  { 

   alert("'To' date should be greater than 'From' date.");

   return false;

  }

 }

 

 if(validateForm(formname, 'frmSearchOrderPrice', 'Order Price', 'isNaN'))

 { 

  return true;

 } 

 else 

 {

     return false;

 } 

 

}



/******************************************

Function name : showMessageReciever

Return type : None

Date created : 6th March 2009

Date last modified : 6th March 2009

Author : Sandeep Kumar

Last modified by : Sandeep Kumar

Comments : Function is used to show hide the message reciever

User instruction : showMessageReciever()

******************************************/

function showMessageReciever(varShowID, varHideID, varSendTo)

{

	 document.getElementById(varShowID).style.display = 'block';	

	 document.getElementById(varHideID).style.display = 'none';

	 document.getElementById('frmSendTo').value = varSendTo;

}

/******************************************

Function name : hideMessageReciever

Return type : None

Date created : 6th March 2009

Date last modified : 6th March 2009

Author : Sandeep Kumar

Last modified by : Sandeep Kumar

Comments : Function is used to hide the message reciever

User instruction : hideMessageReciever()

******************************************/

function hideMessageReciever(varShowID, varHideID, varSendTo)

{

	 document.getElementById(varShowID).style.display = 'none';	

	 document.getElementById(varHideID).style.display = 'none';

	 document.getElementById('frmSendTo').value = varSendTo;

}

/******************************************

Function name : validateSendMessage

Return type : None

Date created : 6th March 2009

Date last modified : 6th March 2009

Author : Sandeep Kumar

Last modified by : Sandeep Kumar

Comments : Function is used to validate message form

User instruction : validateSendMessage()

******************************************/

function validateSendMessage(formname)

{

	//alert(document.getElementById('frmSendTo').value);

	if(document.getElementById('frmSendTo').value == 'All')

	{

		if(validateForm(formname,'frmMessage','Message','R'))

		{	

			return true;

		} 

		else 

		{

			return false;

		} 

	}

	else if(document.getElementById('frmSendTo').value == 'InputFriends')

	{

		if(validateForm(formname, 'friendsList', 'To', 'R','frmMessage','Message','R'))

		{	

			return true;

		} 

		else 

		{

			return false;

		} 

	}

	else

	{

		if(validateForm(formname, 'frmMessageToUsers', 'To', 'R','frmMessage','Message','R'))

		{	

			return true;

		} 

		else 

		{

			return false;

		} 

	}

}





function userFriendList(keyword, userFriendList)

{

	fields = 'keyword='+keyword+'&listedFriend='+userFriendList+'&action=importList';

	doAjax('ajax_friends_list.php', fields, 'showAllList', 'post');

	

}



function showAllList(item)

{

	//alert(item);

	document.getElementById('td_ID').style.display = '';

	document.getElementById('Layer2').style.display = 'block';

	document.getElementById('Layer2').innerHTML = item;

}





function getEventDetails(eid)

{

	fields = 'eid='+eid+'&action=getDetails';



	document.getElementById('eid').value = eid;

	doAjax('ajax_event_details.php',fields,'showEventDetails','post');

	



}

function showEventDetails(item)

{

	var fullValue = item ;

	var Result = fullValue.indexOf("<$$>");

	var arrData = '';

	if(Result >= 0 )

	{

		 arrData = fullValue.split("<$$>");

	}

	if(arrData!='')

	{

		document.getElementById('sdEventDetail').innerHTML = arrData[0];

		document.getElementById('PreRegForEvent').innerHTML = arrData[1];

		document.getElementById('CancelButton').style.display = 'none';

	}

	else

	{

		document.getElementById('sdEventDetail').innerHTML = item;

		document.getElementById('PreRegForEvent').innerHTML = '';

		document.getElementById('CancelButton').style.display = 'block';

	}

	//alert(arrData[1]);

}





function checkPromotionalCode(value, eventId)

{

	

	if(value == '')

	{

		document.getElementById('proCode').innerHTML ='';	

		return false;	

	}

	

	fields = 'value='+value+'&eventId='+eventId+'&action=checkProCode';

	doAjax('ajax_promotional_offer.php', fields, 'showValidOffer', 'post');

	return false;

}





function showValidOffer(item)

{

	document.getElementById('proCode').innerHTML = item;

	

}









function fob(x)

{

	return document.getElementById(x);

}



function hide_div(div_id)

{

	fob(div_id).style.display='none';

	return false;

}



function set_list(uid, action)

{

	var FriendList = document.getElementById('friendsList').value

	arrFriendList = FriendList.split(',');

	if(arrFriendList != '')

	{

		for (var i= 0; i < arrFriendList.length ; i++)

		{

			if(trim(arrFriendList[i]) != trim(uid))

			{

				document.getElementById('friendsList').value = document.getElementById('friendsList').value + uid + ',';

				document.getElementById('frmMessageToUsers123').value="";

				list_id=x = fob('frmMessageToUsers').value;

				x=uid;

				id="td_ID";

				fields="list_id="+list_id+"&uid="+x+"&action="+action;

				doAjax('ajax_friends_list.php',fields,'SetAllList','post');

				return false;

			}

		}

	}

	else

	{

		document.getElementById('friendsList').value = document.getElementById('friendsList').value + uid + ',';

		document.getElementById('frmMessageToUsers123').value="";

		list_id=x = fob('frmMessageToUsers').value;

		x=uid;

		url="ajax.php";

		id="td_ID";

		fields="list_id="+list_id+"&uid="+x+"&action="+action;

		doAjax('ajax_friends_list.php',fields,'SetAllList','post');

		return false;

	}

	

	

}

function SetAllList(item)

{

	//document.getElementById('frmMessageToUsers').style.display='none';

	document.getElementById('td_ID').style.display='block';

	document.getElementById('td_ID').innerHTML = document.getElementById('td_ID').innerHTML + item;

	document.getElementById('frmMessageToUsers123').value = '';

	document.getElementById('frmMessageToUsers123').focus();

}



function delete_list(uid, action)

{

	//list_id=x=fob('frmMessageToUsers123').value;

	var FriendList = document.getElementById('friendsList').value

	arrFriendList = FriendList.split(',');

	if(arrFriendList != '')

	{

		for (var i= arrFriendList.length-1; i>=0; i--)

		{

			if(trim(arrFriendList[i]) == trim(uid))

			{

				document.getElementById('friendsList').value = FriendList.replace(uid+',','');

				document.getElementById(uid).style.display = 'none';

				document.getElementById('frmMessageToUsers123').focus();

				

			}

		}

	}

	return false;

	/*x=uid;

	url="ajax.php";

	WhereToWrite="td_ID";

	id = WhereToWrite;

	

	fields="list_id="+list_id+"&uid="+x+"&action="+action;

	doAjax('ajax_friends_list.php',fields,'deleteList','post');

	return false;*/

}

function deleteList(item)

{

	document.getElementById(id).style.display='';

	document.getElementById('td_ID').innerHTML = document.getElementById('td_ID').innerHTML + item;

	//document.getElementById(id).innerHTML=item;

}

function set_focus()

{

	fob('frmMessageToUsers123').focus();

	return false;	

}





/******************************************

Function name : showSearchBox

Return type : None

Date created : 20th October 2007

Date last modified : 20th October 2007

Author : Sandeep Kumar

Last modified by : Sandeep Kumar

Comments : Function is used to show hide the seacch box

User instruction : showSearchBox()

******************************************/

function showSearchBox(varDocumentID, varShow)

{

	if(varShow == 'show')

	{

	 document.getElementById(varDocumentID).style.display = 'block';	

	}

	else

	{

	  document.getElementById(varDocumentID).style.display = 'none';

	}

	

}



/*****************************

Function name : checkCapsLock

Return type : none

Date created : 20 june 2008

Date last modified : 20 june 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : This function is used to display alert message when caps lock is on.

User instruction : checkCapsLock( e , FieldID) 

************************************/

function checkCapsLock(e , FieldID) 

{

	var myKeyCode=0;

	var myShiftKey=false;

	var myMsg='Caps Lock is ON.\n\nTo prevent entering your password incorrectly,\nYou should press Caps Lock to turn it OFF.';



	// Internet Explorer 4+

	if ( document.all ) {

		myKeyCode=e.keyCode;

		myShiftKey=e.shiftKey;



	// Netscape 4

	} else if ( document.layers ) {

		myKeyCode=e.which;

		myShiftKey=( myKeyCode == 16 ) ? true : false;



	// Netscape 6

	} else if ( document.getElementById ) {

		myKeyCode=e.which;

		myShiftKey=( myKeyCode == 16 ) ? true : false;



	}

	

	if(document.getElementById(FieldID).value.length==0) {



		// Upper case letters are seen without depressing the Shift key, therefore Caps Lock is on

		if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {

			alert( myMsg );

			//return;

	

		// Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on

		} else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {

			alert( myMsg );

		//	return;

		}

		return false;

	}

}

/******************************************

Function name : checkUserName

Return type : None

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : Function is used to login check using ajax.The ajax login check is a combination of functions all are using to check login system.

User instruction : checkUserName()

******************************************/

/* AJAX LOGIN CHECK CODE START FROM HERE */

function checkUserName() 

{

	var alphaNum = /^[0-9a-zA-Z_@.]+$/;

	var Usermail = document.getElementById('frm_login').frmAdminUserName.value;



	var charArray = new Array();

	var tString = "";

	for(i = 0; i < Usermail.length; i++) 

	{

		charArray[i] = Usermail.charAt(i);

	}



	for(i = 0; i < charArray.length; i++) 

	{

		if (charArray[i].match(alphaNum))

		{

			tString += charArray[i];

		}

	}	

	

	if (tString != "")

	{

		checkUserEmail(tString);

	}	

}

function checkUserEmail(mailID)

{ 

	

	doAjax('ajax_act.php','type=signUp&userEmail='+mailID,'showUserEmail','GET');

}

function showUserEmail(item)

{

		

	if(item)

	{

			

		document.getElementById('showUserName').style.display = 'none';	

	}

	else

	{

		document.getElementById('showUserName').style.display = 'inline';

	}



}



function loadEvents(eventType, eventID)

{

		doAjax('ajax_act.php','type=LoadEvent&eventType='+eventType+'&eventID='+eventID,'loadEvent','GET');

}

function loadEvent(item)

{

	document.getElementById('loadEvent').innerHTML = item;

}

/*****************************

Function name : validateAdminForm

Return type : integer

Date created : 20 june 2008

Date last modified : 20 june 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : This is used to check admin login authentications.

User instruction : validateAdminForm(charToCheck)

************************************/

function validateAdminLogin(formname)

{

	if(validateForm(formname,'frmAdminUserName','Username(Email)','R', 'frmAdminPassword','Password','R'))

	{	

		return true;

	} 

	else 

	{

		return false;

	} 

}

/******************************************

Function name : validator

Return type : boolean

Date created : 

Date last modified : 

Author : 

Last modified by : 

Comments : Function will return the true or error message after validating checkboxes

User instruction : validator(btnType)

******************************************/

function validateForm() 

{ 

	var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;

	j=0;

	

	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	var regBlank = /[^\s]/;

	

	//var regSpace = /^([a-zA-Z0-9_\!#@^&*%~-]+)$/;

	var regSpace = /^([a-zA-Z0-9-/_!#@]+)$/;

    var regAlphaNum = /^([a-zA-Z0-9_#@]+)$/;

	var regDate = /^([0-9_]+-[0-9][0-9]+-[0-9][0-9]+)$/; 

  	var regChar = /^([a-zA-Z]+)$/;

	var regNumeric = /^([0-9]+)$/; 

	//var regDecimal = /^([0-9]+|(\.?)[0-9]+)$/;

	var regDecimal = /^([0-9]{0,20}\.?[0-9]{1,2})$/;

	

	for (i=1; i<(args.length-2); i+=3) 

	{	

		mesg=args[i+1];

		test=args[i+2]; 

		var val=document.forms[""+args[0]].elements[""+args[i]];

		

		if (val) 

		{	

			

			nm=mesg; 

			noVal = val;

			val = val.value;

			if(regBlank.test(val))

			{

				if(test.indexOf('isEqual')!=-1)

				{

					result = trim(val);



					if(result.length==0)

					{

											

					errors += ''+nm+' \n'; 

					}

					else

					{

					equal_obj_val = test.substring(8,test.indexOf(":"));

					mesg_string =test.substring((test.indexOf(":")+1));



						if(val != document.forms[""+args[0]].elements[""+equal_obj_val].value)

						{ 

							errors+=''+nm+' and '+mesg_string+' must be same.\n';

						}

					}

				}

				else if(test.indexOf('isAlphaNum')!=-1)

				{

					result = trim(val);

					if(result.length==0){

					errors += ''+nm+'  \n'; 

					}else{

						if(!regAlphaNum.test(val))

						{

							errors += ''+nm+' is not valid.\n';

						}

					}

				

				}

				else if(test.indexOf('isNumeric')!= -1)

				{

						if(!regNumeric.test(val))

						{

							errors += ''+nm+' must contain a numeric value.\n';

							

						}

				}

				else if(test.indexOf('isDecimal') != -1)

				{

					

					if(!regDecimal.test(val))

					{

						errors += ''+nm+' must contain a number.\n';

					}

				}

			

				

				else if(test.indexOf('isSpace')!=-1)

				{

					result = trim(val);

					

					if(result.length==0)

					{

						errors += ''+nm+'  \n'; 

					}

					else

					{

						if(!regSpace.test(val))

						{

							errors += ''+nm+' is not valid.\n';

						}

					}

				}

				else if (test.indexOf('isEmail')!=-1) 

				{ 

					p=val.indexOf('@');

					s=val.indexOf('.');

			        if (p<1 || p==(val.length-1))

					{

						errors+=''+nm+' must contain an e-mail Address.\n';

		

					}

					else if(!regEmail.test(val))

					{

						errors+=''+nm+' must contain a valid e-mail Address.\n';

					}

			     }

				else if (test.indexOf('isUrl')!=-1) 

				{ 

					p=val.indexOf('http://');

					s=val.indexOf('.');

			        if (p<0 || p==(val.length-1))

					{

						errors+='- '+nm+' must be valid URL e.g. http://www.abc.com\n';

		

					}

					else if(s<p || s==(val.length-1))

					{

						errors+=''+nm+' must be valid URL e.g. http://www.abc.com\n';

					}

			     }

				else if (test.indexOf('isChar')!=-1) 

				 { 

					var first_char;

					

					if(val.match(regChar)==null)

					{

					 	errors+=''+nm+' must contain a character.\n';

					}

			     }

				else if(test.indexOf('isCheckbox')!=-1)//Check is check box is not checked generate error

				{	

					var valueCheckbox = noVal.checked;

					if(!valueCheckbox)

					{

						errors+='Accept Privacy Policy.\n';

					}

				}

				else if (test.charAt(0)=='R')

				{

					result = trim(val);

					if(result.length==0){

						

					errors += ''+nm+'  \n'; 

					}

				} 

			

		}

		else if (test.charAt(0)=='R')

		{

			result = trim(val);

				if(result.length==0){

					

				errors += ''+nm+'  \n'; 

				}

		}

		

		 if (test.indexOf('isDate')!=-1) 

				{ 

					//alert("vineet");

					p=val.indexOf('-');

			       // alert(test.indexOf('isDate'));

			       	var sliptdate	= val.split("-");

					

					/*******************Added by rupesh Date is not before current date and month*********************/

					var today=new Date(),TY=today.getFullYear(),TM=today.getMonth(),TD=today.getDate(),TH=today.getHours();

					TM+=1;			

					if(TM<=9) 

					{	

						TM='0'+TM;

					}

					if(TD<=9)

					{

						TD='0'+TD;

					}

					/*******************Added by rupesh*********************/

					

					var sY=sliptdate[0];

					var sM=sliptdate[1];

					var sD=sliptdate[2];

					

					/*******************Added by rupesh*********************/

					

				

				}



		if(errors !="")

		{	if(j<=0)

			{

				focusitem = document.forms[""+args[0]].elements[""+args[i]];

				j++;

			}	

		}

		}

		

	} 

	

  if (errors)

  {

	var MasterString = getMasterString();

	alert(MasterString+'\n'+errors);

	focusitem.focus();

	return false;

   }

   else

	return true;



  document.MM_returnValue = (errors == '');

}

/*****************************

Function name : validateEmailChange

Return type : boolean

Date created : 20 june 2008

Date last modified : 21 june 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : This function is used to validate admin notification email id.

User instruction : validateEmailChange(charToCheck)

************************************/

function validateEmailChange(formname)

{

	if(validateForm(formname, 'frmAdminEmail','Email','RisEmail'))

	{			

		var flag=confirm('Are you sure you want to change notification E-mail?')

		if(flag)

		return true;

		else

		return false;		

	} 

	else 

	{

		return false;

	} 

}

/*****************************

Function name : validateChangePassword

Return type : boolean

Date created : 10th September 2008

Date last modified : 

Author : Gulshan Verma

Last modified by :

Comments : This is used to validate admin password and confirm passwords.

User instruction : validateChangePassword(formname)

************************************/

function validateChangePassword(formname)

{

	if(validateForm(document.getElementById(formname).id,'frmAdminOldPassword', 'Current Password', 'RisSpace', 'frmAdminNewPassword', 'New Password','RisSpace','frmAdminConfirmPassword', 'Confirm New Password', 'RisEqualfrmAdminNewPassword:New Password'))

	{			

		var flag=confirm('Are you sure you want to change password?')

		if(flag)

		{

			return true;

		}

		else

		{

			return false;		

		}

	} 

	else 

	{

		return false;

	} 



}

/*****************************

Function name : validateResetPassword

Return type : boolean

Date created : 23rd September 2008

Date last modified : 23rd September 2008

Author : Ashok Singh Negi

Last modified by : Ashok Singh Negi

Comments : This is used to validate admin password and confirm passwords.

User instruction : validateResetPassword(formname)

************************************/

function validateResetPassword(formname)

{

	if(validateForm(document.getElementById(formname).id, 'frmNewPassword', 'New Password','RisSpace','frmConfirmNewPassword', 'Confirm New Password', 'RisEqualfrmNewPassword:New Password'))

	{	

		return true;

	} 

	else 

	{

		return false;

	} 



}

/*****************************

Function name : validateAdminForgotPassword

Return type : none

Date created : 10th September 2008

Date last modified : 

Author : Gulshan Verma

Last modified by :

Comments : This function is used to validate forgot password form.

User instruction : validateAdminForgotPassword(formname)

************************************/

function validateForgotPassword(formname)

{

	if(validateForm(formname,'frmUserName','Username (E-mail) ','RisEmail','frmSecurityCode','Verification code','R'))

	{	

		return true;

	} 

	else 

	{

		return false;

	} 

}



/******************************************

Function name : ltrim

Return type : string

Date created : 

Date last modified : 

Author : 

Last modified by : 

Comments : Function will return the main string after removing white spaces from the left

User instruction : ltrim(str)

******************************************/

function ltrim(str) { 

	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);

	return str.substring(k, str.length);

}

/******************************************

Function name : rtrim

Return type : string

Date created : 

Date last modified : 

Author : 

Last modified by : 

Comments : Function will return the main string after removing white spaces from the right

User instruction : rtrim(str)

******************************************/

function rtrim(str) {

	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;

	return str.substring(0,j+1);

}

/******************************************

Function name : trim

Return type : string

Date created : 

Date last modified :

Author : 

Last modified by : 

Comments : Function will return the main string after removing white spaces from the right and left of the main string

User instruction : trim(str)

******************************************/

function trim(str) {

	return ltrim(rtrim(str));

}

/******************************************

Function name : isWhitespace

Return type : integer

Date created : 

Date last modified : 

Author : 

Last modified by : 

Comments : Function will return the index of white space encounter in the string.

User instruction : isWhitespace(charToCheck)

******************************************/

function isWhitespace(charToCheck) {

	var whitespaceChars = " \t\n\r\f";

	return (whitespaceChars.indexOf(charToCheck) != -1);

}

/******************************************

Function name : checkError

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : Function will return the true or false acording to form validation

User instruction : checkError(error)

******************************************/

function checkError(error)

{

 var flag=false;

 var MasterString = getMasterString();

 

 if(error != "")

 {

  MasterString = MasterString + error;

  flag=true;

 }

 

 if(flag == true)

 {

  alert(MasterString);

  return false;

 }

 else

  return true;

}

/******************************************

Function name : getMasterString

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : Function will return the main string

User instruction : getMasterString()

******************************************/

function getMasterString()

{

 return "Sorry, we can not process your request.\nKindly provide us the missing information listed below.\n";

}

/******************************************

Function name : toggleOption

Return type : None

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : Function will toggle the select all checkbox option.

User instruction : toggleOption(spanChk)

******************************************/

 

function toggleOption(spanChk)

{

 

 var xState=spanChk.checked;

 var theBox=spanChk;

 

 elm=theBox.form.elements;

 

 for(i=0;i<elm.length;i++)

 {

  if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)

  {

   if(xState == false)

    elm[i].checked = false;

   else

    elm[i].checked = true;

  }

 }

}

/******************************************

Function name : toggleOption

Return type : None

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : Function will deselect the main checkbox

User instruction : deSelectCheckbox(spanChk)

******************************************/

function deSelectCheckbox(formname)

{

 document.getElementById('Main').checked = false;

}

 

/******************************************

Function name : setvalidAction

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : Function will ask for confirmation of updating records

User instruction : setValidAction(value, formname,listname)

******************************************/

function  setValidAction(value, formname,listname)

{

	if(value == 'Delete' || value.indexOf ('Delete')>-1)

	{

		// $Value = document.getElementById('frmHiddenDeleteClicked').value;

 		message = "delete selected "+listname; 

  	}

 	else if(value == 'Send Newsletter')

 	{

		message = "send newsletter to selected "+listname; 

 	}

 	else

 	{

 		message = "change status of selected "+listname;

 	}

 	var flag = validator(message,formname);

 	if(flag)

 	{  

		if(listname == 'Event images(s)')

  		{

			document.getElementById('frmHiddenDeleteClicked').value = 'Yes';

 		}

  		formname.submit();

 	}

 	else

 	{

		if(listname == 'Event images(s)')

  		{

			//alert(document.getElementById('frmChkDeleteImage').length);

			//alert(document.forms[0].elements);

			elm=document.forms[0].elements;

			for(i=0;i<elm.length;i++)

			{

				//alert(document.forms[0].elements[i].id);

				if(document.forms[0].elements[i].id == 'frmChkDeleteImage')

				{

					document.forms[0].elements[i].checked = false;	

				}

			}

			return false;

   		}

		else

		{

 			//alert(listname);return false;

			formname.frmChangeAction.value=''; 

			document.getElementById('Main').checked = false;

			if(listname == 'Member(s)'  )

			{

				document.forms[1].Main.checked=false; 

				elm=document.forms[1].elements;

			}

			else  if(listname == 'Message(s)'  )

			{

				document.forms[1].Main.checked=false; 

				elm=document.forms[1].elements;

			}

			else if(listname =='Report Abuse')

			{

				document.forms[1].Main.checked=false;

				elm=document.forms[1].elements;

			}

			else if(listname =='Offline Matches')

			{

				document.forms[1].Main.checked=false;

				elm=document.forms[1].elements;

			}

			else if(listname =='Event(s)')

			{

				document.forms[1].Main.checked=false;

				elm=document.forms[1].elements;

			}

			else if(listname =='Event Pass(s)')

			{

				document.forms[1].Main.checked=false;

				elm=document.forms[1].elements;

			}

			else

			{

				document.forms[0].Main.checked=false; 

				elm=document.forms[0].elements; 

			}

			for(i=0;i<elm.length;i++)

			{

				//alert(elm[i].type);

				if(elm[i].type == "checkbox" )

				{   

					elm[i].checked = false;

				}

			}

			return false;

 		}

	}

}

/******************************************

Function name : validator

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : Function will return the true or error message after validating checkboxes

User instruction : validator(btnType)

******************************************/

var btnType;

function validator(btnType,formname)

{

 

 var obj = formname;

 var error="", flagCheck=0;

 

 var len = obj.elements.length; 

 var i=0;

 for(i=0;i<len;i++) 

 {

  if(obj.elements[i].type=='checkbox')

  {

   if(obj.elements[i].checked)

   {

    //if(btnType == 'Delete')

     return askConfirm(btnType);

    //else

     //return true;

   }

   else

    flagCheck = 1;

  }

 }

 

 if(flagCheck == 1)

  error += "\n Please select at least one record.";

   

 return checkError(error);

}

/******************************************

Function name : askConfirm

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : Function will return the true or false after asking for confirmation

User instruction : askConfirm(type)

******************************************/

function askConfirm(type)

{ 

 var sen = "Are you sure you want to "+type+"?";

 if(confirm(sen))

 {

  return true;

 }

 else

 {

  return false;

 }

}





/******************************END ADMIN SECTION JS FUNCTION********************************************************/



/****************************************NEWSLETTER SECTION JS START******************************************/

/**************************************************************************

Function name : validateNewsletterForm

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : This function is used to show validate Newsletter form..

User instruction : validateNewsletterForm(formname)

***************************************************************************/

function validateSendNewsletterMail(value, formname, varString)

{

	var MasterString = getMasterString();

	var errorString = '';

	var boolfocus = false;

	var elementID ;

	

	if(formname.frmNewsletterID.value != '')

	{

		if(formname.frmSendOption[0].checked)

		{

			  return setValidAction(value, formname, varString);

		}

		else

		{

			  if(confirm("Are you sure you want to send newsletter to selected Member(s)"))

			  {

				  formname.submit();

				  return true; 	   	

			  }

			  else

			  {

				  return false;

			  }

		}

	}

	else

	{

		  errorString += 'Please select Newsletter.\n';	 

		  if(!boolfocus )

		  {

			boolfocus = true; 

			elementID = 'frmNewsletterID';	 

		  }

			

			alert(MasterString+'\n'+errorString); 

			if(boolfocus)

			{

			 document.getElementById(elementID).focus();

			}

			return false;   

			  

	}

	

}

/*****************************

Function name : NewsletterReciever

Return type : none

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : This function is used to show hide newsletter reciever.

User instruction : NewsletterReciever(formname)

************************************/

function NewsletterReciever(value)

{

	if(value == 'AllMembers')

	{

		document.getElementById('frmMemberID[]').disabled=true;

	}

	if(value=='Members')

	{

		document.getElementById('frmMemberID[]').disabled=false;

	}

}

/**************************************************************************

Function name : validateSendNewsletter

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : This function is used to show validate newsletter send form..

User instruction : validateSendNewsletter(formname)

***************************************************************************/

function validateSendNewsletter(formname)

{

	if(document.getElementById('frmSendToMembers').checked)

	{

		if(validateForm(formname,'frmMemberID[]','Subscriber ','R','frmNewsletterSubject','Subject','R'))

		{	

			flag = confirm('Are you sure you want to send this newsletter to selected member(s)?');

			if(flag)

			{

				return true;

			}

			else

			{

				return false;

			}

		} 

		else 

		{

			return false;

		} 

	}

	if(document.getElementById('frmSendToAll').checked)

	{

		if(validateForm(formname,'frmNewsletterSubject','Subject','R','frmNewsletterMessage','Message','R'))

		{	

			flag = confirm('Are you sure you want to send this newsletter to all members?');

			if(flag)

			{

				return true;

			}

			else

			{

				return false;

			}

		} 

		else 

		{

			return false;

		} 

	}

}





/****************************************NEWSLETTER SECTION JS END******************************************/

/****************************************CMS JS START******************************************/

/*****************************

Function name : validateCMSForm

Return type : bollean

Date created : 28th February 2008

Date last modified : 28th February 2008

Author : Sandeep Kumar

Last modified by : Sandeep Kumar

Comments : This function is used to validate the CMS form.

User instruction : validateCMSForm(formname)

************************************/

function validateCMSForm(formname)

{

	if(validateForm(formname,'frmPageTitle','Page Title','R','frmPageKeywords','Meta Keywords','R','frmPageDescription','Meta Description','R'))

	{	

		return true;

	} 

	else 

	{

		return false;

	} 

}

/****************************************CMS JS END******************************************/

/***********************ORDER SECTION JS START****************************************************************/

/*****************************

Function name : changePaymentStatus

Return type : integer

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : This function is used to validate the User.

User instruction : validateUser(formname)

************************************/

function changePaymentStatus(payment,recordID)

 {

   

   if(payment == "Paid")

   {

	var flag=confirm('Are you sure you want to change payment status?')

	 if(flag) 

	  {

	    

		document.forms[1].action='order_action.php?RecordID='+recordID;

		document.forms[1].submit();

	    return true;  

	  }

	 else

	  {

		var PaymentStatus = 'frmPaymentStatus'+recordID;

      

		document.getElementById(PaymentStatus).value='Unpaid';

	  

		return false;    

      }

	}

  }

/*****************************

Function name : changeOrderStatus

Return type : integer

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : This function is used to validate the User.

User instruction : validateUser(formname)

************************************/

function changeOrderStatus(OrderStatus,recordID)

{

  if(OrderStatus != "Pending")

   {

	 var flag=confirm('Are you sure you want to change order status?')

	 if(flag) 

	  {

	    

		document.forms[1].action='order_action.php?OrderStatus='+OrderStatus+'&RecordID='+recordID;

		document.forms[1].submit();

	    return true;  

	  }

	 else

	  {

		var OrderStatus = 'frmOrderStatus'+recordID;

		

		document.getElementById(OrderStatus).value='Pending';

	    return false;    

      }

	}

}



function changeOfflineStatus(matchStatus, matchID)

{



	 var flag=confirm('Are you sure you want to change offline match  status?')

	 if(flag) 

	  {

		document.location.href='matching_action.php?frmProcess=updateOfflineStatus&MatchStatus='+matchStatus+'&RecordID='+matchID;

//		document.forms[0].submit();

	//    return true;  

	  }

	 else

	  {

		var MatchStatus = 'frmMatchStatus'+matchID;

		document.getElementById(MatchStatus).value='Unmatched';

	    return false;    

      }

	

}

/******************************************

Function name : showPriceField

Return type : boolean

Date created : 10th September 2008

Date last modified : 10th September 2008

Author : Gulshan Verma

Last modified by : Gulshan Verma

Comments : Function will call the ajax function.

******************************************/

function showPriceField(FieldValue)

{

	if(FieldValue=='')

	{

		document.getElementById('frmPrice').disabled=true;

	}

	else

	{

		document.getElementById('frmPrice').disabled=false;

	}

	

}



/**********************ORDER SECTION JS END*******************************************************/



/*****************************

Function name : validBannerForm

Return type : boolean

Date created : 22nd October 2007

Date last modified : 22nd October 2007

Author : Sandeep Kumar

Last modified by : Sandeep Kumar

Comments : This function is used to validate admin setting form

User instruction : validBannerForm(formname)

************************************/

function validBannerForm(formname)

{

	if(document.getElementById('Image').style.display=='none')

	{

		

		if(validateForm(document.getElementById(formname).id,'frmBannerTitle', 'Advert Title', 'R', 'frmBannerPosition', 'Advert Position', 'R','frmBannerURL', 'Advert URL', 'isUrl','frmBannerHTMLCode', 'Advert HTML Code', 'R'))

		{

			

			return true;

		}

		else 

		{

			return false;	

		}

		

	}

	if(document.getElementById('HTML').style.display=='none')

	{

	

		if(document.getElementById('frmBannerImageName').value =='' && document.getElementById('frmUploadedImage').value =='')

		{			

		

			if(validateForm(document.getElementById(formname).id,'frmBannerTitle', 'Advert Title', 'R', 'frmBannerPosition', 'Advert Position', 'R','frmBannerURL', 'Advert URL', 'isUrl','frmBannerImageName', 'Advert Image', 'R'))

			{

				return true;

			}

			else 

			{

				return false;	

			}

			

		}

		

		else

		{	

			

			if(validateForm(document.getElementById(formname).id,'frmBannerTitle', 'Advert Title', 'R', 'frmBannerPosition', 'Advert Position', 'R','frmBannerURL', 'Advert URL', 'isUrl'))

			{

				return true;

			}

			else 

			{

				return false;	

			}

		}

		

	}

}

/*****************************

Function name : changeAdminBannerSize

Return type : no

Date created : 8 March 2007

Date last modified : 

Author : Prashant Bhardwaj

Last modified by :

Comments : This function is used to check banner size.

User instruction : changeAdminBannerSize(formname)

************************************/

function changeAdminBannerSize(varPosition)

{

	alert(varPosition);

	if(varPosition=='Top' || varPosition=='Bottom')

	{

		

		document.getElementById('meMsgID').style.display = 'none';

		document.getElementById('BannerSize').innerHTML = '(Max advert size = 692 x 134 px.)';

	}

	if(varPosition=='Left' || varPosition=='Right')

	{

		document.getElementById('meMsgID').style.display = 'none';	

		document.getElementById('BannerSize').innerHTML = '(Max advert width = 208 px.)';

	}

}

/*****************************

Function name : showBannerOptions

Return type : boolean

Date created : 22nd October 2007

Date last modified : 22nd October 2007

Author : Sandeep Kumar

Last modified by : Sandeep Kumar

Comments : This function is used to show Banner Options.

User instruction : showBannerOptions(formname)

************************************/

function showBannerOptions(option)

{

	if(option == 'Image')

	{

		document.getElementById('Image').style.display = 'block';

		document.getElementById('HTML').style.display = 'none';

		document.getElementById('BannerField').innerHTML = '<span class="color_red">* </span><strong>Advert Image:</strong>';

		document.getElementById('frmBannerImageName').focus();

	}

	else

	{

		document.getElementById('Image').style.display = 'none';	

		document.getElementById('HTML').style.display = 'block';

		document.getElementById('BannerField').innerHTML = '<span class="color_red">* </span><strong>Advert HTML Code:</strong>';

		document.getElementById('frmBannerHTMLCode').focus();	

	}

}



/***************************** admin member section ***************************************************************/

/*****************************

Function name : validateUser

Return type : none

Date created : 20 December 2007

Date last modified :20 December 2007

Author :Sumit Agrawal

Last modified by : Sumit Agrawal

Comments : This function is used to validate the Domain form

User instruction :  validateUser(formname)

************************************/



function validateUser(formname)

{

	if(document.getElementById(formname).frmPasswordIsSet.value == 'No' && document.getElementById(formname).frmConPasswordIsSet.value == 'No')

	{

		if(validateForm(formname, 'frmUserFirstName', 'First Name', 'R', 'frmUserLastName', 'Last Name', 'R', 'frmUserUserName', 'Username', 'RisEmail', 'frmUserPassword', 'Password', 'RisSpace', 'frmUserConfirmPassword', 'Confirm Password', 'RisEqualfrmUserPassword:Password', 'frmUserCountry', 'Country', 'R', 'frmUserState', 'State', 'R', 'frmUserCity', 'City', 'R', 'frmUserZipcode', 'Zipcode', 'isNum', 'frmUserPhone', 'Phone', 'R'))

		{  

			return true;

		} 

		else 

		{

			return false;

		}

	}

	else

	{

		if(document.getElementById(formname).frmPasswordIsSet.value == 'Yes' && document.getElementById(formname).frmConPasswordIsSet.value == 'Yes')

		{

			if(validateForm(formname, 'frmUserFirstName', 'First Name', 'R', 'frmUserLastName', 'Last Name', 'R', 'frmUserUserName', 'Username', 'RisEmail', 'frmUserCountry', 'Country', 'R', 'frmUserState', 'State', 'R', 'frmUserCity', 'City', 'R', 'frmUserZipcode', 'Zipcode', 'isNum', 'frmUserPhone', 'Phone', 'R'))

			{  

				return true;

			} 

			else 

			{

				return false;

			}

		}		

	}

}





function validateContactForm(formname)

{



	if(validateForm(formname, 'frmName', 'Name', 'R', 'frmEmail', 'Email', 'RisEmail', 'frmComments', 'Comments', 'R'))

	{	

		return true;

	} 

	else 

	{

		return false;

	} 

}



/*****************************

Function name : validateUser

Return type : none

Date created : 20 December 2007

Date last modified :20 December 2007

Author :Sumit Agrawal

Last modified by : Sumit Agrawal

Comments : This function is used to validate the Domain form

User instruction :  validateUser(formname)

************************************/

function validateNewsletterForm(formname)

{

	if(validateForm(formname, 'frmNewsletterTitle', 'Title', 'R'))

			{  

				return true;

			} 

			else 

			{

				return false;

			}

}

/*****************************

Function name : validateRegsiterForm

Return type : none

Date created : 16th October 2008

Date last modified :16th October 2008

Author :Gulshan Verma

Last modified by : Gulshan Verma

Comments : This function is used to validate the register form

User instruction :  validateRegsiterForm(formname)

************************************/

function validateRegsiterForm(formname)

{



	if(validateForm(formname, 'frmUserFirstName', 'First Name', 'R', 'frmUserLastName', 'Last Name', 'R', 'frmUserUserName', 'Username', 'RisEmail', 'frmUserPassword', 'Password', 'R', 'frmConfirmPassword', 'Confirm Password', 'RisEqualfrmUserPassword:Password',  'frmUserCountry', 'Country', 'R', 'frmUserCity', 'City', 'R', 'frmUserPinCode', 'Pincode', 'isNumeric', 'frmUserAge', 'Age', 'RisNumeric', 'frmUserGender', 'Gender', 'R', 'frmPrivacyPolicy', 'Privacy policy', 'RisCheckbox'))

	{  

		len = document.getElementById('frmUserPhone').value.length;

		/*

		if(len < 10 || len > 10)

		{

			alert('Enter the mobile number of 10 digit.');

			return false;

		}

		else

		{

			return true;

		}

		*/

		return true;

		

	} 

	else 

	{

		

		return false;

	}	

}









/************************************** promotional offer *********************************/



/*****************************

Function name : dateCompare

Return type : boolean

Date created : 15 March

Date last modified : 29th October 2007

Author : Vineet Kumar

Last modified by : Vineet Kumar

Comments : This function is used to validate the date compare form and to date.[ From date should be less than to date. ]

User instruction : dateCompare(formname)

************************************/

function offerDateCompare(formname)

{

	

		   var sliptdate	= document.getElementById(formname).frmTodate.value.split("-");

		   var FromDate  = document.getElementById(formname).frmDate.value.split("-");

			

		  if(document.getElementById(formname).frmTodate.value)

		   {

			/*********************** From Date *****************/

			var TY = FromDate[0];  //Year

			var TM = FromDate[1];  //Month

			var TD = FromDate[2];  //Date



			/******************* To Date *********************/

			var sY=sliptdate[0];  //Year

			var sM=sliptdate[1];  //Month

			var sD=sliptdate[2];  //Date

			

			/*******************Added by rupesh*********************/

			//alert(TM);

		

				if(sY<TY ) 

				{

					

					alert("'Expiry To' date should be greater than ' Expiry From' date.");

					return false;	  

				}

				else if(sM==TM && sD<TD && sY==TY) { 

	

					alert("'Expiry To' date should be greater than ' Expiry From' date.");

					return false;

					

				}

				else if(sM<TM && sY==TY) { 

				   alert("'Expiry To' date should be greater than ' Expiry From' date.");

					return false;

				}

		  }

   

   

        

		   var sliptdate1 = document.getElementById(formname).frmAddTodate.value.split("-");

		   var FromDate1  = document.getElementById(formname).frmAddDate.value.split("-");

			

		   if(document.getElementById(formname).frmAddTodate.value)

		    {

				/*********************** From Date *****************/

				var TY = FromDate1[0];  //Year

				var TM = FromDate1[1];  //Month

				var TD = FromDate1[2];  //Date

				/******************* To Date *********************/

				var sY=sliptdate1[0];  //Year

				var sM=sliptdate1[1];  //Month

				var sD=sliptdate1[2];  //Date

				

				/*******************Added by rupesh*********************/

				//alert(TM);

			

					if(sY<TY ) 

					{

						

						alert("'Start To' date should be greater than 'Start From' date.");

						return false;	  

					}

					else if(sM==TM && sD<TD && sY==TY) 

					{ 

		

						alert("'Start To' date should be greater than ' Start From' date.");

						return false;

						

					}

					else if(sM<TM && sY==TY) 

					{ 

						alert("'Start To' date should be greater than 'Start From' date.");

						return false;

					}

		   }

  

     }

	 

	 

/*****************************

Function name : validatePromotionalOffer

Return type : integer

Date created : 28 April 2008

Date last modified : 

Author : Prashant Bhardwaj

Last modified by : 

Comments : This is used to check Offer form.

User instruction : validatePromotionalOffer(charToCheck)

************************************/

function validatePromotionalOffer(formname)

{

	if(validateForm(formname,'frmEventsType', 'Event Type', 'R', 'frmEventsID', 'Events', 'R', 'frmOfferTitle', 'Promotional code', 'R', 'frmDate', 'Offer Start Date', 'RisDate', 'frmTodate', 'Offer Expiry Date', 'RisDate', 'frmOfferDiscount', 'Offer Discount', 'RisNaN'))

	{	

		

		   var sliptdate	= document.getElementById(formname).frmTodate.value.split("-");

		   var FromDate  = document.getElementById(formname).frmDate.value.split("-");

			

		 

			/*********************** From Date *****************/

			var TY = FromDate[0];  //Year

			var TM = FromDate[1];  //Month

			var TD = FromDate[2];  //Date

			/******************* To Date *********************/

			var sY=sliptdate[0];  //Year

			var sM=sliptdate[1];  //Month

			var sD=sliptdate[2];  //Date

			

			/*******************Added by rupesh*********************/

			//alert(TM);

		

			if(sY<TY ) 

			{

				

				alert("'Expiry' date should be greater than 'Start' date.");

				return false;	  

			}

			else if(sM==TM && sD<TD && sY==TY) 

			{ 



				alert("'Expiry' date should be greater than 'Start' date.");

				return false;

				

			}

		   else if(sM<TM && sY==TY) 

		    { 

                alert("'Expiry' date should be greater than 'Start' date.");

				return false;

			}

	       return true;

	} 

	else 

	{

		return false;

	} 

}



//******************************  End promotinal offer *******************************/

function getCity(val, city)

{

	doAjax('ajax_act.php','type=putCity&val='+val+'&city='+city,'showCity','GET', 2);

}

function showCity(item)

{

	document.getElementById('City').innerHTML = item;

}



/*****************************

Function name : ValidateMediaForm

Return type : Boolean

Date created : 18th Feb 2009

Date last modified :18th Feb 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the media form

User instruction :  validateRegsiterForm(formname)

************************************/

function ValidateMediaForm(formname)

{

	if(validateForm(formname, 'frmMediaCoverageTitle', 'Title', 'R'))

	{  

		return true;

	} 

	else 

	{

		return false;

	}	

}



/******************************************

Function name : deleteImage

Return type : boolean

Date created : 4th Feb 2009

Date last modified : 4th Feb 2009

Author : Neha Sharma

Last modified by :  Neha Sharma

Comments : Function will validate account details from 

User instruction :validateAccountDetails(formname)

******************************************/

function deleteImage(rID, action)

{

	 var flag=confirm('Are you sure you want to delete the photo?');

	 if(flag)

	 {

		if(action == 'media')

		{

		 location.href='media_coverage_action.php?pid='+rID+'&action=delete';

		}

		else if(action == 'user')

		{

			location.href='user_settings_action.php?pid='+rID+'&action=delete';

		}

  	 }

	 else

	 {

		return false;

	 }

}



/******************************************

Function name : deleteImage

Return type : boolean

Date created : 4th Feb 2009

Date last modified : 4th Feb 2009

Author : Neha Sharma

Last modified by :  Neha Sharma

Comments : Function will validate account details from 

User instruction :validateAccountDetails(formname)

******************************************/

function deleteEventImage(eID, imgtype)

{

	 if(imgtype == 'event')

	 {

	 	var flag=confirm('Are you sure you want to delete the photo?');

	 	if(flag)

		{

		  	location.href='event_action.php?eid='+eID+'&imgtype='+imgtype;

		}

		else

		{

			return false;

		}

		

  	 }

	 else if(imgtype == 'map')

	 {

	 	var flag=confirm('Are you sure you want to delete the location map?');

	 	if(flag)

		{

		 	location.href='event_action.php?eid='+eID+'&imgtype='+imgtype;

		}

		else

		{

			return false;

		}

	 }

}

/*****************************

Function name : validateAdminForgotPassword

Return type : none

Date created : 10th September 2008

Date last modified : 

Author : Gulshan Verma

Last modified by :

Comments : This function is used to validate forgot password form.

User instruction : validateAdminForgotPassword(formname)

************************************/

function validateEventForm(formname)

{

	var MasterString = getMasterString();

	var errorString = '';

	if(validateForm(formname,'frmEventsType', 'Event Type', 'R', 'frmEventsTitle', 'Title', 'R', 'frmEventsDate', 'Date', 'RisDateCheck', 'frmEventsAmount', 'Cost', 'R', 'frmEventsAddress', 'Address', 'R'))

	{	

	/*

		if(document.getElementById('frmHour').value == '0' && document.getElementById('frmMinute').value == '0' && document.getElementById('frmFinishHour').value == '0' && document.getElementById('frmFinishMinute').value == '0')

		{

				errorString += ' Time  \n';

				alert(MasterString+'\n'+errorString);

				return false;

		}

		else

		{

	       if(document.getElementById('frmHour').value > document.getElementById('frmFinishHour').value)

		   {

				errorString += ' Time \'From\' should be less than time \'To\'.\n';

				alert(MasterString+'\n'+errorString);

				return false;

		   }

		   else if(document.getElementById('frmHour').value == document.getElementById('frmFinishHour').value)

		   {

		   		if(document.getElementById('frmMinute').value >= document.getElementById('frmFinishMinute').value)

				{

					errorString += ' Time \'From\' should be less than  time \'To\'.\n';

					alert(MasterString+'\n'+errorString);

					return false;

				}

		   }

		}

		*/

			if(parseInt(document.getElementById('frmAgeFrom').value) > parseInt(document.getElementById('frmAgeTo').value))

			{

				errorString += ' Age From should be less than Age To.\n';

				alert(MasterString+'\n'+errorString);

				return false;

				

			}

		

	/*	  if(document.getElementById('frmEventContactName').value == '' && document.getElementById('frmEventContactNumber').value!= '')

		   {

					errorString += '- Name  \n';

					alert(MasterString+'\n'+errorString);

					return false;

		   }

		   else if(document.getElementById('frmEventContactName').value!= '' && document.getElementById('frmEventContactNumber').value == '')

		   {

					errorString += '- Number  \n';

					alert(MasterString+'\n'+errorString);

					return false;

		   }*/

		   if(document.getElementById('frmImageCount').value >0)

			{

				for(var i=1;i<=document.getElementById('frmImageCount').value;i++)

				{

						if(document.getElementById('frmEventContactName_'+i).value!='' && document.getElementById('frmEventContactNumber_'+i).value == '')

						{

							errorString += ' Number  \n';

							alert(MasterString+'\n'+errorString);

							return false;

						}

						if(document.getElementById('frmEventContactName_'+i).value == '' && document.getElementById('frmEventContactNumber_'+i).value!= '')

						{

							errorString += ' Name  \n';

							alert(MasterString+'\n'+errorString);

							return false;

						}

				}

			}

		 

		 

		 

		return true;

		   

		}

 

	else 

	{

		return false;

	} 

}

/***************************************************************************************************

							FRONTEND FUNCTIONS

****************************************************************************************************/

/*****************************

Function name : validateRegisterStepOne

Return type : Boolean

Date created : 19th Feb 2009

Date last modified :19th Feb 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the First step of registeration

User instruction :  validateRegsiterForm(formname)

************************************/

function validateRegisterStepOne(formname)

{	

			if(validateForm(formname, 'frmUserFirstName', 'First Name', 'R', 'frmUserLastName', 'Last Name', 'R', 'frmUserUserName', 'Email', 'RisEmail', 'frmUserPassword', 'Password', 'R'))

			{  

					var str = document.getElementById(formname).frmUserPassword.value;

					var len = str.length;

					if(len< 6)

					{

						alert('Password must be of atleast 6 characters or more.');

						return false;

					}

					else

					{		

						document.getElementById(formname).submit();

					}

			} 

			else 

			{

				return false;

			}	

	

	

}



/*****************************

Function name : showHideBlocks()

Return type : Boolean

Date created : 19th Feb 2009

Date last modified :19th Feb 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the First step of registeration

User instruction :  validateRegsiterForm(formname)

************************************/

function showHideBlocks(activeBlockID, inactiveBlockIDOne, inactiveBlockIDTwo, activeClassID, inactiveClassIDOne, inactiveClassIDTwo)

{

	

	//alert(activeBlockID, inactiveBlockIDOne, inactiveBlockIDTwo, activeClassID, inactiveClassIDOne, inactiveClassIDTwo);



	document.getElementById(activeBlockID).style.display='block';

	document.getElementById(inactiveBlockIDOne).style.display='none';

	document.getElementById(inactiveBlockIDTwo).style.display='none';

	document.getElementById(activeClassID).className='current'; 

	document.getElementById(inactiveClassIDOne).className=''; 

	document.getElementById(inactiveClassIDTwo).className=''; 

}



/*****************************

Function name : validateRegisterPersonal

Return type : Boolean

Date created : 20th Feb 2009

Date last modified :20th Feb 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the Second step of registeration

User instruction :  validateRegsiterForm(formname)

************************************/

function validateRegisterStepTwo(formname)

{

	var regNumeric = /^([0-9]+)$/;

	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	var errorString = '';

	var boolfocus = false;

	if(document.getElementById('frmUserPhone').value!='')

	{

		var Phone = document.getElementById('frmUserPhone').value;

		if(!regNumeric.test(Phone))

		{

			errorString += 'Mobile Phone must contain a numeric value.\n';

			if(!boolfocus)

			{

				boolfocus = true; 

				elementID = 'frmUserPhone';	 

			}

			

		} 

	}

	/*

	if(document.getElementById('frmUserWebsite').value!='')

	{	alert(document.getElementById('frmUserWebsite').value);

		if(!regEmail.test(document.getElementById('frmUserWebsite').value))

		{

			errorString += 'Website must be valid URL e.g. http://www.abc.com\n';

			if(!boolfocus)

			{

				boolfocus = true; 

				elementID = 'frmUserWebsite';	 

			}

		}

	}

	*/

	

		if (document.getElementById('frmUserWebsite').value != '') 

		{ 

			var val = document.getElementById('frmUserWebsite').value;

			p=val.indexOf('http://');

			s=val.indexOf('.');

			if (p<0 || p==(val.length-1))

			{

				errorString +=' Website must be valid URL e.g. http://www.abc.com\n';

				if(!boolfocus)

				{

					boolfocus = true; 

					elementID = 'frmUserWebsite';	 

				}

			}

			else if(s<p || s==(val.length-1))

			{

				errorString+=' Website must be valid URL e.g. http://www.abc.com\n';

				if(!boolfocus)

				{

					boolfocus = true; 

					elementID = 'frmUserWebsite';	 

				}

			}

	   }

	

	if(errorString == '')

   	{

		document.getElementById(formname).submit();

	}

    else

    {	

		if(boolfocus)

		{

			document.getElementById(elementID).focus();

		}

		alert(errorString);

		return false;

    }



}



/*****************************

Function name : validateRegisterPersonal

Return type : Boolean

Date created : 20th Feb 2009

Date last modified :20th Feb 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the Second step of registeration

User instruction :  validateRegsiterForm(formname)

************************************/

function validateLoginForm(formname)

{

	if(validateForm(formname, 'frmUserUserName', 'Email', 'RisEmail', 'frmUserPassword', 'Password', 'R'))

	{  

		return true;

	} 

	else 

	{

		return false;

	}	

}



/*****************************

Function name : validateForgotPasswordForm

Return type : boolean

Date created : 25 November 2008

Date last modified : 25 November 2008

Author : Neha Sharma

Last modified by : Neha Shrama

Comments : This function is used to validate user Register Form

User instruction : validateEmailID(charToCheck)

************************************/

function validateForgotPasswordForm(formname)

{

	if(validateForm(formname,'frmUserUserName', 'Username', 'RisEmail', 'frmVerificationCode', 'Verification Code', 'R'))

	{

		

		document.getElementById(formname).submit();

	}

	else

	{

		return false;

	}

}



/*****************************

Function name : validateResetPassword

Return type : boolean

Date created : 23rd September 2008

Date last modified : 23rd September 2008

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This is used to validate admin password and confirm passwords.

User instruction : validateResetPassword(formname)

************************************/

function validateResetPassword(formname)

{

	if(validateForm(formname, 'frmNewPassword', 'New Password','RisSpace','frmConfirmNewPassword', 'Confirm New Password', 'RisEqualfrmNewPassword:New Password'))

	{	

		var str = document.getElementById(formname).frmNewPassword.value;

		var len = str.length;

		if(len< 6)

		{

			alert('Password must be of atleast 6 characters or more.');

			return false;

		}

		else

		{		

			document.getElementById(formname).submit();

		}

	} 

	else 

	{

		document.getElementById('frmNewPassword').value='';

		document.getElementById('frmConfirmNewPassword').value='';

		return false;

	} 



}



/*****************************

Function name : validateNewsForm

Return type : boolean

Date created : 23rd February 2009

Date last modified : 23rd February 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the News form.

User instruction : validateCMSForm(formname)

************************************/

function validateNewsForm(formname)

{

	if(validateForm(formname,'frmPageTitle','Page Title','R'))

	{	

		return true;

	} 

	else 

	{

		return false;

	} 

}



/*****************************

Function name : validateMemberRegister

Return type : boolean

Date created : 24th February 2009

Date last modified : 24th February 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the CMS form.

User instruction : validateMemberRegister(formname)

************************************/

function validateMemberRegister(formname)

{

	var errorString = '';

	var boolfocus = false;

	var flagUnCheck = 0;

	var flagCheck = 0;

	var elementID ;

	var obj = document.getElementById(formname);	

	var len = obj.elements.length; 



	if(document.getElementById('frmDate').value =='')

	{

		 errorString += ' Date of Birth  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmDate';	 

		  }

		

	}

	else if(document.getElementById('frmMonth').value == '')

	{

		 errorString += ' Date of Birth  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmMonth';	 

		  }

		

	}

	else if(document.getElementById('frmYear').value == '')

	{

		 errorString += ' Date of Birth  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmYear';	 

		  }

		

	}

	else

	{

		

		

		

				

		var valDate = document.getElementById('frmDate').value+'/'+document.getElementById('frmMonth').value+'/'+document.getElementById('frmYear').value;

						

			var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;

			var matchArray = valDate.match(datePat); // is the format ok?

			

			

			day = matchArray[1]; // p@rse date into variables

			month = matchArray[3];

			year = matchArray[5];

			

			if (month < 1 || month > 12)

			{ // check month range

				errorString += ' Date of Birth is invalid.\n';	 

				  if(!boolfocus )

				  {

					  boolfocus = true; 

					  elementID = 'frmDate';	 

				  }

			}

			

			if (day < 1 || day > 31)

			{

				 errorString += ' Date of Birth is invalid.\n';	 

				  if(!boolfocus )

				  {

					  boolfocus = true; 

					  elementID = 'frmDate';	 

				  }

			}

			

			if ((month==4 || month==6 || month==9 || month==11) && day==31)

			{

				 errorString += ' Date of Birth is invalid.\n';	 

				  if(!boolfocus )

				  {

					  boolfocus = true; 

					  elementID = 'frmDate';	 

				  }

			}

			

			if (month == 2)

			{ 

			  // check for february 29th

				var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));

				if (day > 29 || (day==29 && !isleap))

				{

					errorString += ' Date of Birth is invalid.\n';	 

					  if(!boolfocus )

					  {

						  boolfocus = true; 

						  elementID = 'frmDate';	 

					  }

				}

			}

		

		

		

			var val = document.getElementById('frmYear').value+'-'+document.getElementById('frmMonth').value+'-'+document.getElementById('frmDate').value;

			

		p = val.indexOf('-');

		var sliptdate = val.split("-");

		var today=new Date(),TY=today.getFullYear(),TM=today.getMonth(),TD=today.getDate(),TH=today.getHours();

		TM+=1;			

		if(TM<=9) 

		{	

			TM='0'+TM;

		}

		if(TD<=9)

		{

			TD='0'+TD;

		}

		var sM=sliptdate[1];

		var sD=sliptdate[2];

		var sY=sliptdate[0];

	   if(sY>1)

	   {     

			if(sY>TY)

			{

				errorString += ' Date of Birth should not be greater than current date.\n';

				if(!boolfocus )

				{

					boolfocus = true; 

					elementID = 'frmDate';	 

				}

			}

			else if(sM>TM && sY==TY) 

			{ 

				errorString += ' Date of Birth should not be greater than current date.\n';

				if(!boolfocus )

				{

					boolfocus = true; 

					elementID = 'frmDate';	 

				}

				

			}

			else if(sD>TD && sM==TM && sY==TY) 

			{ 

				errorString += ' Date of Birth should not be greater than current date.\n';

				if(!boolfocus )

				{

					boolfocus = true; 

					elementID = 'frmDate';	 

				}

				

			}

	   }

	}

	

	if(document.getElementById('frmUserRelationshipStatus').value == '')

	{

		errorString += ' Relationship Status  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserRelationshipStatus';	 

		  }

		

	}

	if(document.getElementById('frmUserCity').value == '')

	{

		errorString += ' City  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserCity';	 

		  }

		

	}

	/*

	if(document.getElementById('frmUserLookingFor[]').checked == false)

	{

		if(document.getElementById('frmUserLookingFor[]').checked == false)

		{

			if(document.getElementById('frmUserLookingFor[]').checked == false)

			{

				errorString += '- Looking For  \n';	 

				if(!boolfocus )

				{

					boolfocus = true; 

					elementID = 'frmUserLookingFor[]';	 

				}

			}

		}

	}*/

		for(i=0;i<len;i++) 

		{

			if(obj.elements[i].type=='checkbox')

			{

				if(obj.elements[i].checked && obj.elements[i].name == 'frmUserLookingFor[]')

				{

					flagUnCheck = 1;	

				}

				else

				{

					flagCheck = 1;

				}

			}

		}

		if(flagCheck && flagUnCheck == 0)

		{

			errorString += ' Looking For  \n';	 



		}



	if(document.getElementById('frmUserSecurityQuestion').value == '')

	{

		 errorString += ' Security Question  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserSecurityQuestion';	 

		  }

		

	}

	if(document.getElementById('frmUserSecurityAnswer').value == '')

	{

		 errorString += ' Security Answer  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserSecurityAnswer';	 

		  }

		

	}

	if(document.getElementById('frmPolicyCheck').checked == false)

	{

		 errorString += ' Accept Privacy Policy.\n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmPolicyCheck';	 

		  }

		

	}

	if(errorString == '')

   	{

		document.getElementById(formname).submit();

	}

    else

    {	

		if(boolfocus)

		{

		 document.getElementById(elementID).focus();

		}

		masterString =  getMasterString();

		alert(masterString+'\n'+errorString);

		return false;

    }

}











/*****************************

Function name : validateNewMemberRegister

Return type : boolean

Date created :  04th March 2009

Date last modified : 04th March 2009

Author : Sharad Agarwal

Last modified by : Sharad Agarwal

Comments : This function is used to validate the CMS form.

User instruction : validateNewMemberRegister(formname)

************************************/

function validateNewMemberRegister(formname)

{

	var errorString = '';

	var boolfocus = false;

	var flagUnCheck = 0;

	var flagCheck = 0;

	var elementID ;

	var obj = document.getElementById(formname);	

	var len = obj.elements.length; 

	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	

			//alert(formname.frmUserUserName.value);

			//alert(document.getElementById(formname).frmUserUserName.value);

	if(document.getElementById('frmUserFirstName').value == '')

	{

		 errorString += ' First Name  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserFirstName';	 

		  }

		

	}



	if(document.getElementById('frmUserLastName').value == '')

	{

		 errorString += ' Last Name  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserLastName';	 

		  }

		

	}





	if(document.getElementById(formname).frmUserUserName.value == '')

	{

		 errorString += ' Email  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserUserName';	 

		  }

		

	}

	else if(!regEmail.test(document.getElementById(formname).frmUserUserName.value))

	{

		 errorString += ' Email must contain a valid e-mail Address.\n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserUserName';	 

		  }

	}



	

	if(document.getElementById('frmDate').value =='')

	{

		 errorString += ' Date of Birth  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmDate';	 

		  }

		

	}

	else if(document.getElementById('frmMonth').value == '')

	{

		 errorString += ' Date of Birth  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmMonth';	 

		  }

		

	}

	else if(document.getElementById('frmYear').value == '')

	{

		 errorString += ' Date of Birth  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmYear';	 

		  }

		

	}

	else

	{		

			var valDate = document.getElementById('frmDate').value+'/'+document.getElementById('frmMonth').value+'/'+document.getElementById('frmYear').value;

						

			var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;

			var matchArray = valDate.match(datePat); // is the format ok?

			

			

			day = matchArray[1]; // p@rse date into variables

			month = matchArray[3];

			year = matchArray[5];

			

			if (month < 1 || month > 12)

			{ // check month range

				errorString += ' Date of Birth is invalid.\n';	 

				  if(!boolfocus )

				  {

					  boolfocus = true; 

					  elementID = 'frmDate';	 

				  }

			}

			

			if (day < 1 || day > 31)

			{

				 errorString += ' Date of Birth is invalid.\n';	 

				  if(!boolfocus )

				  {

					  boolfocus = true; 

					  elementID = 'frmDate';	 

				  }

			}

			

			if ((month==4 || month==6 || month==9 || month==11) && day==31)

			{

				 errorString += ' Date of Birth is invalid.\n';	 

				  if(!boolfocus )

				  {

					  boolfocus = true; 

					  elementID = 'frmDate';	 

				  }

			}

			

			if (month == 2)

			{ 

			  // check for february 29th

				var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));

				if (day > 29 || (day==29 && !isleap))

				{

					errorString += ' Date of Birth is invalid.\n';	 

					  if(!boolfocus )

					  {

						  boolfocus = true; 

						  elementID = 'frmDate';	 

					  }

				}

			}





		var val = document.getElementById('frmYear').value+'-'+document.getElementById('frmMonth').value+'-'+document.getElementById('frmDate').value;

		

			

		p = val.indexOf('-');

		var sliptdate = val.split("-");

		var today=new Date(),TY=today.getFullYear(),TM=today.getMonth(),TD=today.getDate(),TH=today.getHours();

		TM+=1;			

		if(TM<=9) 

		{	

			TM='0'+TM;

		}

		if(TD<=9)

		{

			TD='0'+TD;

		}

		var sM=sliptdate[1];

		var sD=sliptdate[2];

		var sY=sliptdate[0];

	   if(sY>1)

	   {     

			if(sY>TY)

			{

				errorString += ' Date of Birth should not be greater than current date.\n';

				if(!boolfocus )

				{

					boolfocus = true; 

					elementID = 'frmDate';	 

				}

			}

			else if(sM>TM && sY==TY) 

			{ 

				errorString += ' Date of Birth should not be greater than current date.\n';

				if(!boolfocus )

				{

					boolfocus = true; 

					elementID = 'frmDate';	 

				}

				

			}

			else if(sD>TD && sM==TM && sY==TY) 

			{ 

				errorString += ' Date of Birth should not be greater than current date.\n';

				if(!boolfocus )

				{

					boolfocus = true; 

					elementID = 'frmDate';	 

				}

				

			}

	   }

	  

	}

	

	if(document.getElementById('frmUserRelationshipStatus').value == '')

	{

		errorString += ' Relationship Status  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserRelationshipStatus';	 

		  }

		

	}

	if(document.getElementById('frmUserCity').value == '')

	{

		errorString += ' City  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserCity';	 

		  }

		

	}



		for(i=0;i<len;i++) 

		{

			if(obj.elements[i].type=='checkbox')

			{

				if(obj.elements[i].checked && obj.elements[i].name == 'frmUserLookingFor[]')

				{

					flagUnCheck = 1;	

				}

				else

				{

					flagCheck = 1;

				}

			}

		}

		if(flagCheck && flagUnCheck == 0)

		{

			errorString += ' Looking For  \n';	 



		}



	if(document.getElementById('frmUserSecurityQuestion').value == '')

	{

		 errorString += ' Security Question  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserSecurityQuestion';	 

		  }

		

	}

	if(document.getElementById('frmUserSecurityAnswer').value == '')

	{

		 errorString += ' Security Answer  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserSecurityAnswer';	 

		  }

		

	}

	if(document.getElementById('frmPolicyCheck').checked == false)

	{

		 errorString += ' Accept Privacy Policy.\n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmPolicyCheck';	 

		  }

		

	}

	

	if(errorString == '')

   	{

		var str = document.getElementById(formname).frmUserPassword.value;

		var len = str.length;

		

		if(len< 6)

		{

				alert('Password must be of atleast 6 characters or more.');

				return false;

		}

		else

		{

				document.getElementById(formname).submit();

		}

	}

    else

    {	

		if(boolfocus)

		{

		 document.getElementById(elementID).focus();

		}

		masterString =  getMasterString();

		alert(masterString+'\n'+errorString);

		return false;

    }

}



















/*****************************

Function name : isValidDate

Return type : boolean

Date created : 1st April 2009

Date last modified : 1st April 2009

Author : Sharad Agarwal

Last modified by : Sharad Agarwal

Comments : This function is used to validate the date.

User instruction : isValidDate(dateStr)

************************************/

function isValidDate(dateStr) // Pass Date in dd/mm/yyyy format

{

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;

var matchArray = dateStr.match(datePat); // is the format ok?



if (matchArray == null)

{

alert('Please enter your birth date as dd/mm/yyyy. Your current selection reads: '+ dateStr);

return false;

}



day = matchArray[1]; // p@rse date into variables

month = matchArray[3];

year = matchArray[5];



if (month < 1 || month > 12) { // check month range

alert('Month must be between 1 and 12.');

return false;

}



if (day < 1 || day > 31) {

alert('Day must be between 1 and 31.');

return false;

}



if ((month==4 || month==6 || month==9 || month==11) && day==31) {

alert('Month “+month+” doesn`t have 31 days!');

return false;

}



if (month == 2) { // check for february 29th

var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));

if (day > 29 || (day==29 && !isleap)) {

alert('February ' + year + ' doesn`t have ' + day + ' days!');

return false;

}

}

return true; // date is valid

}











/*****************************

Function name : validateEditProfile

Return type : boolean

Date created : 24th February 2009

Date last modified : 24th February 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the CMS form.

User instruction : validateEditProfile(formname)

************************************/

function validateEditProfile(formname)

{

	var errorString = '';

	var boolfocus = false;

	var elementID ;

	var flagUnCheck = 0;

	var flagCheck = 0;

	var obj = document.getElementById(formname);	

	var len = obj.elements.length; 

	var regNumeric = /^([0-9]+)$/;

	if(document.getElementById('frmUserFirstName').value == '')

	{

		 errorString += ' First Name  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserFirstName';	 

		  }

		

	}	

	if(document.getElementById('frmUserLastName').value == '')

	{

		errorString += ' Last Name  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserLastName';	 

		  }

		

	}

	if(document.getElementById('frmUserGender').checked == false)

	{

		 errorString += ' Gender  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserGender';	 

		  }

		

	}

	/*if(document.getElementById('frmUserDateOfBirth').value == '')

	{

		 errorString += '- Date of Birth  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserDateOfBirth';	 

		  }

		

	}*/

	if(document.getElementById('frmDate').value == '' || document.getElementById('frmMonth').value == '' || document.getElementById('frmYear').value == '')

	{

		 errorString += ' Date of Birth  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmDate';	 

		  }

		

	}

	else

	{

		

		

		var valDate = document.getElementById('frmDate').value+'/'+document.getElementById('frmMonth').value+'/'+document.getElementById('frmYear').value;

						

			var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;

			var matchArray = valDate.match(datePat); // is the format ok?

			

			

			day = matchArray[1]; // p@rse date into variables

			month = matchArray[3];

			year = matchArray[5];

			

			if (month < 1 || month > 12)

			{ // check month range

				errorString += ' Date of Birth is invalid.\n';	 

				  if(!boolfocus )

				  {

					  boolfocus = true; 

					  elementID = 'frmDate';	 

				  }

			}

			

			if (day < 1 || day > 31)

			{

				 errorString += ' Date of Birth is invalid.\n';	 

				  if(!boolfocus )

				  {

					  boolfocus = true; 

					  elementID = 'frmDate';	 

				  }

			}

			

			if ((month==4 || month==6 || month==9 || month==11) && day==31)

			{

				 errorString += ' Date of Birth is invalid.\n';	 

				  if(!boolfocus )

				  {

					  boolfocus = true; 

					  elementID = 'frmDate';	 

				  }

			}

			

			if (month == 2)

			{ 

			  // check for february 29th

				var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));

				if (day > 29 || (day==29 && !isleap))

				{

					errorString += ' Date of Birth is invalid.\n';	 

					  if(!boolfocus )

					  {

						  boolfocus = true; 

						  elementID = 'frmDate';	 

					  }

				}

			}

		

		

		var val = document.getElementById('frmDate').value+"-"+document.getElementById('frmMonth').value+"-"+document.getElementById('frmYear').value;

		//alert('dfgdf');

		p = val.indexOf('-');

		var sliptdate = val.split("-");

		var today=new Date(),TY=today.getFullYear(),TM=today.getMonth(),TD=today.getDate(),TH=today.getHours();

		TM+=1;			

		if(TM<=9) 

		{	

			TM='0'+TM;

		}

		if(TD<=9)

		{

			TD='0'+TD;

		}

		var sM=sliptdate[1];

		var sD=sliptdate[2];

		var sY=sliptdate[0];

		  if(sY>1)

		   {     

				if(sY>TY )

				{

					errorString += ' Date of Birth should not be greater than current date.\n';

					if(!boolfocus )

					{

						boolfocus = true; 

						elementID = 'frmDate';	 

					}

				}

				else if(sM>TM && sY==TY) 

				{ 

					errorString += ' Date of Birth should not be greater than current date.\n';

					if(!boolfocus )

					{

						boolfocus = true; 

						elementID = 'frmDate';	 

					}

					

				}

				else if(sD>TD && sM==TM && sY==TY) 

				{ 

					errorString += ' Date of Birth should not be greater than current date.\n';

					if(!boolfocus )

					{

						boolfocus = true; 

						elementID = 'frmDate';	 

					}

					

				}

		   }

		}

	if(document.getElementById('frmUserRelationshipStatus').value == '0')

	{

		 errorString += ' Relationship Status  \n';	 

		  if(!boolfocus )

		  {

			  boolfocus = true; 

			  elementID = 'frmUserRelationshipStatus';	 

		  }

		

	}

	for(i=0;i<len;i++) 

	{

		if(obj.elements[i].type=='checkbox')

		{

			if(obj.elements[i].checked && obj.elements[i].name == 'frmUserLookingFor[]')

			{

				flagUnCheck = 1;	

			}

			else

			{

				flagCheck = 1;

			}

		}

	}

	if(flagCheck && flagUnCheck == 0)

	{

		errorString += ' Looking For  \n';	 



	}

	//alert(document.getElementById('frmUserPhone').value);

	if(document.getElementById('frmUserPhone').value!='')

	{

		var Phone = document.getElementById('frmUserPhone').value;

		if(!regNumeric.test(Phone))

		{

			errorString += 'Mobile Phone must contain a numeric value.\n';

			if(!boolfocus )

			{

				boolfocus = true; 

				elementID = 'frmUserPhone';	 

			}

		} 

	}

	

	if (document.getElementById('frmUserWebsite').value != '') 

	{ 

		var val = document.getElementById('frmUserWebsite').value;

		p=val.indexOf('http://');

		s=val.indexOf('.');

		if (p<0 || p==(val.length-1))

		{

			errorString +=' Website must be valid URL e.g. http://www.abc.com\n';



		}

		else if(s<p || s==(val.length-1))

		{

			errors+=' Website must be valid URL e.g. http://www.abc.com\n';

		}

	 }

	if(errorString == '')

   	{

		document.getElementById(formname).submit();

	}

    else

    {	

		if(boolfocus)

		{

		 document.getElementById(elementID).focus();

		}

		masterString =  getMasterString();

		alert(masterString+'\n'+errorString);

		return false;

    }

}







/*****************************

Function name : displayCity

Return type : integer

Date created : 17 March 2008

Date last modified : 17 March 2008

Author : Vineet Kumar

Last modified by : Vineet Kumar

Comments : This function is used to validate the User.

User instruction : DispayCity(formname)

************************************/

function displayState(CountryName,val)

 {



	 	var QryStr = "CountryName="+CountryName+'&city='+val;

		doAjax('ajax_act.php',QryStr,'addCityToDiv','get','1');

 }

	 





/*****************************

Function name : addCity

Return type : integer

Date created : 17 March 2008

Date last modified : 17 March 2008

Author : Vineet Kumar

Last modified by : Vineet Kumar

Comments : This function is used to validate the User.

User instruction : addCity(formname)

************************************/

function addCityToDiv(item)

{

	 if(item)

	  {	

		 document.getElementById('frmCityVisibility').innerHTML = item;	

	  }

}  







/*****************************

Function name : displayCity

Return type : integer

Date created : 17 March 2008

Date last modified : 17 March 2008

Author : Vineet Kumar

Last modified by : Vineet Kumar

Comments : This function is used to validate the User.

User instruction : DispayCity(formname)

************************************/

function displayStateForUserReg(CountryName,val)

 {



	 	var QryStr = "CountryName="+CountryName+'&city='+val;

		doAjax('ajax_act_user_reg.php',QryStr,'addCityToDivForUserReg','get','1');

 }

	 





/*****************************

Function name : addCity

Return type : integer

Date created : 17 March 2008

Date last modified : 17 March 2008

Author : Vineet Kumar

Last modified by : Vineet Kumar

Comments : This function is used to validate the User.

User instruction : addCity(formname)

************************************/

function addCityToDivForUserReg(item)

{

	 if(item)

	  {	

		 document.getElementById('frmCityVisibilityForUserReg').innerHTML = item;	

	  }

} 



/*****************************

Function name : showHidePrivacyBlocks()

Return type : Boolean

Date created : 19th Feb 2009

Date last modified :19th Feb 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the First step of registeration

User instruction :  validateRegsiterForm(formname)

************************************/

function showHidePrivacyBlocks(activeBlockID, inactiveBlockIDOne, inactiveBlockIDTwo, inactiveBlockIDThree, activeClassID, inactiveClassIDOne, inactiveClassIDTwo, inactiveClassIDThree, messageID)

{

	document.getElementById(activeBlockID).style.display='block';

	document.getElementById(inactiveBlockIDOne).style.display='none';

	document.getElementById(inactiveBlockIDTwo).style.display='none';

	document.getElementById(inactiveBlockIDThree).style.display='none';

	document.getElementById(activeClassID).className='current'; 

	document.getElementById(inactiveClassIDOne).className=''; 

	document.getElementById(inactiveClassIDTwo).className=''; 

	document.getElementById(inactiveClassIDThree).className='';

	var html = '<ul><li class="first"><a href="my_profile.php">Home</a></li>';

	if(activeBlockID == 'account')

	{

	   html = html+ '<li class="last">Account Settings</li></ul>';

	}

	else if(activeBlockID == 'email')

	{

	   html = html+ '<li class="last">Email Alerts</li></ul>';		

	}

	else if(activeBlockID == 'blocked')

	{

	   html = html+ '<li class="last">Blocked Members</li></ul>';		

	}

	else

	{

		html = html+ '<li class="last">Privacy Settings</li></ul>';	

	}

	document.getElementById('bread_crumbs').innerHTML = html;

	if(messageID == 'message')

	{

		document.getElementById(messageID).innerHTML = '';

	}

}



/*****************************

Function name : showHideReportBlocks()

Return type : Boolean

Date created : 19th Feb 2009

Date last modified :19th Feb 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the First step of registeration

User instruction :  validateRegsiterForm(formname)

************************************/

function showHideReportBlocks(activeBlockID, inactiveBlockIDOne, activeClassID, inactiveClassIDOne, messageID)

{

	document.getElementById(activeBlockID).style.display='block';

	document.getElementById(inactiveBlockIDOne).style.display='none';

	document.getElementById(activeClassID).className='current'; 

	document.getElementById(inactiveClassIDOne).className='';

	if(messageID == 'message')

	{

		document.getElementById(messageID).innerHTML = '';

	}

}

/*****************************



Function name : validateAccountForm()

Return type : Boolean

Date created : 19th Feb 2009

Date last modified :19th Feb 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to validate the First step of registeration

User instruction :  validateRegsiterForm(formname)

************************************/

function validateAccountForm(formname)

{

	if(validateForm(formname,'frmUserSecurityQuestion','Security Question','R' , 'frmUserSecurityAnswer', 'Security Answer', 'R'))

	{	

		document.getElementById(formname).submit();

	} 

	else 

	{

		return false;

	} 

}





/*****************************

Function name : divShowHIde()

Return type : Boolean

Date created : 26th Feb 2009

Date last modified :26th Feb 2009

Author : Sharad Agarwal

Last modified by : Sharad Agarwal

Comments : This function is used to Show HIde div at index page

User instruction :  divShowHIde(formname)

*****************************/

function divShowHIde(divid)

{

	// Code for Index 	

	if(divid =='divNews')

	{

		document.getElementById('anchorNews').className ="current";

		document.getElementById('anchorEvent').className ="";

		document.getElementById('anchorDomain').className ="";

		document.getElementById('divNews').style.display = 'block';

		document.getElementById('divEvents').style.display = 'none';

		document.getElementById('divDomains').style.display = 'none';

	}

	else if(divid == 'divEvents')

	{

		document.getElementById('anchorNews').className ="";

		document.getElementById('anchorEvent').className ="current";

		document.getElementById('anchorDomain').className ="";

		document.getElementById('divNews').style.display = 'none';

		document.getElementById('divEvents').style.display = 'block';

		document.getElementById('divDomains').style.display = 'none';

	}

		else if(divid == 'divDomains')

	{

		document.getElementById('anchorNews').className ="";

		document.getElementById('anchorEvent').className ="";

		document.getElementById('anchorDomain').className ="current";

		document.getElementById('divNews').style.display = 'none';

		document.getElementById('divEvents').style.display = 'none';

		document.getElementById('divDomains').style.display = 'block';

	}



	// Code for My Profile 

	

	if(divid =='News')

	{

		document.getElementById('aNews').className ="current";

		document.getElementById('aUpcomingEvents').className ="";

		document.getElementById('News').style.display = 'block';

		document.getElementById('UpcomingEvents').style.display = 'none';

	}

	else if(divid == 'UpcomingEvents')

	{

		document.getElementById('aUpcomingEvents').className ="current";

		document.getElementById('aNews').className ="";

		document.getElementById('UpcomingEvents').style.display = 'block';

		document.getElementById('News').style.display = 'none';

	}

	

	

}



/*****************************

Function name : checkPasswordLength

Return type : Boolean

Date created : 2nd March 2009

Date last modified :2nd March 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to check the length of the password.

User instruction :  divShowHIde(formname)

*****************************/

function checkPasswordLength(str)

{



	var len = str.length;

	if(len< 6)

	{

		alert('Password must be of atleast 6 characters or more.');

		return false;

	}



}



/*****************************

Function name : validateReportEmail

Return type : Boolean

Date created : 3nd March 2009

Date last modified :3nd March 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to check validate the email.

User instruction :  divShowHIde(formname)

*****************************/

function validateReportEmail(formname)

{

	if(validateForm(formname, 'frmAbusedUserFullName', 'Name', 'R', 'frmAbusedUserUrl', 'URL', 'RisUrl', 'frmAbuseContent', 'Violating content', 'R'))

	{	

		document.getElementById(formname).submit();

	} 

	else 

	{

		return false;

	} 

}



/*****************************

Function name : validateReportEmail

Return type : Boolean

Date created : 3nd March 2009

Date last modified :3nd March 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This function is used to check validate the email.

User instruction :  divShowHIde(formname)

*****************************/

function validateEventImage(formname)

{

	if(document.getElementById('frmEventImage_1').value == '' && document.getElementById('frmEventImage_2').value == '' && document.getElementById('frmEventImage_3').value == '' && document.getElementById('frmEventImage_4').value == '' && document.getElementById('frmEventImage_5').value == '')

	{

		errors = '- Upload Images  ';	

		var MasterString = getMasterString();

		alert(MasterString+'\n'+errors);

		return false;

	}

	else

	{

		document.getElementById(formname).submit();	

	}

	 	

}

/******************************************

Function name : changeImageStatus

Return type : boolean

Date created : 6th March 2009

Date last modified : 6th March 2009

Author : Neha Sharma

Last modified by :  Neha Sharma

Comments : Function will validate account details from 

User instruction :validateAccountDetails(formname)

******************************************/

function changeImageStatus(imgid, radioButtonID)

{

	 var flag=confirm('Are you sure you want to make this photo featured?');

	 if(flag)

	 {

		location.href='user_settings_action.php?imgid='+imgid+'&action=changeStatus';

	 }

	 else

	 {

		document.getElementById(radioButtonID).checked = false;

		return false;

	 }

}



/******************************************

Function name : rateUser

Return type : boolean

Date created : 6th March 2009

Date last modified : 6th March 2009

Author : Vineet Kumar

Last modified by :  Vineet Kumar

Comments : Function will validate account details from 

User instruction :rateUser(formname)

******************************************/

function rateUser(rateID)

{

  	document.getElementById('ratingMessage').innerHTML = '';

	var panelID = document.getElementById('currentPannel').value;

	var userID = document.getElementById('ratedUserID').value;

	url = 'op=rate&ruid='+userID+'&rating='+rateID+'&panelID='+panelID;

	doAjax('ajax_act.php', url, 'changeRating', 'get', 1);

	

}

/******************************************

Function name : changeRating

Return type : boolean

Date created : 7th March 2009

Date last modified : 7th March 2009

Author : Vineet Kumar

Last modified by :  Vineet Kumar

Comments : Function will validate account details from 

User instruction :changeRating(formname)

******************************************/

function changeRating(returnData)

{

	var splitData =  returnData.split('&');

    var panelID = document.getElementById('currentPannel').value;

	

	

	document.getElementById('rating_'+panelID).innerHTML= splitData[0]; 

    document.getElementById('ratingMessage').innerHTML = splitData[1];

/*	document.getElementById('frmHitchhRate1').checked = false;

	document.getElementById('frmHitchhRate2').checked = false;

	document.getElementById('frmHitchhRate3').checked = false;

	document.getElementById('frmHitchhRate4').checked = false;

	document.getElementById('frmHitchhRate5').checked = false;*/

   

}









/*****************************

Function name : validateDelete

Return type : boolean

Date created : 29th December 2008

Date last modified : 29th December 2008

Author : Sharad Agarwal

Last modified by : Sharad Agarwal

Comments : This function is used to validate cart for delete.

User instruction : validateDelete(formname)

************************************/

function validateDelete(form)

{

	dml=document.forms[form];

	len = dml.elements.length;

	var flag=1;

	for( i=1 ; i<len ; i++) 

	{

		if ((dml.elements[i].type=='checkbox'))

		{		

				if(dml.elements[i].checked==true)

				{

					flag=0;

				}

		}	

		

	}

	if(flag==0)

	{

		var flag=confirm('Are you sure you want to delete selected message(s)');

		if(!flag)

		{

			for(i=0; i<len; i++)

			{

				//alert(elm[i].type);

				if(dml.elements[i].type == "checkbox" )

				{   

					dml.elements[i].checked = false;

				}

			}

			return false;

		}

		else

		{

			document.getElementById(form).submit();

		}

	}

	else

	{

		alert('Please Select at least one message');

		return false;	

	}

}









/*****************************

Function name : validateMarkAsUnread

Return type : boolean

Date created : 24th march 2009

Date last modified : 24th march 2009

Author : Sharad Agarwal

Last modified by : Sharad Agarwal

Comments : This function is used to validate cart for delete.

User instruction : validateMarkAsUnread(formname)

************************************/



function validateMarkAsUnread(form)

{



	dml=document.forms[form];

	len = dml.elements.length;

	var flag=1;

	for( i=1 ; i<len ; i++) 

	{

		if ((dml.elements[i].type=='checkbox'))

		{		

				if(dml.elements[i].checked==true)

				{

					flag=0;

				}

		}	

		

	}

	if(flag==0)

	{

		//var flag=confirm('Are you sure you want to make unread selected message(s)');

		//alert(flag);

		flag = true;

		if(!flag)

		{

			for(i=0; i<len; i++)

			{

				//alert(elm[i].type);

				if(dml.elements[i].type == "checkbox" )

				{   

					dml.elements[i].checked = false;

				}

			}

			return false;

		}

		else

		{

			//document.getElementById(form).submit();

			document.getElementById(form).ur.value = 't';

			document.getElementById(form).submit();

		}

	}

	else

	{

		alert('Please Select at least one message');

		return false;	

	}



	

}







/******************************************

Function name : confirmDeleteFriend()

Return type : none

Date created : 12th March 2009

Date last modified : 12th March 2009

Author : Neha Sharma

Last modified by :  Neha Sharma

Comments : Function will remove the friends

User instruction :confirmDeleteFriend(formname)

******************************************/	

function confirmDeleteFriend(fid)

{

	var flag=confirm('Are you sure you want to remove this friend?');

	if(flag)

	{

		location.href='user_settings_action.php?fid='+fid+'&action=deleteFriend';

	}

	else

	{

		return false;

	}

}











/******************************************

Function name : confirmDeleteFriendFromSearch()

Return type : none

Date created : 16th April 2009

Date last modified : 16th April 2009

Author : Sharad Agarwal

Last modified by :  Sharad Agarwal

Comments : Function will remove the friends

User instruction :confirmDeleteFriendFromSearch(formname)

******************************************/	

function confirmDeleteFriendFromSearch(fid)

{

	var flag=confirm('Are you sure you want to remove this friend?');

	if(flag)

	{

		location.href='user_settings_action.php?rp=search&fid='+fid+'&action=deleteFriend';

	}

	else

	{

		return false;

	}

}











/******************************************

Function name : validateMessageForm()

Return type : none

Date created : 16th March 2009

Date last modified : 16th March 2009

Author : Sharad Agarwal

Last modified by :  Sharad Agarwal

Comments : Function will validate MessageForm

User instruction :validateMessageForm(formname)

******************************************/	

function validateMessageForm(formname)

{

	if(validateForm(formname, 'frmSubject', 'Subject', 'R', 'frmMessage','Flirt','R'))

	{	

		return true;

	} 

	else 

	{

		return false;

	} 

}



/******************************************

Function name : validateMessageForm()

Return type : none

Date created : 16th March 2009

Date last modified : 16th March 2009

Author : Sharad Agarwal

Last modified by :  Sharad Agarwal

Comments : Function will validate MessageForm

User instruction :validateMessageForm(formname)

******************************************/	

function validateFlirtMessageForm(formname)

{

	

	if(validateForm(formname,'frmMessage','Flirt','R'))

	{	

		return true;

	} 

	else 

	{

		return false;

	} 

}





/******************************************

Function name : validateMessageReply()

Return type : none

Date created : 21th March 2009

Date last modified : 21th March 2009

Author : Sharad Agarwal

Last modified by :  Sharad Agarwal

Comments : Function will validate MessageForm

User instruction :validateMessageReply(formname)

******************************************/	

function validateMessageReply(formname,Url)

{

	if(validateForm(formname, 'frmMessageSubject', 'Subject', 'R', 'frmMessage','Message','R'))

	{	

			 document.getElementById(formname).action = Url; 

			 document.getElementById(formname).submit();

	} 

	else 

	{

		return false;

	} 

}













/*****************************

Function name : getSubjectList

Return type : string

Date created : 13 january 2009

Date last modified : 13 january 2009

Author : Shardendu Singh

Last modified by :Shardendu Singh

Comments : This is used to generate subject list through ajax for department

User instruction : getSubjectList(department, selected)

************************************/

function changeUser(index, blind)

{

	if(blind!='')

	{

	    doAjax('ajax_blind_date.php','type=changeUser&index='+index+'&blind='+blind, 'showUserDetail', 'post', '2');

	}

	else

	{

	 	//alert('Vineet');

		doAjax('ajax_speed_date.php','type=changeUser&index='+index+'&blind='+blind, 'showUserDetail', 'post', '2');	  

	}

}



/*****************************

Function name : showSubjectList

Return type : string

Date created : 13 january 2009

Date last modified : 13 january 2009

Author : Shardendu Singh

Last modified by :Shardendu Singh

Comments : This is used to shows subject list through ajax for department

User instruction : showSubjectList(item)

************************************/

function showUserDetail(item)

{



	if(item)

	{

		document.getElementById('UserDiv').innerHTML =  item;	

	}

}









/******************************************

Function name : confirmDeleteFriend()

Return type : none

Date created : 12th March 2009

Date last modified : 12th March 2009

Author : Neha Sharma

Last modified by :  Neha Sharma

Comments : Function will remove the friends

User instruction :confirmDeleteFriend(formname)

******************************************/	

function confirmRemoveMatch(mid, eid, ename)

{

	var flag=confirm('Are you sure you want to remove this match?');

	if(flag)

	{

		location.href='user_settings_action.php?mid='+mid+'&eid='+eid+'&ename='+ename;

	}

	else

	{

		return false;

	}

}



/*****************************

Function name : getRProductPagingPage

Return type : integer

Date created : 16th June 2008

Date last modified : 16th June 2008

Author : Vineet Kumar

Last modified by : Vineet Kumar

Comments : This is used to check admin login authentications.

User instruction : validateAdminForm(charToCheck)

************************************/

function getRProductPagingPage(pageID,catID)

 {

     var QryStr = "page="+pageID;

	 doAjax('member_list_ajax_act.php',QryStr,'disPlayRProductPagingData','get','1');	 

 }





/*****************************

Function name : disPlayRProductPagingData

Return type : integer

Date created : 16th June 2008

Date last modified : 16th June 2008

Author : Vineet Kumar

Last modified by : Vineet Kumar

Comments : This function is used to validate the User.

User instruction : addCity(formname)

************************************/

 function disPlayRProductPagingData(item)

  {

	 if(item)

	  {	

		 document.getElementById('frmreplace1').innerHTML = item;	

	  }

  }

  

  /******************************************

Function name : confirmDeleteFriend()

Return type : none

Date created : 12th March 2009

Date last modified : 12th March 2009

Author : Neha Sharma

Last modified by :  Neha Sharma

Comments : Function will remove the friends

User instruction :confirmDeleteFriend(formname)

******************************************/	

function removeBlockedMember(bid)

{

	var flag=confirm('Are you sure you want to remove this user from the blocked member List?');

	if(flag)

	{

		location.href='user_settings_action.php?bid='+bid;

	}

	else

	{

		return false;

	}

}



/*****************************

Function name : validateUserChangePassword

Return type : boolean

Date created : 17th March 2009

Date last modified : 17th March 2009

Author : Neha Sharma

Last modified by : Neha Sharma

Comments : This is used to validate User change password form

User instruction : validChangePass(charToCheck)

************************************/

function validateUserChangePassword(formname)

{

	if(validateForm(formname,'frmUserOldPassword', 'Current Password', 'RisSpace', 'frmUserNewPassword', 'New Password','RisSpace','frmUserConfirmPassword','Confirm New Password','RisEqualfrmUserNewPassword:New Password'))

	{			

		var strOne = document.getElementById('frmUserOldPassword').value;

		var lenOne = strOne.length;

		if(lenOne< 6)

		{

			alert('Current Password must be of atleast 6 characters or more.');

			document.getElementById('frmUserOldPassword').value='';

			return false;

		}

		var strTwo = document.getElementById('frmUserNewPassword').value;

		var lenTwo = strTwo.length;

		if(lenTwo< 6)

		{

			alert('New Password must be of atleast 6 characters or more.');

			document.getElementById('frmUserNewPassword').value='';

			document.getElementById('frmUserConfirmPassword').value='';

			return false;

		}

		document.getElementById(formname).submit();

	} 

	else 

	{

		document.getElementById('frmUserOldPassword').value='';

		document.getElementById('frmUserNewPassword').value='';

		document.getElementById('frmUserConfirmPassword').value='';

		document.getElementById('frmUserOldPassword').focus();

	    return false;

	} 

}







/*****************************

Function name : validateUserChangePassword

Return type : boolean

Date created : 18th March 2009

Date last modified : 18th March 2009

Author : Sharad Agarwal

Last modified by : Sharad Agarwal

Comments : This is used to count Contacts

User instruction : 

************************************/

function countContacts(objForm, elementID)

{

	//alert(objForm);

	var len = objForm.elements.length; 

	var count = 0;

	for(i=0; i<len; i++) 

	{

		if(objForm.elements[i].type=='checkbox' && objForm.elements[i].checked && objForm.elements[i].id != 'Main')

		{

			count++;

		}

	}

	

	if(count ==1)

	{ 

	 	document.getElementById(elementID).innerHTML = count+' contact ';

	}

	else if(count >1)

	{

		document.getElementById(elementID).innerHTML = count+' contacts ';	

	}

	else

	{

	 	document.getElementById(elementID).innerHTML = count+' contact ';	

	}

	document.getElementById('MemInvitePackageCount').value = count ;

	return true;

}













/*****************************

Function name : validateEventPasses

Return type : boolean

Date created : 20th March 2009

Date last modified : 20th March 2009

Author : Sharad Agarwal

Last modified by : Sharad Agarwal

Comments : 

User instruction : 

************************************/

function validateEventPasses(formname)

{

	

	/*if(validateForm(formname, 'frmPlaceTitle', 'Title', 'R','frmUserCountry','Country','R','frmUserCity','City','R', 'frmEmail', 'Email', 'RisEmail','frmAddress','Address','R'))

	{	

		return true;

	} 

	else 

	{

		return false;

	}*/ 

	

	var val = document.getElementById('frmImageHidden1').value;	

	var country = document.getElementById('frmEventPassCountry').value;	

	if(val == 0)

	{

		if(country == 'India')

		{

			if(validateForm(formname, 'frmPlaceTitle', 'Place Title', 'R', 'frmEventPassCountry', 'Country', 'R', 'frmEventPassCity', 'City', 'R', 'frmEventPassEmail', 'Email', 'RisEmail', 'frmEventPassImage', 'Image', 'R'))

			{	

				return true;

			} 

			else 

			{

				return false;

			}

		}

		else

		{

			if(validateForm(formname, 'frmPlaceTitle', 'Place Title', 'R', 'frmEventPassCountry', 'Country', 'R', 'frmUserCityOut', 'City', 'R', 'frmEventPassEmail', 'Email', 'RisEmail', 'frmEventPassImage', 'Image', 'R'))

			{	

				return true;

			} 

			else 

			{

				return false;

			}	

		}

	}

	else

	{

		if(country == 'India')

		{

			if(validateForm(formname, 'frmPlaceTitle', 'Place Title', 'R', 'frmEventPassCountry', 'Country', 'R', 'frmEventPassCity', 'City', 'R', 'frmEventPassEmail', 'Email', 'RisEmail'))

			{	

				return true;

			} 

			else 

			{

				return false;

			}

		}

		else

		{

			if(validateForm(formname, 'frmPlaceTitle', 'Place Title', 'R', 'frmEventPassCountry', 'Country', 'R', 'frmUserCityOut', 'City', 'R', 'frmEventPassEmail', 'Email', 'RisEmail'))

			{	

				return true;

			} 

			else 

			{

				return false;

			}	

		}	

	}

}





/*****************************

Function name : displayEventPassCity

Return type : integer

Date created : 22 Oct 2008

Date last modified : 

Author : Prashant Kumar

Last modified by : 

Comments : This function is used to populate state.

User instruction : displayEventPassCity(formname)

************************************/

function displayEventPassCity(countryID)

{

	if(countryID == '')

	{

		document.getElementById('frmVisibleCityLabel').style.display = 'none';

	}

	else

	{

		if(countryID == 'India')	

		{

			document.getElementById('frmOutOfUsaDiv').style.display = 'none';

			document.getElementById('frmVisibleCityLabel').style.display = 'block';

			var QryStr = "EventPassCountryID="+countryID;

			doAjax('ajax_act.php',QryStr,'addEventPassCityToDiv','get','1');

		}

		else

		{

			document.getElementById('frmOutOfUsaDiv').style.display = 'block';

			document.getElementById('frmVisibleCityLabel').style.display = 'none';

		}	

	}

}

 /*****************************

Function name : addEventPassCityToDiv

Return type : string

Date created : 22 Oct 2008

Date last modified : 

Author : Prashant Kumar

Last modified by : 

Comments : This function is used to display states into div.

User instruction : addEventPassCityToDiv(formname)

************************************/

function addEventPassCityToDiv(item)

{

	if(item)

	{	

		 document.getElementById('frmVisibleCity').innerHTML = item;	

	}

}









/*****************************

Function name : validatePhoto

Return type : string

Date created : 25 March 2009

Date last modified : 25 March 2009

Author : Sharad Agarwal

Last modified by : Sharad Agarwal

Comments : 

User instruction : validatePhoto(formname)

************************************/

function validatePhoto(formname)

{

	if(validateForm(formname, 'fileToUpload_1', 'Photo', 'R'))

	{	

		return true;

	} 

	else 

	{

		return false;

	} 



}









/*****************************

Function name : validateEventConfirm

Return type : bool

Date created : 26 March 2009

Date last modified : 26 March 2009

Author : Sharad Agarwal

Last modified by : Sharad Agarwal

Comments : 

User instruction : validateEventConfirm(formname)

************************************/

function validateEventConfirm(formname)

{

	if(validateForm(formname, 'eid', 'Event', 'R'))

	{	

			document.getElementById(formname).submit();

			return true;

	} 

	else 

	{

		return false;

	} 

	

	

}







/******************************************

Function name : addMorePackage

Return type : none

Date created : 12th March 2009

Date last modified : 12th March 2009

Author : Neha Sharma

Last modified by :  Neha Sharma

Comments : Function will  add email fields for inviting friends

User instruction :addMorePackage(formname)

******************************************/

function addMorePackage(maxLimit)

{	

	if(document.getElementById("frmImageCount").value)

	{

		var appNav = navigator.appName;

		var cnt = document.getElementById("frmImageCount").value;

		var checkCnt = document.getElementById("frmCheckExistImageCount").value;

	  if(checkCnt >= maxLimit)

		{

			alert('You have reached the maximum limit');

		    return false;

		}

		else

		{

		if(cnt >= 5)

		{

			alert('You cannot upload more than 5 photos simultaneously!');

			return false;

		}

		else

		{

			var sub_package_block = document.getElementById("sub_package_block").innerHTML;

			var main_package_block = document.getElementById("main_package_block");

			document.getElementById("frmImageCount").value = parseInt(document.getElementById("frmImageCount").value) + 1;

			document.getElementById("frmCheckExistImageCount").value =  parseInt(document.getElementById("frmCheckExistImageCount").value) + 1;

			var oDiv=document.createElement("DIV");

			oDiv.id = "sub_package_group"+document.getElementById("frmImageCount").value;

			

			if(appNav == "Microsoft Internet Explorer")

			{

				var frmContent = document.getElementById("main_package_block").childNodes[0].innerHTML;

			}

			else

			{

				var frmContent = document.getElementById("main_package_block").childNodes[1].innerHTML;

			}

			var re = /AUTONUM/g;

			var frmContent1 = frmContent.replace(re,document.getElementById("frmImageCount").value);

			oDiv.innerHTML = frmContent1;

			document.getElementById("main_package_block").appendChild(oDiv);

			var delB = document.getElementById("delButton_"+document.getElementById("frmImageCount").value);		

			if(cnt == '0')

			{ 

		 	 	delB.style.display = 'none';		

			}

	   		else

	   		{

		  		delB.style.display = 'inline';	

	   		}

			//delB.style.display = 'inline';	

		}

	}

	}

}



/******************************************

Function name : removeThisPackage

Return type : none

Date created : 12th March 2009

Date last modified : 12th March 2009

Author : Neha Sharma

Last modified by :  Neha Sharma

Comments : Function will remove email box

User instruction :addMorePackage(formname)

******************************************/

function removeThisPackage(num)

{

	var rmDiv = "sub_package_group"+num;

	var cnt = document.getElementById("frmImageCount").value;

	document.getElementById("main_package_block").removeChild(document.getElementById(rmDiv));

	document.getElementById("frmImageCount").value = parseInt(document.getElementById("frmImageCount").value) - 1;

}



/******************************************

Function name : validateLimit

Return type : none

Date created : 12th March 2009

Date last modified : 12th March 2009

Author : Neha Sharma

Last modified by :  Neha Sharma

Comments :

User instruction :addMorePackage(formname)

******************************************/

function validateLimit(val, formname)

{

	var val = document.getElementById(val).value;

	var regNumeric = /^([0-9]+)$/; 

	if(val != '')

	{

		if(!regNumeric.test(val))

		{

			alert('Duration must contain a numeric value.');

			return false;

		}

		else

		{

			document.getElementById(formname).submit();

		}

	}

}









function ShowFrontbanner()

{

	fields = 'banner=true';

	doAjax('random_banner.php', fields, 'showBanner', 'post');

	

}



function showBanner(item)

{

	document.getElementById('Showbanner').innerHTML = '';

	document.getElementById('Showbanner').innerHTML = item;

}




