var listDetailPager = "";
var listProductsPager = "";

var path="";
if(document.getElementById("contextPathJsp")){
	path= document.getElementById("contextPathJsp").value;
	//alert(path);
}
function forwardId(rUserId,userId)
	{
		var answer = confirm("Are you sure to delete profile?")
		if(answer){
			makeRequest(path+'/faces/user/removeFromUserModule.jsp','rUserId='+rUserId+'&userId='+userId);
		}
}
function deleteProduct(prodId,usrId)
{	
			var answer = confirm("Are u sure to delete product?")
			if(answer){
				makeRequest(path+'/faces/user/removeFromUserModule.jsp','userId='+usrId+'&prodId='+prodId);
				
			}
		
}
function addtoMyFavorite(userId)
{
		
		makeRequest(path+'/faces/user/addProfileToMyFavorite.jsp','userId='+userId);
}
function showopt() {
	if(flag == 0){

document.getElementById('changePasswordMessage').style.display='none';
	
document.getElementById('changepassword').style.visibility = "visible";
document.getElementById('changepassword').style.display = "block";
flag++;

}
else {
	hidept();
	}
}

function hidept() {

document.getElementById('changepasswords').style.display = "none";
document.getElementById('changePasswordMessages').style.display='none';
flag=0;
}

function shdept(){
//alert("hiiiiiiiiii");
document.getElementById('LoginInformationView').style.display = "block";

}
function changePasswordToNew(form,emailId)

{
   
	var thisForm = form;
    document.getElementById('changePasswordMessages').style.display='none';
	var frm = document.forms[thisForm];
	var oldPasswd = frm.oldPassword.value;
	var newPasswd = frm.newPassword.value;
	var secuirty = frm.security.value;
	if(validateForm(form)){
	makeMyRequest('/faces/jsp/changeOldPassword.jsp','oldPasswd='+oldPasswd+'&newPasswd='+newPasswd+'&secuirty='+secuirty+'&emailId='+emailId+'&changePasswords=changePasswords','changePasswords');
    hidept();
	shdept();
	}
	
}

function changePasswords (params){
 var divObj = document.getElementById('changePasswordMessages');
 divObj.style.display='block';
 divObj.style.visibility="visible";
 divObj.innerHTML = '<font color=red>'+params[0]+'</font>'

}

function show(divId){
  var divObj = document.getElementById(divId);
  
  if(divObj){
  	  divObj.style.visibility="visible";
	  divObj.style.display='block';
	  
  }
}
function hide(divId){

var divObj = document.getElementById(divId);
if(divObj){
	divObj.style.visibility="hidden";
	divObj.style.display='none';
	
}
}
function test (params){

//alert("params"+params[0]);

}
function resetFields(){
		document.getElementById('oldPassword').value="";
		document.getElementById('newPassword').value="";
		document.getElementById('confirmNewPassword').value="";
		return false;
}
function validateForm(form){
		
	var thisForm = form.name;
				
	var current_password=document.getElementById('oldPassword').value ;
	var new_password=document.getElementById('newPassword').value ;
	var confirm_password=document.getElementById('confirmNewPassword').value ;
	var minLength = 6; // Minimum length for password
			  
			  
	if(current_password.length==0){
		alert('Old password should not be blank.');
				document.forms[thisForm].oldPassword.focus();	
         
		return false;
	}
	else{
		if(current_password.length<minLength){
			alert('Old password must be at least ' + minLength + ' characters long');
			document.forms[thisForm].oldPassword.focus();	

			return false;
		}
	}
	
	if(new_password.length==0){
		alert('New password should not be blank.');
		document.forms[thisForm].newPassword.focus();
         
		return false;
	}
	else{
		if(new_password.length<minLength){
			alert('New Password must be at least ' + minLength + ' characters long');
			document.forms[thisForm].newPassword.focus();	

			return false;
		}
	}

	if(confirm_password.length==0){
		alert('Confirm password field should not be blank');
		document.forms[thisForm].confirmNewPassword.focus();
         
		return false;
	}
	else{
		if(confirm_password!=new_password){
			alert('New password should be same as confirm password');
			document.forms[thisForm].confirmNewPassword.focus();
         
			return false;
		}
		
	}
	return true;
}

function validateUserEditProfile()
{

	 var formName = document.forms['userProfileEditForm'];
	 
	 var country = formName.country;
	 var state = formName.state;
	 var city = formName.city;
	 var otherState = formName.otherState;
	 var otherCity = formName.otherCity;
	 
	 var genderradioobj = formName.gender;
	
	 var genderstatus = false;
	  
	 for(var i =0 ; i<genderradioobj.length; i++) {
	 		if(genderradioobj[i].checked){
	 			genderstatus = genderradioobj[i].checked;
	 		}
	 }
	  
	 if(!firstName()) {
	 	return false;
	 }
	 	
	 if( !genderstatus ){
	 	alert("Please select your gender");
	 	return false;
	 }
	
	 if(checkValidDate()){
	 	if(country.options[country.options.selectedIndex].value=="0")
	 	{	
	 		alert("Please select country"); 
	 		country.focus();
	 		return false;
	 	}
	 	
	 	if(state.options[state.options.selectedIndex].value=="0")
	 	{	
	 		alert("Please select state"); 
	 		state.focus();
	 		return false;
	 	}
	 	if(state.options[state.options.selectedIndex].text=="Other" && otherState.value=="")
	 	{
	 		alert("Please enter state"); otherState.focus(); 
	 		
	 		return false;	
	 	}
	 	if(city.options[city.options.selectedIndex].value=="0")
	 	{	
	 		alert("Please select city"); 
	 		city.focus();
	 		return false;
	 	}
	 	
	 	if(city.options[city.options.selectedIndex].text=="Other" && otherCity.value=="")
	 	{
	 		alert("Please enter city"); otherCity.focus(); return false;		 	
	 	}
	 	if(checkPincodeLength()){
	 		editProfileSave();
	 	}
	 
	 	
	 }
	
	 		
}
function editProfileSave(){

	var frm = document.userProfileEditForm;

	var fname = frm.firstName.value;
	
	var gender="";
	if(frm.gender[0].checked)
		gender=frm.gender[0].value;
	else if(frm.gender[1].checked)
		gender=frm.gender[1].value;

	var Marital = "";
	
	if(frm.Marital[0].checked)
		Marital=frm.Marital[0].value;
	else if(frm.Marital[1].checked)
		Marital=frm.Marital[1].value;
	
	var date =  frm.date.value;
	var month = frm.month.value;
	var year = frm.year.value;
	var Occupation = frm.Occupation.value;
	var phone1 =  frm.phone1.value;
	var phone2 =  frm.phone2.value;
	var mobile =  frm.mobile.value;
	var address1 =  frm.address1.value;
	var address2 =  frm.address2.value;
	var pincode = frm.pincode.value;
	var otherCity =  frm.otherCity.value;
	var otherState =  frm.otherState.value;
	var city =  frm.city.value;
	var state =  frm.state.value;
	var country =  frm.country.value;
	var buttonValue =  frm.Editbutton.value;
	
	makeRequest(path+'/faces/jsp/saveUserProfile.jsp','firstName='+fname+'&gender='+gender+'&Marital='+Marital+'&date='+date+'&month='+month+'&year='+year+'&Occupation='+Occupation+'&phone1='+phone1+'&phone2='+phone2+'&mobile='+mobile+'&address1='+address1+'&address2='+address2
	+'&pincode='+pincode+'&city='+city+'&state='+state+'&country='+country+'&otherCity='+otherCity+'&otherState='+otherState);

}
function deleteBrowsingHistory(browsdate,usrId,bProdId)
{

		var answer = confirm("Are you sure you want to delete this item")
			if(answer){
				makeRequest(path+'/faces/user/removeFromUserModule.jsp','pageId=removeBrowse_History&userId='+usrId+'&bprodId='+bProdId+'&browsdate='+browsdate);
				
			}
}
function deleteSearchHistory(prodName,usrId,searchDate,searchTime)
{		
		var answer = confirm("Are you sure you want to delete this item")
			if(answer){
				makeRequest(path+'/faces/user/removeFromUserModule.jsp','pageId=removeSearch_History&userId='+usrId+'&pname='+prodName+'&sDate='+searchDate+'&sTime='+searchTime);
				//alert("Record deleted successfully");
			}
		
}
function isAlphabeticKey(evt){
	var charCode = (evt.which) ? evt.which : evt.keyCode

	if (!((charCode > 64 && charCode < 91) || ((charCode > 96) && (charCode < 123)) || (charCode < 33) || ((charCode > 34) && (charCode < 47)))){
		alert("Please enter alphabets only");
  		return false;
	}
  	return true;
}

function isNumberKey(evt){
	var charCode = (evt.which) ? evt.which : evt.keyCode
//		alert(charCode)
	if ((charCode > 31) && (charCode < 48 || charCode > 57)){
		if(charCode !=99 && charCode !=118 && charCode !=97 && charCode !=46 && charCode !=120){
			alert("Please enter numeric value");
  		return false;
	}}
  	return true;
}
function checkValidDate(){
	//alert("in the fun");
	var dayobj = document.getElementById('date');
	//alert("day obj---"+dayobj);
	var day =  dayobj.value;
	//alert("---dayvalue"+day);
	var monthobj = document.getElementById('month');
	var month =  monthobj.value;
	var yearobj = document.getElementById('year');
	var year =  yearobj.value;

	var countryobj = document.getElementById('country');
	var country = countryobj.value;
	var stateobj = document.getElementById('state');
	var state  = stateobj.value;
	var cityobj = document.getElementById('city');
	var city  = cityobj.value;
	
	var mobileobj = document.getElementById('Mobile');	
	var mobile  = mobileobj.value;	
	var Occupatobj = document.getElementById('Occupation')
	var Occupat  = Occupatobj.value;	
	
	if(day == "0" &&  month == "00" && year == "0")	{
			alert("Enter your date of birth");
			dayobj.focus();
		return false;
	}
	if(day != "0" && month == "00" && year == "0"){
		alert("Select month & year");
		monthobj.focus();
		return false;
	}
	if(day == "0" && month != "00" && year == "0"){
		alert("Select date & year");
		dayobj.focus();
		return false;
	}
	if(day == "0" && month == "00" && year != "0"){
		alert("Select date & month");
		dayobj.focus();
		return false;
	}
	if(day == "0" && month != "00" && year != "0"){
		alert("Select date");
		//alert("date fin");
		dayobj.focus();
		return false;
	}
	if(day != "00" && month == "00" && year != "0"){
		alert("Select month");
		monthobj.focus();
		return false;
	}
	if(day != "0" && month != "00" && year == "0"){
		alert("Select year");
		yearobj.focus();
		return false;
	}
	var maritalradioobj = document.forms['userProfileEditForm'].Marital;
	var martialstatus = false;
	for(var i =0 ; i<maritalradioobj.length; i++) {
	 		if(maritalradioobj[i].checked){
	 			martialstatus = maritalradioobj[i].checked;
	 		}
	 }	
	if( !martialstatus ){
	 	alert("Please select your marital status");
	 	return false;
	 }
	if(Occupat=="0"){
		alert("Please select your occupation");
		Occupatobj.focus();
		return false;
	}
	if(mobile ==""){
		alert("Please specify your mobile number");
		mobileobj.focus();
		return false;
	}
		
	var myDate = new Date();
	myDate.setFullYear( year.substring(2,4), month, day );	
	//alert(myDate);

	if ( myDate.getMonth() != month ) {
		alert( 'Date is not valid' );
		dayobj.focus();
		return false;
	} 
	else
		return true;

	
}
function checkPincodeLength()	{
	
	var pinobj = document.getElementById('pincode')
	var pin = pinobj.value;
	
		if(pin.length > 0)	{
				if(pin.length < 6)	{
						alert("Please enter 6 digit pincode");
						pinobj.focus();
						return false;
					}
		}
		else
			return true;
		return true;
}
function firstName(){
	var nameObj = document.getElementById('firstName');
	var name = nameObj.value;
		if(name.length < 1)	{
			alert("Please enter your name");
			nameObj.focus();
			return false;
		}
		else
			return true;
}
function backToProfile(){
	location.href="userProfile.jsp";
}

function validatebirthdate(form)
{
//alert("jdfhdfj");
var thisform = form.name ;
var frm = document.forms[thisform];
//alert("thisform"+thisform);
var dayobj = document.getElementById('date');
	//alert("day obj---"+dayobj);
	var day =  dayobj.value;
	//alert("---dayvalue"+day);
	var monthobj = document.getElementById('month');
	//alert("monthobj---"+monthobj);
	var month =  monthobj.value;
	//alert("month---"+month);
	var yearobj = document.getElementById('year');
	//alert("yearobj---"+yearobj);
	var year =  yearobj.value;
	//alert("year---"+year);
	 		

if(day == "0" &&  month == "00" && year == "0")	{
			alert("Enter your date of birth");
			dayobj.focus();
		return false;
	}
	if(day != "0" && month == "00" && year == "0"){
		alert("Select month & year");
		monthobj.focus();
		return false;
	}
	if(day == "0" && month != "00" && year == "0"){
		alert("Select date & year");
		dayobj.focus();
		return false;
	}
	if(day == "0" && month == "00" && year != "0"){
		alert("Select date & month");
		dayobj.focus();
		return false;
	}
	if(day == "0" && month != "00" && year != "0"){
		alert("Select date");
		//alert("date fin");
		dayobj.focus();
		return false;
	}
	if(day != "00" && month == "00" && year != "0"){
		alert("Select month");
		monthobj.focus();
		return false;
	}
	if(day != "0" && month != "00" && year == "0"){
		alert("Select year");
		yearobj.focus();
		return false;
	}
    return true;
}
function  editPersonalProfileSave(form,emailId){
  	var thisform = form ;
    var frm = document.forms[thisform];
    var fname = frm.firstName.value;
    if(fname == ""){
   alert("Please enter your first name");
    fname.focus();
    return false;
    }
    var lName = frm.lastName.value;
    if(lName == ""){
    alert("Please enter your last name");
    lName.focus();
    return false;
    }
	var gender="";
	if(frm.gender[0].checked)
		gender=frm.gender[0].value;
	else if(frm.gender[1].checked)
		gender=frm.gender[1].value;
	
	var secuirtyG = frm.secuirtyG.value;
	var  secuirtyDate = frm.secuirtydate.value;
	var secuirtyM = frm.secuirtyM.value;
    var  secuirtyO = frm.secuirtyO.value;
    var aboutme = frm.aboutme.value;
   // var secuirtyab = frm.secuirtyab.value; 
    var Interestedin = frm.Interestedin.value;
    //var secuirtyin = frm.secuirtyin.value;
    var Webpage = frm.Webpage.value;
    //var websec = frm.secuirtyweb.value;
 
    var Marital = frm.Marital.value;
    //alert(Marital);
    var education = frm.Education.value ;
    //alert(education)
    var college  = frm.College.value;
    //alert(college)
    var languages = frm.Languages.value;
    //alert(languages)
    var employer = frm.Employer.value;
    //alert(employer)
    var industry = frm.Industry.value;
    //alert(industry)
    var hobbies = frm.Hobbies.value;
   // alert(hobbies)
    var hometown = frm.Hometown.value;
   // alert(hometown)
   // alert(Marital);
    /**
    var Marital = "";
	if(frm.Marital[0].checked)
		Marital=frm.Marital[0].value;
	else if(frm.Marital[1].checked)
		Marital=frm.Marital[1].value;
		**/

	var date =  frm.date.value;
	var month = frm.month.value;
	var year = frm.year.value;

	if(date == "0" &&  month == "00" && year == "0")	{
			alert("Enter your date of birth");
			dateobj.focus();
		return false;
	}
	if(date != "0" && month == "00" && year == "0"){
		alert("Select month & year");
		monthobj.focus();
		return false;
	}
	if(date == "0" && month != "00" && year == "0"){
		alert("Select date & year");
		dateobj.focus();
		return false;
	}
	if(date == "0" && month == "00" && year != "0"){
		alert("Select date & month");
		dateobj.focus();
		return false;
	}
	if(date == "0" && month != "00" && year != "0"){
		alert("Select date");
		//alert("date fin");
		dateobj.focus();
		return false;
	}
	if(date != "00" && month == "00" && year != "0"){
		alert("Select month");
		monthobj.focus();
		return false;
	}
	if(date != "0" && month != "00" && year == "0"){
		alert("Select year");
		yearobj.focus();
		return false;
	}
	var Occupation = frm.Occupation.value;
	
	var OccupationText = frm.Occupation.options[frm.Occupation.selectedIndex].text;
    if(OccupationText == "Select Occupation"){
	alert("Please select your occupation");
	Occupation.focus();
	return false;
	}
	
	
	makeMyRequest(path+'/faces/jsp/saveUserPersonalProfile.jsp','firstName='+fname+'&lastName='+lName+'&gender='+gender+'&secuirtyG='+secuirtyG+'&secuirtyM='+secuirtyM+'&secuirtyO='+secuirtyO+'&aboutme='+aboutme+'&Interestedin='+Interestedin+'&Webpage='+Webpage+'&Marital='+Marital+'&date='+date+'&month='+month+'&year='+year+'&secuirtyDate='+secuirtyDate+'&Occupation='+Occupation+'&emailId='+emailId+'&occupationtext='+OccupationText+'&education='+education+'&college='+college+'&languages='+languages+'&employer='+employer+'&industry='+industry+'&hobbies='+hobbies+'&hometown='+hometown+'&changeProfile=changeProfile','changeProfile');
	
	
}
function changeProfile(params)
{
	
    var nameObj = document.getElementById('myname');
    if(params[1] !=""){
     if(nameObj){
		nameObj.innerHTML = params[1];
	  }
	  }else{
	  nameObj.innerHTML = "&nbsp;";
	  }
	  
	  
	var lastnameObj = document.getElementById('lastName');
	if(params[2]!=""){
	if(lastnameObj){
	lastnameObj.innerHTML = params[2];
	}}else{
	lastnameObj.innerHTML ="&nbsp;";
	}
    var genderObj = document.getElementById('Gender');
    if(genderObj){
    if(params[3]!=""){
    genderObj.innerHTML = params[3];
	}
	else{
	genderObj.innerHTML = "&nbsp;";
	}
	}
	var dateObj = document.getElementById('dates');
	//alert(dateObj.innerHTML);
	if(dateObj){
	if(params[4]!=""){
	dateObj.innerHTML = params[4];
	}else{
	dateObj.innerHTML = "&nbsp;"
	}
	}
    var maritalObj = document.getElementById('martialStatus');
    if(maritalObj){
    if(params[5]!=""){
	maritalObj.innerHTML = params[5];
	}else{
	maritalObj.innerHTML = "&nbsp;";
	}
	}
	var aboutObj = document.getElementById('aboutme');
	if(aboutObj){
	if(params[6]!=""){
	aboutObj.innerHTML = params[6];
	}else{
	aboutObj.innerHTML = "&nbsp;";
	}
	}
	
	var interestedObj = document.getElementById('interested');
	
	if(interestedObj){
	if(params[7]!=""){
	interestedObj.innerHTML = params[7];
	}else{
	interestedObj.innerHTML = "&nbsp;";
	}
	}
	var webpageObj = document.getElementById('webpage');
	
	if(webpageObj){
	if(params[8]!=""){
	webpageObj.innerHTML = params[8];
	}else{
	webpageObj.innerHTML = "&nbsp;";
	}
	}
	
	var occupationObj = document.getElementById('occupation');
	//alert("occupationObj-->"+occupationObj);
	if(occupationObj){
	if(params[9]!=""){
	occupationObj.innerHTML = params[9];
	}else{
	occupationObj.innerHTML = "&nbsp;";
	}
	}
	 var employeObj = document.getElementById('Employer')
	// alert("employeObj-->"+employeObj);
	if(employeObj){
	if(params[10]!=""){
	employeObj.innerHTML = params[10];
	}else{
	employeObj.innerHTML = "&nbsp;";
	}
	}
	
	var collegeObj = document.getElementById('College');
	 //alert("collegeObj-->"+collegeObj);
	if(collegeObj){
	if(params[10]!=""){
	collegeObj.innerHTML = params[12];
	}else{
	collegeObj.innerHTML = "&nbsp;";
	}
	}
	
	var languageObj = document.getElementById('Languages');
	//alert("languageObj-->"+languageObj);
	if(languageObj){
	if(params[13]!=""){
	languageObj.innerHTML = params[13];
	}else{
	languageObj.innerHTML = "&nbsp;";
	}
	}
	
	var industryObj = document.getElementById('Industry');
	//alert("industryObj-->"+industryObj);
	if(industryObj){
	if(params[14]!=""){
	industryObj.innerHTML = params[14];
	}else{
	industryObj.innerHTML = "&nbsp;";
	}
	}
	
	var hobbiesObj = document.getElementById('Hobbies');
	//alert("hobbiesObj-->"+hobbiesObj);
	if(hobbiesObj){
	if(params[15]!=""){
	hobbiesObj.innerHTML = params[15];
	}else{
	hobbiesObj.innerHTML = "&nbsp;";
	}
	}
	
	var hometownObj = document.getElementById('Hometown');
	//alert("hometownObj-->"+hometownObj);
	if(hometownObj){
	if(params[15]!=""){
	hometownObj.innerHTML = params[16];
	}else{
	hometownObj.innerHTML = "&nbsp;";
	}
	}
	
	
	var educationObj = document.getElementById('Education')
	//alert("educationObj-->"+educationObj);
	if(educationObj){
	if(params[11]!=""){
	educationObj.innerHTML = params[11];
	}else{
	educationObj.innerHTML = "&nbsp;";
	}
	}
	
	var divobj = document.getElementById('profileUpdateMessages');
	//alert("divobj----ssasasa--->>"+divobj);
	//divobj.style.display = "";
	if(divobj){
		divobj.innerHTML = '<font color=red>'+params[0]+'</font>';
		divobj.style.visibility = "visible";
		divobj.style.display = "block";
	}
	
}
function editContactInformation (form,emailId){
var thisform = form ;
var frm = document.forms[thisform];
var phone1 = frm.PhoneNo1.value;
var secuirtyph1 = frm.secuirtyph1.value;
var phone2 = frm.PhoneNo2.value;
var secuirtyph2 = frm.secuirtyph2.value;
var Mobile   = frm.Mobile.value;
var secuirtyM = frm.secuirtyM.value;
var Address1 = frm.Address1.value;
var secuirtyADD1 = frm.secuirtyADD1.value;
var Address2 = frm.Address2.value;
var secuirtyADD2 = frm.secuirtyADD2.value;
var country = frm.country.value;
if (country == "0"){
alert("please select country");
country.focus();
return false ;
}
var state = frm.state.value;
if(state == "0"){
alert("please select state")
state.focus();
return false ;
}

var otherState = frm.otherState.value;
var city = frm.city.value;
if (city =="0"){
alert("please select city")
city.focus();
return false ;
}
var otherCity = frm.otherCity.value;
var pincode = frm.pinCode.value;
if(pincode == ""){
alert("Please enter pincode")
pincode.focus();
return false;
}
var citytext = frm.city.options[frm.city.selectedIndex].text;
var statetext = frm.state.options[frm.state.selectedIndex].text;
var  countrytext = frm.country.options[frm.country.selectedIndex].text;

makeMyRequest(path+'/faces/jsp/saveUserContactProfile.jsp','phone1='+phone1+'&secuirtyph1='+secuirtyph1+'&phone2='+phone2+'&secuirtyph2='+secuirtyph2+'&secuirtyM='+secuirtyM+'&Mobile='+Mobile+'&Address1='+Address1+'&secuirtyADD1='+secuirtyADD1+'&Address2='+Address2+'&secuirtyADD2='+secuirtyADD2+'&country='+country+'&state='+state+'&city='+city+'&otherCity='+otherCity+'&pincode='+pincode+'&otherState='+otherState+'&emailId='+emailId+'&citytext='+citytext+'&statetext='+statetext+'&countrytext='+countrytext+'&changeContactProfile=changeContactProfile','changeContactProfile');
}

function changeContactProfile (params){
//alert("params[0]----------------->>"+params[0]);
var phone1Obj = document.getElementById('phone1');
if(params[1]!= ""){
if(phone1Obj){
phone1Obj.innerHTML = params[1];
}}else{
phone1Obj.innerHTML ="&nbsp;";
}

var phone2Obj = document.getElementById('phone2');
if(params[2]!=""){
if(phone2Obj){
phone2Obj.innerHTML = params[2];
}}else{
phone2Obj.innerHTML ="&nbsp;";
}
var mobileObj = document.getElementById('mobile');
if(params[3]!=""){
if(mobileObj){
mobileObj.innerHTML = params[3];
}}else{
mobileObj.innerHTML ="&nbsp;";
}
var add1Obj = document.getElementById('address1');
if(params[4]!=""){
if(add1Obj){
add1Obj.innerHTML = params[4];
}
}
else{
add1Obj.innerHTML = "Not available";
}
var add2Obj = document.getElementById('address2');
if(params[5]!=""){
if(add2Obj){
add2Obj.innerHTML = params[5];
}}else{
add2Obj.innerHTML = "Not available"
}
var pincode = document.getElementById('pincode');
if(params[6]!=""){
if(pincode){
pincode.innerHTML = params[6];
}
}else{
pincode.innerHTML = "&nbsp;";
}

var cityobj = document.getElementById('citys');
if(params[7]== "Other"){
cityobj.innerHTML = params[10];
}
else{
cityobj.innerHTML = params[7];
}

var stateobj = document.getElementById('states');
if(params[8]=="Other"){
stateobj.innerHTML = params[11];
}
else{
stateobj.innerHTML = params[8];
}

var countryObj = document.getElementById('countrys');
if(countryObj){
countryObj.innerHTML = params[9];
}

var divObj = document.getElementById('infoUpdateMessages');
divObj.style.visibility = "visible";
divObj.style.display = "block";
divObj.innerHTML = '<font color=red>'+params[0]+'</font>'

}


function getProfileResult(level,sessionUserId){
invoke(path+"/faces/user/myProfile.jsp?sl="+level+"&sessionUserId="+sessionUserId,"myProfile");
}

function getConnectionResult(level,sessionUserId,activeId){
connectionSortLevel = level;
var divobj = document.getElementById('DisplayItems');
divobj.style.visibility="visible";
divobj.style.display = 'block';
document.getElementById("recentlyModi").style.color='#FF0000';
document.getElementById("atozSort").style.color='#003399';
document.getElementById("ztoaSort").style.color='#003399';
document.getElementById("mostPopular").style.color='#003399';
var url = path+"/faces/user/connections.jsp?sl="+level+"&sessionUserId="+sessionUserId;
invoke(url,"connection");
var freind = document.getElementById('freinds');

var fan = document.getElementById('fans');

var  fav = document.getElementById('favs');
var all = document.getElementById('all');

var search = document.getElementById('search');
var pending = document.getElementById('pending');

if(activeId == "freinds"){
freind.className = "current";
fan.className = "";
fav.className = "";
all.className = "";
search.className = "";
pending.className = "";
}
if(activeId == "fans"){
freind.className = "";
fan.className = "current";
fav.className = "";
all.className = "";
search.className = "";
pending.className = "";
}
if(activeId == "favs"){
freind.className = "";
fan.className = "";
all.className = "";
fav.className = "current";
search.className = "";
pending.className = "";
}
if(activeId == "all"){
freind.className = "";
fan.className = "";
all.className = "current";
fav.className = "";
search.className = "";
pending.className = "";
}
}
function getConnectionResultforotherUser(level,sessionUserId,activeId){
connectionSortLevel = level ;
var divobj = document.getElementById('DisplayItems');
divobj.style.visibility="visible";
divobj.style.display = 'block';
document.getElementById("recentlyModi").style.color='#FF0000';
document.getElementById("atozSort").style.color='#003399';
document.getElementById("ztoaSort").style.color='#003399';
document.getElementById("mostPopular").style.color='#003399';
var url = path+"/faces/user/otherUserConnectionDetails.jsp?sl="+level+"&sessionUserId="+sessionUserId;
invoke(url,"connection");
var freind = document.getElementById('freinds');
var fan = document.getElementById('fans');
var  fav = document.getElementById('favs');
var all = document.getElementById('all');

if(activeId == "freinds"){
freind.className = "current";
fan.className = "";
fav.className = "";
all.className = "";
}
if(activeId == "fans"){
freind.className = "";
fan.className = "current";
fav.className = "";
all.className = "";
}
if(activeId == "favs"){
freind.className = "";
fan.className = "";
all.className = "";
fav.className = "current";
}
if(activeId == "all"){
freind.className = "";
fan.className = "";
all.className = "current";
fav.className = "";
}
}




function invokeList(){

if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
var url = path+"/faces/user/list/allListDetailsOuter.jsp?flag=1";

invoke(url,"RightPanel");
}

function invokeconnection(sessionUserId){
if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
//if(document.getElementById("listTitles"))
// document.getElementById("listTitles").style.display='none';
var url = path+"/faces/user/connectionsHeader.jsp?sessionUserId="+sessionUserId;
invoke(url,"RightPanel");
}
function invokehistory(sessionUserId){
if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
//if(document.getElementById("listTitles"))
// document.getElementById("listTitles").style.display='none';
var url = path+"/faces/user/userHistoryDetails.jsp?sessionUserId="+sessionUserId;
invoke(url,"RightPanel");
}

function invokeProfile(sessionUserId){
if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
//if(document.getElementById("listTitles"))
// document.getElementById("listTitles").style.display='none';
var url = path+"/faces/user/newProfile.jsp?sessionUserId="+sessionUserId;
invoke(url,"RightPanel");
}

function invokeListProducts(otherUserId,listId){

if(document.getElementById("listSubscribers")){
	invoke(path+"/faces/user/list/subscribers.jsp?listId="+listId ,"listSubscribers");
 document.getElementById("listSubscribers").style.display='';
}
//if(document.getElementById("listTitles"))
// document.getElementById("listTitles").style.display='';
var url ="";
if(otherUserId!=null && otherUserId!="")
	url=path+"/faces/user/list/listProducts.jsp?otherUserId="+otherUserId+"&listId="+listId;
else
	 url = path+"/faces/user/list/listProducts.jsp?listId="+listId;
invoke(url,"RightPanel");
}


function invokeSearchHistory(sessionUserId){
var url = path+"/faces/user/searchHistoryDetails.jsp?sessionUserId="+sessionUserId;
invoke(url,"historydetails");

var browse = document.getElementById('browse');
var review = document.getElementById('review');
var search = document.getElementById('search1');

search.className = "current";
review.className = "";
browse.className = "";

}
function invokeBrowsingHistory(sessionUserId){
var url = path+"/faces/user/browsingHistoryDetails.jsp?sessionUserId="+sessionUserId;
invoke(url,"historydetails");
var browse = document.getElementById('browse');
var review = document.getElementById('review');
var search = document.getElementById('search1');

review.className = "";
search.className = "";
browse.className = "current";
}
function invokeReviewHistory(sessionUserId){
var url = path+"/faces/user/reviewsHistoryDetails.jsp?sessionUserId="+sessionUserId;
invoke(url,"historydetails");

var browse = document.getElementById('browse');
var review = document.getElementById('review');
var search = document.getElementById('search1');

review.className = "current";
search.className = "";
browse.className = "";
}

function invokeconnectionOtherProfile(otherUserId){
if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
 var conn = document.getElementById("conn");
 var list = document.getElementById("list");
 var history = document.getElementById("history");
 var profile = document.getElementById("profile");
 conn.className = "ActiveLink";
 list.className = "";
 history.className = "";
 profile.className = "";
var url = path+"/faces/user/otherUserProfileConnectionHeader.jsp?sessionUserId="+otherUserId;
invoke(url,"RightPanel");
}
function invokeProfileOtherProfile(otherUserId){
if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
 var conn = document.getElementById("conn");
 var list = document.getElementById("list");
 var history = document.getElementById("history");
 var profile = document.getElementById("profile");
 conn.className = "";
 list.className = "";
 history.className = "";
 profile.className = "ActiveLink";
 
 
var url = path+"/faces/user/otherUserProfile.jsp?otherUserId="+otherUserId;
invoke(url,"RightPanel");
}

function invokeListOtherProfile(otherUserId){
if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
 var conn = document.getElementById("conn");
 var list = document.getElementById("list");
 var history = document.getElementById("history");
 var profile = document.getElementById("profile");
 conn.className = "";
 list.className = "ActiveLink";
 history.className = "";
 profile.className = "";
 
var url = path+"/faces/user/list/allListDetailsOuter.jsp?otherUserId="+otherUserId;
invoke(url,"RightPanel");
}
function invokeHistoryOtherProfile(otherUserId){
var conn = document.getElementById("conn");
 var list = document.getElementById("list");
 var history = document.getElementById("history");
 var profile = document.getElementById("profile");
 conn.className = "";
 list.className = "";
 history.className = "ActiveLink";
 profile.className = "";
 var url = path+"/faces/user/userHistoryDetails.jsp?sessionUserId="+otherUserId;
invoke(url,"RightPanel");
}

function displayResultsScreen(tableID,count) {
         //alert("mittal");
	     var result ="Result";
        var answerTable = document.getElementById(tableID);
     	var totalField = "26";
		var setfield = count;
		//alert(setfield);
		if(totalField<setfield){
		   alert("Internal error in calculating your profile completeness level");
           return false;
		}
		
		var sum= 0;
		sum=parseInt(totalField)
		 
  
        var tableRowCode = "<TR>" +
                           "<TD align=\"left\">" +
                           "<TABLE cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">" +
                           "<TR><TD bgcolor=\"{color}\" width=\"{percent_value}%\" height=\"10\"></TD>" +			               
                           "<TD width=\"{remander_percent_value}%\" height=\"10\" style=\"border:0; font-size: 8px; letter-spacing:2px; font-family:Tahoma;\">" +
                           "&nbsp;{percent_value}% "+
                           "</TD></TR>" +
                           "</TABLE>" +
                           "</TD></TR>";
 
           
        
        for (i=0; i < (answerTable.rows.length); i++) {
                answerTable.deleteRow(i);
        }
        var totalPercentValue = 0;
        var newRow = answerTable.insertRow(0);
        col1 = newRow.insertCell(0);
        var colData =  "<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" STYLE=\"font-family: Tahoma; font-size: 4.5pt; border-color:#2163a0;\" width=\"100%\">";
		var colors = "#bdddf6";
       
               
					    var a = parseInt(setfield);
					
                        var percentValue =Math.round((100*a)/sum); 
						//var percentValue=Math.floor(Math.random()*(100*a/sum));  
						totalPercentValue+= percentValue;
						if(totalPercentValue>100){
						  percentValue = 100 - (101-percentValue);
						}
						// var percentValue = aryScr[i];        
                        //var str = tableRowCode.replace(/\{option_text\}/g , result);
                        var str = tableRowCode.replace(/\{percent_value\}/g, percentValue.toString());
                        str = str.replace(/\{remander_percent_value\}/g, (100 - percentValue).toString());
                        str = str.replace(/\{color\}/g, colors);
                        colData += str;
             
       
        colData += "<TR><TD align=\"left\" class=\"special\" style=\"font-size:7pt;\"></TD></TR>";
        colData += "</TABLE>";
        col1.innerHTML = colData;        
        for (i = answerTable.rows.length -1; i > 0; i--) {
                answerTable.deleteRow(i);
        }

}


/*Function added for getting the all category types by the use of Ajax*/

function getnameforcategory(catId,listName,listId)
{
//alert(listId);
	if(catId != "" && catId != null)
		makeMyRequest(path+'/faces/jsp/categoryNames.jsp','categoryId='+catId+'&listName='+listName+'&listId='+listId+'&getcategoryname=getcategoryname','getcategoryname');
		
		var forFocusObj = document.getElementById('brandTable');
			if(forFocusObj)
				forFocusObj.focus();
	
}

/*End of the method*/

/*response for the categoryname*/
function getcategoryname(params){
var html = "";
var isLength = true;
var i=2;var j = 2;
if(params[1] == "subCategory")
{    

    var subDivObj = document.getElementById('subCategoryDiv');
  
	var html = "<table cellpadding='0' cellspacing='0'><tr><td class='textnormal_12' align='right' width='130'><span style='font-weight:bold;'>Sub-Category&nbsp;:&nbsp;</span></td><td align='left'><select name=\"subCategory\" id=\"subCategory\" onchange=\"getnameforcategory(this.value,'subsubCategory','"+params[0]+"');\"><option value=''>Select-SubCategory</option>";
	while(i < params.length-1)
	{
		//subCategory.options[j] = new Option(params[i],params[++i]);
		html = html + "<option value="+params[i]+">"+params[++i]+"</option>";
		j++;
		i++;
	}
	html = html + "</select></td></tr></table>";
	
	subDivObj.innerHTML = html;
	subDivObj.style.visibility = "visible";
	subDivObj.style.display = "block";
	i = 2;j = 2;
}

else if(params[1] == "subsubCategory")
{
	hideDiv('brandNameDiv');
	var subsubDivObj = document.getElementById('subsubCategoryDiv');
	var html = "<table cellpadding='0' cellspacing='0'><tr><td class='textnormal_12' align='right' width='130'><span style='font-weight:bold;'>Sub-Sub-Category&nbsp;:&nbsp;</span></td><td align='left'><select name=\"subsubCategory\" id=\"subsubCategory\" onchange=\"getnameforcategory(this.value,'brandName','"+params[0]+"');\"><option value=''>Select-Sub-Sub-Category</option>";
	
	while(i < params.length-1)
	{
		html = html + "<option value="+params[i]+">"+params[++i]+"</option>";
		
		j++;
		i++;
	}
	html = html + "</select></td></tr></table>";
	subsubDivObj.innerHTML = html;
	subsubDivObj.style.visibility = "visible";
	subsubDivObj.style.display = "block";
	
	i = 2;j = 2;
	
	
}

else if(params[1].match("brandName") == 'brandName')
{
	var catId = null;
	if(params[1] == 'brandNameHideSubSubCategory')
	{
		hideDiv('subsubCategoryDiv');
		catId = document.getElementById('subCategory').value;
	}
	else
	{
		catId = document.getElementById('subsubCategory').value;
	}
	
	
	var brandNameDivObj = document.getElementById('brandNameDiv');
	var html = "<table cellpadding='0' cellspacing='0'><tr><td class='textnormal_12' align='right' width='130'><span style='font-weight:bold;'>BrandName&nbsp;:&nbsp;</span></td><td align='left'><select name=\"brandNames\" id=\"brandNames\" onchange=\"getAllproductInformation(this.value,'allProductNames','"+catId+"','"+params[0]+"');\"><option value=''>Select-BrandName</option>";
		
	while(i < params.length-1)
	{
		html = html + "<option value="+params[i]+" id="+params[i]+">"+params[++i]+"</option>";
		j++;
		i++;
	}
	html = html + "</select></td></tr></table>";
	//alert(html);
	brandNameDivObj.innerHTML = html;
	brandNameDivObj.style.visibility = "visible";
	brandNameDivObj.style.display = "block";
	
	i = 2;j = 2;
}
}
/*End of the method*/


function getAllproductInformation(prdId,listName,catId,listId)
{
var brandNameObj = document.getElementById(prdId);

if(brandNameObj)
{
var brandName = brandNameObj.innerHTML;
if(catId != "" && catId != null)
{
	if(prdId != "" && prdId != null)
	{
		if(brandName != "" && brandName != null)
		{
			invoke(path+"/faces/user/list/productInfoForList.jsp?brandName="+brandName+"&catId="+catId+"&listId="+listId,"productInformation");
	
			var Obj = document.getElementById('productInfo');
			Obj.style.visibility = "visible";
			Obj.style.display = "block";
			
			var forFocusObj = document.getElementById('brandTable');
			if(forFocusObj)
				forFocusObj.focus();
		}
	}
}
}
}


/*function added for the addition of product for the list Id */

function updateproductList (checkBoxId,len,fieldIdArray,listId,brandName,catId){
var kk = 0;
var kkk = 0;
var isAnySelected = false;
var idsArray = new Array();
idsArray = fieldIdArray.split(",");
//alert(idsArray);
var bulkProducts = new Array();
for(var i=0;i<len;i++)
	{
		var checkBoxObj = document.getElementById(""+checkBoxId+i);
			
		if(checkBoxObj)
		{
		if(checkBoxObj.checked)
		{
			var prdId = checkBoxObj.value;
		    //alert("prdId-->>"+prdId);
			var bulkVal = "";
			for(var j=0;j<idsArray.length;j++)
			{
			//alert("neehit");
				var fieldObj = document.getElementById(""+idsArray[j]+i);
				//alert(fieldObj);
				var fieldValue = fieldObj.value;
				bulkVal = bulkVal + fieldValue + "~";
				
				}
			if(!isAnySelected)
			isAnySelected = true;
			bulkVal = ""+ bulkVal + prdId;
			//alert("neehit---------->>"+bulkVal);
			bulkProducts[kkk] = ""+bulkVal;
		   kkk++;
		}
		}
        }
       if(!isAnySelected){
		alert("Select products you want to add in this list");
		}
		
		else
		{
			var records = "";
			for(var ii=0;ii<bulkProducts.length;ii++)
			{				
				records = records + "submitBulkProducts="+bulkProducts[ii];
				if(ii != (bulkProducts.length)-1)
					records = records + "&";
					
			}
				makeMyRequest(path+'/faces/jsp/updateProductInList.jsp',records+'&listId='+listId+'&brandName='+brandName+'&catId='+catId+'&addProductlist=addProductlist','addProductlist');
         }


}
function addProductlist(params){

var divObj = document.getElementById('responsemessages');
divObj.style.display = "";
divObj.innerHTML = '<font color=red>'+params[0]+'</font>'
invoke(path+"/faces/user/list/productInfoForList.jsp?brandName="+params[2]+"&catId="+params[3]+"&listId="+params[1],"productInformation");
invoke(path+"/faces/user/list/listTitles.jsp?flag=1","listTitles");



}

/*End of the method*/


/*method added to deactivate the checkbox*/

 function deactivateField(compId,aryIds){
//alert("activateField-->"+aryIds);
var fieldIdAry = new Array(aryIds.length);
fieldIdAry = aryIds.split(",");
var obj1 = document.getElementById(compId);
//alert("obj1.checked->"+obj1.checked);
if(obj1.checked)
{
	for(var i=0;i<fieldIdAry.length;i++)
	{
		var obj = document.getElementById(fieldIdAry[i]);
		obj.disabled = true;
	}
}
else
{
	for(var i=0;i<fieldIdAry.length;i++)
	{
		var obj = document.getElementById(fieldIdAry[i]);
		obj.disabled = false;
	}
}
}

/* validate and submit new list or edited list*/
function validateNewJspList()
{

	var frm = document.NewListForm;

	if(frm.listName.value==""){
		alert("Please enter list name"); 
		frm.listName.focus();
		return false;
	}
	else if(frm.listTags.value==""){
		alert("Please Enter comma seperated tags for list"); 
		frm.listTags.focus();
		return false;
	}
	var listId=frm.listId.value;
	var listTitle=frm.listName.value;
	var listTags=frm.listTags.value;
	var listDescription=frm.listDescription.value;
	var listImage="";
	if(document.getElementById("editListImage"))
	{
		listImage="";
	}
	else{
		listImage="listDefaImage.gif";
	}
		
	var listPrivacy;
	
		if(frm.listPrivacy[0].checked)
			listPrivacy = frm.listPrivacy[0].value;
		else
			listPrivacy = frm.listPrivacy[1].value;

	//alert(getFolderNames(frm));
	//var listImageFolder =getFolderNames(frm,'listImage');
	//alert(listImageFolder+" / "+listImage);

	
	var sessionUserId = frm.sessionUserId.value;
	
	makeMyRequest(path+'/faces/jsp/commonForMakeRequest.jsp','listId='+listId+'&listTitle='+listTitle+'&listImage='+listImage+'&listTags='+listTags+'&listDescription='+listDescription+'&listPrivacy='+listPrivacy+'&sessionUserId='+sessionUserId+'&pageId=submitUserNewList','submitUserNewList');
	
	
}

/*method to remove product from list*/
function removeProductFromList(productId,listId){

	var answer = confirm("Are you sure You want to delete this product from your list?");	
	if(answer)
		makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","productId="+productId+"&listId="+listId+"&pageId=removeProductFromListId",'removeProductFromListId');	
	
}
/*method to invoke page after removing product from list*/
function removeProductFromListId(params){
	if(params[1]=="success"){
		invoke(path+'/faces/user/list/listProducts.jsp?listId='+params[0],'RightPanel');
	}
	invoke(path+"/faces/user/list/listTitles.jsp?flag=1","listTitles");
}

/*Method to change product tag on onChange event od select box*/
function changeProductTag(selectBox,productId,listId){
	
	makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","productId="+productId+"&listId="+listId+"&productTag="+selectBox.value+"&pageId=changeProductTagId",'changeProductTagId');	
}

function changeProductTagId(params){}

/*Method addedd for the invoke of userreview history on the click of reviews in connections*/
function invokereviewHistory(sessionUserId){
var url = path+"/faces/user/userHistoryDetails.jsp?sessionUserId="+sessionUserId;
invoke(url,"RightPanel");
}

/*method added forhe read more tab on the review history page*/
function switchMenu(obj) {
   var el = document.getElementById(obj);
   if(el){
   if ( el.style.display != "none" ) {
   
      el.style.display = 'none';
      
   }
   else {
      el.style.display = '';
   }
   }
}

function switchMenuPlusMinus(obj,imgId) {
   var el = document.getElementById(obj);
   var imgId = document.getElementById(imgId);
   if(el && imgId){
  
   if ( el.style.display != "none" ) {
   
      el.style.display = 'none';
      imgId.src=contextPath+"/naaptolImages/plus.gif";
   }
   else {
      el.style.display = '';
      imgId.src=contextPath+"/naaptolImages/minus.gif";
   }
   }
}

/*method to check user is logged in already or not*/
function checkUserLogin(objId){
		
		var lArray = new Array();
	
		lArray['submitDivId']=objId;
		lArray['action']='checkLoggedId';
	
		doRequest('request:isLoginCheck','',lArray);
	}
/* This function to change button to unsubsribe for subsribed user*/
function changeButtonToUnSubscribe(listId){
	//alert(listId);
	var divId = document.getElementById(listId+"@subscribeToListId");
	if(document.getElementById("subscribe"))
		document.getElementById("subscribe").style.display='none';
	
	if(document.getElementById("unsubscribe"))
		document.getElementById("unsubscribe").style.display='';
	
	if(document.getElementById("subsMessage"))
			document.getElementById("subsMessage").innerHTML="Successfully subscribed ";
}	

function unSubscribe(listId,sessionUserId){
	if(confirm("Are you sure You want to unsubscribe from this list?"))
		makeMyRequest(path+'/faces/jsp/commonForMakeRequest.jsp','listId='+listId+'&sessionUserId='+sessionUserId+'&pageId=unsubscribeFromList','unsubscribeFromList');
		
}

function unsubscribeFromList(params){
	//alert(params[0]);
	if(document.getElementById("subscribe"))
			document.getElementById("subscribe").style.display='';
	
	if(document.getElementById("unsubscribe"))
			document.getElementById("unsubscribe").style.display='none';
			
	if(document.getElementById("subsMessage"))
		document.getElementById("subsMessage").innerHTML="Successfully unsubscribed ";		
			
			
}

function checkIsUserSubscribed(params){
//alert("params "+params[0]);
	if(params[1]=='success'){
		if(document.getElementById("subscribe"))
			document.getElementById("subscribe").style.display='none';
	
		if(document.getElementById("unsubscribe"))
			document.getElementById("unsubscribe").style.display='';
		
		if(document.getElementById("subsMessage"))
			document.getElementById("subsMessage").innerHTML="Already subscribed  to this list ";
	}
	else{
		if(document.getElementById("subscribe"))
			document.getElementById("subscribe").style.display='';
	
		if(document.getElementById("unsubscribe"))
			document.getElementById("unsubscribe").style.display='none';
			
			var pArray = new Array();
			pArray['submitDivId']=params[0]+'@subscribeToListId';
			pArray['listId']=params[0];
		
		doRequest('request:subscribeToListForm',params[0]+'@subscribeToListId',pArray);
	}
	
}
	

/* Function to rate the product wiht star rating*/
function setListRating(rateList,listId,otherUserId){


	var rate = document.getElementById(rateList);
	
	if(rate.value==""){
		alert("Please rate this list"); 
	}
	else{
	for (ui=1;ui<=5;ui++)
  	  {
  	   mobj=document.getElementById(rateList + ui);
	   mobj.onmouseout="";	 
	   mobj.onmouseover="";	
	   mobj.onclick="";
		   	   
  	  }
	//document.getElementById("submitRating").href="javascript:doNothing();";
	makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","listId="+listId+"&otherUserId="+otherUserId+"&listRating="+rate.value+"&pageId=setListRatingRes",'setListRatingRes');	
	}
}

/*Function to return response after rating the list*/
function setListRatingRes(params){
	if(params[2]=="success"){
		alert("Thank you for rating the list");
		invoke(path+'/faces/user/list/listProducts.jsp?otherUserId='+params[1]+'&listId='+params[0],'RightPanel');
				
	}
}

/*function added to remove a connection*/
function removeconnection(sessionUserId,otherUserId,connectionType){
var  answer = "";
if(connectionType == "0"){
answer = confirm("Are you sure you want to remove this friend from your connections?");
}
else if (connectionType == "1"){
makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","sessionUserId="+sessionUserId+"&otherUserId="+otherUserId+"&connectiontype="+connectionType+"&pageId=removeConnection",'removeConnection');
}
else if (connectionType == "2"){
answer = confirm("Are you sure you want to cancel this invitaion?");
}
else if (connectionType = "3"){
makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","sessionUserId="+sessionUserId+"&otherUserId="+otherUserId+"&connectiontype="+connectionType+"&pageId=removeConnection",'removeConnection');
}
if(answer)
makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","sessionUserId="+sessionUserId+"&otherUserId="+otherUserId+"&connectiontype="+connectionType+"&pageId=removeConnection",'removeConnection');
}
function removeConnection(params){

var url = path+"/faces/user/connections.jsp?sl="+params[1]+"&sessionUserId="+params[2];
invoke(url,"connection");
}
/*End of the method*/

function removeList(listId){

	var answer = confirm("Are you sure you want to delete your list?");	
	if(answer)
		makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","listId="+listId+"&pageId=removeListId",'removeListId');	
}

function removeListId(params){
	if(params[1]=="success"){
		invoke(path+'/faces/user/list/allListDetailsOuter.jsp?listId='+params[0],'RightPanel');
		invoke(path+'/faces/user/list/listTitles.jsp?flag=1','listTitles');
	}
}


function addconnections(UserId,othersUserId,conn){
//alert("usertId"+UserId);
//alert("othersUserId"+othersUserId);
//alert("conn"+conn);
makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","sessionUserId="+UserId+"&otherUserId="+othersUserId+"&connectiontype="+conn+"&pageId=addconnection",'addconnection');
}
function addconnection(params){
var mesg = "";
//alert("params[3]---------------->>"+params[3]);
//alert("hi");
var otherUsrId="";
if(document.getElementById("other_userId"))
	otherUsrId= document.getElementById("other_userId").value;
	
if(!params[0])
	params[0]=otherUsrId;
if(params[3]){
//alert("if");
mesg = "d";
//alert(mesg);
}
else{
mesg = "Y"
}
//alert("outer--------------->>mesg"+mesg);
var url = path+"/faces/user/securityButton.jsp?otherUserId="+params[0]+"&mesg="+mesg+"&value="+params[3];
//alert(url);
invoke(url,"ButtonsForAdding");
invoke(url,"ButtonsForAddings");

invoke(url,"secuirtybuttons");
var urls = path+"/faces/user/otherUserProfile.jsp?otherUserId="+params[0];
invoke(urls,"RightPanel");
}


function loginconnect(objId){
var lArray = new Array();
lArray['submitDivId']=objId;
lArray['action']='checkLoggedId';
doRequest('request:isLoginCheck','',lArray);
//doRequest('request:loginforuserprofile',objId,lArray);
}

function mypopups(listId){
mywindow = window.open(path+'/faces/jsp/listImageUpload.jsp?listId='+listId,'mywindow','status=no,scrollbars=No,width=350,height=100'+'resizable=yes,status=no');
   mywindow.moveTo(200,465);
 } 

 function uploadListImage(objId,listId){
		alert(listId);
		var lArray = new Array();
	
		lArray['listId']=listId;
		
		doRequest('request:listImageUpload',objId,lArray);
	}
	
	
	/*Method added for the invoke of connetion related pages*/
	
	function invokeconnectiontab(level , sessionUserId){
	var xss = Math.random();
	var url = path+'/faces/user/connectionsHeader.jsp?sessionUserId='+sessionUserId+'&level='+level+'&xs='+xss;
    invoke(url,"RightPanel");
    }
	/*End of the method*/
	
	function getcontactImporter(invite,sessionUserId){
	var url = path+'/faces/contactImporter/contactsImporter.jsp?sessionUserId='+sessionUserId;
    invoke(url,"connection");
	}
	
	function getsearchpage (search ,sessionUserId){
	var divobj = document.getElementById('DisplayItems');
	divobj.style.visibility="hidden";
	divobj.style.display = 'none';
	var url = path+'/faces/components/search/peopleSearch.jsp?sessionUserId='+sessionUserId;
    invoke(url,"connection");
    var freind = document.getElementById('freinds');
    var fan = document.getElementById('fans');
    var  fav = document.getElementById('favs');
    var all = document.getElementById('all');
    var searchs = document.getElementById('searches');
    var pending = document.getElementById('pending');
    freind.className = "";
    fan.className = "";
    fav.className = "";
    all.className = "";
    searchs.className = "current";
    pending.className = "";
    
    } 
	
	function getpendingInvitation (level,sessionUserId , pending){
	var divobj = document.getElementById('DisplayItems');
	divobj.style.visibility="hidden";
	divobj.style.display = 'none';
	var url = path+'/faces/user/pendingInvitation.jsp?sessionUserId='+sessionUserId+'&level='+level;
    invoke(url,"connection");
     var freind = document.getElementById('freinds');
    var fan = document.getElementById('fans');
    var  fav = document.getElementById('favs');
    var all = document.getElementById('all');
    var searchs = document.getElementById('searches');
    var pending = document.getElementById('pending');
    freind.className = "";
    fan.className = "";
    fav.className = "";
    all.className = "";
    searchs.className = "";
    pending.className = "current";
    }
	
	function invokemenuhistory(sessionUserId ,pagetab){
	var url = path+'/faces/user/userHistoryDetails.jsp?sessionUserId='+sessionUserId+'&pageTab='+pagetab;
    invoke(url,"RightPanel");
	}
	
	
	function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{

	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	//alert(countCheckBoxes);
	if(!countCheckBoxes){
	//alert("if");
		objCheckBoxes.checked = CheckValue;
		}
	else{
	//alert("else");
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++){
			objCheckBoxes[i].checked = CheckValue;

}}
}


function reverse(inp) { 
//alert(inp);
var outp = "";
for (i = 0; i <= inp.length; i++) { 
    outp = inp.charAt (i) + outp 
} 

return outp ;
} 

   function sendreminder(formId,FieldName){
   var emailId = "";
   //alert("formId--------------->>"+formId);
   var objCheckBoxes = document.forms[formId].elements[FieldName];
   var countCheckBoxes = objCheckBoxes.length;
    if(!countCheckBoxes){
	//alert("if--------------"+objCheckBoxes.checked);
	var chked = objCheckBoxes.checked;
	//alert("chked----------------->>"+chked);
	if(chked == true){
	emailId = objCheckBoxes.value;
	makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","emailId="+emailId+"&pageId=reminderMail",'reminderMail');	
	}else{
	alert("Please select contact to remind");
	}
	}
	else{
	for(var i = 0; i<countCheckBoxes; i++){
	var objcheck = document.forms[formId].elements[FieldName];
	var chk = objcheck[i].checked ;
	if (chk == true){
    emailId = emailId + objcheck[i].value+",";
	}
	}
	if(emailId){
	var value = reverse(emailId);
    var indexval = value.indexOf(",");
	var reverseStr = value.substring(1,value.length);
    var result = reverse(reverseStr);
   // alert("result-----------------------"+result);
	makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","emailId="+result+"&pageId=reminderMail",'reminderMail');
	}
	else{alert("Please Select contacts to remind")}
	}}
	
	function reminderMail(params){
	//alert("params------------>>"+params[1]);
	//alert("params------------>>"+params[2]);
	var divObj = document.getElementById('responsemessageforinvite');
	divObj.innerHTML = '<font color=red>'+params[1]+'</font>'
	divObj.style.display= "block";
	divObj.style.visibility = "visible";
	}

 function toQueryStringForCatalog(requestMap)
 {

  //alert("toQueryString - Entered");
	var query = ""
	if(!requestMap)
		return query;

	for (var pname in requestMap)
	{
	   //alert("toQueryString - sunil1");
		var vObj  = requestMap[pname];
		 var strValue = ""+vObj;
		if(vObj && typeof(vObj) != "string")
		{
			strValue = "";
			for (var i=0; i<vObj.length; i++)
			{
				
				if(vObj[i] && vObj[i] != null && vObj[i].length > 0)
				{
					strValue = strValue+vObj[i]+",";
				}
			}
			
			strValue = strValue.substring(0,strValue.length-1);
		
		}
		
		if(strValue.length >0)
		{
			strValue = strValue.substring(0,strValue.length);
			query  = query  + "" + pname + "=" + strValue + "&";
		}
		
		
	}
	if(query.length > 0)
	{
		query = query.substring(0,query.length-1);
	}
	//ert(query);
	return query;
 }
 
 function listSort(catId,tagValue,otherUserId,userId,sortType){
	 if(sortType=="1"){
	  	invoke(path+'/faces/user/list/allListDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=1','MyListContent')
	  	document.getElementById("atozSort").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("atozSort").style.color='#003399';
	  }
	  
	  if(sortType=="2"){
	  	invoke(path+'/faces/user/list/allListDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=2','MyListContent')
	  	document.getElementById("ztoaSort").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("ztoaSort").style.color='#003399';
	  }
	  
	  if(sortType=="3"){
	  	invoke(path+'/faces/user/list/allListDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=3','MyListContent')
	  	document.getElementById("mostPopular").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("mostPopular").style.color='#003399';
	  }
	  if(sortType=="4"){
	  	invoke(path+'/faces/user/list/allListDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=4','MyListContent')
	  	document.getElementById("recentlyModi").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("recentlyModi").style.color='#003399';
	  }
	  
	  if(sortType=="5"){
	  	invoke(path+'/faces/user/list/allListDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=5','MyListContent')
	  	document.getElementById("mostSubscribed").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("mostSubscribed").style.color='#003399';
	  }
 }
 
 
function callComparePage(prodListSize, catId){

	var productIds="";
	var flag=0;
	
	for(var i=0; i<prodListSize; i++){
		var chkbox = document.getElementById("compareChk"+i);
		var prodId = document.getElementById("lpProdId"+i);
		
		
		if(chkbox && chkbox.checked)
    	{ 	
    			productIds = productIds+"&productId="+prodId.value;
    			
    			flag=flag+1;
    		
    		
    	}
	}
	
	if(flag==0 || flag==1 || flag>10)
		alert("Please select minimum 2 or maximum 10 products to compare.");
	else
		
		location.href = path+"/faces/product/compareProduct.jsp?catId="+catId+productIds;
	
}

function callComparePageForHistory(prodListSize, catId){

	var productIds="";
	var flag=0;
	
	for(var i=0; i<prodListSize; i++){
		var chkbox = document.getElementById("compareChk"+i);
		var prodId = document.getElementById("lpProdId"+i);
		
		
		if(chkbox && chkbox.checked)
    	{ 	if(productIds.match(prodId.value)){
    			
    		}
    		else{
    			productIds = productIds+"&productId="+prodId.value;
    			
    			flag=flag+1;
    		}
    		
    	}
	}
	
	if(flag==0 || flag==1 || flag>10)
		alert("Please select minimum 2 or maximum 10 products to compare.");
	else
		
		location.href = path+"/faces/product/compareProduct.jsp?catId="+catId+productIds;
	
}

function showHelpMessageOnCheck(chk,msgDivId){

	if(chk.checked){
	
				
			showHelpPopup(chk.id,msgDivId,-2,0);
			var msgId = document.getElementById(msgDivId);
			
			setTimeout('hideCompareHelpMesg('+msgId.id+')',5000);		
	}		
	else
			document.getElementById(msgDivId).style.display='none';
}

function hideCompareHelpMesg(msgId){
	if(msgId)
		msgId.style.display='none';
}

var refIdPrev="";
function valueSelected(refId){
	if(document.getElementById(refId)){
		if(document.getElementById(refIdPrev))
			document.getElementById(refIdPrev).style.color='#003399';
		document.getElementById(refId).style.color='#FF0000';
		refIdPrev=refId;
	}
}
/*method for the user status update*/
function updatestatus(formId , emailId){
var thisform = formId ;
var frm = document.forms[thisform];
var status = frm.status.value;
makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","status="+status+"&emailId="+emailId+"&pageId=statusUpdate",'statusUpdate');
}

function statusUpdate(params){
var statusdivObj = document.getElementById('statusvalue');
statusdivObj.innerHTML = params[0];

}
/*End of the method*/



/*Method added for the addition of new user signIn*/
function NewUsersignIn(formId){

var thisform = formId ;
var frm = document.forms[thisform];
var emailId = frm.emailId.value;

var password = frm.password.value;
var errordivObj = document.getElementById('ErrMsgSignUp');

if(emailId == ""){

errordivObj.innerHTML = "Please Enter EmailId.";
return false;
}
if(password == ""){
errordivObj.innerHTML = "Please Enter Password.";
return false;
}
makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","password="+password+"&emailId="+emailId+"&pageId=newUserSignIn",'newUserSignIn');

}

function newUserSignIn (params){
if (params[0] == "validUser"){
window.location.href = path+"/faces/user/myDetails.jsp";
}
else if(params[0] == "InvalidUser") {
var errordivObj = document.getElementById('ErrMsgSignUp');
errordivObj.innerHTML = "Please check your email Id and password";
}
}

function onkeypress(formId,events){
if(events && events.keyCode==13){
NewUsersignIn(formId)
}
}


/*end of the method*/
function createNewUser(params){
if(params[0] == "done"){
window.location.href = path+"/faces/user/myDetails.jsp";
}else if(params[0] == "notdone"){
alert("Please check the values")
}
else if(params[0] == "userExist"){
alert("This Email Id is already exists, please choose another email id")
}
}

function rateThisList(rateDiv, ratingDiv){

if(document.getElementById(rateDiv)){
	document.getElementById(rateDiv).style.display="";
	document.getElementById(ratingDiv).style.display="none";
	}
}

function invokeQuestionAnswer(sessionId ,pageTab){
var url = path+'/faces/user/questionHeader.jsp?sessionUserId='+sessionId+'&pageTab='+pageTab;
invoke(url,"RightPanel");
}

function invokeQuestion(sessionUserId){
if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
//if(document.getElementById("listTitles"))
// document.getElementById("listTitles").style.display='none';
var url = path+"/faces/user/questionHeader.jsp?sessionUserId="+sessionUserId;
invoke(url,"RightPanel");
}




function invokeaskQuestion(sessionId){
var url = path+'/faces/user/askQuestion.jsp?sessionUserId='+sessionId;
invoke(url,"historydetails");
var Questiontab = document.getElementById('QuestionMain');
var answertab = document.getElementById('answertab');
var asktab = document.getElementById('asktab');
Questiontab.className = "";
answertab.className = "";
asktab.className = "current";
}



function invokeMyanswers(sessionId){
var url = path+'/faces/user/userAnswers.jsp?sessionUserId='+sessionId;
invoke(url,"historydetails");
var Questiontab = document.getElementById('QuestionMain');
var answertab = document.getElementById('answertab');
var asktab = document.getElementById('asktab');
Questiontab.className = "";
answertab.className = "current";
asktab.className = "";
}

function invokeMyquestion(sessionId){
var url = path+'/faces/user/questionAnswer.jsp?sessionUserId='+sessionId;
invoke(url,"historydetails");
var Questiontab = document.getElementById('QuestionMain');
var answertab = document.getElementById('answertab');
var asktab = document.getElementById('asktab');
Questiontab.className = "current";
answertab.className = "";
asktab.className = "";
}

/*function adedd for getting the category names and product name by ajax*/
function getnameforcategoryQA(catId,listName,listId)
{
//alert(catId);
//alert("catgeory Name for Qa");
if(catId != "" && catId != null)
		makeMyRequest(path+'/faces/jsp/categoryNamesforQAcategory.jsp','categoryId='+catId+'&listName='+listName+'&listId='+listId+'&getcategorynameQA=getcategorynameQA','getcategorynameQA');
		
		var forFocusObj = document.getElementById('brandTable');
			if(forFocusObj)
				forFocusObj.focus();
	
}
/*end of the method*/


/*function added for getting the complte details  of the category*/
function getcategorynameQA(params){
//alert("response for category Name for Qa")
var html = "";
var isLength = true;
var i=2;var j = 2;
if(params[1] == "subCategory")
{    

    var subDivObj = document.getElementById('subCategoryDiv');
  
	var html = "<table cellpadding='3' cellspacing='0'><tr><td class='textnormal_12' align='left' width='120'><span style='font-weight:bold;'>Sub-Category&nbsp;:&nbsp;</span></td><td align='left'><select class=\"inputBox\" name=\"subCategory\" id=\"subCategory\" onchange=\"getnameforcategoryQA(this.value,'subsubCategory','"+params[0]+"');\"><option value=''>Select-SubCategory</option>";
	while(i < params.length-1)
	{
		//subCategory.options[j] = new Option(params[i],params[++i]);
		html = html + "<option value="+params[i]+">"+params[++i]+"</option>";
		j++;
		i++;
	}
	html = html + "</select></td></tr></table>";
	
	subDivObj.innerHTML = html;
	subDivObj.style.visibility = "visible";
	subDivObj.style.display = "block";
	i = 2;j = 2;
}

else if(params[1] == "subsubCategory")
{
	hideDiv('brandNameDiv');
	var subsubDivObj = document.getElementById('subsubCategoryDiv');
	var html = "<table cellpadding='3' cellspacing='0'><tr><td class='textnormal_12' align='left' width='120'><span style='font-weight:bold;'>Sub-Sub-Category&nbsp;:&nbsp;</span></td><td align='left'><select class=\"inputBox\" name=\"subsubCategory\" id=\"subsubCategory\" onchange=\"getnameforcategoryQA(this.value,'brandName','"+params[0]+"');\"><option value=''>Select-Sub-Sub-Category</option>";
	
	while(i < params.length-1)
	{
		html = html + "<option value="+params[i]+">"+params[++i]+"</option>";
		
		j++;
		i++;
	}
	html = html + "</select></td></tr></table>";
	subsubDivObj.innerHTML = html;
	subsubDivObj.style.visibility = "visible";
	subsubDivObj.style.display = "block";
	
	i = 2;j = 2;
	
	
}

else if(params[1].match("brandName") == 'brandName')
{
	var catId = null;
	if(params[1] == 'brandNameHideSubSubCategory')
	{
		hideDiv('subsubCategoryDiv');
		catId = document.getElementById('subCategory').value;
	}
	else
	{
		catId = document.getElementById('subsubCategory').value;
	}
	
	
	var brandNameDivObj = document.getElementById('brandNameDiv');
	var html = "<table cellpadding='3' cellspacing='0'><tr><td class='textnormal_12' align='left' width='120'><span style='font-weight:bold;'>BrandName&nbsp;:&nbsp;</span></td><td align='left'><select class=\"inputBox\" name=\"brandNames\" id=\"brandNames\" onchange=\"getAllproductInformationQA(this.value,'allProductNames','"+catId+"','"+params[0]+"');\"><option value=''>Select-BrandName</option>";
		
	while(i < params.length-1)
	{
		html = html + "<option value="+params[i]+" id="+params[i]+">"+params[++i]+"</option>";
		j++;
		i++;
	}
	html = html + "</select></td></tr></table>";
	//alert(html);
	brandNameDivObj.innerHTML = html;
	brandNameDivObj.style.visibility = "visible";
	brandNameDivObj.style.display = "block";
	
	i = 2;j = 2;
}
}
/*End of the method*/


/*function added for gettin the product list*/
function getAllproductInformationQA(prdId,listName,catId,listId)
{
//alert("all product information QA");
var brandNameObj = document.getElementById(prdId);

if(brandNameObj)
{
var brandName = brandNameObj.innerHTML;
if(catId != "" && catId != null)
{
	if(prdId != "" && prdId != null)
	{
		if(brandName != "" && brandName != null)
		{
			makeMyRequest(path+'/faces/jsp/categoryNamesForQA.jsp','categoryId='+catId+'&listName='+listName+'&brandName='+brandName+'&listId='+listId+'&getproductNameQA=getproductNameQA','getproductNameQA');;
	
			var Obj = document.getElementById('productInfo');
			Obj.style.visibility = "visible";
			Obj.style.display = "block";
			
			var forFocusObj = document.getElementById('brandTable');
			if(forFocusObj)
				forFocusObj.focus();
		}
	}
}
}
}



/*end of the method*/

/*Function adedd for getting the response and generation of productName feild*/

function getproductNameQA(params) {
//alert("get Product NAmes QA"+params);
var html = "";
var isLength = true;
var i=2;var j = 2;
if(params[1] == "allProductNames")
{    

    var subDivObj = document.getElementById('productNameDiv');
  
	var html = "<table cellpadding='3' cellspacing='0'><tr><td class='textnormal_12' align='left' width='120'><span style='font-weight:bold;'>Product Name&nbsp;:&nbsp;</span></td><td align='left'><select class=\"inputBox\" name=\"productName\" id=\"productName\"><option value=''>Select-Product</option>";
	while(i < params.length-1)
	{
		//subCategory.options[j] = new Option(params[i],params[++i]);
		html = html + "<option value="+params[i]+">"+params[++i]+"</option>";
		j++;
		i++;
	}
	html = html + "</select></td></tr></table>";
	
	subDivObj.innerHTML = html;
	subDivObj.style.visibility = "visible";
	subDivObj.style.display = "block";
	i = 2;j = 2;
}
}

/*end of method*/


function postQuestion(form , sessionUserId){
var subsubcategory = "";
var subcatgeory = "";
var productName = "";
var Questiontitle = "";
var categorys = null;
var tags = "";
//alert("form"+form);
//alert("sessionUserId"+sessionUserId);
	var thisform = form ;
    var frm = document.forms[thisform];
    //alert(frm);

var questiontile = frm.questionTitle.value;
if(questiontile){
Questiontitle = questiontile
}
else{
alert("Please enter question title");
questionTitle.focus();
return false;
}
//alert(Questiontitle);
var QuesdDesc = frm.quesdesc.value;
//alert("QuesdDesc----->>"+QuesdDesc);
 var valid = "";
 var x = document.getElementById('alertmail').checked ;
 //alert(x);
 if (document.getElementById('alertmail').checked == true)
	{
	///alert("Y");
	   valid = "Y" ;
	}
	   else {
	  // alert("N");
	   valid = "N" ;
	} 

//alert("valid"+valid);
var tag = frm.tags.value;
if(tag){
tags = tag ;
}
else{
alert("Please enter Tag");
tags.focus();
return false;
}
//alert(tags);
var category = frm.categoryname.value;
if(category){
categorys = category;
}else{
categorys = null;
}
//alert("category"+categorys);
if(frm.subCategory){
subcatgeory = frm.subCategory.value;
//alert("subcatgeory---->>"+subcatgeory);
}else{
subcatgeory = "";
//alert("subcatgeory else------>>"+subcatgeory);
}
//alert("subcatgeory---->>"+subcatgeory);
if(frm.subsubCategory){
subsubcategory = frm.subsubCategory.value;
}else{
subsubcategory = "";
//alert("subsubcategory else ---------->>"+subsubcategory);
}
if(frm.productName){
 productName = frm.productName.value;
//alert("productName----->>"+productName);
}else{
productName = "";
//alert("productName----->>"+productName);
}

var categorytext = frm.categoytext.value;
var producttext = frm.producttext.value;

makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","sessionUserId="+sessionUserId+"&QuesdDesc="+QuesdDesc+"&questiontile="+Questiontitle+"&valid="+valid+"&Tags="+tags+"&categoryId="+categorys+"&subcategory="+subcatgeory+"&subsubcategory="+subsubcategory+"&productName="+productName+"&categorytext="+categorytext+"&producttext="+producttext+"&pageId=PostQuestionforAsk",'PostQuestionforAsk');
}
function PostQuestionforAsk(params){
//alert("params[0]---------->>"+params[0]);
//alert("params[1]---------->>"+params[1]);
if(params[0] == "done"){
var divobj = document.getElementById('messagedivforask');
document.getElementById('questionTitle').value = "";
document.getElementById('quesdesc').value = "";
document.getElementById('alertmail').checked = false;
document.getElementById('tags').value = "";
if(document.getElementById('radio'))
	document.getElementById('radio').checked = false;
if(document.getElementById('radio2'))
	document.getElementById('radio2').checked = false;
var areadiv = "";
if(document.getElementById('area1')){
	areadiv = document.getElementById('area1');
	areadiv.style.visibility = "hidden";
	areadiv.style.display = "none";
}
if(document.getElementById('categoryname'))
	document.getElementById('categoryname').value = ""; 
if(document.getElementById('subCategory')){
document.getElementById('subCategory').value = "";
}
if(document.getElementById('subsubCategory')){
document.getElementById('subsubCategory').value = "";
}
if(document.getElementById('brandNames')){
document.getElementById('brandNames').value = "";
}
if(document.getElementById('productName')){
document.getElementById('productName').value = "";
}

var areadiv2 ="";
if(document.getElementById('area2')){
	areadiv2 = document.getElementById('area2');
	areadiv2.style.visibility = "hidden";
	areadiv2.style.display = "none";
}
if(document.getElementById('categoytext')){
document.getElementById('categoytext').value = "";   
}
if(document.getElementById('producttext'))   {
document.getElementById('producttext').value = ""; 
}                 
divobj.innerHTML = '<font color=red>'+params[1]+'</font>';
divobj.style.visibility = "visible";
divobj.style.display = "block";
}
else if(params[0]== "notdone"){
var divobj = document.getElementById('messagedivforask');
divObj.innerHTML = '<font color=red>'+params[1]+'</font>'
divobj.style.visibility = "visible";
divobj.style.display = "block";
}
}


function  invokeQuestionDetail(sessionId,QuestionId){
//alert("heloo");
//alert(QuestionId);
var url = path+'/faces/user/QuestionAnswerDetail.jsp?sessionUserId='+sessionId+'&Questionid='+QuestionId;
invoke(url,"RightPanel"); 

}

function reportAbuseAction(answerId,questionId,sessionId){
makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","answerId="+answerId+"&questionId="+questionId+"&sessionId="+sessionId+"&pageId=reportabuse",'reportabuse');
}
function reportabuse(params){
if(params[0] == "done"){
var url = path+'/faces/user/answerDetails.jsp?sessionId='+params[3]+'&questionId='+params[2];
invoke(url,"answerDeatails"); 
}
if(params[0] == "notdone"){
alert("Please try again");
}
}


function submitanswer(formid ,questionId,sessionId){
var thisform = formid ;
var frm = document.forms[thisform];
var answertitle = null ;
var answerdesc = null ;
var anstitle = frm.answertitle.value;
reWhiteSpace = new RegExp(/^\s+$/)
if (reWhiteSpace.test(anstitle)) {
          alert("Please Check Your Fields For Spaces");
          return false;
 }
if(anstitle){
answertitle = anstitle;
}
else{
alert("Please enter answer title");
return false;
}
var ansdesc = frm.ansdesc.value;
if (reWhiteSpace.test(ansdesc)) {
          alert("Please Check Your Fields For Spaces");
          return false;
 }
if(ansdesc){
answerdesc = ansdesc;
}else{
alert("Please enter answer description");
return false;
}

makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","questionId="+questionId+"&sessionId="+sessionId+"&answertitle="+answertitle+"&answerdesc="+answerdesc+"&pageId=responseSubmitanswer",'responseSubmitanswer');
}
function responseSubmitanswer(params){

//alert("params----->>>"+params[0]);
//alert("params----------->>"+params[1]);
//alert("params-------------->>"+params[2]);

if(params[0] == "done"){
var url = path+'/faces/user/QuestionAnswerDetail.jsp?sessionUserId='+params[2]+'&Questionid='+params[1];
invoke(url,"RightPanel"); 

}
if(params[0] == "notdone"){
alert("please try again")
}
}


function invokeMyquestionforotherUser(sessionId){
var url = path+'/faces/user/otherUserquestionAnswer.jsp?sessionUserId='+sessionId;
invoke(url,"historydetails");
var Questiontab = document.getElementById('QuestionMain');
var answertab = document.getElementById('answertab');
Questiontab.className = "current";
answertab.className = "";
}

function invokeMyanswersforotherUser(sessionId){
var url = path+'/faces/user/otheruserAnswers.jsp?sessionUserId='+sessionId;
invoke(url,"historydetails");
var Questiontab = document.getElementById('QuestionMain');
var answertab = document.getElementById('answertab');
Questiontab.className = "";
answertab.className = "current";

}


function QuestionDetailforotherUser(sessionId,QuestionId){
//alert("heloo");
//alert(QuestionId);
var url = path+'/faces/user/otherUserQuestionAnswerDetail.jsp?sessionUserId='+sessionId+'&Questionid='+QuestionId;
invoke(url,"RightPanel"); 
}


function invokeQuestionotheruser(sessionId,pagetab) {
var url = path+'/faces/user/otherUserquestionHeader.jsp?otherUserId='+sessionId+'&pageTab='+pagetab;
invoke(url,"RightPanel");
}
function checkSubmitanswer(objId){
var lArray = new Array();
lArray['submitDivId']=objId;
lArray['action']='checkLoggedId';
doRequest('request:isLoginCheck','',lArray);
}



function otherUserSubmitAnswer(formid ,questionId,sessionId){
//alert("in other user---->>"+formid);
var thisform = formid ;
var frm = document.forms[thisform];
var answertitle = null ;
var answerdesc = null ;
var anstitle = frm.answertitle.value;
if(anstitle){
answertitle = anstitle;
}
else{
alert("Please enter answer title");
return false;
}
var ansdesc = frm.ansdesc.value;
if(ansdesc){
answerdesc = ansdesc;
}else{
alert("Please enter answer description");
return false;
}

makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","questionId="+questionId+"&sessionId="+sessionId+"&answertitle="+answertitle+"&answerdesc="+answerdesc+"&pageId=otherUserresponseSubmitanswer",'otherUserresponseSubmitanswer');
}
function otherUserresponseSubmitanswer(params){

//alert("params----->>>"+params[0]);
//alert("params----------->>"+params[1]);
//alert("params-------------->>"+params[2]);

if(params[0] == "done"){
var url = path+'/faces/user/otherUserQuestionAnswerDetail.jsp?sessionUserId='+params[2]+'&Questionid='+params[1];
invoke(url,"RightPanel"); 

}
if(params[0] == "notdone"){
alert("please try again")
}
}
function invokeMyorder(sessionUserId){
if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
//if(document.getElementById("listTitles"))
// document.getElementById("listTitles").style.display='none';
var url = path+"/faces/user/orderList.jsp?sessionUserId="+sessionUserId;
invoke(url,"RightPanel");
}

function invokeMyNeworder(sessionUserId){
if(document.getElementById("listSubscribers"))
 document.getElementById("listSubscribers").style.display='none';
//if(document.getElementById("listTitles"))
// document.getElementById("listTitles").style.display='none';
var url = path+"/faces/user/orderListNew.jsp?sessionUserId="+sessionUserId;
invoke(url,"RightPanel");
}

function invokeOrderdetail(orderId , sessionId){
var url = path+"/faces/user/orderCompleteDetail.jsp?sessionUserId="+sessionId+"&orderId="+orderId;
invoke(url,"RightPanel");
}

function invokeOrderdetailNew(orderId , sessionId){
var url = path+"/faces/user/orderCompleteDetailNew.jsp?sessionUserId="+sessionId+"&orderId="+orderId;
invoke(url,"RightPanel");
}

function showforQa(divId){
  var divObj = document.getElementById(divId);
  
  if(divObj){
  if(divId == "area1"){
      divObj.style.visibility="visible";
	  divObj.style.display='block';
	  document.getElementById('categoryname').value = ""; 
      if(document.getElementById('subCategory')){
      document.getElementById('subCategory').value = "";
       }
		if(document.getElementById('subsubCategory')){
		document.getElementById('subsubCategory').value = "";
		}
		if(document.getElementById('brandNames')){
		document.getElementById('brandNames').value = "";
		}
		if(document.getElementById('productName')){
		document.getElementById('productName').value = "";
		}
	  
	  }
	if(divId == "area2"){
	 divObj.style.visibility="visible";
	 divObj.style.display='block';
	 
	 
	}
	  
  }
}
function hideforQa(divId){

var divObj = document.getElementById(divId);
if(divObj){
if(divId == "area2"){
	divObj.style.visibility="hidden";
	divObj.style.display='none';
	document.getElementById('radio2').checked = false;
	}
	
if(divId == "area1"){
    divObj.style.visibility="hidden";
	divObj.style.display='none';
	document.getElementById('radio').checked = false;
	if(document.getElementById('categoytext')){
	document.getElementById('categoytext').value = "";   
	}
	if(document.getElementById('producttext'))   {
	document.getElementById('producttext').value = ""; 
	} 
}

}
}


/*method added for the sorting criteria of q&A home  */


function QuestionSort(catId,tagValue,otherUserId,userId,sortType,unCategQues){
	
	 if(document.getElementById("showCatnTagValue") && tagValue=='0')
	  		document.getElementById("showCatnTagValue").style.visibility="visible";
	
	 if(sortType=="1"){
	  	invoke(path+'/faces/user/allQuestionDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=1&unCategQues='+unCategQues,'MyListContent')
	  	document.getElementById("atozSort").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("atozSort").style.color='#003399';
	  }
	  
	  if(sortType=="2"){
	  	invoke(path+'/faces/user/allQuestionDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=2&unCategQues='+unCategQues,'MyListContent')
	  	document.getElementById("ztoaSort").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("ztoaSort").style.color='#003399';
	  }
	  
	  if(sortType=="3"){
	  	invoke(path+'/faces/user/allQuestionDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=3&unCategQues='+unCategQues,'MyListContent')
	  	document.getElementById("mostPopular").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("mostPopular").style.color='#003399';
	  }
	  if(sortType=="4"){
	  	invoke(path+'/faces/user/allQuestionDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=4&unCategQues='+unCategQues,'MyListContent')
	  	document.getElementById("recentlyModi").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("recentlyModi").style.color='#003399';
	  }
	  
	  if(sortType=="5"){
	  	invoke(path+'/faces/user/allQuestionDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=5&unCategQues='+unCategQues,'MyListContent')
	  	document.getElementById("mostSubscribed").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("mostSubscribed").style.color='#003399';
	  }
	  if(sortType=="6"){
	  	invoke(path+'/faces/user/allQuestionDetails.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=6&unCategQues='+unCategQues,'MyListContent')
	  	document.getElementById("unAnsweredQues").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("unAnsweredQues").style.color='#003399';
	  }
	  
	  
 }
/*end of the method*/

/*Login check for the question*/
function QuestionLogin(objId){
//alert("heloo")
var lArray = new Array();
lArray['submitDivId']=objId;
lArray['action']='checkLoggedId';
doRequest('request:isLoginCheck','',lArray);
//doRequest('request:loginforuserprofile',objId,lArray);
}
/*end of the method*/

function actionforQuestionHome(navTab){

window.location= path+"/faces/user/myQuestion.jsp?navTab="+navTab;
}
function sortConnection(sessionId,sortLevel){
	if(connectionSortLevel == "")
		connectionSortLevel = 3;
     if(sortLevel=="0"){
	  	invoke(path+"/faces/user/connections.jsp?sl="+connectionSortLevel+"&sessionUserId="+sessionId+"&sortlevel="+sortLevel,"connection"); 
	  	document.getElementById("atozSort").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("atozSort").style.color='#003399';
	  }
	  
	  if(sortLevel=="1"){
	  	invoke(path+"/faces/user/connections.jsp?sl="+connectionSortLevel+"&sessionUserId="+sessionId+"&sortlevel="+sortLevel,"connection"); 
	  	document.getElementById("ztoaSort").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("ztoaSort").style.color='#003399';
	  }
	  
	  if(sortLevel=="2"){
	  	invoke(path+"/faces/user/connections.jsp?sl="+connectionSortLevel+"&sessionUserId="+sessionId+"&sortlevel="+sortLevel,"connection"); 
	  	document.getElementById("recentlyModi").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("recentlyModi").style.color='#003399';
	  }
	   if(sortLevel=="3"){
	  	invoke(path+"/faces/user/connections.jsp?sl="+connectionSortLevel+"&sessionUserId="+sessionId+"&sortlevel="+sortLevel,"connection"); 
	  	document.getElementById("mostPopular").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("mostPopular").style.color='#003399';
	  }

}

function Otherusersort(sessionId,sortLevel){
	if(connectionSortLevel == "")
		connectionSortLevel = 3;
     if(sortLevel=="0"){
	  	invoke(path+"/faces/user/otherUserConnectionDetails.jsp?sl="+connectionSortLevel+"&sessionUserId="+sessionId+"&sortlevel="+sortLevel,"connection"); 
	  	document.getElementById("atozSort").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("atozSort").style.color='#003399';
	  }
	  
	  if(sortLevel=="1"){
	  	invoke(path+"/faces/user/otherUserConnectionDetails.jsp?sl="+connectionSortLevel+"&sessionUserId="+sessionId+"&sortlevel="+sortLevel,"connection"); 
	  	document.getElementById("ztoaSort").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("ztoaSort").style.color='#003399';
	  }
	  
	  if(sortLevel=="2"){
	  	invoke(path+"/faces/user/otherUserConnectionDetails.jsp?sl="+connectionSortLevel+"&sessionUserId="+sessionId+"&sortlevel="+sortLevel,"connection"); 
	  	document.getElementById("recentlyModi").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("recentlyModi").style.color='#003399';
	  }
	   if(sortLevel=="3"){
	  	invoke(path+"/faces/user/otherUserConnectionDetails.jsp?sl="+connectionSortLevel+"&sessionUserId="+sessionId+"&sortlevel="+sortLevel,"connection"); 
	  	document.getElementById("mostPopular").style.color='#FF0000';
	  }
	  else
	  {
	  	document.getElementById("mostPopular").style.color='#003399';
	  }

}




function CheckemailVerification(formId){
var thisform = formId ;
var frm = document.forms[thisform];
var emailId = frm.emailId.value;

var password = frm.password.value;
var errordivObj = document.getElementById('ErrMsgSignUp2');

if(emailId == ""){
errordivObj.innerHTML = "Please Enter EmailId.";
return false;
}
if(password == ""){
errordivObj.innerHTML = "Please Enter Password.";
return false;
}
makeMyRequest(path+"/faces/jsp/commonForMakeRequest.jsp","password="+password+"&emailId="+emailId+"&pageId=verifiedEmail",'verifiedEmail');
}

function verifiedEmail (params){
if (params[0] == "validUser"){
var errordivObj = document.getElementById('ErrMsgSignUp');
var logindiv = document.getElementById('loginDiv');
logindiv.style.visibility="hidden";
logindiv.style.display='none';
errordivObj.innerHTML = "Your email id is verified sucessfully. <br><a href='/'><b>Click here</b></a> to continue.";
}
else if(params[0] == "InvalidUser") {
var errordivObj = document.getElementById('ErrMsgSignUp2');
errordivObj.innerHTML = "Please check your email Id and password";
}
else if(params[0] == "verifiedValidUser") {
var logindiv = document.getElementById('loginDiv');
logindiv.style.visibility="hidden";
logindiv.style.display='none';
var errordivObj = document.getElementById('ErrMsgSignUp');
errordivObj.innerHTML = "Your  email id is already verified. <br><a href='/'><b>Click here</b></a> to continue.";
}
}

function verificationKeypress(formId,events){
if(events.keyCode==13){
CheckemailVerification(formId)
}
}

/*following function is used to min max div with [+] and [-] signs by satish sapate*/

function minMaxTab(divId,linkId){

	var divObj = document.getElementById(divId);
	var linkObj = document.getElementById(linkId);

	if(divObj.style.visibility == "hidden"){
		divObj.style.visibility = "visible";
		divObj.style.display = "block";
		linkObj.innerHTML = "[Hide]";
	}else{
		divObj.style.visibility = "hidden";
		divObj.style.display = "none";
		linkObj.innerHTML = "[Show]";
	}
}

function clearFilteredResult(divId,catId,tagValue,otherUserId,userId){
	invoke(path+'/faces/user/allQuestionDetailsOuter.jsp?catId='+catId+'&tagValue='+tagValue+'&otherUserId='+otherUserId+'&noUserId='+userId+'&sortType=4','RightPanel')
}

function showUncategorizedQues(){
	document.getElementById("unCategorisedQues").style.color='#669900';
	if(document.getElementById("showCatnTagValue")){
	  		document.getElementById("showCatnTagValue").style.visibility="visible";
	 }
	invoke(path+'/faces/user/allQuestionDetailsOuter.jsp?catId=0&tagValue=0&otherUserId=&noUserId=true&sortType=4&unCategQues=true','RightPanel')
}


