<!--
var saved_search_exp=false;
var recent_search_exp=false;

// To get the HTTP object to call a method..
function getHTTPObject()
{
	var xmlhttp;

	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlhttp = new XMLHttpRequest();
			}
			catch (e)
			{
				xmlhttp = false;
			}
		}
	}

	return xmlhttp;

} // EO function getHTTPObject()



// Two objects are created for displaying state and city drop downs because one is overwriting another..


//################ Builds the options for State drop down..###################

/* Called from :

- profile -> Edit profile
- html-template -> Smart Search
- city-search -> City Search
- included_modify -> Registration page

*/

//Instatiate another object to call method..
var http_state = new getHTTPObject();

var check_selected_state;
var check_state_obj;
var check_state_from_page;

/*
selected_country : All selected county list - In case of error or preselection
selected_state   : All selected state list -------- " --------
selected_city	 : All selected city list -------- " --------
state_obj		 : Functions gets called from diff files so passing state object that needs to be filled in with the 				   values.
img_url			 : Img server path
from_page		 : On search pages we hv multiple selection of countries, so using diff. script file for searches.
flag			 : Used to preselect the values while loading a page first time.
*/

function display_state_dropdown(selected_country, selected_state, selected_city, state_obj, img_url, from_page, flag)
{
	// Using these 2 vars for city drop down as well, so assigning the values..
	check_state_obj = state_obj;
	check_state_from_page = from_page;

	if(from_page == "smart_search")// for Search page AJAX - Mulitple countries selected..
	{
		var myurl = "/ssi/ajax-india-usa-states.php?country=" + escape(selected_country);
	}
	else // for Profile, registration, City Ssearch AJAX
	{
		var myurl = "/ssi/ajax-state.php?country=" + escape(selected_country) + "&state=" + escape(selected_state) + "&city=" + escape(selected_city);

		if(selected_country == "")
		{
			state_obj.options.length = 0;
			state_obj[0] = new Option("Select state", "");
			return false;
		}

		document.getElementById("loading_state").innerHTML = "<img src=\"" + img_url + "/imgs/loading.gif\" hspace=\"16\" vspace=\"3\" align=\"absmiddle\">";
	}

	if(selected_state == "-")
	{
		check_selected_state = "Other";
	}
	else
	{
		check_selected_state = selected_state;
	}


	if(flag == "Y") // required coz it doesnot preselect the values. it hides the form element by default..
	{
		//Resetting the state os residence array..
		state_obj.options.length = 0;
		document.getElementById("show_hide_state").style.display = "none";
	}

	http_state.open("GET", myurl, true);
	if(from_page == "smart_search")
	{
		http_state.onreadystatechange = useHttpResponse_india_usa_state;
	}
	else
	{
		http_state.onreadystatechange = useHttpResponse_state;
	}
	http_state.send(null);

} // EO function display_state_dropdown()


// To populate the multiple drop down with state values..
function useHttpResponse_india_usa_state()
{
	// This is used to preselect the castes in smart search..
	var state_to_obj = document.frm_main.elements['stateofresidencearray[]'];

	if (http_state.readyState == 4 && http_state.status == 200)
	{
		var textout = http_state.responseText;
		myString    = new String(textout);
		splitString = myString.split("|");

		check_state_obj.size = 5;
		check_state_obj.options.length = 0;

		// Getting all preselected states from the list box..
		var arr_to_states	= new Array();
		for (i=0;i<state_to_obj.options.length;i++)
		{
			arr_to_states[i] = state_to_obj.options[i].value;
		}

		//Resetting the state os residence array..
		state_to_obj.options.length = 0;
		state_to_obj.options[0] = new Option("Doesn't Matter", ""); // On smart search to set it Doesn't Matter by default

		var j = 0;
		var m = 0;
		for(var i=1; i<splitString.length; i++)
		{
			var curr_state = splitString[i].trim();

			if(curr_state.match("-----"))
			{
				curr_state_val = "";
			}
			else
			{
				curr_state_val = curr_state;
			}

			if(check_selected_state.match(curr_state))
			{
				if(check_state_from_page == "smart_search") // For preselected values, putting them in right list
				{
					state_to_obj[m] = new Option(curr_state, curr_state_val);
					m++;
				}
				else // For other searches, selecting value from the list..
				{
					check_state_obj[j] = new Option(curr_state, curr_state_val, false, true);
					check_state_obj[j].selected = true;
					j++;
				}
			}
			else
			{
				if(InArray(arr_to_states, curr_state) >= 0)
				{
					state_to_obj[m] = new Option(curr_state, curr_state_val);
					m++;
				}
				else
				{
					check_state_obj[j] = new Option(curr_state, curr_state_val);
					j++;
				}
			}
		}

		document.getElementById("show_hide_state").style.display = "";
	}
	else if(check_selected_state && check_state_from_page == "smart_search")
	{
		var splitString = check_selected_state.split("|");

		for(var i=0; i<splitString.length; i++)
		{
			var curr_state = splitString[i].trim();

			state_to_obj[i] = new Option(curr_state, curr_state);
		}
	}
}



// To populate the drop down with state values..
function useHttpResponse_state()
{
	if (http_state.readyState == 4 && http_state.status == 200)
	{
		var textout = http_state.responseText;
		myString    = new String(textout);
		splitString = myString.split("|");

		check_state_obj.options.length = 0;
		check_state_obj[0] = new Option("Select state", "");

		for(var i=0; i<splitString.length; i++)
		{
			var curr_state = splitString[i].trim();
			var curr_state_val;

			//when getting 'Other' value then internally in database passing it as '-'..
			if(curr_state == "Other")
			{
				curr_state_val = "-";
			}
			else
			{
				curr_state_val = curr_state;
			}

			//Creating new options of state ..
			check_selected_state_spilt_string = check_selected_state.split('|');

			if(InArray(check_selected_state_spilt_string, curr_state) >= 0)
			{
				check_state_obj[i+1] = new Option(curr_state, curr_state_val, false, true);
				check_state_obj[i+1].selected = true;
			}
			else
			{
				check_state_obj[i+1] = new Option(curr_state, curr_state_val);
			}
		}

		document.getElementById("loading_state").innerHTML = "";

		document.getElementById("show_hide_state").style.display = "";
	}
}




//################################ END ####################################





//################ Builds the options for City drop down..###################


/* Called from :

- profile -> Edit profile
- city-search -> City Search
- included_modify -> Registration page

*/

//Instantiate an object to call method..
var http = new getHTTPObject();

// These vars coming frm state srop down function,
//setting them as global so that we can use them in city drop down function..
var check_selected_city;
var check_city_obj;
var check_city_from_page;

/*
selected_country : All selected county list - In case of error or preselection
selected_state   : All selected state list -------- " --------
selected_city	 : All selected city list -------- " --------
city_obj		 : Functions gets called from diff files so passing city object that needs to be filled in with the values.
img_url			 : Img server path
from_page		 : On search pages we hv multiple selection of countries, so using diff. script file for searches.
flag			 : Used to preselect the values while loading a page first time.
state_option	 : In every case, city gets populated from state selected, but in case of city search, state drop down is optional. so to tackle this condition, passing this parameter.
*/

function display_dropdown(selected_country, selected_state, selected_city, city_obj, img_url, from_page, flag, state_option)
{
	var myurl = "/ssi/ajax-city.php?country=" + escape(selected_country) + "&state=" + escape(selected_state) + "&city=" + escape(selected_city) + "&state_option=" + escape(state_option) + "&from_page=" + escape(from_page);

	check_city_obj = city_obj;
	check_city_from_page = from_page;

	if((selected_state == "" && state_option != "no_state_selected") || selected_country == "")
	{
		city_obj.options.length = 0;

		if(from_page == "city_search") // For Multiple list of cities..
		{
			city_obj.options.size = 1;
			city_obj[0] = new Option("---------No City---------", "");
		}
		else
		{
			city_obj[0] = new Option("Select city", "");
		}

		return false;
	}

	if(flag == "Y") // required coz it doesnot preselect the values. it hides the form element by default..
	{
		document.getElementById("show_hide_city").style.display = "none";
	}

		document.getElementById("loading_city").innerHTML = "<img src=\"" + img_url + "/imgs/loading.gif\" hspace=\"16\" align=\"absmiddle\">";


	if(selected_city == "-")
		check_selected_city = "Other";
	else
		check_selected_city = selected_city;

	http.open("GET", myurl, true);
	http.onreadystatechange = useHttpResponse;
	http.send(null);

} // EO function display_dropdown()


// To populate the drop down with city values..
function useHttpResponse()
{
	// readyState = 0 being unintialised, 1 being loading, 2 being loaded, 3 being interactive and 4 being finished
	if (http.readyState == 4 && http.status == 200)
	{
		var textout = http.responseText;

		myString    = new String(textout);
		splitString = myString.split("|");

		check_city_obj.options.length = 0;
		if(check_city_from_page == "city_search") // For Multiple list of cities..
		{
			check_city_obj[0] = new Option("---------Select city---------", "");

			if(splitString)
			{
				if(splitString.length < 5)
				{
					check_city_obj.options.size = splitString.length+1;
				}
				else
				{
					check_city_obj.options.size = 5;
				}
			}
			else
			{
				check_city_obj.options.size = 1;
			}
		}
		else
		{
			check_city_obj[0] = new Option("Select city", "");
		}


		for(var i=0; i<splitString.length; i++)
		{
			var curr_city = splitString[i].trim();
			var curr_city_val;

			//when getting 'Other' value then internally in database passing it as '-'..
			if(curr_city == "Other")
			{
				curr_city_val = "-";
			}
			else
			{
				curr_city_val = curr_city;
			}

			if(curr_city)
			{
				//Creating new options of city ..
				check_selected_city_spilt_string = check_selected_city.split('|');
				if (InArray(check_selected_city_spilt_string, curr_city) >= 0)
				{
					check_city_obj[i+1] = new Option(curr_city, curr_city_val, false, true);
					check_city_obj[i+1].selected = true;
				}
				else
				{
					check_city_obj[i+1] = new Option(curr_city, curr_city_val);
				}
			}
		}

		document.getElementById("loading_city").innerHTML = "";
		document.getElementById("show_hide_city").style.display = "";
	}
}// EO function useHttpResponse()

//################################ END ####################################

//PSL_EN_2-start



//PSL_EN_3-start
/**
 * track the express interest clicks for a particular search type
 *
 * @author Madhuvanti
 * @param string search_cookie_name - the type of search performed
 *
 * @usage  <a onclick="track_express_interest('".$search_cookie_name."');"></a>

*/
function track_express_interest(search_cookie_name,type)
{
	var myurl = "/ssi/track-express-interest.php?search_cookie_name=" + escape(search_cookie_name)+ "&type=" + escape(type);
	http.open("GET", myurl, true);
	http.send(null);
}
//PSL_EN_3-end

//PSL Phase II
function track_expand_interest(search_cookie_name,type,searchId)
{
	var myurl = "/ssi/track-expand-interest.php?search_cookie_name=" + escape(search_cookie_name)+ "&type=" + escape(type);
	if(searchId)
	{
		myurl += "&set="+escape(searchId);
	}

	http.open("GET", myurl, true);
	http.send(null);
}
//PSL_EN_4-end

//################ Builds the options for Refined City drop down..###################


/* Called from :

- searchresults -> Action page of City Search, Keyword Search, Smart Search.

*/


//Instatiate another object to call method..
var http_refined_city = new getHTTPObject();

var check_selected_refined_city;
var check_refined_city_obj;


function display_refined_city_dropdown(selected_country, selected_city, search_id)
{
	var myurl = "/ssi/ajax-refined-city.php?country=" + escape(selected_country) + "&search_id=" + escape(search_id);

	check_refined_city_obj_new = document.refinedsearchnew.elements['nearestcityarray[]'];
	check_refined_city_obj = document.refinedsearch.elements['nearestcityarray[]'];

	if(selected_country == "")
	{
		check_refined_city_obj.options.length = 0;
		check_refined_city_obj_new.options.length = 0;
		check_refined_city_obj[0] = new Option("Doesn't Matter", "");
		check_refined_city_obj_new[0] = new Option("Doesn't Matter", "");
		return false;
	}

	if(selected_city)
	{
		check_selected_refined_city = selected_city;
	}

	http_refined_city.open("GET", myurl, true);
	http_refined_city.onreadystatechange = useHttpResponse_refined_city;
	http_refined_city.send(null);

} // EO function display_state_dropdown()


// To populate the drop down with city values..
function useHttpResponse_refined_city()
{
	if (http_refined_city.readyState == 4 && http_refined_city.status == 200)
	{
		var textout = http_refined_city.responseText;

		myString    = new String(textout);
		splitString = myString.split("|");

		check_refined_city_obj.options.length = 0;
		check_refined_city_obj_new.options.length = 0;
		check_refined_city_obj[0] = new Option("Doesn't Matter", "");
		check_refined_city_obj_new[0] = new Option("Doesn't Matter", "");

		for(var i=0; i<splitString.length; i++)
		{
			var curr_refined_city = splitString[i].trim();

			//Creating new options of city ..
			if(curr_refined_city)
			{
				//Creating new options of state ..
				if(curr_refined_city == check_selected_refined_city)
				{
					check_refined_city_obj[i+1] = new Option(curr_refined_city, curr_refined_city, false, true);
					check_refined_city_obj[i+1].selected = true;
					check_refined_city_obj_new[i+1] = new Option(curr_refined_city, curr_refined_city, false, true);
					check_refined_city_obj_new[i+1].selected = true;
				}
				else
				{
					check_refined_city_obj[i+1] = new Option(curr_refined_city, curr_refined_city);
					check_refined_city_obj_new[i+1] = new Option(curr_refined_city, curr_refined_city);
				}
			}
		}

	}
}

//################################ END ####################################





//################################ START CASTE ####################################


//Instantiate an object to call method..
var http_caste = new getHTTPObject();

var check_from_page;
var check_selected_caste;

function display_dropdown_caste(from_page, selected_caste, gender)
{
	if(from_page == "registration")
	{
		var frm_obj		  = document.profile;
		var community_obj = frm_obj.religion;
		var mothertongue_obj = frm_obj.elements['mothertongue'];
	}
	else if(from_page == "smart_search")
	{
		var frm_obj		  = document.frm_main;
		var community_obj = frm_obj.elements['communityarray[]'];
		var mothertongue_obj = frm_obj.elements['mothertonguearray[]'];
	}
	else
	{
		var frm_obj		  = document.quicksearch;
		var community_obj = frm_obj.community;
		var mothertongue_obj = frm_obj.elements['mothertonguearray[]'];
	}

	var community		 = "";
	var mothertongue	 = "";

	check_from_page		 = from_page;
	check_selected_caste = selected_caste;

	//###### We need to pass community(only religion) while building the caste options.. ######

	if(check_from_page == "smart_search")
	{
		// This for loop is to pass multiple communities to the ajax script..
		for(var i=0; i < community_obj.options.length; i++)
		{
			var community_value = community_obj.options[i].value;

			if(!community.match(community_value)) // Not to insert duplicate values..
			{
				community += new String(community_value).split("|")[0] + "|"; // Taking only 1st element like 'Hindu'.
			}
			else if(community_value.match("Muslim") || community_value.match("Christian") || community_value.match("Sikh") || community_value.match("Jain") )
			{
				// Take all value if community value found one of the Muslim, Christian, Sikh, Jain
				//In this value may com like 'Muslim: Sunni'and 'Muslim: All'
				//which will not give duplicate value
				community += new String(community_value).split("|")[0] + "|";
			}

		} // EO for(var i=0; i < community_obj.options.length; i++)
	}
	else // Other searches..we can at a time select only one community..
	{
		community = new String(community_obj.options[community_obj.selectedIndex].value).split("|")[0];
	}


	//###### We need to pass community while building the caste options.. ######



	//###### Passing mothertongue while building the caste options.. ######

	var arr_mothertongue = new Array;
	// This for loop is to pass multiple mothertongues to the ajax script..
	var j = 0;
	for(var i=0; i < mothertongue_obj.options.length; i++)
	{
		var mothertongue_value = mothertongue_obj.options[i].value;

		if(check_from_page == "smart_search") // We are by default taking all added mothertongues
		{
			// Not to insert duplicate values..
			if(!mothertongue.match(mothertongue_value))
			{
				if(mothertongue_value)
				{
					arr_mothertongue[j] = mothertongue_value;
				}
			}
		}
		else // We are taking only selected mothertongues.. in other searches..
		{
			if(mothertongue_obj.options[i].selected == true)
			{
				if(mothertongue_value)
				{
					arr_mothertongue[j] = mothertongue_value;
				}
			}
		}

		j++;

	} // EO for(var i=0; i < mothertongue_obj.options.length; i++)


	if(arr_mothertongue)
	{
		mothertongue = arr_mothertongue.join("|");
	}

	//###### Passing mothertongue while building the caste options.. ######

	if(community && mothertongue && gender)
	{
		var url = "/ssi/ajax-community.php?community=" + escape(community) + "&mothertongue=" + escape(mothertongue)+ "&gender=" + escape(gender) + "&from_page=" + escape(from_page);
		http_caste.open("GET", url, true);
		http_caste.onreadystatechange = useHttpResponse_caste;
		http_caste.send(null);
	}

} // EO function display_dropdown_caste()



function useHttpResponse_caste()
{
	if(http_caste.readyState == 4 && http_caste.status == 200)
	{
		var caste = http_caste.responseText;

		if(check_from_page == "registration")
		{
			var caste_obj = document.profile.elements['caste'];
		}
		else if(check_from_page == "smart_search") // Multiple select at a time..
		{
			var caste_obj = document.frm_main.elements['caste_fromarray[]'];

			// This is used to preselect the castes in smart search..
			var caste_to_obj = document.frm_main.elements['castearray[]'];

			var arr_rightlist_caste = new Array();
			for(var k=0; k<caste_to_obj.options.length; k++)
			{
				arr_rightlist_caste[k] = caste_to_obj.options[k].value;

			} // EO for(var k=0; k<community_obj.options.length; k++)

			//If user has selected castes n then he changes the gender field then we r nullifying the caste list.
			caste_to_obj.options.length = 0;
		}
		else
		{
			var caste_obj = document.quicksearch.elements['castearray[]'];
		}

		if(caste != "") // If caste exists then display it..
		{
			var caste_txt_val		 = new String(caste).split("|");
			caste_obj.options.length = 0;
			caste_obj[0]			 = new Option("---------Select Caste---------", "");

			if(check_from_page != "registration" && check_from_page != "smart_search")
			{
				// For limiting the size of caste list box..
				if(caste_txt_val.length > 5)
				{
					caste_obj.size = 5;
				}
				else
				{
					caste_obj.size = caste_txt_val.length+1;
				}

			} // EO if(check_from_page == "registration")

			var j = 1;
			var m = 0;
			for(var i=0; i<caste_txt_val.length; i++)
			{
				var caste_txt  = caste_txt_val[i].trim();

				// Splitting the db values n then checking if it matches for preselection..
				check_selected_caste_spilt_string = check_selected_caste.split('|');

				if(caste_txt && InArray(check_selected_caste_spilt_string, caste_txt) >= 0)
				{
					if(check_from_page == "smart_search") // For preselected values, putting them in right list
					{
						caste_to_obj[m] = new Option(caste_txt, caste_txt);
						m++;
					}
					else // For other searches, selecting value from the list..
					{
						caste_obj[j] = new Option(caste_txt, caste_txt, false, true);
						caste_obj[j].selected = true;
						j++;
					}
				}
				else
				{
					if(check_from_page == "smart_search"
					&& InArray(arr_rightlist_caste, caste_txt) >= 0)
					{
						caste_to_obj[m] = new Option(caste_txt, caste_txt);
						m++;
					}
					else
					{
						caste_obj[j] = new Option(caste_txt, caste_txt);
						j++;
					}
				}

			} // EO for(var i=0; i<caste_txt_val.length; i++)

			document.getElementById("show_hide_caste").style.display = "";
		}
		else // If caste doesnot exist then hide it..
		{
			if(check_from_page == "registration")
			{
				caste_obj.options.length = 0;
				caste_obj[0]			 = new Option("---------Select Caste---------", "");
			}
			else
			{

				document.getElementById("show_hide_caste").style.display = "none";
				return false;
			}
		}

	} // EO if(http_caste.readyState == 4 && http_caste.status == 200)

} // EO useHttpResponse_caste()


//################################ END CASTE ####################################





// Minimum Characters Validation..
function check_keyword(obj)
{
	var _iMinLength = 4;

	myString = new String(obj.value);
	var keyword = myString.trim();

	if(keyword && keyword.length < _iMinLength)
	{
		alert('Please enter atleast '+_iMinLength+' characters.');
		return false;
	}

	return true;

} // EO function check_keyword()

// PSL_EN_2-start - This function is made common for city search,keyword search, profession search, photo search, who is online and special cases
function chk_country(frm_name)
{
	if(!frm_name)
{
	if (document.quicksearch.countryofresidence.options[document.quicksearch.countryofresidence.selectedIndex].value == "")
	{
		alert("Please select Country");
		return false;
	}

	else
	{
		return true;
	}
}
	else
	{
		if (document.frm_main.countryofresidence.options[document.frm_main.countryofresidence.selectedIndex].value == "")
		{
			alert("Please select Country");
			return false;
		}
		else
		{
			return true;
		}
	}
}


//PSL_EN_2 - This function is made common for city search,keyword search, profession search, photo search, who is online and special cases

//This function is getting used to display the state drop down of India and USA states ONLY
//country_val	: Country Value
//state_val		: State value
//city_val		: City value (cud be pipe separated)
//flag_val		: By default we are passing "" n onchange we r passing "Y"
//img_url		: the location for images, we are passing IMG_HTTP_URL from search pages
//frm_name		: form name - passed only in case of profession search


function check_india_usa(country_val,state_val,city_val, flag_val,img_url,frm_name)
{

	if(!state_val) var state_val = "";
	if(!city_val)  var city_val  = "";
	if(!flag_val)  var flag_val  = "";
	if(!frm_name) var frm_name  = document.getElementById("quicksearch");
	if(country_val == "India"
	|| country_val == "USA")
	{
		if (document.getElementById("state_only"))
		{
			document.getElementById("state_only").style.display = "";
		}
		frm_name.stateofresidence.disabled = false; // Not passing state value for other countries..
		display_state_dropdown(country_val,state_val,city_val,frm_name.stateofresidence,img_url,'city_search',flag_val,'state_selected');
		display_dropdown(country_val,state_val,city_val,frm_name.elements['nearestcityarray[]'], img_url, 'city_search',flag_val,'state_selected');
	}
	else
	{
		if (document.getElementById("state_only") && document.getElementById("state_only").selectedIndex != 0)
		{
			document.getElementById("state_only").style.display = "none";
		}
		frm_name.stateofresidence.disabled = true; // Not passing state value for other countries..
		display_dropdown(country_val,state_val,city_val,frm_name.elements['nearestcityarray[]'], img_url, 'city_search',flag_val,'no_state_selected');
	}

	if(document.getElementById("city_only"))
	{
		document.getElementById("city_only").style.display = (country_val.trim() != "") ? "" : "none";
	}

}

// PSL_EN_2-end
//-->
function mediator_accept_decline_expanded(msg,status,profileid,se,memberlogin,check)
{
	if(status == 'Accepted')
	{
		accept_decline1 = 'true';
	}
	else
	{
		accept_decline1 = 'false';
	}
	var t = this.title || this.name || this.href || null;
	$("#profilezedo").hide();

	$("body").css("overflow", "hidden");



	var pos = function(){ $.tweenbox.position($('#tweenContent')[0]); };
	try{

	var setup=false;var url ="interest-accept.php?msg="+msg.toString()+"&canned=true"+"&searchpage=yes"+"&expanded=yes"+"&accept_decline="+accept_decline1+"&profileid="+profileid+"&se="+se+"&memberlogin="+memberlogin+"&check="+check;
	}catch(e)
	{
	}

	try{
	$("body").tweenbox("interest-accept.php?msg="+msg.toString()+"&canned=true"+"&searchpage=yes"+"&expanded=yes"+"&accept_decline="+accept_decline1+"&profileid="+profileid+"&se="+se+"&memberlogin="+memberlogin+"&check="+check);
		}catch(e)
		{
		}

	return false;
}
//PSL Phase II bug fixes
//This function is getting used to send the values of the accept or decline button from the expanded profile.
function accept_decline(status,profileid,se,memberlogin,valentine)
{
	var personalisedmessage = "";
	for (var i=0; i < document.acceptdeclineval.personilze.length; i++)
	{
	  if (document.acceptdeclineval.personilze[i].checked)
      {
		 var rad_val = document.acceptdeclineval.personilze[i].value;
      }
    }

	if(status == 'Accepted' && rad_val == "I like your profile however please provide the following details")
	{
		var total="" ;
		if (typeof document.acceptdeclineval.checkselected.length != "undefined")
		{
			// multiple checkboxes with the same name
			for(var j=0; j < document.acceptdeclineval.checkselected.length; j++)
			{
				if(document.acceptdeclineval.checkselected[j].checked)
				{
					total +=document.acceptdeclineval.checkselected[j].value + "|";
				}
			}
		}
		else
		{
			// only one checkbox
			if(document.acceptdeclineval.checkselected.checked)
			{
				total +=document.acceptdeclineval.checkselected.value + "|";
			}
		}
		if(total == "")
		{
			document.getElementById("accept_error").style.display = "block";
			return false;
		}

		total= total.slice(0, -1);
		personalisedmessage = rad_val+": "+total;

	}
	else
	{
		personalisedmessage = rad_val;
	}
	if(personalisedmessage == "")
	{
		if(document.getElementById("personalisedmessage1"))
		{
			personalisedmessage  = document.getElementById("personalisedmessage1").value;
		}
	}
	else if(personalisedmessage == "none")
	{
		personalisedmessage  = "";
	}
	if(status == 'Accepted-from-layer')
	{
		personalisedmessage = "Accepted-from-layer";
		status = 'Accepted';
	}
	
	var valentine_url="";
	if(valentine == 'true')
	{
		var valentine_val = "";
		for (var i=0; i < document.acceptdeclineval.giftoption1.length; i++)
		{
		if (document.acceptdeclineval.giftoption1[i].checked)
		  {
			valentine_val = document.acceptdeclineval.giftoption1[i].value;
		  }
	   }
		valentine_url = "&gift_option="+escape(valentine_val);
	}

    $.tweenbox.tearDown();
    
 	var myurl = "/ssi/p-action/acceptdecline.php?personalisedmessage="+escape(personalisedmessage)+"&profileid=" + escape(profileid)+ "&acceptdecline=" + escape(status)+"&se=" + escape(se)+"&memberlogin="+escape(memberlogin)+valentine_url;
	var img = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"right\" style=\"height:120px;width=70%\" valign=\"top\"><tr><td class=\"top_left_png\" align=\"left\"></td><td class=\"top_middle_png\"></td><td class=\"top_right_png\"></td></tr><tr><td class=\"left_border_png\" align=\"left\" align=\"top\"></td><td bgcolor=\"#ffffff\" style=\" font: normal 11px verdana;\" valign=\"middle\" align=\"center\"><img src=\""+ IMG_PATH + "/imgs/profiles/loading-ajax.gif\"></td><td class=\"right_border_png\"></td></tr><tr><td class=\"bottom_left_png\"></td><td class=\"bottom_middle_png\"></td><td class=\"bottom_right_png\"></td></tr></table>";
	var response = AjaxRequest.get(
		{
			'url':myurl
			,'onLoading':function(req)
				{
				document.getElementById('acceptdeclinediv').innerHTML=img;
				}
			,'onSuccess':function(req){
				var temp=req.responseText
 				document.getElementById('acceptdeclinediv').innerHTML ="<b>"+ temp + "</b>";

				//PSL PHASE II Bugfixes
				//to change the content from exress interest<-> send reminnder and so on
				td_id = "link_change_id_" + profileid;

				if(status == "Accepted")
				{
					link_name_display = "Accepted Member";
				}
				else
				{
					link_name_display = "Declined Member";
				}
				div_id_to_change = document.getElementById(td_id);

				if(div_id_to_change != null)
				{
					document.getElementById(td_id).innerHTML = "<span class='smallbluelink'><img src='"+IMG_PATH+"/imgs/icons/icon-express-interest-default-panel.gif' align='absmiddle' hspace='5' border='0' vspace='1'  >"+link_name_display+"&nbsp;<img src='"+IMG_PATH+"/imgs/bullet/blue-arrow.gif' border='0' style='margin-bottom:-2px;'></span>";
					//PSL phase II added to replace the send reminder in mini profile
				}
				div_id_to_change = document.getElementById("pos_featured_"+td_id);

				if(div_id_to_change != null)
				{
					div_id_to_change.innerHTML = "<span style='font:normal 11px verdana; color:#0066CC;'>"+link_name_display+"&nbsp;</span>";
				}
				if(status == "Accepted")
				{
					if(document.getElementById('contact_#'+profileid) != null)
					{
						document.getElementById('contact_#'+profileid).src = IMG_PATH + "/imgs/icons/icon_accept.gif";
						document.getElementById('contact_#'+profileid).setAttribute("title", "Accepted")
					}
					if(document.getElementById('decline_#'+profileid) != null)
					{
						document.getElementById('decline_#'+profileid).src = IMG_PATH + "/imgs/icons/icon_accept.gif";
						document.getElementById('decline_#'+profileid).setAttribute("title", "Accepted")
					}
				}
				else if(status == "Declined")
				{
					if(document.getElementById('contact_#'+profileid) != null)
					{
						document.getElementById('contact_#'+profileid).src = IMG_PATH + "/imgs/icons/icon_decline.gif";
						document.getElementById('contact_#'+profileid).setAttribute("title", "Declined")
					}
					if(document.getElementById('accept_#'+profileid) != null)
					{
						document.getElementById('accept_#'+profileid).src = IMG_PATH + "/imgs/icons/icon_decline.gif";
						document.getElementById('accept_#'+profileid).setAttribute("title", "Declined")
					}
				}
			   }
				,'timeout':30000
				,'onTimeout':function(req){ alert('A problem occurred while communicating with the server.\nPlease make sure you are connected to the Internet and try again in sometime.'); return false;}
				,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
			}
	);

}

//PSL EN phase 3
var saved_search_widget_height = 0;
var saved_search_widget_transition = false;

//function to expand and restore the saved and recent search panel
function expand_collapse(widget_type, body, searchid, img_url)
{
	eval("widget_transition="+widget_type+"_widget_transition");
	if(widget_transition==false)
	{
		var img ="<img src=\"" + img_url + "/imgs/icons/up-arrow.gif\" width=\"10\" height=\"5\">";
		var img_up ="<img src=\"" + img_url + "/imgs/icons/down-arrow.gif\" width=\"10\" height=\"5\">";
		eval(widget_type+"_widget_height=parseInt(document.getElementById('"+widget_type+"_right').offsetHeight)");
		if(document.getElementById(body).style.display == 'block')
		{
			document.getElementById(body).style.display = 'none';
			document.getElementById(widget_type+"_right").style.height=saved_search_widget_height-16;
			document.getElementById(searchid).innerHTML = img_up;
			document.getElementById(searchid).title = "Click here to edit or delete Saved Search.";
		}
		else
		{
			document.getElementById(widget_type+"_right").style.height=saved_search_widget_height+16;
			document.getElementById(body).style.display = 'block';
			document.getElementById(searchid).innerHTML = img;
			document.getElementById(searchid).title = "Collapse";
		}

		saved_search_widget_height = parseInt(document.getElementById('saved_search_right').offsetHeight);
	}
}

//function to delete the saved/recent search from RHS panel
function dodelete(id,searchname,loggerlogin,IMG_PATH)
{
	if(!confirm("Delete Search: \""+searchname+"\"  Are you sure?"))
	{
		return false;
	}

	var http_state = new getHTTPObject();

	var myurl = "/ssi/delete-saved-search.php?deletesearch_id="+id+"&loggerlogin="+loggerlogin;
	var img = "<br><center><img src=\""+IMG_PATH+"/imgs/profiles/loading-ajax-small.gif\" align=\"center\"></center><br>";

	var title=id+"title";
	var tableid=id+"table";

	var height_diff = 0;

	var status = AjaxRequest.get(
	{
		'url':myurl,
		'onLoading':function(req)
		{
			height_diff_before = parseInt(document.getElementById(title).offsetHeight);
			document.getElementById(title).innerHTML=img;
			height_diff_after = parseInt(document.getElementById(title).offsetHeight);

			saved_search_widget_height += height_diff_after - height_diff_before;

			document.getElementById('saved_search_right').style.height = saved_search_widget_height;
		},
		'onSuccess':function(req)
		{
			var responsetext=req.responseText
			if(document.getElementById(tableid))
			{
				saved_search_widget_height -= height_diff_after + 20;
				if(responsetext=='0')
				{
					document.getElementById('saved_search_right').innerHTML =
						"<table id=\"saved_search_right_table\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td style=\"padding: 8px;\" class=\"searchmedium\">You have no saved searches.</td></tr></table>";

					saved_search_widget_height = 44;
				}
				else
				{
					document.getElementById(tableid).style.display = "none";
				}

				(saved_search_widget_height<0)?saved_search_widget_height=0:"";
				document.getElementById('saved_search_right').style.height = saved_search_widget_height;
			}
		},
		'timeout':30000,
		'onTimeout':function(req){ alert('A problem occurred while communicating with the server.\nPlease make sure you are connected to the Internet and try again in sometime.'); return false;}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	}
	);
}//EO dodelete()



//functions for expand and restore saved search
function exp_trans_saved()
{
if(saved_search_exp) return false;
saved_search_exp = true;
saved_search_widget_transition = true;
saved_search_widget_height=parseInt(document.getElementById('saved_search_right').offsetHeight);
$("#saved_search_right").animate({height:0},800);
setTimeout("hide_minus_icon()",800);
setTimeout("document.getElementById('saved_search_right_table').style.display='none'",700);
setTimeout("saved_search_widget_transition = false",810);
}


function rest_trans_saved()
{
if(!saved_search_exp) return false;
saved_search_exp = false;
saved_search_widget_transition = true;
$("#saved_search_right").animate({height:saved_search_widget_height},800);
setTimeout("document.getElementById('saved_search_right_table').style.display='block'",100);
setTimeout("hide_plus_icon()",800);
setTimeout("saved_search_widget_transition = false",810);
}


function hide_plus_icon()
{
	document.getElementById('plus_icon').style.display='none';
	document.getElementById('minus_icon').style.display='block';
}

function hide_minus_icon()
{
	document.getElementById('minus_icon').style.display='none';
	document.getElementById('plus_icon').style.display='block';

}


var recent_search_widget_height = 0;
var recent_search_widget_transition = false;

//functions for expand and restore recent search
function exp_trans_recent()
{
if(recent_search_exp) return false;
recent_search_exp = true;
recent_search_widget_transition = true;
recent_search_widget_height=parseInt(document.getElementById('recent_search_right').offsetHeight);
$("#recent_search_right").animate({height:0},800);
setTimeout("hide_minus_icon_recent()",800);
setTimeout("document.getElementById('recent_search_right_table').style.display='none'",750);
setTimeout("recent_search_widget_transition = false",810);
}


function rest_trans_recent()
{
if(!recent_search_exp) return false;
recent_search_exp = false;
recent_search_widget_transition = true;
$("#recent_search_right").animate({height:recent_search_widget_height},800);
setTimeout("document.getElementById('recent_search_right_table').style.display='block'",100);
setTimeout("hide_plus_icon_recent()",800);
setTimeout("recent_search_widget_transition = false",810);
}


function hide_plus_icon_recent()
{
	document.getElementById('plus_icon_recent').style.display='none';
	document.getElementById('minus_icon_recent').style.display='block';
}

function hide_minus_icon_recent()
{
	document.getElementById('minus_icon_recent').style.display='none';
	document.getElementById('plus_icon_recent').style.display='block';
}

function clear_list(from_page,loggerlogin,IMG_PATH)
{
	var http_state = new getHTTPObject();

	var myurl = "/ssi/delete-saved-search.php?loggerlogin="+loggerlogin+"&frompage="+from_page;
	var img = "<br><center><img src=\""+IMG_PATH+"/imgs/profiles/loading-ajax-small.gif\" align=\"center\"></center><br>";

	//var title=id+"title";
	var status = AjaxRequest.get(
	{
		'url':myurl,
		'onLoading':function(req)
		{
			document.getElementById('recent_search_right').innerHTML=img;
		},
		'onSuccess':function(req)
		{
			document.getElementById('recent_search_right').innerHTML = "<table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"2\"><tr><td style=\"padding: 8px;\" class=\"searchmedium\">You have no recent searches.</td></tr></table>";
			//document.getElementById('clear_list').innerHTML = '';
		},
		'timeout':30000,
		'onTimeout':function(req){ alert('A problem occurred while communicating with the server.\nPlease make sure you are connected to the Internet and try again in sometime.'); return false;}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	}
	);
}//EO clear_list()
