var imgload=new Image();

// loding function
var xval;
function showLoadingModal() 
{
	xval=getBusyOverlay('viewport',{color:'#407DBC', opacity:0.20, text:'loading...', style:'text-shadow: 0 0 3px black;font-weight:normal;font-size:12px;color:black'},{color:'#ffffff', size:40, type:'p'});
}

function hideLoadingModel()
{
	xval.remove();
}

/********************************** Function for User Registartion Start *******************************************/
function ShowUserTypeInformation(userType)
{
	if(userType==2)
	{
		jQuery("#divpersonal").attr("style","display:block");
		jQuery("#divcorporate").attr("style","display:none");
	}
	else if(userType==3)
	{
		jQuery("#divpersonal").attr("style","display:none");
		jQuery("#divcorporate").attr("style","display:block");
	}	
}
	
function SignUp(regType)
{
	if(regType==2)
		SignUpPersonal();
	else if(regType==3)
		SignUpCorporate();	
}

function SignUpPersonal()
{
 jQuery("#personalForm").validate({
      rules: {
	  	first_name:{
			required: true, maxlength:100
		},
		last_name:{
			required: true, maxlength:100
		},
		emailId:{
			required: true
		},
		c_email: {
          required: true, email:true ,
		  equalTo: "#emailId"
        },
		ddl_per_country: {
          required: true
        },
		password: {
          required: true,minlength: 6
        },
		cpassword: {
          required: true,minlength: 6,equalTo: "#password"
        }
	},
      messages: {
        first_name: {
          required: "First Name required",
		  maxlength: "Max lenght : 100 characters"
        },
		last_name: {
          required: "Last Name required",
		  maxlength: "Max lenght : 100 characters"
        },
		emailId: {
          required: "Email required"
        },		
		c_email: {
          required: "Confirm email required",
		  equalTo: " Please confirm email"
        },
		ddl_per_country: {
          required: "Please select Country"
        },
		password: {
          required: "Password required"
        },
		cpassword: {
          required: "Confirm Password required",
		  equalTo: " Confirm Password not match"
        },
		gender: {
          required: "Gender required"
        },		
		month: {
          required: "Month required"
        },
		day: {
          required: "Day required"
        },		
		year: {
          required: "Year required"
        }
	  }
  });	
}

function SignUpCorporate()
{
 jQuery("#corporateForm").validate({
      rules: {
	  	company_name:{
			required: true, maxlength:100
		},
		corporate_email:{
			required: true
		},
		c_corporate_email: {
          required: true, email:true ,
		  equalTo: "#corporate_email"
        },
		ddl_corp_country: {
          required: true
        },
		corporate_password: {
          required: true,minlength: 6
        },
		corporate_cpassword: {
          required: true,minlength: 6,equalTo: "#corporate_password"
        },
		full_name: {
          required: true
        },
		address: {
          required: true
        }
	},
      messages: {
        company_name: {
          required: "Company Name name required",
		  maxlength: "Max lenght : 100 characters"
        },
		corporate_email: {
          required: "Email required"
        },		
		c_corporate_email: {
          required: "Confirm email required",
		  equalTo: " Please confirm email"
        },
		ddl_corp_country: {
          required: "Please select Country"
        },
		corporate_password: {
          required: "Password required"
        },
		corporate_cpassword: {
          required: "Confirm Password required",
		   equalTo: " Confirm Password not match"
        },
		full_name: {
          required: "Contact Name required"
        },		
		address: {
          required: "Address required"
        }
	  }
  });	
}

function OpenTwitterWindow(twitterUrl)
{
	window.open(twitterUrl,'twitter',"status=1,toolbar=0,location=1,menubar=0,resizable=1,scrollbars=1,width=600,height=500,directories=0");	
}

function SignUpByTwitter()
{
 jQuery("#twitterForm").validate({
      rules: {
	  	first_name:{
			required: true, maxlength:100
		},
		emailId:{
			required: true,email:true
		}
	},
      messages: {
        first_name: {
          required: "Please enter your name",
		  maxlength: "Max lenght : 100 characters"
        },
		emailId: {
          required: "Please enter your email id",
		  email: 'Please enter valid email id'
        }
	  }
  });	
}
/********************************** Function for User Registartion End *******************************************/

function setULSortable()
{
	jQuery("#contentLeft ul").sortable({ handle : '.handle',opacity: 0.6, cursor: 'move', update: function() {
		var order = $(this).sortable("serialize") + '&action=updateRecordsListings';
		//alert(order);
		jQuery.post("update_category_order.php", order, function(theResponse){
			jQuery("#contentRight").html(theResponse);
		});
	}
	});
}

function checkAll()
{
	var totalVal=document.getElementById("totalmsg").value;
	for (i=0;i<=totalVal;i++)
	{
		var chkbx = "chkmsg" + i; 
		if (document.getElementById(chkbx))
		{
			if (document.getElementById('chkall').checked == true)
			{
				document.getElementById(chkbx).checked = true;
			}
			else
			{
				document.getElementById(chkbx).checked = false;
			}
		}
	}
}


function getFriendsTop10Categories(tabType,userId)
{
	var currentTabType=jQuery("#hidcurrenttab").val();
	if(currentTabType=='newsfeed')
		tabType='newsfeed'
	else if(currentTabType=='club')
		tabType='club'
	getTop10Categories(tabType,userId);	
}

function getTop10Categories(tabType,userId,catId,orderType,pCatId,listId,feedfrndsettings,shcategory,shchoices,shbookmark)
{
	var category = '';

	UnSelectAllFriendList();

	if(!orderType)
		orderType='';
	
	if(!pCatId)
		pCatId='0';
		
	if(!listId)
		listId='0';
	
	/*if((jQuery("#user_tab a.active").attr("id")=='mytop10' || jQuery("#user_tab a.active").attr("id")=='setup_my_category') && tabType=='setup_mytop10')
	{
		if(jQuery('.divcatgray').length){
			
			if(jQuery('#slideshow1 .drop-shadow img:first-child').length && jQuery('#slideshow .divcatgray').length && jQuery('#slideshow1 .drop-shadow img:first-child').attr("id")!=jQuery('#slideshow .divcatgray').attr("id")){
				splitParentCatId = jQuery('#slideshow1 .drop-shadow img:first-child').attr("id").split("_");
				if(splitParentCatId[1]){
					pCatId = splitParentCatId[1];
				}
			}
			
			splitCatId = jQuery('.divcatgray').attr("id").split("_");
			if(splitCatId[1] && (catId=='' || catId=='0')){
				catId = splitCatId[1];
			}	
		}
	}*/
	
	if((jQuery("#user_tab a.active").attr("id")!=tabType) && (userId=='' || userId==jQuery('#txtuserid').val()) && (tabType!='top10' && tabType!='techservices'))
	{
		if(jQuery('#txtselcatid').val()!='' && jQuery('#txtselcatid').val()!='0')
			catId = jQuery('#txtselcatid').val();
		if(jQuery('#txtselpcatid').val()!='' && jQuery('#txtselpcatid').val()!='0')
			pCatId = jQuery('#txtselpcatid').val();
		
		if(jQuery('#txtuserid').val()!=jQuery('#txtmyid').val())
		{
			userId='';
			catId = '';
			pCatId = '';
		}
		
		if((jQuery("#user_tab a.active").attr("id")=="friendstop10" && (tabType=="newsfeed" || tabType=="club")) || (jQuery("#user_tab a.active").attr("id")=="newsfeed" && (tabType=="friendstop10" || tabType=="club")) || (jQuery("#user_tab a.active").attr("id")=="club" && (tabType=="newsfeed" || tabType=="friendstop10")))
		{
			userId=jQuery('#txtuserid').val();
			catId = jQuery('#txtselcatid').val();
			pCatId = jQuery('#txtselpcatid').val();
		}	
	}

	if(!pCatId)
		pCatId='0';
	if(!catId)
		catId='';
	
	/*if(tabType=="mytop10" || tabType=="setup_mytop10" || tabType=="setup_my_category"){
		if(jQuery('#txtuserid').val()!='' && jQuery('#txtselcatid').val()!='')
		{
			jQuery('#txtselcatid').val('');
			jQuery('#txtselpcatid').val('');
			jQuery('#txtuserid').val('');
		}
	}
	
	catId = jQuery('#txtselcatid').val();
	pCatId = jQuery('#txtselpcatid').val();	
	userId=jQuery('#txtuserid').val();
	*/
	//alert(" C "+catId+" P "+pCatId+" U "+userId)

	
	
	jQuery('#divfrndlist').attr('style',"display:none");
	// SELECTED TAB
	jQuery("#user_tab a").removeClass('active');
	jQuery('#'+tabType+'').attr('class', 'active south');

	// POST DATA
	showLoadingModal();
	
	//jQuery("#divcheck").html('1');
	jQuery.post("gettabdata.php", {tabType: tabType, userId: userId,orderType:orderType,pCatId:pCatId,catId:catId}, function(response){
		jQuery('#contentLeft').html(response);
//jQuery("#divcheck").html('2');

		setULSortable();
		var puserId=jQuery('#txtuserid').val();

		/*if(puserId!=userId)
			catId='';*/
		/*if(tabType=='top10' && userId=='' && (jQuery("#slideshow li:first-child").attr("id")==jQuery("#slideshow li:last-child").attr("id")))
		{
			category = jQuery("#slideshow li:first-child").attr("id");
			category = category.split("_")[1];
		}*/
		
		if(tabType=='setup_mytop10')
		{
			category = jQuery("#slideshow li:first-child").attr("id");
			category = category.split("_")[1];
		}
		
		if(tabType=='friendstop10' || tabType=='newsfeed' || tabType=='club')
		{
			UnSelectAllFriendList();
			
			ChangeStyleOfSelectedFriend(puserId);
			//jQuery("#divheader").attr("style","min-height:285px");
		}
		if(catId)
			category = catId;
		
		if(tabType=='friendstop10' || tabType=='newsfeed' || tabType=='club')
		{
			ShowFriendsDetails(puserId);
		}
		else
		{
			jQuery('#divsearchuserimg').attr('style', 'display:none');
			
			if(getCookie("hideheaderimg")!=1)
				jQuery('#divmainimg').attr('style', 'display:block');
		}
		hideLoadingModel();
		//jQuery("#divcheck").html('3');
		var callChoicesFunction=true;
		
		if(shcategory)
		{
			var totalshcategory=jQuery("#hidshcategorycount").val();
			if(totalshcategory>1)
			{
				getUserSharedCategory(tabType);
				callChoicesFunction=false;
			}
		}
		
		if(shchoices)
		{
			var totalshchoice=jQuery("#hidshchoicecount").val();
			if(totalshchoice>1)
			{
				getUserSharedChoices(tabType);
				callChoicesFunction=false;
			}
		}
		
		if(shbookmark)
		{
			var totalshbookmark=jQuery("#hidshbookmarkcount").val();
			if(totalshbookmark>1)
			{
				getUserSharedBookmark(tabType);
				callChoicesFunction=false;
			}
		}
		//jQuery("#divcheck").html('4');
		if(callChoicesFunction)
			getTop10CategoriesChoices(puserId,category,orderType,0,'',pCatId,listId,'',feedfrndsettings);
	});	
}
	
function getTop10CategoriesChoices(puserId,catId,orderType,pagenum,searchval,pCatId,listId,clubdayval,feedfrndsettings,clubChoiceCat,myfrndId)
{
	showLoadingModal();
		
	//jQuery("#divcheck").html('5');
	if(!pagenum)
		pagenum=0;
		
	if(!orderType)
		orderType='';
	
	if(!searchval)
		searchval='';
	
	if(!pCatId)
		pCatId='0';
		
	if(!listId)
		listId='0';
	
	if(!clubdayval)
		clubdayval='';
	
	if(!clubChoiceCat)
		clubChoiceCat=0;
	
	if(!myfrndId)
		myfrndId='';
		
	tabType=jQuery("#hidcurrenttab").val();
	
	if(catId!="")
	{
		jQuery('.drop-shadow img').removeClass('divcatgray');
		jQuery('#catImg_'+catId).attr('class', 'divcatgray');
	}
	jQuery('#txtselcatid').val(catId);
	jQuery('#txtselpcatid').val(pCatId);
	jQuery('#top10_choiceof_users').html('');
	// POST DATA	
	jQuery.post("tab_action.php", {tab: tabType,category: catId,puserId:puserId,orderType:orderType,pagenum:pagenum,searchval:searchval,pCatId:pCatId,listId:listId,clubdayval:clubdayval,clubChoiceCat:clubChoiceCat,myfrndId:myfrndId}, function(response){
		
		//jQuery("#divcheck").html('6');
		
		jQuery("#user_tab a").removeClass('active');
		jQuery('#'+tabType+'').attr('class', 'active south');
		//jQuery("#divcheck").html('abc11');
		
		//document.getElementById("top10_choiceof_users").innerHTML=response;
		jQuery('#top10_choiceof_users').html(response);	
		/*try{
		jQuery('#top10_choiceof_users').html(response);	
		}catch(e){
		alert(e);
		alert(response);
		}*/
		
				//jQuery("#divcheck").html('abc');
		if(tabType=='mytop10' || tabType=='setup_mytop10')
		{
			updateOrderPname="update_list_order.php";
			SortOrderSetUpMyTop10(catId);
		}
		//jQuery("#divcheck").html('7');
		if(tabType=='setup_mytop10')
		{
			ExpandCollapseSetupMyTop10();
			AutoCompleteChoicesTitle();
		}
		if(tabType=='setup_my_category')
		{
			AutoCompleteCategoriesTitle();
		}
		
		if(listId!='' && listId!='0')
			document.location.href="#choices_"+listId;
			
		$('#itemList a.imggallery').lightBox();
		//jQuery("#divcheck").html('8');
		if(tabType=='setup_mytop10' && listId!='' && listId!=0)
		{
			jQuery("#btnexpcollpase_"+listId).val("Collapse");
			jQuery("#divexpcollpase_"+listId).slideToggle(600);	
		}
		
		if(tabType=='setup_my_category' && catId!='' && catId!=0)
		{
			document.location.href="#categories_"+catId;
		}
		/*if(feedfrndsettings==1)
		{
			ShowFriendListOption();	
		}*/
		hideLoadingModel();
		//jQuery("#divcheck").html('9');
	});
	
}

function AutoCompleteChoicesTitle()
{
	$(".autofillchoicestitle").autocomplete("autofillchoicetitle.php", {
		width: 325,
		mustMatch: false,
		matchContains: true,
		selectFirst: false,
		cacheLength: 10
	});	
}

function AutoCompleteCategoriesTitle()
{
	$(".autofillchoicestitle").autocomplete("autofillcategorytitle.php", {
		width: 378,
		mustMatch: false,
		matchContains: true,
		selectFirst: false,
		cacheLength: 10
	});	
}

function ResetAutoCompleteChoiceImagePath(txtObj,counter,imagePath)
{
	if(txtObj.value=='')
	{
		jQuery("#img_"+counter).attr("src",imagePath);
		jQuery("#hidautofillid"+counter).val(0);
		jQuery("#hidautofilltype"+counter).val(0);
	}
}

function ViewChoicesSlideShow()
{
	$('#itemList a.imggallery:first').click();
}

function ViewSubCategory(catnum)
{
	$('#ulsubchoice_'+catnum+' li.ancbluebox a:first').click();
}

function getTechServices(tabType,serviceIndex,orderType)
{
	showLoadingModal();
	
	if(!orderType)
		orderType='';
		
	UnSelectAllFriendList();
	
	jQuery('#divsearchuserimg').attr('style', 'display:none');
	
	if(getCookie("hideheaderimg")!=1)
		jQuery('#divmainimg').attr('style', 'display:block');
		
	// SELECTED TAB
	jQuery("#user_tab a").removeClass('active');
	jQuery('#'+tabType+'').attr('class', 'active south');
	
	// POST DATA		
	jQuery.post("gettechservicesdata.php", {tabType: tabType,orderType:orderType}, function(response){
		jQuery('#contentLeft').html(response);
		
		getTechServicesData(serviceIndex,0,orderType);		
	});	
}

function getTechServicesData(serviceIndex,pagenum,orderType,searchval,countryCode)
{
	showLoadingModal();
	
	if(!pagenum && pagenum!='')
		pagenum=0;
		
	if(!orderType)
		orderType='';
		
	if(!searchval)
		searchval='';
		
	if(!countryCode)
		countryCode='';
		
	tabType=jQuery("#hidcurrenttab").val();
	
	if(serviceIndex!="")
	{
		jQuery('.drop-shadow img').removeClass('divcatgray');
		jQuery('#suggestedcatImg_'+serviceIndex).attr('class', 'divcatgray');
	}

	// POST DATA	
	jQuery.post("tab_techservices.php", {tab: tabType,serviceIndex: serviceIndex,pagenum:pagenum,orderType:orderType,searchval:searchval,countryCode:countryCode}, function(response){
																																					
		jQuery("#user_tab a").removeClass('active');
		jQuery('#'+tabType+'').attr('class', 'active south');
	
		jQuery('#top10_choiceof_users').html(response);		
		$('#itemList a.imggallery').lightBox();
		hideLoadingModel();
	});	
}

function SearchChoicesByCountry()
{
	var searchval=jQuery("#txtsearch").val();
	var orderType=document.getElementById("ddlorder").value;
	var countryCode=document.getElementById("ddlcountry").value;
	getTechServicesData(3,0,orderType,searchval,countryCode);
}

function getSortDataByCountry()
{
	var orderType=document.getElementById("ddlorder").value;
	//var searchval=jQuery("#txtsearch").val();
	var searchval='';
	var countryCode=document.getElementById("ddlcountry").value;
	getTechServicesData(3,0,orderType,searchval,countryCode);
}

function getChoicesByCountry()
{
	var countryCode=document.getElementById("ddlcountry").value;
	getTechServicesData(3,0,'','',countryCode);
}



function UnSelectAllFriendList()
{
	jQuery('.currentfrndonline').attr('style', '');
	jQuery('.currentfrnd').attr('style', '');
	jQuery('.currentfrndonline p').attr('style', 'color:#FFFFFF');
	jQuery('.currentfrnd p').attr('style', 'color:#FFFFFF');	
}

function SearchTop10CategoriesChoices(puserId,catId,orderType,pagenum,pCatId,listId,clubdayval,clubChoiceCat,myfrndId)
{
	var searchval=jQuery("#txtsearch").val();
	jQuery('#catImg_'+catId).attr('class', '');
	getTop10CategoriesChoices(puserId,catId,orderType,pagenum,searchval,pCatId,listId,clubdayval,'',clubChoiceCat,myfrndId);
}

function SortClubChoices(puserId,catId,orderType,pagenum,pCatId,listId,clubdayval,clubChoiceCat,myfrndId)
{
	var orderType=document.getElementById("ddlorder").value;
	var searchval=jQuery("#txtsearch").val();
	jQuery('#catImg_'+catId).attr('class', '');
	getTop10CategoriesChoices(puserId,catId,orderType,pagenum,searchval,pCatId,listId,clubdayval,'',clubChoiceCat,myfrndId);
}

function getSortData(tabType,userId,catId,pCatId)
{
	var orderType=document.getElementById("ddlorder").value;
	
	if(orderType=='sentchoices' || orderType=='receivedchoices')
		getTop10CategoriesChoices(userId,catId,orderType,'','',pCatId,0,'','','');
	else
		getTop10Categories(tabType,userId,catId,orderType,pCatId);
}

function getFriendsSentReceivedChoices(puserId,catId,orderType,pagenum,pCatId,listId,clubdayval,clubChoiceCat)
{
	var orderType=document.getElementById("ddlorder").value;
	var myfrndId=document.getElementById("ddlmyfrndlist").value;
	var searchval=jQuery("#txtsearch").val();
	getTop10CategoriesChoices(puserId,catId,orderType,pagenum,searchval,pCatId,listId,clubdayval,'',clubChoiceCat,myfrndId);
}

function getSortTechServicesData(tabType,userId,catId)
{
	var orderType=document.getElementById("ddlorder").value;
	getTechServices(tabType,1,orderType);
}

function getSortMyCategory(tabType,userId,catId,pCatId)
{
	var orderType=document.getElementById("ddlorder").value;
	//getTop10Categories(tabType,userId,catId,orderType,pCatId);
	getTop10CategoriesChoices(userId,catId,orderType,'','',pCatId,'0','');
}

function ExpandCollapseSetupMyTop10()
{
	jQuery(".divexpcollpase").hide();
	jQuery(".expendcancel").hide();
	jQuery(".divexpcollpasebtn").click(function(){
											
		
		if(jQuery(this).find("input").val()=="Expand")
		{
			jQuery(this).find("input").val("Collapse");
			$(this).closest("form").find(".expendcancel").show();
		}
		else
		{		
			jQuery(this).find("input").val("Expand");
			$(this).closest("form").find(".expendcancel").hide();
		}
		
		jQuery(this).next(".divexpcollpase").slideToggle(600);
	});
	tinymcEditor();
		/*jQuery(".successmsg").each(function(){
		if($(this).html()!=''){
			var divcounter=$(this).attr("listIdVal");
			jQuery("#divexpcollpase_"+divcounter).show();
			jQuery("#btnexpcollpase_"+divcounter).val("Collapse");
			
		}
	});	*/
}

function ExpandCollapseSetupMyTop10Cancel(btnid)
{
	jQuery("#btnexpcollpase_"+btnid).click();
	location.href="#choices_"+btnid;
	//jQuery(".divexpcollpasebtn").click();
	//jQuery(this).hide();
	//jQuery(".divexpcollpase").hide();
	//jQuery(this).hide();		
	//	if(jQuery(".divexpcollpasebtn").find("input").val()=="Collapse")
	//		jQuery(".divexpcollpasebtn").find("input").val("Expand");

	
}

function returnTo(tabType,puserId,catId,orderType,pCatId,listId)
{
	window.scrollTo(0,200)
	jQuery("#hidcurrenttab").val(tabType);
	//getTop10CategoriesChoices(puserId,catId,orderType,0,'',pCatId,listId);
	getTop10Categories(tabType,puserId,catId,orderType,pCatId,listId)
}

function getMyCategoryList(tabType,userId,orderType,catId,dbclick)
{
	var category = '';

	// SELECTED TAB
	jQuery("#user_tab a").removeClass('active');
	jQuery('#'+tabType+'').attr('class', 'active south');
	
	UnSelectAllFriendList();
	
	
	// POST DATA
	showLoadingModal();
	jQuery.post("gettabdata.php", {tabType: tabType, userId: userId}, function(response){
		jQuery('#contentLeft').html(response);

		setULSortable();
		var puserId=jQuery('#txtuserid').val();
		
		jQuery('.drop-shadow img').removeClass('divcatgray');
		jQuery('#catImg_'+catId).attr('class', 'divcatgray');
		hideLoadingModel();
	});	
}

/***************************** Function for Bookmark Start ****************************************/

function getFavWebsiteData(catId,puserId,catName,pCatId)
{
	showLoadingModal();
	
	jQuery(".divsortby a").removeClass('anctagactiveund');
	jQuery('#andmybookmark').attr('class', 'anctagactiveund');
	
	
	// POST DATA	
	jQuery.post("list_bookmark.php", {category: catId,puserId:puserId,catName:catName,pCatId:pCatId}, function(response){
		jQuery('#itemList').html(response);	
		
		jQuery("#divtitleh6").html('Setup My Top 10 &quot;'+catName+' BOOKMARKS&quot;');
		jQuery("#imgancnewup").attr('style','display:block');
		jQuery("#imgancnewdown").attr('style','display:block');
		
		jQuery(".btnchoices").attr("src","images/btn_create_bookmark.png");
		jQuery(".btnchoices").mouseover(function ()
		{
			jQuery(this).attr("src","images/btn_create_bookmark-over.png");
		});

		jQuery(".btnchoices").mouseout(function ()
		{
			jQuery(this).attr("src","images/btn_create_bookmark.png");
		});
		
		updateOrderPname='update_favwebsite_order.php';
		
		
		jQuery.post("gettabdata.php", {tabType: 'setup_mytop10', userId: puserId,pCatId:pCatId}, function(data){
			jQuery('#contentLeft').html(data);
	
			setULSortable();
			var puserId=jQuery('#txtuserid').val();		
					
			jQuery('.drop-shadow img').removeClass('divcatgray');
			jQuery('#catImg_'+catId).attr('class', 'divcatgray');			
		});	
		
		
		hideLoadingModel();
	});
}


function AddEditMyFavWebData(obj)
{
	var form_name = obj;
	jQuery(document).ready(function() {
	  jQuery("#"+form_name).validate({
		  rules: {
			title: {
			  required: true
			},
			website_url: {
			  required: true
			}
		},
		  messages: {
			title: {
			  required: "Title required"
			},			
			website_url: {
			  required: "Website URL required"
			}
		  },
		  submitHandler: function(form) {
			form.submit();
		 }
	
	  });
	
	});
}

function deleteMyFavWebData(catId,uid,favweb_id,action,counterVal,catName,pCatId)
{
	// POST DATA	
	if(window.confirm('Are you sure, Do you want to delete this ?'))
	{
		jQuery.post("save_bookmark_action.php", {favweb_id: favweb_id,action: action,catName:catName}, function(data){
			getFavWebsiteData(catId,uid,catName,pCatId);
		},{dataType: 'json'});
	}
}

/***************************** Function for Bookmark End ****************************************/




var updateOrderPname='';

function SortOrderSetUpMyTop10(catId)
{
	//jQuery("#divcheck").html('10');
	jQuery("#main1 ul").sortable({handle : '.handle',opacity: 0.6, cursor: 'move', update: function() {
			var order = $(this).sortable("serialize") + '&action=updateRecordsListings&catId='+catId;
			
			jQuery.post(updateOrderPname, order, function(theResponse){
				jQuery("#contentRight").html(theResponse);
				
				if(theResponse=='1')
				{
					ShowAddNewsFeedDiv();
				}
			});
		},
			containment : $("#main1"),
			stop: function(event, ui) {
				//jQuery("#divcheck").html('11');
				SetLiOrder("itemList","rec_[]=");
			}
		});	
	//jQuery("#divcheck").html('12');
}

function CreateNewsFeedForSetOrder(catId)
{
	showLoadingModal();
	jQuery.post("save_mychoices_action.php", {catId:catId,action: "newsfeedforsetorder"}, function(data){
		alert('Your feed has been successfully created');
		hideLoadingModel();
	});
}
var hidefeeddivtime;
function ShowAddNewsFeedDiv()
{
	jQuery("#divnewsfeedaction").show("slow");
	hidefeeddivtime=setTimeout("HideAddNewsFeedDiv()",15000);
}

function HideAddNewsFeedDiv()
{
	jQuery("#divnewsfeedaction").hide("slow");
	clearTimeout(hidefeeddivtime);
}


function SearchDesFromWiki(counter)
{
	var topic=jQuery("#title"+counter).val();
	
	if(topic!='')
	{
		showLoadingModal();
		jQuery.post("wiki.php", {topic:topic}, function(data){																
			jQuery("#description"+counter).val(data)
			hideLoadingModel();
		});
	}
}

function ShowHeaderImgDiv()
{
	/*if(jQuery("#divsearchuserimg").html()=='')
	{
		jQuery("#divmainimg").attr("style","display:block");
		jQuery("#divmainimg").show("slow");
	}
	else
	{
		jQuery("#divsearchuserimg").attr("style","display:block");
		jQuery("#divsearchuserimg").show("slow");
	}*/
	//jQuery("#imgheader").attr("style","display:block");
	jQuery("#imgheader").show("slow");
	jQuery("#divheader").attr("style","min-height:285px");
	document.getElementById("ancheaderimghide").style.display="block";
	document.getElementById("ancheaderimgshow").style.display="none";
}

function HideHeaderImgDiv()
{
	/*if(jQuery("#divsearchuserimg").html()=='')
	{
		jQuery("#divmainimg").hide("slow");
		//jQuery("#divmainimg").attr("style","display:none");		
	}
	else
	{
		jQuery("#divsearchuserimg").hide("slow");
		//jQuery("#divsearchuserimg").attr("style","display:none");
	}*/
	//jQuery("#imgheader").attr("style","display:none");
	jQuery("#imgheader").hide("slow");
	jQuery("#divheader").attr("style","min-height:100px");
	document.getElementById("ancheaderimghide").style.display="none";
	document.getElementById("ancheaderimgshow").style.display="block";
}

function SetLiOrder(ulId,replaceVal)
{
	var sno=1;
		jQuery("#"+ulId+" li").each(function(){
		if($(this).attr("itemID")){
			var numberId=$(this).attr("itemID").replace(replaceVal,"");
			jQuery("#number_"+numberId).html(sno);
			sno++;
		}
	});
}

var popuptimer;
var hidePopUpBox=true;
function showBoxText(textObj, obj,abc) {
	$(obj).find(".popBox").css("display","block");
}


function OpenFavWebSite(favurl,favid)
{
	var windowId="favwebsite"+favid;
	window.open(favurl,windowId,"status=1,toolbar=1,location=1,menubar=1,resizable=1,scrollbars=1,width=1000,height=600,directories=1");
}


function hideBoxText() {	
	jQuery(".popBox").css("display","none");
}

function deleteMyMsg(inoutnum)
{
	var totalVal=document.getElementById("totalmsg").value;
	var delMsgId='';
	for (i=0;i<=totalVal;i++)
	{
		var chkbx = "chkmsg" + i; 
		if (document.getElementById(chkbx))
		{
			if (document.getElementById(chkbx).checked == true)
			{
				delMsgId+=document.getElementById(chkbx).value+',';
			}
		}
	}
	
	if(delMsgId!='')
		delMsgId=delMsgId.substr(0,delMsgId.length-1);		
	
	if(delMsgId=='')
	{
		alert('Please select message for delete');
		return false;
	}
	else if(window.confirm('Are you sure, Do you want to delete this ?'))
	{
		
		jQuery.post("mymessage_action.php", {inoutnum:inoutnum,action: 'deletemsg',delMsgId: delMsgId}, function(response){
			getInOutMsg(inoutnum);	
		});
	}	
}

function getReceiverId()
{
	var receiverId=document.getElementById("ddlfriendslist").value;
	document.getElementById("hidrecid").value=receiverId;
}

function getLogoMemoData()
{
	jQuery("#logomemoForm").bind("submit", function() {

		jQuery.ajax({
			type		: "POST",
			cache	: false,
			url		: BASE_URL+"mylogomemo_action.php",
			data		: jQuery(this).serializeArray(),
			dataType : 'json',
			success: function(data) {	
				jQuery('#comment_error_message').html(data.msg);
			}
		});
	
		return false;
	  });	
}

function showChatOptions(divobj)
{
	$(divobj).find(".chatoptions").css("display","block");
}

function hideChatOptions() {	
	jQuery(".chatoptions").css("display","none");
}


function showDivSpecFriendList(optVal,optCounter)
{
	if(optVal==4)
	{
		jQuery("#divspecfriendlist_"+optCounter).css("display","block");
		jQuery("#btnguestlist_"+optCounter).attr("src","images/btn_guest_list-over.png");
		jQuery("#btnguestlist_"+optCounter).mouseout(function ()
		{
			jQuery("#btnguestlist_"+optCounter).attr("src","images/btn_guest_list-over.png");
		});
	}
	else
	{
		jQuery("#divspecfriendlist_"+optCounter).css("display","none");
		jQuery("#btnguestlist_"+optCounter).attr("src","images/btn_guest_list.png");
		jQuery("#btnguestlist_"+optCounter).mouseout(function ()
		{
			jQuery("#btnguestlist_"+optCounter).attr("src","images/btn_guest_list.png");
		});
	}
}

/***************************** Funciton for Shared Category Start *************************************/

function ShowFriendsListDivForShareMyCategory(divcounter)
{
	jQuery(".divsharemaincategory").attr('style','display:none');
	jQuery(".classbtnsendcategory").attr("src","images/btn_share.png");
	jQuery(".classbtnsendcategory").mouseout(function ()
	{
		if(jQuery(".classbtnsendcategory").attr("id")!=jQuery("#btnsendcategory_"+divcounter)){
			jQuery(this).attr("src","images/btn_share.png");
		}
	});
	
	jQuery("#divsharecategorylist_"+divcounter).attr('style','display:block');
	jQuery("#divshcategorylist_"+divcounter).attr('style','display:block');
	jQuery('#lblsharedcategorymsg_'+divcounter).html('');
	document.getElementById("divsharecategorylist_"+divcounter).style.display='';
	
	jQuery("#btnsendcategory_"+divcounter).attr("src","images/btn_share-over.png");
	jQuery("#btnsendcategory_"+divcounter).mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share-over.png");
	});
}


function ShowFriendsListForShareMyCategory(optVal,optCounter)
{
	if(optVal==4)
	{
		jQuery("#divsharecategoryopt_"+optCounter).css("display","block");
		jQuery("#btnshcategoryguestlist_"+optCounter).attr("src","images/btn_guest_list-over.png");
		jQuery("#btnshcategoryguestlist_"+optCounter).mouseout(function ()
		{
			jQuery("#btnshcategoryguestlist_"+optCounter).attr("src","images/btn_guest_list-over.png");
		});
	}
	else
	{
		jQuery("#divsharecategoryopt_"+optCounter).css("display","none");
		jQuery("#btnshcategoryguestlist_"+optCounter).attr("src","images/btn_guest_list.png");
		jQuery("#btnshcategoryguestlist_"+optCounter).mouseout(function ()
		{
			jQuery("#btnshcategoryguestlist_"+optCounter).attr("src","images/btn_guest_list.png");
		});
	}
}


function CancelShareMyCategory()
{
	jQuery(".divsharemaincategory").attr('style','display:none');
	
	jQuery(".classbtnsendcategory").attr("src","images/btn_share.png");
	jQuery(".classbtnsendcategory").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share.png");
	});
}

function ShareMyCategoryToFriend(frmname,cat_id,ddlcounter)
{
	showLoadingModal();
	var order = jQuery("#"+frmname+ddlcounter).serialize() + '&action=sharemycategory&cat_id='+cat_id+'&counter='+ddlcounter;

	jQuery.post("save_shared_category.php", order, function(data){		
															alert(data.msg);
		jQuery("#divshcategorylist_"+ddlcounter).attr('style','display:none');
		jQuery('#lblsharedcategorymsg_'+ddlcounter).html(data.msg);
		jQuery('#lblsharedcategoryerrmsg_'+ddlcounter).html(data.errmsg);
		
		if(data.shchoicetyype==3)
		{
			jQuery("input[name='chkfrndshcategory_"+ddlcounter+"[]']").each(function() {
				if($(this).val())
				{
					$(this).attr('checked',false);
				}
			});
		}
		else if(data.shchoicetyype==4)
		{
			jQuery("input[name='chkfrndshcategory_"+ddlcounter+"[]']:checked").each(function() {
				if($(this).val())
				{
					$(this).attr('checked',false);
				}
			});
		}
		hideLoadingModel();
	},'json');
}


function ShowFriendsListForShareCategory(catId,ddlcounter)
{
	jQuery(".divsharemain").attr('style','display:none');
	jQuery(".classbtnsendchoice").attr("src","images/btn_share.png");
	jQuery(".classbtnsendchoice").mouseout(function ()
	{
		if(jQuery(".classbtnsendchoice").attr("id")!=jQuery("#btnsendchoice_"+ddlcounter)){
			jQuery(this).attr("src","images/btn_share.png");
		}
	});
	
	jQuery("#divsharelist_"+catId).attr('style','display:block');
	jQuery("#divshchoicelist_"+ddlcounter).attr('style','display:block');
	jQuery('#lblsharedmsg_'+ddlcounter).html('');
	document.getElementById("divsharelist_"+catId).style.display='';
	
	jQuery("#btnsendchoice_"+ddlcounter).attr("src","images/btn_share-over.png");
	jQuery("#btnsendchoice_"+ddlcounter).mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share-over.png");
	});
}

function showDivShCategoryFriendList(optVal,optCounter)
{
	if(optVal==4)
	{
		jQuery("#divshareopt_"+optCounter).css("display","block");
		jQuery("#btnshchoicesguestlist_"+optCounter).attr("src","images/btn_guest_list-over.png");
		jQuery("#btnshchoicesguestlist_"+optCounter).mouseout(function ()
		{
			jQuery("#btnshchoicesguestlist_"+optCounter).attr("src","images/btn_guest_list-over.png");
		});
	}
	else
	{
		jQuery("#divshareopt_"+optCounter).css("display","none");
		jQuery("#btnshchoicesguestlist_"+optCounter).attr("src","images/btn_guest_list.png");
		jQuery("#btnshchoicesguestlist_"+optCounter).mouseout(function ()
		{
			jQuery("#btnshchoicesguestlist_"+optCounter).attr("src","images/btn_guest_list.png");
		});
	}
}


function CancelSharedCategory()
{
	jQuery(".divsharemain").attr('style','display:none');
	
	jQuery(".classbtnsendchoice").attr("src","images/btn_share.png");
	jQuery(".classbtnsendchoice").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share.png");
	});
}

function SendCategoryForShareToFriend(userId,cat_id,ddlcounter)
{
	showLoadingModal();
	var order = jQuery("#setup_category_from"+ddlcounter).serialize() + '&action=share&cat_id='+cat_id+'&userId='+userId+'&counter='+ddlcounter;

	jQuery.post("save_shared_category.php", order, function(data){			
		jQuery("#divshchoicelist_"+ddlcounter).attr('style','display:none');
		jQuery('#lblsharedmsg_'+ddlcounter).html(data.msg);
		jQuery('#lblsharederrmsg_'+ddlcounter).html(data.errmsg);
		
		if(data.shchoicetyype==3)
		{
			jQuery("input[name='chkfrndshchoices_"+ddlcounter+"[]']").each(function() {
				if($(this).val())
				{
					$(this).attr('checked',false);
				}
			});
		}
		else if(data.shchoicetyype==4)
		{
			jQuery("input[name='chkfrndshchoices_"+ddlcounter+"[]']:checked").each(function() {
				if($(this).val())
				{
					$(this).attr('checked',false);
				}
			});
		}
		hideLoadingModel();
	},'json');
}

function getUserSharedCategory(tabType)
{
	showLoadingModal();

	jQuery('.drop-shadow img').removeClass('divcatgray');
	jQuery('#ShCategoryImg').attr('class', 'divcatgray');
		
	jQuery.post("list_shared_category.php", {tabType:tabType}, function(response){
		jQuery('#top10_choiceof_users').html(response);
		
		hideLoadingModel();
	});	
}

function RejectSharedCategory(tabType,shchoiceid)
{
	if(window.confirm(('Are you sure, Do you want to cancel this Category?')))
	{
		showLoadingModal();
		jQuery.post("save_shared_category.php", {shchoiceid: shchoiceid,action:'reject'}, function(response){
			getTop10Categories(tabType,'','','','','','',true);
			alert('You have successfully canceled Category.');
		});
	}
}

function AcceptSharedCategoryAsMainCategory(tabType,shchoiceid,suggCatId,friendId)
{
	jQuery(".divsugcat").attr("style",'display:none;');
		
	if(window.confirm('Are you sure, Do you want to add this Category?'))
	{
		showLoadingModal();	
	
		var chkfeed=0;
		if(jQuery('input:checkbox[id=notfeed'+suggCatId+']:checked').val())
			chkfeed=1;
		
		jQuery.post("save_shared_category.php", {action: 'accept',shchoiceid:shchoiceid, suggCatId: suggCatId,friendId:friendId,chkfeed:chkfeed}, function(data){
			alert(data.msg);
			getTop10Categories(tabType,'','','','','','',true);
		},'json');
	}
}

function AcceptSharedCategoryAsSubCategory(tabType,shchoiceid,suggCatId,friendId)
{
	var pcatId=jQuery("#ddlcategorylist_"+suggCatId).val();
	if(pcatId==0 || pcatId=='')
	{
		alert('Please select category.')
	}
	else if(window.confirm('Are you sure, Do you want to add this Category?'))
	{
		showLoadingModal();	
		
		var chkfeed=0;
		if(jQuery('input:checkbox[id=notfeed'+suggCatId+']:checked').val())
			chkfeed=1;
			
		jQuery.post("save_shared_category.php", {action: 'accept',shchoiceid:shchoiceid, suggCatId: suggCatId,pCatId:pcatId,friendId:friendId,chkfeed:chkfeed}, function(data){
			alert(data.msg);
			getTop10Categories(tabType,'','','','','','',true);
		},'json');
	}
}

/***************************** Funciton for Shared Category End *************************************/


/***************************** Funciton for Shared Choices start *************************************/

function getUserSharedChoices(tabType)
{
	showLoadingModal();

	jQuery('.drop-shadow img').removeClass('divcatgray');
	jQuery('#ShChoicesImg').attr('class', 'divcatgray');
		
	jQuery.post("list_shared_choices.php", {tabType:tabType}, function(response){
		jQuery('#top10_choiceof_users').html(response);	
		hideLoadingModel();
	});	
}

function ShowCategoryForSharedChoices(divnum)
{
	jQuery(".divshare").attr("style",'display:none;');
	jQuery("#divsharelist_"+divnum).attr("style",'display:block;');
}

function AcceptSharedChoice(tabType,countersh,userId,shchoiceid,list_id,friendId)
{
	var catId=document.getElementById("ddlcategorylist"+countersh).value;
	
	if(catId!='' && catId!='0')
	{
		if(window.confirm(('Are you sure, Do you want to accept this choice?')))
		{
			showLoadingModal();	
			
			var chkfeed=0;
			if(jQuery('input:checkbox[id=notfeed'+countersh+']:checked').val())
				chkfeed=1;
				
			jQuery.post("save_shared_choice.php", {userId:userId,shchoiceid: shchoiceid,list_id:list_id,friendId:friendId,catId:catId,chkfeed:chkfeed,action:'accept'}, function(response){
				
				getTop10Categories(tabType,'','','','','','',false,true);
	
				alert('You have successfully accepted choice.');
			});			
		}
	}
	else
	{
		alert('Please select category');	
	}
}

function RejectSharedChoice(tabType,shchoiceid)
{
	if(window.confirm(('Are you sure, Do you want to cancel this choice?')))
	{
		showLoadingModal();
		jQuery.post("save_shared_choice.php", {shchoiceid: shchoiceid,action:'reject'}, function(response){
			getTop10Categories(tabType,'','','','','','',false,true);
			alert('You have successfully canceled choice.');
		});
	}
}

/**************************************** Funciton for Shared Choices end ************************************************/

/***************************** Funciton for Shared Bookmark Start *************************************/

function ShowFriendsListForShareBookmark(bookmarkId,ddlcounter)
{
	jQuery(".divsharemain").attr('style','display:none');
	jQuery(".classbtnsendchoice").attr("src","images/btn_share.png");
	jQuery(".classbtnsendchoice").mouseout(function ()
	{
		if(jQuery(".classbtnsendchoice").attr("id")!=jQuery("#btnsendchoice_"+ddlcounter)){
			jQuery(this).attr("src","images/btn_share.png");
		}
	});
	
	jQuery("#divsharelist_"+bookmarkId).attr('style','display:block');
	jQuery("#divshchoicelist_"+ddlcounter).attr('style','display:block');
	jQuery('#lblsharedmsg_'+ddlcounter).html('');
	document.getElementById("divsharelist_"+bookmarkId).style.display='';
	
	jQuery("#btnsendchoice_"+ddlcounter).attr("src","images/btn_share-over.png");
	jQuery("#btnsendchoice_"+ddlcounter).mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share-over.png");
	});
}

function showDivShBookmarkFriendList(optVal,optCounter)
{
	if(optVal==4)
	{
		jQuery("#divshareopt_"+optCounter).css("display","block");
		jQuery("#btnshchoicesguestlist_"+optCounter).attr("src","images/btn_guest_list-over.png");
		jQuery("#btnshchoicesguestlist_"+optCounter).mouseout(function ()
		{
			jQuery("#btnshchoicesguestlist_"+optCounter).attr("src","images/btn_guest_list-over.png");
		});
	}
	else
	{
		jQuery("#divshareopt_"+optCounter).css("display","none");
		jQuery("#btnshchoicesguestlist_"+optCounter).attr("src","images/btn_guest_list.png");
		jQuery("#btnshchoicesguestlist_"+optCounter).mouseout(function ()
		{
			jQuery("#btnshchoicesguestlist_"+optCounter).attr("src","images/btn_guest_list.png");
		});
	}
}


function CancelSharedBookmark()
{
	jQuery(".divsharemain").attr('style','display:none');
	
	jQuery(".classbtnsendchoice").attr("src","images/btn_share.png");
	jQuery(".classbtnsendchoice").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share.png");
	});
}

function SendBookmarkForShareToFriend(userId,bookmark_id,ddlcounter)
{
	showLoadingModal();
	var order = jQuery("#settop10_myfavwebfrom"+ddlcounter).serialize() + '&action=share&bookmark_id='+bookmark_id+'&userId='+userId+'&counter='+ddlcounter;

	jQuery.post("save_shared_bookmark.php", order, function(data){			
		jQuery("#divshchoicelist_"+ddlcounter).attr('style','display:none');
		jQuery('#lblsharedmsg_'+ddlcounter).html(data.msg);
		jQuery('#lblsharederrmsg_'+ddlcounter).html(data.errmsg);
		
		if(data.shchoicetyype==3)
		{
			jQuery("input[name='chkfrndshchoices_"+ddlcounter+"[]']").each(function() {
				if($(this).val())
				{
					$(this).attr('checked',false);
				}
			});
		}
		else if(data.shchoicetyype==4)
		{
			jQuery("input[name='chkfrndshchoices_"+ddlcounter+"[]']:checked").each(function() {
				if($(this).val())
				{
					$(this).attr('checked',false);
				}
			});
		}
		hideLoadingModel();
	},'json');
}

function getUserSharedBookmark(tabType)
{
	showLoadingModal();

	jQuery('.drop-shadow img').removeClass('divcatgray');
	jQuery('#ShBookmarkImg').attr('class', 'divcatgray');
		
	jQuery.post("list_shared_bookmark.php", {tabType:tabType}, function(response){
		jQuery('#top10_choiceof_users').html(response);
		
		hideLoadingModel();
	});	
}

function ShowCategoryForSharedBookmark(divnum)
{
	jQuery(".divshare").attr("style",'display:none;');
	jQuery("#divsharelist_"+divnum).attr("style",'display:block;');
}

function RejectSharedBookmark(tabType,shbookmarkid)
{
	if(window.confirm(('Are you sure, Do you want to cancel this Bookmark?')))
	{
		showLoadingModal();
		jQuery.post("save_shared_bookmark.php", {shbookmarkid: shbookmarkid,action:'reject'}, function(response){
			getTop10Categories(tabType,'','','','','','',false,false,true);
			alert('You have successfully canceled Bookmark.');
		});
	}
}

function AcceptSharedBookmark(tabType,countersh,userId,shbookmarkid,bookmark_id,friendId)
{
	var catId=document.getElementById("ddlcategorylist"+countersh).value;

	if(catId!='' && catId!='0')
	{
		if(window.confirm(('Are you sure, Do you want to accept this Bookmark?')))
		{
			showLoadingModal();			
			jQuery.post("save_shared_bookmark.php", {userId:userId,shbookmarkid: shbookmarkid,bookmark_id:bookmark_id,friendId:friendId,catId:catId,action:'accept'}, function(response){
				
				getTop10Categories(tabType,'','','','','','',false,false,true);
	
				alert('You have successfully accepted Bookmark.');
			});			
		}
	}
	else
	{
		alert('Please select category');	
	}
}

/***************************** Funciton for Shared Bookmark End *************************************/






/************************ Funciton for My Category Management start ***************************************/

function CreateNewSubCategory()
{
	jQuery('.drop-shadow img').removeClass('divcatgray');
	jQuery('#subcatImg').attr('class', 'divcatgray');
	document.location.href="#addnew_category";
}

function getMyDeletedCategory(pCatId)
{
	showLoadingModal();
	jQuery("#ancaddnewup").attr("style","display:none;");
	jQuery("#ancaddnewdown").attr("style","display:none;");
	jQuery(".divsortby").attr("style","display:none;");
	
	jQuery("#mydeletedcategory").attr("src","images/delete_active.png");
	
	jQuery(".divsetupmytop a").removeClass('anctagactiveund');
	jQuery('#ancmydeletedcategory').attr('class', 'anctagactiveund');	
	
	// POST DATA	
	jQuery.post("list_mycategory_deleted.php", {pCatId:pCatId}, function(response){
		jQuery('#categoryList').html(response);	
		
		if(pCatId=='' || pCatId=='0')
			jQuery("#divtitleh6").html('Setup My Deleted Category');
		else
			jQuery("#divtitleh6").html('Setup My Sub Deleted Category');

		hideLoadingModel();
	});	
}

function AddEditMyCategory(formName,valGroup)
{
	if(eval(getFormElement(formName,valGroup)))
	{
		var addupdate = true;
		if(valGroup == 'editcategory')
		{
			if(!window.confirm('Are you sure, Do you want to update this Category?'))
			{	
				addupdate = false;
			}
		}
		
		if(addupdate)
		{
			formName.submit();
		}
	}
}


function AddEditMyCategory1(obj,action)
{
	var addupdate = true;
	if(action == 'update')
	{
		if(!window.confirm('Are you sure, Do you want to update this Category?'))
		{	
			addupdate = false;
		}
	}
	
	if(addupdate)
	{		
		var form_name = obj;
		   jQuery("#"+form_name).validate({
			  rules: {
				title: {
				  required: true
				}
			},
			  messages: {
				title: {
				  required: "Title / Name / Product / Brand etc..  required"
				}		
			  },
			  submitHandler: function(form) {
				form.submit();
			 }
		  });
	}
	else
		return false;
		
		
	
}

function SoftDeleteMyCategory(obj,id,pCatId)
{
	if(window.confirm('Are you sure, Do you want to delete this category?'))
	{
		var form_name = obj;

		jQuery.post("save_mycategory_action.php", {action: 'softdelete',category_id: id,pCatId:pCatId}, function(data){
			getTop10Categories('setup_my_category','','','',pCatId);
			alert(data.msg); 
		},'json');
	}
	else
		return false;
}

function RestoreMyCategory(obj,id,pCatId,counter)
{
	if(window.confirm('Are you sure, Do you want to restore this category?'))
	{
		var form_name = obj;
		var restchoices=0;
		var restsubcat=0;
		var restsubcatchoices=0;
		
		if(jQuery("#chkallchoices"+counter).attr('checked'))
			restchoices=1;
		if(jQuery("#chkallsubcat"+counter).attr('checked'))
			restsubcat=1;
		if(jQuery("#chkallsubcatchoices"+counter).attr('checked'))
			restsubcatchoices=1;
			
		jQuery.post("save_mycategory_action.php", {action: 'restore',category_id: id,pCatId:pCatId,restchoices:restchoices,restsubcat:restsubcat,restsubcatchoices:restsubcatchoices}, function(data){
			getTop10Categories('setup_my_category','','','',pCatId);
			alert(data.msg); 
		},'json');
		
	}
	
	return false;
}

function ShowRestoreList(divcounter)
{
	jQuery("#divrestorelist_"+divcounter).attr("style","display:block");
}

function CancelRestore(divcounter)
{
	jQuery("#divrestorelist_"+divcounter).attr("style","display:none");
}

function SetSubCatSelected(counter)
{
	if(jQuery("#chkallsubcatchoices"+counter).attr('checked'))
	{
		jQuery("#chkallsubcat"+counter).attr('checked','checked');
	}
}

function ResetSubCatChoicesSelected(counter)
{
	if(!jQuery("#chkallsubcat"+counter).attr('checked'))
	{
		jQuery("#chkallsubcatchoices"+counter).removeAttr('checked');
	}
}

function PermanentDeleteMyCategory(obj,id,pCatId)
{
	if(window.confirm('Are you sure, Do you want to permanent delete this category?'))
	{
		var form_name = obj;

		jQuery.post("save_mycategory_action.php", {action: 'permanentdelete',category_id: id}, function(data){
			getMyDeletedCategory(pCatId);
			alert(data.msg); 
		},'json');
	}
	
	return false;
}

/************************ Funciton for My Category Management end *********************************************/

/************************ Funciton for My Category Choices Management start ***************************************/

function getMyDeletedCategoryChoices(catId,catName,pCatId)
{
	showLoadingModal();
	
	jQuery(".divsortby a").removeClass('anctagactiveund');
	jQuery('#ancmydelchoices').attr('class', 'anctagactiveund');
	
	// POST DATA	
	jQuery.post("list_mychoices_deleted.php", {category: catId,catName:catName,pCatId:pCatId}, function(response){
		jQuery('#itemList').html(response);	
		
		jQuery("#divtitleh6").html('Setup My Top 10 &quot;'+catName+' &quot;');
		jQuery("#imgancnewup").attr('style','display:none');
		jQuery("#imgancnewdown").attr('style','display:none');
		jQuery("#mydeletedchoices").attr("src","images/delete_active.png");
		ExpandCollapseSetupMyTop10();
		
		hideLoadingModel();
	});	
}

function AddEditMyCategoryChoices(obj,action)
{
	var addupdate = true;
	if(action == 'update')
	{
		if(!window.confirm('Are you sure, Do you want to update this choice?'))
		{	
			addupdate = false;
		}
	}
	
	if(addupdate)
	{
		var form_name = obj;
	
	jQuery(document).ready(function() {
	  jQuery("#"+form_name).validate({
		  rules: {
			title: {
			  required: true
			}
			/*,description: {
			  required: true
			},
			comment: {
			  required: true
			}*/
		},
		  messages: {
			title: {
			  required: "Title / Name / Product / Brand etc..  required"
			}
			
			/*,description: {
			  required: "Your description required"
			},
			comment: {
			  required: "Your comments required"
			}*/
		  },
		  submitHandler: function(form) {
			
			form.submit();
			
		 }
	  });
	
	});
  }
  else
  	return false;
}

function DeleteMyChoices(tabType,listId,userId,catId,orderType,pagenum,pCatId)
{
	if(window.confirm('Are you sure, Do you want to delete this choice?'))
	{
		jQuery.post("save_mychoices_action.php", {action: 'softdelete',category_id: catId,list_id:listId}, function(data){
			getTop10CategoriesChoices(puserId,catId,orderType,pagenum,'',pCatId,0,'','');
			//getTop10Categories(tabType,userId,catId,orderType,pCatId);
			alert(data.msg);
		},'json');
	}
}

function SoftDeleteMyCategoryChoices(obj,catId,listId,pCatId)
{
	if(window.confirm('Are you sure, Do you want to delete this choice?'))
	{
		var form_name = obj;

		jQuery.post("save_mychoices_action.php", {action: 'softdelete',category_id: catId,list_id:listId}, function(data){
			getTop10Categories('setup_mytop10','',catId,'',pCatId);
			alert(data.msg);
		},'json');
	}
	else
		return false;
}

function RestoreMyCategoryChoices(obj,catId,listId,pCatId)
{
	if(window.confirm('Are you sure, Do you want to restore this choice?'))
	{
		var form_name = obj;

		jQuery.post("save_mychoices_action.php", {action: 'restore',category_id: catId,list_id:listId}, function(data){
			getTop10Categories('setup_mytop10','',catId,'',pCatId);
			alert(data.msg); 
		},'json');
		
	}
	
	return false;
}

function PermanentDeleteMyCategoryChoices(obj,catId,listId,catName,pCatId)
{
	if(window.confirm('Are you sure, Do you want to permanent delete this choice?'))
	{
		var form_name = obj;

		jQuery.post("save_mychoices_action.php", {action: 'permanentdelete',category_id: catId,list_id:listId}, function(data){
			getMyDeletedCategoryChoices(catId,catName,pCatId);
			alert(data.msg); 
		},'json');
	}
	
	return false;
}

/************************ Funciton for My Category Choices Management end *********************************************/

/************************ Funciton for Friends Request Management strat *********************************************/
function ChangeStyleOfSelectedFriend(puserId)
{
	jQuery('#lifrnd'+puserId).attr('style', 'background:url(images/steel-bg.jpg) repeat-x;');
	jQuery('#lifrnd'+puserId+' p').attr('style', 'color:#000000');
}

function getFriendsList(chkhideloding)
{
	jQuery.post("list_friends.php", {}, function(data){
		jQuery("#divfriendslist").html(data);
		
		puserId=jQuery("#txtuserid").val();
		ChangeStyleOfSelectedFriend(puserId);
			
		if(chkhideloding)
			hideLoadingModel();
	});
}

function AcceptFriendRequest(reqId)
{
	showLoadingModal();			
	jQuery.post("save_frndreq_action.php", {reqId:reqId,action:'accept'}, function(data){		
		getFriendsList(true);
		alert(data.msg);
	},'json');			
}

function RejectFriendRequest(reqId)
{
	if(window.confirm('Are you sure, Do you want to reject this request?'))
	{
		showLoadingModal();
		jQuery.post("save_frndreq_action.php", {reqId: reqId,action:'reject'}, function(data){
			getFriendsList(true);
			alert(data.msg);
		},'json');
	}
}
/************************ Funciton for Friends Request Management End *********************************************/

/************************ Function for Choices Thumbs Up and Ten Start ****************************************************/

function ChoicesThumbUpTen(listUserId,catId,listId,action)
{
	showLoadingModal();
	jQuery.post("save_mychoices_action.php", {action: action,category_id: catId,list_id:listId,listUserId:listUserId}, function(data){
			if(data.msg==1)
			{
				if(action=='thumbsup')
				{
					var totalThumbsUp=jQuery("#lblthumbs_"+listId).html();
					totalThumbsUp++;
					jQuery("#lblthumbs_"+listId).html(totalThumbsUp);
				}
				else if(action=='ten')
				{
					var totalTen=jQuery("#lblten_"+listId).html();
					totalTen++;
					jQuery("#lblten_"+listId).html(totalTen);
					alert('you gave 10 to this choice as a " Best Top 10"!');
				}
			}
			else
			{
				if(action=='thumbsup')
				{
					alert("Your have already thumbsup.");
				}
				else if(action=='ten')
				{
					alert("You have already voted this choice.");
				}			
			}
			
			hideLoadingModel();
		},'json');
}

function ChoicesCommentTen(listId,listUserId)
{
	showLoadingModal();
	jQuery.post("comments_action.php", {action: 'commentten',listid:listId,listUserId:listUserId}, function(data){
			
			if(data.chksave==1)
			{
				var totalTen=jQuery("#lblten_"+data.listid).html();
				totalTen++;
				jQuery("#lblten_"+data.listid).html(totalTen);
			}
			else
				alert(data.msg);
			hideLoadingModel();
		},'json');
}

/************************ Function for Choices Thumbs Up and Ten End ****************************************************/

/************************ Function for Check New Comment And Shared Choice Start *************************************/
var newmessagetimer;

function checkNewMessageCommentAndSharedChoice(userId)
{
	if(userId>0)
	{
		clearTimeout(newmessagetimer);
		
		jQuery.post("checknew_msg_com_shchoice.php", {userId: userId}, function(data){
				
				if(data.newcomments || data.newshchoices || data.newshbookmark)
				{
					jQuery("#mytop10 span").attr("class",'tab_main_red');
					var tabType=jQuery("#hidcurrenttab").val();
					
					if(data.newshchoices && tabType=='mytop10')
					{
						jQuery("#lirecchoices").attr("style",'display:block');
						jQuery("#divshchoicestext").html(data.newshchoicestext);
					}
					else
						jQuery("#lirecchoices").attr("style",'display:none');
						
					if(data.newshbookmark && tabType=='mytop10')
					{
						jQuery("#lirecbookmark").attr("style",'display:block');
						jQuery("#divshbookmarktext").html(data.newshbookmarktext);
					}
					else
						jQuery("#lirecbookmark").attr("style",'display:none');
				}
				else
					jQuery("#mytop10 span").attr("class",'tab_main');
					
				if(data.newshcategory)
				{
					jQuery("#setup_my_category span").attr("class",'tab_main_red');
					var tabType=jQuery("#hidcurrenttab").val();
					
					if(data.newshcategory && (tabType=='mytop10' || tabType=='setup_my_category'))
					{
						jQuery("#lireccat").attr("style",'display:block');
						jQuery("#divshcategorytext").html(data.newshcategorytext);
					}
					else
						jQuery("#lireccat").attr("style",'display:none');
				}
				else
					jQuery("#setup_my_category span").attr("class",'tab_main');
					
				
				if(data.newmsg)
					jQuery("#messagetab").attr("style",'color:#FF0000;font-weight:bold;');
				else
					jQuery("#messagetab").attr("style",'');
				
				getFriendsList(false);
				
			},'json');
		
		newmessagetimer=setTimeout("checkNewMessageCommentAndSharedChoice('"+userId+"')",10000);
	}
}
/************************ Function for Check New Comment And Shared Choice End *************************************/

/********************************** Function for Delete Comments Start ********************************************/
function deleteComments(id)
{

	if(confirm('Are you sure, Do you want to delete this ?'))
	{
		jQuery("#action").val('delete');
		jQuery("#commentid").val(id);
			
		document.commentFormFancybox.submit();
		/*jQuery.post("comments_action.php", {task: 'delete',list_id: list_id,uid: uid,id: id}, function(response){
			jQuery('#ullistcomments').html(response.htmldata);
			
			var commentCount = (jQuery("#hidtotalcount").val());
			jQuery('#lblcommentcounter'+response.listid).html(commentCount);
		},'json');	*/
	}
	
}
/********************************** Function for Delete Comments End ********************************************/

/********************************** Function for Show User Deatils Start ********************************************/
function ShowFriendsDetails(puserId)
{
	if(puserId!='')
	{
		jQuery.post("showuserdata.php", {userId: puserId}, function(response){
			if(response!='')
			{
				jQuery('#divsearchuserimg').html(response);
				jQuery('#divmainimg').attr('style', 'display:none');
				jQuery('#divsearchuserimg').attr('style', 'display:block;height:175px;');			
				
				jQuery.post("list_friends_of_friends.php", {frndId: puserId}, function(data){
					jQuery('#divusersfriendslist').html(data);
					jQuery('#divfrndlist').attr('style', 'display:block;float:left;');
				});
			}
			else
			{
				jQuery('#divsearchuserimg').attr('style', 'display:none');
				
				if(getCookie("hideheaderimg")!=1)
					jQuery('#divmainimg').attr('style', 'display:block');				
			}
		});
	}
	else
		getTop10Categories('top10','');
}
/********************************** Function for Show User Deatils End ********************************************/

/********************************** Function for Chat Status Start ********************************************/
function ShowChatStatusBox()
{
	jQuery("#divchatstatusbox").attr("style","display:block");
}

function HideChatStatusBox()
{
	jQuery("#divchatstatusbox").attr("style","display:none");
}

function ChangeMyChatStatus(chatstatus)
{
	jQuery.post("account_action.php", {action:'changestatus',chatstatus: chatstatus}, function(data){
			jQuery('#chatstatus').html(data.chatstatus);
			jQuery('#chatimg').attr("src","images/chat_"+data.chatstatus.toLowerCase()+".png");
		},'json');
	jQuery("#divchatstatusbox").attr("style","display:none");
}

function BlockUnblockFriend(friendId,friendstatus)
{
	var blocktext="block";
	if(friendstatus==1)
		blocktext="unblock";
		
	if(window.confirm('Are you sure you want to '+blocktext+' this friend ?'))
	{
		showLoadingModal();			
		jQuery.post("save_frndreq_action.php", {action:'blockunblockfrnd',friendId:friendId,friendstatus:friendstatus}, function(data){		
			getFriendsList(true);
			//alert(data.msg);
		},'json');
	}
}


function DeleteFriendFromList(friendId)
{
	if(window.confirm('Are you sure you want to delele this friend ?'))
	{
		showLoadingModal();	

		jQuery.post("save_frndreq_action.php", {action:'deletefrnd',friendId:friendId}, function(data){		

			if(jQuery('#lifrnd'+friendId).css('background-image')!= 'none')
			{
				getTop10Categories('friendstop10','');
			}
			
			getFriendsList(true);
			alert(data.msg);
		},'json');
	}
}
/********************************** Function for Chat Status End ********************************************/

/********************************** Function for Suggested Category Start ********************************************/
function AddSuggestedCategory(suggCatId)
{
	jQuery(".divsugcat").attr("style",'display:none;');
	if(window.confirm('Are you sure, Do you want to add this ?'))
	{
		showLoadingModal();	

		jQuery.post("save_mycategory_action.php", {action: 'savesuggestedcat',suggCatId: suggCatId}, function(data){
			alert(data.msg);
			hideLoadingModel();
		},'json');
	}
}

function ShoMyCategory(suggCatId)
{
	jQuery(".divsugcat").attr("style",'display:none;');
	jQuery("#divsugcat_"+suggCatId).attr("style",'display:block;');	
}

function AddSuggestedCategoryInSubCategory(suggCatId)
{
	var pcatId=jQuery("#ddlcategorylist_"+suggCatId).val();
	if(pcatId==0 || pcatId=='')
	{
		alert('Please select category.')
	}
	else if(window.confirm('Are you sure, Do you want to add this ?'))
	{
		showLoadingModal();	
		
		jQuery.post("save_mycategory_action.php", {action: 'savesuggestedcat',suggCatId: suggCatId,pCatId:pcatId}, function(data){
			alert(data.msg);
			hideLoadingModel();
		},'json');
	}
}
/********************************** Function for Suggested Category End ********************************************/

function SwitchUserAccount()
{
	showLoadingModal();
	
	// POST DATA	
	jQuery.post("switchaccount_action.php", {}, function(data){
		if(data.msg==0)
			ShowLoginPopup();
		else if(data.msg==1)
			jQuery(window.location).attr('href', BASE_URL);
			
		hideLoadingModel();
	},'json');
}

function ShowLoginPopup()
{
	callForAjax('login','Login','login.php',500,300);
}

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

function showFriendsTop10(ddlcounter)
{
	var friendId=document.getElementById("ddlfriendslist"+ddlcounter).value;	
	getFriendsCategoryList('friendstop10',friendId);
}

function getFriendsCategoryList(tabType,userId)
{
	var category = '';
	
	// SELECTED TAB
	jQuery("#user_tab a").removeClass('active');
	jQuery('#'+tabType+'').attr('class', 'active south');
	
	// POST DATA
	showLoadingModal();
	jQuery.post("gettabdata.php", {tabType: tabType, userId: userId}, function(response){
		jQuery('#contentLeft').html(response);

		setULSortable();
		var puserId=jQuery('#txtuserid').val();	
		
		if(tabType=='friendstop10')
		{
			UnSelectAllFriendList();
			
			ChangeStyleOfSelectedFriend(puserId);
		}
		hideLoadingModel();
	});	
}

function showFriendsList(listId,ddlcounter)
{
	jQuery(".divshareaccessmain").attr('style','display:none');
	jQuery(".divshare").attr('style','display:none');
	jQuery(".divalertmain").attr('style','display:none');
	
	jQuery("#divsharelist_"+listId).attr('style','display:block');
	jQuery("#divshareopt_"+ddlcounter).attr('style','display:block');
	document.getElementById("ddlfriendslist"+ddlcounter).value=0;
	jQuery('#lblsharedmsg_'+ddlcounter).html('');
	document.getElementById("divsharelist_"+listId).style.display='';
}

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

function chnageTextOnFocus(txtObj,txtVal)
{
	if(txtObj.value==txtVal)
		txtObj.value='';
}

function setTextOnBlur(txtObj,txtVal)
{
	if(txtObj.value=='')
	txtObj.value=txtVal;
}


/************************************* Function for Country Select in Profile Start ********************************/

function MoveLeftToRight(ddlList,ddlSelList,hidSelList)
{
	var len = document.getElementById(ddlList).length;
	for(i=0;i<len;i++)
	{
		if(document.getElementById(ddlList).options[i].selected)
		{
			var choice = document.getElementById(ddlList).options[i].text;
			var ddlval = document.getElementById(ddlList).options[i].value;
			
			var slen = document.getElementById(ddlSelList).length;
			document.getElementById(ddlSelList).options[slen] = new Option(choice,ddlval,false,false);
			document.getElementById(ddlList).remove(i);
			i--;
			len = document.getElementById(ddlList).length;
		}
	}
	getAllSelectedListData(ddlSelList,hidSelList);
}

function MoveRightToLeft(ddlList,ddlSelList,hidSelList)
{
	var len = document.getElementById(ddlSelList).length;
	for(i=0;i<len;i++)
	{
		if(document.getElementById(ddlSelList).options[i].selected)
		{
			var choice = document.getElementById(ddlSelList).options[i].text;
			var ddlval = document.getElementById(ddlSelList).options[i].value;
			
			var slen = document.getElementById(ddlList).length;
			document.getElementById(ddlList).options[slen] = new Option(choice,ddlval,false,false);
			document.getElementById(ddlSelList).remove(i);
			i--;
			len = document.getElementById(ddlSelList).length;
		}
	}
	getAllSelectedListData(ddlSelList,hidSelList);
}

function MoveAllRight(ddlList,ddlSelList,hidSelList)
{
	var len1 = document.getElementById(ddlList).length;
	for(i=0;i<len1;i++)
	{
		var element = document.getElementById(ddlList).options[i].text;
		var ddlval = document.getElementById(ddlList).options[i].value;
		
		var len2 = document.getElementById(ddlSelList).length;
		document.getElementById(ddlSelList).options[len2] =  new Option(element,ddlval,false,false);
	}
	document.getElementById(ddlList).length= 0;
	
	getAllSelectedListData(ddlSelList,hidSelList);
}

function MoveAllLeft(ddlList,ddlSelList,hidSelList)
{
	var len1 = document.getElementById(ddlSelList).length;
	for(i=0;i<len1;i++)
	{
		var element = document.getElementById(ddlSelList).options[i].text;
		var ddlval = document.getElementById(ddlSelList).options[i].value;
		
		var len2 = document.getElementById(ddlList).length;
		document.getElementById(ddlList).options[len2] =  new Option(element,ddlval,false,false);
	}
	document.getElementById(ddlSelList).length= 0;
	
	getAllSelectedListData(ddlSelList,hidSelList);
}


function getAllSelectedListData(ddlSelList,hidSelList)
{
	var len = document.getElementById(ddlSelList).length;
	var strCountryCode="";
	for(i=0;i<len;i++)
	{
		strCountryCode+=document.getElementById(ddlSelList).options[i].value+",";
	}
	
	if(strCountryCode!="")
		strCountryCode=strCountryCode.substr(0,strCountryCode.length-1);
	
	document.getElementById(hidSelList).value=strCountryCode;
}
/************************************* Function for Country Select in Profile End ********************************/

function getMyFriendSettings(frndId)
{
	showLoadingModal();
	jQuery.post("list_myfrnd_setting.php", {frndId: frndId}, function(response){
		jQuery('#divmyfriendsetting').html(response);
		hideLoadingModel();
	});	
}

function ShowDivOfAssignedFriendList(chkObj)
{
	if(chkObj.checked)
		document.getElementById("divAssignedFrndList").style.display='none';
	else
		document.getElementById("divAssignedFrndList").style.display='block';
}
/*********************************************************************************************************************/




/***************************** Function for News Feed Start ****************************************/

function ShowNewsFeedOption(optNewsfeed)
{
	jQuery("#divpostfeed").attr("style","display:block");
	jQuery("#divfeedfrndlist").addClass("displayhidediv");
	jQuery("#"+optNewsfeed).attr("style","display:block");
}
function HideNewsFeedOption(optNewsfeed)
{
	jQuery("#"+optNewsfeed).attr("style","display:none");
}

function ShowFeedSettings1()
{
	if(jQuery("#divfeedsettings").hasClass('displayhidediv'))
	{
		jQuery("#divfeedsettings").removeClass("displayhidediv");
		jQuery("#divfeedsettings").addClass("displayshowdiv");
	}
	else
	{
		jQuery("#divfeedsettings").removeClass("displayshowdiv");
		jQuery("#divfeedsettings").addClass("displayhidediv");
	}
}

function ShowFeedSettings()
{
	jQuery("#divfeedsettings").attr("style","display:block");
}

function HideFeedSettings()
{
	jQuery("#divfeedsettings").attr("style","display:none");
}

function ShowFeedSettingsOption(obj,divObjId,removeFeed)
{
	if(removeFeed)
	{
		jQuery("#chkchoosecat").removeAttr("checked");
		jQuery("#chkchooseimg").removeAttr("checked");
		jQuery("#chkchoosesettings").removeAttr("checked");
		
		jQuery("#newsfeedcategory").removeClass("displayshowdiv");
		jQuery("#newsfeedcategory").addClass("displayhidediv");
		
		jQuery("#newsfeedupdimg").removeClass("displayshowdiv");
		jQuery("#newsfeedupdimg").addClass("displayhidediv");
		
		jQuery("#newsfeedsetting").removeClass("displayshowdiv");
		jQuery("#newsfeedsetting").addClass("displayhidediv");
		
		jQuery("#divfeedpostdata").removeClass("displayshowdiv");
		jQuery("#divfeedpostdata").addClass("displayhidediv");
		
		jQuery("#divfeedfrndlist").removeClass("displayhidediv");
		jQuery("#divfeedfrndlist").addClass("displayshowdiv");
	}
	else
	{
		jQuery("#chkchooseremovefeed").removeAttr("checked");
		jQuery("#divfeedpostdata").removeClass("displayhidediv");
		jQuery("#divfeedpostdata").addClass("displayshowdiv");
		
		jQuery("#divfeedfrndlist").removeClass("displayshowdiv");
		jQuery("#divfeedfrndlist").addClass("displayhidediv");
	}
	
	if(obj.checked)
	{
		jQuery("#"+divObjId).removeClass("displayhidediv");
		jQuery("#"+divObjId).addClass("displayshowdiv");
	}
	else
	{
		jQuery("#"+divObjId).removeClass("displayshowdiv");
		jQuery("#"+divObjId).addClass("displayhidediv");
	}
}

function ShowFriendListOption()
{
	if(jQuery("#divfeedfrndlist").hasClass('displayhidediv'))
	{
		jQuery("#divfeedfrndlist").removeClass("displayhidediv");
		jQuery("#divfeedfrndlist").addClass("displayshowdiv");
		//jQuery("#divpostfeed").attr("style","display:none");
	}
	else
	{
		jQuery("#divfeedfrndlist").removeClass("displayshowdiv");
		jQuery("#divfeedfrndlist").addClass("displayhidediv");
		//jQuery("#divpostfeed").attr("style","display:block");
	}
}

function ShowFeedDeleteDiv(optNewsfeed)
{
	jQuery("#ancfeeddelete_"+optNewsfeed).attr("style","display:block;");
}
function HideFeedDeleteDiv(optNewsfeed)
{
	jQuery("#ancfeeddelete_"+optNewsfeed).attr("style","display:none");
}

function ShowFeedCommentDeleteDiv(optNewsfeed)
{
	jQuery("#anccommentdelete_"+optNewsfeed).attr("style","display:block;");
}
function HideFeedCommentDeleteDiv(optNewsfeed)
{
	jQuery("#anccommentdelete_"+optNewsfeed).attr("style","display:none");
}


function showEmbededCode(counter)
{
	if(document.getElementById("rdbembededcode"+counter).checked)
	{
		document.getElementById("txtembededcode"+counter).style.display='';
		document.getElementById("file_"+counter).style.display='none';
	}
	else
	{
		document.getElementById("txtembededcode"+counter).style.display='none';
		document.getElementById("file_"+counter).style.display='';
	}
}

function AddEditMyNewsFeed(obj)
{
	var form_name = obj;
   jQuery("#"+form_name).validate({
      rules: {
		title: {
          required: true
        }
	},
      messages: {
        title: {
          required: "Title required"
        }		
	  },
	  submitHandler: function(form) {
		form.submit();
	 }
  });
}

function DeleteFeed(feedId,puserId,catId,orderType,pagenum,pCatId)
{
	if(window.confirm('Are you sure, Do you want to delete this feed ?'))
	{
		jQuery.post("save_feed_action.php", {feedId:feedId,action:"deletefeed"}, function(response){
			getTop10CategoriesChoices(puserId,catId,orderType,pagenum,'',pCatId,0,'','')
			alert(response.msg);
		},'json');
	}
}

function FocusFeedComment(counter)
{
	jQuery("#txtfeedcomment_"+counter).focus();
}

function SubmitFeedComment(feedId,counter)
{
	var commentText=jQuery("#txtfeedcomment_"+counter).val();
	
	jQuery.post("save_feedcomment_action.php", {feedId:feedId,commentText:commentText,action:"postcomment"}, function(response){
		jQuery("#txtfeedcomment_"+counter).val('');
		jQuery("#divfeedcommentmain_"+counter).html(jQuery("#divfeedcommentmain_"+counter).html()+response);
	});
}

function UsersAllFeedRemove(frndId,userId,catId,pCatId)
{
	if(window.confirm("Are you sure, Do you want to remove All Feed of this user ?"))
	{
		showLoadingModal();	
		jQuery.post("save_feed_action.php", {action: 'removeallfeed',frndId:frndId}, function(response){
			getTop10Categories('newsfeed',userId,catId,'',pCatId,'');
			
			alert(response.msg);
		},'json');
	}
}

function UsersFeedRemove(feedId,puserId,catId,orderType,pagenum,pCatId)
{
	if(window.confirm("Are you sure, Do you want to remove this Feed?"))
	{
		showLoadingModal();	
		jQuery.post("save_feed_action.php", {action: 'removefeed',feedId:feedId}, function(response){
			getTop10CategoriesChoices(puserId,catId,orderType,pagenum,'',pCatId,0,'','')
			alert(response.msg);
		},'json');
	}	
}

function DeleteFeedComment(feedId,commentId,counter)
{
	if(window.confirm('Are you sure, Do you want to delete this comment ?'))
	{
		jQuery.post("save_feedcomment_action.php", {feedId:feedId,commentId:commentId,action:"deletecomment"}, function(response){
			jQuery("#divfeedcommenttext_"+commentId).remove();
			//alert(response.msg);
		},'json');
	}
}

function KeyOnFeedComment(obj,e,feedId,counter)
{
	//alert(e.keyCode);
	var key;
	var isCtrl = false;
	var keychar;
	var reg;		

	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 13 && e.shiftKey!=1)
	{
		SubmitFeedComment(feedId,counter);
		return false;
	}
	else
		return true;
}

function FeedThumbsUp(feedUserId,feedId)
{
	showLoadingModal();
	jQuery.post("save_feed_action.php", {action: 'thumbsup',feedId:feedId,feedUserId:feedUserId}, function(data){
			if(data.msg==1)
			{
				var totalThumbsUp=jQuery("#lblfeedthumbs_"+feedId).html();
				totalThumbsUp++;
				jQuery("#lblfeedthumbs_"+feedId).html(totalThumbsUp);				
			}
			else
			{
				alert("Your have already thumbsup.");
			}
			
			hideLoadingModel();
		},'json');
}
/***************************** Function for News Feed End ****************************************/

/***************************** Function for Web Images Start *************************************/
var imgArr= new Array();
var imgSrcArr= new Array();

var changeWatcher = {
    timeout: null,
    currentValue: '',
    watchForChange: function( el,counter ) {
        if( el.value != this.currentValue ) {
            this.changed( el,counter );
        }
        this.timeout = setTimeout( function() {
             changeWatcher.watchForChange(el,counter)
        }, 500 );
    },
    cancelWatchForChange: function(el,counter) {
        clearTimeout( this.timeout );
        this.timeout = null;
	
		if(jQuery('#divwebimages_'+counter).html()=='')
			changeWatcher.getWebImages(el.value,counter,'0');
    },
    changed: function( el,counter ) {
        this.currentValue = el.value;
		changeWatcher.getWebImages(el.value,counter,'0');
        // do something with the element and/or it's value
        //console.log( el.value );
    },
	getWebImages: function( webUrl,counter,webClip ) {
		//var webUrl=jQuery("#listlink"+counter).val();
		if(webUrl!='')
		{
			//showLoadingModal();
			jQuery("#imgloading_"+counter).attr("style","display:block");
			jQuery(".classdivwebimg").html('');
			imgArr= new Array();
			imgSrcArr= new Array();

			jQuery.post("list_webimages.php", {webUrl: webUrl,counter:counter,webClip:webClip}, function(response){
				jQuery('#divwebimages_'+counter).html(response);
				webimgcounter=0;
				//jQuery("#hidwebimage"+counter).val('');
				//jQuery('#divwebimages_'+counter).attr("style","display:block");
				jQuery("#imgloading_"+counter).attr("style","display:none");
			});
		}
		else
		{
			jQuery(".classdivwebimg").html('');
			jQuery("#imgloading_"+counter).attr("style","display:none");
		}
	}
}

var webimgcounter=0;

function FirstWebImage(counter,webClip)
{
	webimgcounter=0;
	
	jQuery("#imgwebsite_"+counter).attr("src",imgArr[webimgcounter]);
	jQuery("#lblimgwebcounter_"+counter).html((parseInt(webimgcounter)+1) + " of "+imgArr.length);
	if(webClip=='1')
		jQuery("#hidwebimage"+counter).val(imgSrcArr[webimgcounter]);
}

function PreviousWebImage(counter,webClip)
{
	if(webimgcounter>0)
	{
		webimgcounter--;
		
		jQuery("#imgwebsite_"+counter).attr("src",imgArr[webimgcounter]);
		jQuery("#lblimgwebcounter_"+counter).html((parseInt(webimgcounter)+1) + " of "+imgArr.length);
		if(webClip=='1')
			jQuery("#hidwebimage"+counter).val(imgSrcArr[webimgcounter]);
	}
}


function NextWebImage(counter,webClip)
{
	if(webimgcounter<(parseInt(imgArr.length)-1))
	{
		webimgcounter++;

		jQuery("#imgwebsite_"+counter).attr("src",imgArr[webimgcounter]);
		jQuery("#lblimgwebcounter_"+counter).html((parseInt(webimgcounter)+1) + " of "+imgArr.length);
		if(webClip=='1')
			jQuery("#hidwebimage"+counter).val(imgSrcArr[webimgcounter]);
	}
}

function LastWebImage(counter,webClip)
{
	webimgcounter=parseInt(imgArr.length)-1;

	jQuery("#imgwebsite_"+counter).attr("src",imgArr[webimgcounter]);
	jQuery("#lblimgwebcounter_"+counter).html((parseInt(webimgcounter)+1) + " of "+imgArr.length);
	if(webClip=='1')
		jQuery("#hidwebimage"+counter).val(imgSrcArr[webimgcounter]);
}

function UseWebImage(counter)
{
	jQuery("#img_"+counter).attr("src",jQuery("#imgwebsite_"+counter).attr("src"));
	jQuery("#hidwebimage"+counter).val(imgSrcArr[webimgcounter]);
}

function UseWebTitle(counter)
{
	jQuery("#title"+counter).val(jQuery("#websitetitle_"+counter).html());
}

function UseWebDescription(counter)
{
	jQuery("#description"+counter).val(jQuery("#websitedes_"+counter).html());
}

function NoThumbnailImage(chkObj)
{
	if(chkObj.checked)
	{
		jQuery("#divwebimg").attr("style","display:none");
	}
	else
	{
		jQuery("#divwebimg").attr("style","display:block");
	}
}
/***************************** Function for Web Images End *************************************/










/***************************** Function for Image Over and Out Start ****************************************/
function SetImageOnMouseOver(imgObj,imageName,imgCounter)
{
	imgObj.src="images/"+imageName+"-over.png";
	imgObj.style.cursor='pointer';
}

function ResetImageOnMouseOut(imgObj,imageName,imgCounter)
{
	imgObj.src="images/"+imageName+".png";
}
/***************************** Function for Image Over and Out End ****************************************/

/***************************** Function for Choices List Over and Out Start ****************************************/
function SetChoicesStyleOnMouseOver(listObj)
{
	jQuery(listObj).attr("style","background:#FFFFFF");
	//alert(jQuery(listObj + " .number").attr("id"))
	
	jQuery(listObj).find(".number").attr("style","color:#6BAED9");
	
	//jQuery(listObj + " .number").attr("style","color:#000000");
}

function ResetChoicesStyleOnMouseOut(listObj)
{
	jQuery(listObj).attr("style","background:#f8f8f8");	
	jQuery(listObj).find(".number").removeAttr("style");
}

/***************************** Function for Choices List Over and Out End ****************************************/

/***************************** Function for Search Image Start ****************************************/

function SearchImages(counter)
{
	showLoadingModal();
	var searchVal=jQuery("#title"+counter).val();
	callForAjax('searchimg','Search Image','searchimg.php?counter='+counter+'',850,400,'getSearchImages('+counter+',"'+searchVal+'")');
}

function getSearchImages(counter,searchVal)
{
	showLoadingModal();
	if(searchVal)
		jQuery("#searchtitle").val(searchVal);
	var title=jQuery("#searchtitle").val();
	
	jQuery.post("list_searchimg.php", {title: title}, function(response){
		jQuery('#divsearchimg').html(response);
		hideLoadingModel();
	});
}


function setSearchImages(counter)
{
	var imgsrc=jQuery('input:radio[name=chksearchimg]:checked').val();
	var imgdataval=jQuery('input:radio[name=chksearchimg]:checked').attr("data-value");
	jQuery("#img_"+counter).attr("src",imgsrc);
	jQuery("#hidwebimage"+counter).val(imgdataval);
	jQuery(".window-container .window-closeButton").click();
}

/***************************** Function for Search Image End ****************************************/

function HideHeaderImage()
{
	jQuery("#divmainimg").hide("slow");
	//jQuery("#divmainimg").attr("style","display: none;");
	setCookie("hideheaderimg",1,null);	
}

function ShowCloseIcon()
{
	jQuery("#headerimgclose").attr("style","display:block");
}

var headerCloseTimer;

function HideCloseIcon()
{
	headerCloseTimer=setTimeout("HideCloseIconTimer()",500);
}
function HideCloseIconTimer()
{
	jQuery("#headerimgclose").attr("style","display:none");
}

function CloseIconMouseOver()
{
	clearTimeout(headerCloseTimer);	
}

function setCookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	{
		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x=x.replace(/^\s+|\s+$/g,"");
		if (x==c_name)
		{
			return unescape(y);
		}
	}
}

function getUserAgeYear()
{
	var todaydate=jQuery("#hidtoday").val();
	var dobdate=jQuery("#txtdob").val();
	var ageval=mydiff(dobdate,todaydate,'years');
	jQuery("#lbldobage").html(ageval+" years");
}

function mydiff(date1,date2,interval) {
    var second=1000, minute=second*60, hour=minute*60, day=hour*24, week=day*7;
    date1 = new Date(date1);
    date2 = new Date(date2);
    var timediff = date2 - date1;
    if (isNaN(timediff)) return NaN;
    switch (interval) {
        case "years": return date2.getFullYear() - date1.getFullYear();
        case "months": return (
            ( date2.getFullYear() * 12 + date2.getMonth() )
            -
            ( date1.getFullYear() * 12 + date1.getMonth() )
        );
        case "weeks"  : return Math.floor(timediff / week);
        case "days"   : return Math.floor(timediff / day); 
        case "hours"  : return Math.floor(timediff / hour); 
        case "minutes": return Math.floor(timediff / minute);
        case "seconds": return Math.floor(timediff / second);
        default: return undefined;
    }
}

var hidemsg;
function ShowMessage()
{
	//jQuery(".classmsg").show("slow");
	hidefeeddivtime=setTimeout("HideMessage()",15000);
}

function HideMessage()
{
	jQuery(".classmsg").hide("slow");
	clearTimeout(hidemsg);
}
ShowMessage();


/*function SetHeaderClipTitle()
{
	jQuery("#btnhederwebclip").attr("alt","sohan");
	jQuery("#btnhederwebclip").attr("title","sohan");
	jQuery("#btnhederwebclip").mouseover();

	return false;
}*/

/************************************************* Feedback Start **************************************************/

function FeedbackPopUp()
{
	jQuery("#feedbackFormFancybox").validate({
		rules: {
			first_name: {
				required: true
			},
			useremail: {
				required: true, email: true
			},
			txtsubject: {
				required: true
			}
		},
		messages: {
			first_name: {	
				required: "Please enter name."
			},
			useremail: {	
				required: "Please enter valid email."
			},
			txtsubject: {	
				required: "Please enter your subject."
			}
		}
	});
	
	tinymcEditor();
	
	jQuery("#feedbackFormFancybox").bind("submit", function() {	
		if(jQuery('#txtmessage').val()!='')
		{
			showLoadingModal();
			jQuery.ajax({
				type		: "POST",
				cache	: false,
				url		: BASE_URL+"feedback_action.php",
				data		: jQuery(this).serializeArray(),
				dataType : 'json',
				success: function(data) {
					
					jQuery('#feedback_error_message').attr("style","display:none");
					jQuery('#feedback_success_message').attr("style","display:none");
					if(data.success!='')
					{
						jQuery('#feedback_success_message').attr("style","display:block");
						jQuery('#feedback_success_message').html(data.success);
						jQuery('#txtsubject').val('');
						jQuery('#txtmessage').val('');
					}
					else
					{
						jQuery('#feedback_error_message').attr("style","display:block");
						jQuery('#feedback_error_message').html(data.error);
					}
					hideLoadingModel();
				}
			});
		}
		else
			alert('Please enter your message.');
		return false;
	});
}
/*************************************************** Feedback End **************************************************/

function EnterSubmit(obj, e, btnSearchId)
{
    //alert(e.keyCode);
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		

	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 13)
	{
		jQuery("#"+btnSearchId).click();
	}
}

/* *************************************** web clip shared ************************************** */

/***************************** Function for Gift Images Start *************************************/
var giftimgArr= new Array();
var giftimgSrcArr= new Array();
var giftimgIdArr= new Array();
var giftimgcounter=0;

function FirstGiftImage(counter)
{
	giftimgcounter=0;
	
	jQuery("#imggiftwrap_"+counter).attr("src",giftimgArr[giftimgcounter]);
	jQuery("#lblimggiftwrapcounter_"+counter).html((parseInt(giftimgcounter)+1) + " of "+giftimgArr.length);
	jQuery("#hidgiftimage"+counter).val(giftimgIdArr[giftimgcounter]);
}

function PreviousGiftImage(counter)
{
	if(giftimgcounter>0)
	{
		giftimgcounter--;
		
		jQuery("#imggiftwrap_"+counter).attr("src",giftimgArr[giftimgcounter]);
		jQuery("#lblimggiftwrapcounter_"+counter).html((parseInt(giftimgcounter)+1) + " of "+giftimgArr.length);
		jQuery("#hidgiftimage"+counter).val(giftimgIdArr[giftimgcounter]);
	}
}


function NextGiftImage(counter)
{
	if(giftimgcounter<(parseInt(giftimgArr.length)-1))
	{
		giftimgcounter++;

		jQuery("#imggiftwrap_"+counter).attr("src",giftimgArr[giftimgcounter]);
		jQuery("#lblimggiftwrapcounter_"+counter).html((parseInt(giftimgcounter)+1) + " of "+giftimgArr.length);
		jQuery("#hidgiftimage"+counter).val(giftimgIdArr[giftimgcounter]);
	}
}

function LastGiftImage(counter)
{
	giftimgcounter=parseInt(giftimgArr.length)-1;

	jQuery("#imggiftwrap_"+counter).attr("src",giftimgArr[giftimgcounter]);
	jQuery("#lblimggiftwrapcounter_"+counter).html((parseInt(giftimgcounter)+1) + " of "+giftimgArr.length);
	jQuery("#hidgiftimage"+counter).val(giftimgIdArr[giftimgcounter]);
}

function UseGiftImage(counter)
{
	jQuery("#img_"+counter).attr("src",jQuery("#imgwebsite_"+counter).attr("src"));
	jQuery("#hidgiftimage"+counter).val(giftimgIdArr[giftimgcounter]);
}
function NoThumbnailImage(chkObj)
{
	if(chkObj.checked)
	{
		jQuery("#divgiftimg").attr("style","display:none");
	}
	else
	{
		jQuery("#divgiftimg").attr("style","display:block");
	}
}

function displayGiftWrap(counter)
{
	//alert("hello");
	jQuery("#recgiftchoice_"+counter).attr("style","display:none");
	jQuery("#recchoice_"+counter).show("slow");
}
/***************************** Function for Gift Images End *************************************/

/***************************** Function for Stamp Images Start *************************************/
var stampimgArr= new Array();
var stampimgSrcArr= new Array();
var stampimgIdArr= new Array();
var stampimgcounter=0;

function FirstStampImage(counter)
{
	stampimgcounter=0;
	
	jQuery("#imgstamp_"+counter).attr("src",giftimgArr[stampimgcounter]);
	jQuery("#lblimgstampcounter_"+counter).html((parseInt(stampimgcounter)+1) + " of "+stampimgArr.length);
	jQuery("#hidstampimage"+counter).val(stampimgIdArr[stampimgcounter]);
}

function PreviousStampImage(counter)
{
	if(stampimgcounter>0)
	{
		stampimgcounter--;
		
		jQuery("#imgstamp_"+counter).attr("src",stampimgArr[stampimgcounter]);
		jQuery("#lblimgstampcounter_"+counter).html((parseInt(stampimgcounter)+1) + " of "+stampimgArr.length);
		jQuery("#hidstampimage"+counter).val(stampimgIdArr[stampimgcounter]);
	}
}


function NextStampImage(counter)
{
	if(stampimgcounter<(parseInt(stampimgArr.length)-1))
	{
		//alert("hello");
		stampimgcounter++;

		jQuery("#imgstamp_"+counter).attr("src",stampimgArr[stampimgcounter]);
		jQuery("#lblimgstampcounter_"+counter).html((parseInt(stampimgcounter)+1) + " of "+stampimgArr.length);
		jQuery("#hidstampimage"+counter).val(stampimgIdArr[stampimgcounter]);
	}
}

function LastStampImage(counter)
{
	stampimgcounter=parseInt(stampimgArr.length)-1;

	jQuery("#imgstampwrap_"+counter).attr("src",stampimgArr[stampimgcounter]);
	jQuery("#lblimgstampcounter_"+counter).html((parseInt(stampimgcounter)+1) + " of "+stampimgArr.length);
	jQuery("#hidstampimage"+counter).val(stampimgIdArr[stampimgcounter]);
}

function UseStampImage(counter)
{
	jQuery("#img_"+counter).attr("src",jQuery("#imgwebsite_"+counter).attr("src"));
	jQuery("#hidstampimage"+counter).val(stampimgIdArr[stampimgcounter]);
}
/*function NoThumbnailStampImage(chkObj)
{
	if(chkObj.checked)
	{
		jQuery("#divstampimg").attr("style","display:none");
	}
	else
	{
		jQuery("#divstampimg").attr("style","display:block");
	}
}*/

function displayStampWrap(counter)
{
	//alert("hello");
	jQuery("#recstampchoice_"+counter).attr("style","display:none");
	jQuery("#recchoice_"+counter).show("slow");
}
/***************************** Function for Stamp Images End *************************************/







/************************************* Function for Whiz Alert My Choices Start ************************************************/

function ShowFriendsListForWhizAlertMyChoices(choiceCounter)
{
	jQuery(".divmychsettingmain").attr('style','display:none');
	jQuery(".divmychsharemain").attr('style','display:none');
	jQuery(".divmychwhizalertmain").attr('style','display:none');
	jQuery(".classbtnwhizalert").attr("src","images/btn_whiz_alert.png");
	jQuery(".classbtnmychwhizalert").mouseout(function ()
	{
		if(jQuery(".classbtnmychwhizalert").attr("id")!=jQuery("#btnmychwhizalert_"+choiceCounter)){
			jQuery(this).attr("src","images/btn_whiz_alert.png");
		}
	});
	
	jQuery("#divmychwhizalertmain_"+choiceCounter).attr('style','display:block');
	jQuery("#divmychwhizalert_"+choiceCounter).attr('style','display:block');
	jQuery('#lblmychwhizalertmsg_'+choiceCounter).html('');
	document.getElementById("divmychwhizalertmain_"+choiceCounter).style.display='';
	
	jQuery("#btnmychwhizalert_"+choiceCounter).attr("src","images/btn_whiz_alert-over.png");
	jQuery("#btnmychwhizalert_"+choiceCounter).mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_whiz_alert-over.png");
	});
	
	jQuery(".classbtnmychshare").attr("src","images/btn_share.png");
	jQuery(".classbtnmychshare").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share.png");
	});
}

function CancelForWhizAlertMyChoices()
{
	jQuery(".divmychwhizalertmain").attr('style','display:none');
	jQuery(".classbtnmychwhizalert").attr("src","images/btn_whiz_alert.png");
	jQuery(".classbtnmychwhizalert").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_whiz_alert.png");
	});
}

function SendMyChoiceWhizAlertToFriends(pCatId,catId,list_id,choiceCounter)
{
	showLoadingModal();
	var order = jQuery("#frmmychwhizalert_"+choiceCounter).serialize() + '&action=sendalert&list_id='+list_id+'&pCatId='+pCatId+'&catId='+catId+'&counter='+choiceCounter;

	jQuery.post("save_alert_message.php", order, function(data){
		jQuery("#txtalertmessage_"+choiceCounter).val('');				  
		jQuery("#divmychwhizalert_"+choiceCounter).attr('style','display:none');
		jQuery('#lblmychwhizalertmsg_'+choiceCounter).html(data.msg);
		jQuery('#lblmychwhizalerterrmsg_'+choiceCounter).html(data.errmsg);
		hideLoadingModel();
	},'json');
}
/************************************* Function for Whiz Alert My Choices End ************************************************/

/************************************* Function for Share My Choices Start ************************************************/

function ShowFriendsListForShareMyChoices(choiceCounter)
{
	jQuery(".divmychsettingmain").attr('style','display:none');
	jQuery(".divmychsharemain").attr('style','display:none');
	jQuery(".divmychwhizalertmain").attr('style','display:none');
	jQuery(".classbtnmychshare").attr("src","images/btn_share.png");
	jQuery(".classbtnmychshare").mouseout(function ()
	{
		if(jQuery(".classbtnmychshare").attr("id")!=jQuery("#btnmychshare_"+choiceCounter)){
			jQuery(this).attr("src","images/btn_share.png");
		}
	});
	
	jQuery("#divmychsharemain_"+choiceCounter).attr('style','display:block');
	jQuery("#divmychshare_"+choiceCounter).attr('style','display:block');
	jQuery('#lblmychsharedmsg_'+choiceCounter).html('');
	document.getElementById("divmychsharemain_"+choiceCounter).style.display='';
	
	jQuery("#btnmychshare_"+choiceCounter).attr("src","images/btn_share-over.png");
	jQuery("#btnmychshare_"+choiceCounter).mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share-over.png");
	});
	
	jQuery(".classbtnmychwhizalert").attr("src","images/btn_whiz_alert.png");
	jQuery(".classbtnmychwhizalert").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_whiz_alert.png");
	});
}


function CancelForShareMyChoice()
{
	jQuery(".divmychsharemain").attr('style','display:none');
	
	jQuery(".classbtnmychshare").attr("src","images/btn_share.png");
	jQuery(".classbtnmychshare").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share.png");
	});
}


function ShareMyChoiceToFriends(list_id,choiceCounter)
{
	showLoadingModal();
	var order = jQuery("#frmmychshare_"+choiceCounter).serialize() + '&action=share&list_id='+list_id+'&counter='+choiceCounter;

	jQuery.post("save_shared_choice.php", order, function(data){
														  
		jQuery("#divmychshare_"+choiceCounter).attr('style','display:none');
		jQuery('#lblmychsharedmsg_'+choiceCounter).html(data.msg);
		jQuery('#lblmychsharederrmsg_'+choiceCounter).html(data.errmsg);
		
		if(data.shchoicetyype==3)
		{
			jQuery("input[name='chkfrndshchoices_"+choiceCounter+"[]']").each(function() {
				if($(this).val())
				{
					$(this).attr('checked',false);
				}
			});
		}
		else if(data.shchoicetyype==4)
		{
			jQuery("input[name='chkfrndshchoices_"+choiceCounter+"[]']:checked").each(function() {
				if($(this).val())
				{
					$(this).attr('checked',false);
				}
			});
		}
		hideLoadingModel();
	},'json');
}

/************************************* Function for Share My Choices End ************************************************/

/******************************** Function for Change Setting of My Choices Start ******************************************/
function ShowFriendsListForChangeAccessSettingOfMyChoices(choiceCounter)
{
	jQuery(".divmychsettingmain").attr('style','display:none');
	jQuery(".divmychsharemain").attr('style','display:none');
	jQuery(".divmychwhizalertmain").attr('style','display:none');
	
	jQuery("#divmychsettingmain_"+choiceCounter).attr('style','display:block');
	jQuery("#divmychsetting_"+choiceCounter).attr('style','display:block');
	jQuery('#lblmychsettingmsg_'+choiceCounter).html('');
	document.getElementById("divmychsettingmain_"+choiceCounter).style.display='';	
	
	jQuery(".classbtnmychwhizalert").attr("src","images/btn_whiz_alert.png");
	jQuery(".classbtnmychwhizalert").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_whiz_alert.png");
	});
	
	jQuery(".classbtnmychshare").attr("src","images/btn_share.png");
	jQuery(".classbtnmychshare").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share.png");
	});
}

function CancelForChangeAccessSettingOfMyChoices()
{
	//jQuery(".divmychsettingmain").attr('style','display:none');
	jQuery(".divmychsettingmain").hide('slow');
}

function UpdateAccessSettingOfMyChoices(catId,listId,choiceCounter)
{
	var order = jQuery("#frmmychsetting_"+choiceCounter).serialize() + '&action=updshareaccess&list_id='+listId+'&category_id='+catId;

	jQuery.post("save_mychoices_action.php", order, function(data){
		jQuery("#divmychsetting_"+choiceCounter).attr('style','display:none');
		jQuery('#lblmychsettingmsg_'+choiceCounter).html(data.msg);
		jQuery('#ancmychaccesssetting_'+choiceCounter).removeAttr('class');
		jQuery('#ancmychaccesssetting_'+choiceCounter).attr('class',data.ShareAccessClass);		
		jQuery('#lblancmychaccesssetting_'+choiceCounter).html(data.ShareAccessText);		
	},'json');
}
/******************************** Function for Change Setting of My Choices End ******************************************/

/***************************** Function for Add in My Top 10 Start ****************************************/
function ShowCategoryListForAddChoicesInMyAccount(choiceCounter)
{
	jQuery(".divaddchoicesinmyaccountmain").attr("style",'display:none;');
	jQuery("#divaddchoicesinmyaccountmain_"+choiceCounter).attr("style",'display:block;');
	
	jQuery(".classbtnaddchoicesinmyaccount").attr("src","images/btn_addtop10.png");
	jQuery(".classbtnaddchoicesinmyaccount").mouseout(function ()
	{
		if(jQuery(".classbtnaddchoicesinmyaccount").attr("id")!=jQuery("#btnaddchoicesinmyaccount_"+choiceCounter)){
			jQuery(this).attr("src","images/btn_addtop10.png");
		}
	});
	
	
	jQuery("#btnaddchoicesinmyaccount_"+choiceCounter).attr("src","images/btn_addtop10-over.png");
	jQuery("#btnaddchoicesinmyaccount_"+choiceCounter).mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_addtop10-over.png");
	});	
}

function CancelForAddChoicesInMyAccount()
{
	jQuery(".divaddchoicesinmyaccountmain").attr("style",'display:none;');

	jQuery(".classbtnaddchoicesinmyaccount").attr("src","images/btn_addtop10.png");
	jQuery(".classbtnaddchoicesinmyaccount").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_addtop10.png");
	});
	
}

function AcceptForAddChoicesInMyAccount(choiceCounter,list_id,puserId,fcatId,orderType,pagenum,pCatId)
{
	var category_id=document.getElementById("ddlmycategorylist_"+choiceCounter).value;

	if(category_id!='' && category_id!='0')
	{
		if(window.confirm(('Are you sure, Do you want to add this choice?')))
		{
			showLoadingModal();
			
			var chkfeed=0;
			if(jQuery('input:checkbox[id=notfeed'+choiceCounter+']:checked').val())
				chkfeed=1;
			
			jQuery.post("save_mychoices_action.php", {list_id:list_id,category_id:category_id,chkfeed:chkfeed,action:'addinmychoices'}, function(response){																																							   				getTop10CategoriesChoices(puserId,fcatId,orderType,pagenum,'',pCatId,0,'','')
				alert('You have successfully added choice.');
				hideLoadingModel();
			});			
		}
	}
	else
	{
		alert('Please select category');	
	}
}
/***************************** Function for Add in My Top 10 End ****************************************/



function ShowAndHideMyFriendList(optVal,divId,btnId)
{
	if(optVal==4)
	{
		//jQuery("#"+divId).css("display","block");
		jQuery("#"+divId).show("slow");
		jQuery("#"+btnId).attr("src","images/btn_guest_list-over.png");
		jQuery("#"+btnId).mouseout(function ()
		{
			jQuery("#"+btnId).attr("src","images/btn_guest_list-over.png");
		});
	}
	else
	{
		//jQuery("#"+divId).css("display","none");
		jQuery("#"+divId).hide('slow');
		jQuery("#"+btnId).attr("src","images/btn_guest_list.png");
		jQuery("#"+btnId).mouseout(function ()
		{
			jQuery("#"+btnId).attr("src","images/btn_guest_list.png");
		});
	}
}

function ResetAllDivAndButton()
{
	jQuery(".divmychsettingmain").attr('style','display:none');
	jQuery(".divmychsharemain").attr('style','display:none');
	jQuery(".divmychwhizalertmain").attr('style','display:none');
	
	jQuery(".classbtnmychwhizalert").attr("src","images/btn_whiz_alert.png");
	jQuery(".classbtnmychwhizalert").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_whiz_alert.png");
	});
	
	jQuery(".classbtnmychshare").attr("src","images/btn_share.png");
	jQuery(".classbtnmychshare").mouseout(function ()
	{
		jQuery(this).attr("src","images/btn_share.png");
	});
}

/* for tech services part for gift wrap */
function getSortGiftWrapData(tabType,userId)
{
	var orderType=document.getElementById("ddlorder").value;
	getTechServices(tabType,4,orderType);
}

/* for tech services part for gift wrap */
function getSortGiftStampData(tabType,userId)
{
	var orderType=document.getElementById("ddlorder").value;
	getTechServices(tabType,5,orderType);
}
function getSortWebClipData(tabType,userId)
{
	var orderType=document.getElementById("ddlorder").value;
	getTechServices(tabType,6,orderType);
}

/******************************* Function for Manage Tech App Images by User Start *********************************/
function SortTechAppImage(serviceIndex)
{
	var orderType=document.getElementById("ddlorder").value;
	getTechServicesData(serviceIndex,'',orderType);
}

function ChangeTechAppImageByUser(formName,valGroup)
{
	if(eval(getFormElement(formName,valGroup)))
	{
		if(window.confirm('Are you sure, Do you want to Change this image?'))
		{	
			formName.submit();
		}
	}
}

function ShowChangeTechAppImageForm(image_id)
{
	jQuery(".divtechappimage").attr("style",'display:none;');
	jQuery("#divtechappimage_"+image_id).attr("style",'display:block;');
}

function ShowTechAppImageDeleteIconDiv(image_id)
{
	jQuery("#anctechappimagedelete_"+image_id).attr("style","display:block;");
}
function HideTechAppImageDeleteIconDiv(image_id)
{
	jQuery("#anctechappimagedelete_"+image_id).attr("style","display:none");
}

function DeleteTechAppImagebyUser(image_id,image_type,serviceIndex)
{
	if(window.confirm('Are you sure, Do you want to delete this image?'))
	{
		jQuery.post("save_techapp_image_mgmt.php", {action: 'delete',image_id: image_id,image_type:image_type}, function(data){
			getTechServicesData(serviceIndex,'');
			alert(data.msg);
		},'json');
	}
}

function RestoreTechAppImageByUser(image_id,image_type,serviceIndex)
{
	if(window.confirm('Are you sure, Do you want to restore this image?'))
	{
		jQuery.post("save_techapp_image_mgmt.php", {action: 'restore',image_id: image_id,image_type:image_type}, function(data){
			getTechServicesData(serviceIndex,'');
			alert(data.msg);
		},'json');
	}
}
/******************************* Function for Manage Tech App Images by User End *********************************/

function ShowHideAttachedDocument(choicesCounter)
{
	if(jQuery("#divattacheddoc_"+choicesCounter).attr("style")=="display: block;")
	{
		jQuery("#divattacheddoc_"+choicesCounter).attr("style","display:none");	
	}
	else
		jQuery("#divattacheddoc_"+choicesCounter).attr("style","display:block");	
}

/******************************** Function For Show Hide Wrap Icon Start *********************************************/
var showWrapUserImageTimer;

function ShowWrapUserImage(recordCounter,showImageType)
{
	if(showImageType==1)
	{
		jQuery("#ancwrapimg_"+recordCounter).hide();
		jQuery("#ancwrapuserimg_"+recordCounter).show("slow");
	}
	else if(showImageType==2)
	{
		jQuery("#ancwrapuserimg_"+recordCounter).hide();
		jQuery("#ancwrapimg_"+recordCounter).show("slow");		
	}
	clearTimeout(showWrapUserImageTimer);
}

function ShowWrapUserImageOnMouseover(recordCounter,showImageType)
{
	showWrapUserImageTimer=setTimeout("ShowWrapUserImage('"+recordCounter+"','"+showImageType+"')",3000);
}

function ShowWrapUserImageOnMouseout()
{
	clearTimeout(showWrapUserImageTimer);
}

function ShowUserImageOnMouseOverOfWrapImage(recordCounter)
{
	var imgpath=jQuery("#wrapimg_"+recordCounter).attr("src");
	jQuery("#wrapimg_"+recordCounter).attr("src",jQuery("#userwrapimg_"+recordCounter).attr("src"));
	jQuery("#userwrapimg_"+recordCounter).attr("src",imgpath);
	
	var imgalt=jQuery("#wrapimg_"+recordCounter).attr("alt");
	jQuery("#wrapimg_"+recordCounter).attr("alt",jQuery("#userwrapimg_"+recordCounter).attr("alt"));
	jQuery("#userwrapimg_"+recordCounter).attr("alt",imgalt);
	
	var imgtitle=jQuery("#wrapimg_"+recordCounter).attr("title");
	jQuery("#wrapimg_"+recordCounter).attr("title",jQuery("#userwrapimg_"+recordCounter).attr("title"));
	jQuery("#userwrapimg_"+recordCounter).attr("title",imgtitle);
}

function HideUserImageOnMouseOverOfWrapImage(recordCounter)
{
	var imgpath=jQuery("#userwrapimg_"+recordCounter).attr("src");
	jQuery("#userwrapimg_"+recordCounter).attr("src",jQuery("#wrapimg_"+recordCounter).attr("src"));
	jQuery("#wrapimg_"+recordCounter).attr("src",imgpath);
	
	var imgalt=jQuery("#userwrapimg_"+recordCounter).attr("alt");
	jQuery("#userwrapimg_"+recordCounter).attr("alt",jQuery("#wrapimg_"+recordCounter).attr("alt"));
	jQuery("#wrapimg_"+recordCounter).attr("alt",imgalt);
	
	var imgtitle=jQuery("#userwrapimg_"+recordCounter).attr("title");
	jQuery("#userwrapimg_"+recordCounter).attr("title",jQuery("#wrapimg_"+recordCounter).attr("title"));
	jQuery("#wrapimg_"+recordCounter).attr("title",imgtitle);
}

function ShowWrapIconDeleteDiv(recordCounter)
{
	jQuery("#ancwrapicondelete_"+recordCounter).attr("style","display:block;");
}
function HideWrapIconDeleteDiv(recordCounter)
{
	jQuery("#ancwrapicondelete_"+recordCounter).attr("style","display:none");
}

function RemoveChoicesWrapIcon(listId,userId,catId,orderType,pagenum,searchval,pCatId)
{
	if(window.confirm('Are you sure, Do you want to remove this icon?'))
	{
		jQuery.post("save_mychoices_action.php", {action: 'removeicon',list_id:listId}, function(data){
			getTop10CategoriesChoices(userId,catId,orderType,pagenum,searchval,pCatId,0,'','');
			alert(data.msg);
		},'json');
	}
}

function RemoveCategoriesWrapIcon(userId,catId,orderType,pagenum,searchval,pCatId,clubdayval,clubChoiceCat)
{
	if(window.confirm('Are you sure, Do you want to remove this icon?'))
	{
		jQuery.post("save_mycategory_action.php", {action: 'removeicon',category_id: catId}, function(data){
			getTop10CategoriesChoices(userId,catId,orderType,pagenum,searchval,pCatId,0,clubdayval,'',clubChoiceCat);
			alert(data.msg);
		},'json');
	}
}
/******************************** Function For Show Hide Wrap Icon End *********************************************/

function showDivGiftWrap(optCounter,type)
{	
	if(type == 1)
	{
		jQuery("#rdbstamp_"+optCounter).attr('checked',false);		
		if(jQuery("#rdbgiftwrap_"+optCounter).attr('checked'))
		{
			jQuery("#divgiftwrap_"+optCounter).css("display","block");
			jQuery("#divstamp_"+optCounter).css("display","none");
		}
		else
		{
			jQuery("#divgiftwrap_"+optCounter).css("display","none");
			jQuery("#divstamp_"+optCounter).css("display","none");
		}
	}
	else if(type == 2)
	{
		jQuery("#rdbgiftwrap_"+optCounter).attr('checked',false);		
		if(jQuery("#rdbstamp_"+optCounter).attr('checked'))
		{
			jQuery("#divgiftwrap_"+optCounter).css("display","none");
			jQuery("#divstamp_"+optCounter).css("display","block");
		}
		else
		{
			jQuery("#divgiftwrap_"+optCounter).css("display","none");
			jQuery("#divstamp_"+optCounter).css("display","none");
		}
	}
}
