var preId = 'allfav';
var preactId = 'all';

SocialEngineAPI.Favorite = new Class({ 
	Implements: [Options],
	Base: {
		'actdiv': null,
		'time': 300
	},
	Type: {
		'favType' : null
	},
	options: {
		    'ajaxURL' : jsBaseUrl+'favorites_ajax.php', 
	    'ajaxMethod' : 'post'
	},
		initialize: function(options){
		this.setOptions(options);
	},
		_delete: function(id){
		var bind = this;
		if(bind.confirmDel(bind.Base.Language.Translate(7000005))){
				var request = new Request.JSON({
				'method' : 'get',
				'url' : bind.options.ajaxURL,
				'data' : {
					'task' : '_deletes',
					'favoid' : id
				}, 
				'onComplete' : function(ajx){
					if(ajx.result == "success"){
						$(bind.Base.actdiv).set('html', bind.Base.Language.Translate(7000009));
						$(bind.Base.actdiv).className = 'success';
					}
					else{
						$(bind.Base.actdiv).set('html', bind.Base.Language.Translate(141));
						$(bind.Base.actdiv).className = 'error';
					}
					window.location.reload(false);
				}
			});
			request.send();
		}
	},	
	addFavorite: function(id){
		var bind = this;
		var request = new Request.JSON({
			'method' : 'get',
			'url' : bind.options.ajaxURL,
			'data' : {
				'task' : '_addfavos',
				'type': bind.Type.favType,
				'favoid' : id
			},
			'onComplete' : function(ajx){
				var text="";
				if(ajx.result == 1)
				{
					text=bind.Base.Language.Translate(7000008);
				}
				else if(ajx.result == 2)
				{
					text=bind.Base.Language.Translate(7000007);
				}
				else
				{
					text=bind.Base.Language.Translate(7000006);
				}
				
				var html2 = '<div class="addFavBlogPop_light" id="addFavBlogPop">'+
								'<div class="poptop-image">'+
									'<div class="hdg_image_fav" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/added_to_fav.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
									'</div>'+
									'<a href="javascript:void(0);" class="cross_pop_bt" onclick="TB_remove()" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
								'</div>'+
								'<div class="popmiddle-image">'+
									'<!--[if IE 7]><div class="frnds_form_blog"><![endif]--><!--[if lt IE 7]> <div class="frnds_form_blog"><![endif]--><!--[if !IE ]>--> <div class="frnds_form_blog"><!--<![endif]-->'+text+
										'<br /><div class="okbtn_blog cursor">'+
											'<div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="OK" onclick="TB_remove()" />'+
											'</div>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="popbottom-image"></div>'+
							'</div>';
				$('msgdiv').set('html', html2);
				TB_show('', '#TB_inline?height=auto&width=460&inlineId=msgdiv', '', '{$BASE_REL_URL}images/trans.gif');
			}
		});
		request.send();
	},
	addFanlist1: function(id, full_name, callbackFunctionString){
		var bind = this;
		if(!callbackFunctionString){ //Since we're attaching events/html elements by innerHTMLing, we have to pass a STRING for the callback
			callbackFunctionString = '';
		}
		var request = new Request.JSON({
			'method' : 'get',
			'url' : bind.options.ajaxURL,
			'data' : {
				'task' : '_addfans',
				'favoid' : id
			},
			'onComplete' : function(ajx){
				var _tmp = "";
				if(ajx.result == 1){
					_tmp = 'Now you have become a fan of '+full_name;
					callbackFunctionString = 'function(){ '+callbackFunctionString+' }';					
				}
				else if(ajx.result == 2){
					_tmp = 'You are already a fan of '+full_name;
					callbackFunctionString = '';
				}
				else{
					_tmp = bind.Base.Language.Translate(7005005);
					callbackFunctionString = '';
				}
				var html2 = '<div class="addFavTopPop_light" id="addFavBlogPop">'+
								'<div class="poptop-image">'+
									'<div class="hdg_image_fan" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/new_fans.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
									'</div>'+
									'<a href="javascript:void(0);" class="cross_pop_bt" onclick="TB_remove('+callbackFunctionString+')" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
								'</div>'+
								'<div class="popmiddle-image">'+
									'<div class="frnds_form_blog">'+_tmp+
										'<div class="okbtn_blog cursor">'+
											'<div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="Ok" onclick="TB_remove('+callbackFunctionString+')" />'+
											'</div>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="popbottom-image"></div>'+
							'</div>';
				$('msgdivt').set('html', html2);
				TB_show('', '#TB_inline?height=auto&width=460&inlineId=msgdivt', '', '{$BASE_REL_URL}images/trans.gif');
			}
		});
		request.send();
	},
	addFanlist: function(id, nums, full_name, callbackFunctionString){
		var bind = this;
		var num = nums || '';
		if(!callbackFunctionString){ //Since we're attaching events/html elements by innerHTMLing, we have to pass a STRING for the callback
			callbackFunctionString = '';
		}
		var request = new Request.JSON({
			'method' : 'get',
			'url' : bind.options.ajaxURL,
			'data' : {
				'task' : '_addfans',
				'favoid' : id
			},
			'onComplete' : function(ajx){
				var _tmp = "";
				if(ajx.result == 1){
					_tmp = 'Now you have become a fan of '+full_name;
					$('span'+num).set('html', ajx.fancount);
					callbackFunctionString = 'function(){ '+callbackFunctionString+' }';
				}
				else if(ajx.result == 2){
					_tmp = 'You are already fan of '+full_name;
					callbackFunctionString = '';
				}
				else{
					_tmp = bind.Base.Language.Translate(7005005);
					callbackFunctionString = '';
				}
				var html2 = '<div class="addFavHomePop_light" id="addFavBlogPop">'+
								'<div class="poptop-image">'+
									'<div class="hdg_image_fan" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/new_fans.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
									'</div>'+
									'<a href="javascript:void(0);" class="cross_pop_bt" onclick="TB_remove('+callbackFunctionString+')" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
								'</div>'+
								'<div class="popmiddle-image">'+
									'<div class="frnds_form_blog"><p style="clear:both;">'+_tmp+
										'</p><div class="okbtn_blog cursor">'+
											'<div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="" onclick="TB_remove('+callbackFunctionString+')" />'+
											'</div>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="popbottom-image"></div>'+
							'</div>';

				$('fmsgdiv').set('html', html2);
				TB_show('', '#TB_inline?height=auto&width=460&inlineId=fmsgdiv', '', '{$BASE_REL_URL}images/trans.gif');
			}
		});
		request.send();
	},
	addStarToFanlist: function(starid ,userid ,nums, full_name, callbackFunctionString){
		var bind = this;
		var num = nums || '';
		if(!callbackFunctionString){ //Since we're attaching events/html elements by innerHTMLing, we have to pass a STRING for the callback
			callbackFunctionString = '';
		}
		var request = new Request.JSON({
			'method' : 'get',
			'url' : bind.options.ajaxURL,
			'data' : {
				'task' : 'addstartofans',
				'userid' : userid,
				'favoid' : starid
			},
			'onComplete' : function(ajx){
				var _tmp = "";
				if(ajx.result == 1){
					_tmp = 'Now you have become a fan of '+full_name;
					if(num !=""){
						$('span'+num).set('html', ajx.fancount);
					}
					callbackFunctionString = 'function(){ '+callbackFunctionString+' }';
				}
				else if(ajx.result == 2){
					_tmp = 'You are already a fan of '+full_name;
					callbackFunctionString = '';
				}
				else{
					_tmp = bind.Base.Language.Translate(7005005);
					callbackFunctionString = '';
				}
				var html2 = '<div class="addFavHomePop_light" id="addFavBlogPop">'+
								'<div class="poptop-image">'+
									'<div class="hdg_image_fan" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/new_fans.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
									'</div>'+
									'<a href="javascript:void(0);" class="cross_pop_bt" onclick="TB_remove('+callbackFunctionString+')" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
								'</div>'+
								'<div class="popmiddle-image">'+
									'<div class="frnds_form_blog"><p style="clear:both;">'+_tmp+
										'</p><div class="okbtn_blog cursor">'+
											'<div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="" onclick="TB_remove('+callbackFunctionString+')" />'+
											'</div>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="popbottom-image"></div>'+
							'</div>';

				$('fmsgdiv').set('html', html2);
				TB_show('', '#TB_inline?height=auto&width=460&inlineId=fmsgdiv', '', '{$BASE_REL_URL}images/trans.gif');
			}
		});
		request.send();
	},
	remove: function(id, type){
		var bind = this;
		var type = type || '';
		if(type == '_starfanlist'){
			bind.removeFanlist(id);
		}
		else if(type == '_favlist'){
			bind.removeFavorite(id);
		}
		else if(type == '_friendlist'){
			bind.removeFriends(id);
		}
	},
	removeBox: function(id, div, type){
		var html1 = '<div id="chg_frnd1">\
			<div class="chg_bg"></div>\
			<div class="chg_relative">\
				<div class="chg_content">\
					<a href="javascript:void(0);" onclick="SocialEngine.Favorite.hide(\''+div+'\');" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>\
					<div class="frnds_form1">\
						<div id="errmsg"></div><br />\
						<div class="formline"><label><center>Are you sure to delete?</center></label></div>\
						<div id="passbutton" class="chg_btn123">\
							<input type="button" onclick="SocialEngine.Favorite.remove('+id+',\''+type+'\');" src="'+jsBaseUrl+'images/spacer.gif" class="btn_yes2" title="Yes" />\
							<input type="button" onclick="SocialEngine.Favorite.hide(\''+div+'\');" src="'+jsBaseUrl+'images/spacer.gif" class="btn_no2" title="No" />\
						</div>\
					</div>\
				</div>\
			</div>\
		</div>';
		$(div).set('html', html1);
	},
	removeBox2: function(id, div, type){
		var msg = '';
		if(type == "_starfanlist")
		{
			msg = "Are you sure you want to remove this star from your star(s) list";
		}
		else if(type == "_favlist")
		{
			msg = "Are you sure you want to remove this item from your favorite(s) list";
		}
		else
		{
			msg = "Are you sure you want to remove this person from your friend(s) list";
		}
		var html2 = '<div class="frSrhPop_light" id="addFavBlogPop">'+
						'<div class="poptop-image">'+
							'<div class="remove_image_fan" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/removed.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
							'</div>'+
							'<a href="javascript:void(0);" class="cross_pop_bt" onclick="TB_remove()" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
						'</div>'+
						'<div class="popmiddle-image">'+
							'<div class="popup_form_search_new pb20">'+
								'<div id="errmsg" class="pb5"><img src="'+jsBaseUrl+'images/spacer.gif"/></div>'+msg+
								'<div class="okbtn_search">'+
									'<div class="yesPopBt cursor" onclick="SocialEngine.Favorite.remove('+id+',\''+type+'\');"><img src="'+jsBaseUrl+'images/spacer.gif"/>'+
									'</div>'+
									'<div class="noPopBt cursor" onclick="TB_remove()"><img src="'+jsBaseUrl+'images/spacer.gif"/>'+
									'</div>'+
								'</div>'+
							'</div>'+
						'</div>'+
						'<div class="popbottom-image"><img src="'+jsBaseUrl+'images/spacer.gif"/></div>'+
					'</div>';
		$(div).set('html', html2);
		TB_show('', '#TB_inline?height=auto&width=460&inlineId='+div, '', '{$BASE_REL_URL}images/trans.gif');
	},	
	commonBox: function(div, str, bool){
		if(bool){
			var html1 = '<div id="chg_frnd1">\
				<div id="staradded_maincontainer">\
					<div class="popup_continer"><div class="popup_continer1">'+str+' has been added to your<br /> Star List.<div class="okbtn cursor"><div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="" onclick="SocialEngine.Favorite.hide1(\''+div+'\', true);" /></div></div></div>\
					<div class="hdg_image" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/added_to_fav.png\');"></div>\
					<div class="delete_icon"><div class="float_left" style="display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'.'+jsBaseUrl+'images/delete_icon.png\');"><a href="javascript:void(0);" onclick="SocialEngine.Favorite.hide1(\''+div+'\', true);"><img src="'+jsBaseUrl+'images/delete_icon.png" alt="" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a></div></div>\
				</div>\
			</div>';
		}
		else{
			var html1 = '<div id="chg_frnd1">\
				<div id="staradded_maincontainer">\
					<div class="popup_continer"><div class="popup_continer1">'+str+'<div class="okbtn cursor"><div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="" onclick="SocialEngine.Favorite.hide1(\''+div+'\', true);" /></div></div></div>\
					<div class="hdg_image"></div>\
					<div class="delete_icon"><div class="float_left" style="display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'.'+jsBaseUrl+'images/delete_icon.png\');"><a href="javascript:void(0);" onclick="SocialEngine.Favorite.hide1(\''+div+'\', true);"><img src="'+jsBaseUrl+'images/delete_icon.png" alt="" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a></div></div>\
				</div>\
			</div>';
		}
		$(div).set('html', html1);
	},
	removeFriends: function(id){
		var bind = this;
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'user_friends_manage.php',
			'data' : {
				'task' : 'remove_friend',
				'id' : id
			}, 
			'onComplete' : function(ajx){
				if(ajx.result){
					$('errmsg').set('html', bind.Base.Language.Translate(ajx.result));
					$('errmsg').setStyle('color','#00CC33');
					TB_remove();
				}
				else{
					$('errmsg').set('html', bind.Base.Language.Translate(7005005));
					$('errmsg').setStyle('color','#dd0000');
					TB_remove();
				}
				window.location.reload(false);
			}
		});
		request.send();
	},
	removeFavorite: function(id){
		var bind = this;
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'userfavorites.php',
			'data' : {
				'task' : 'remove_fav',
				'id' : id
			}, 
			'onComplete' : function(ajx){
				if(ajx.result){
					$('errmsg').set('html', bind.Base.Language.Translate(ajx.result));
					$('errmsg').setStyle('color','#00CC33');
					TB_remove();
				}
				else{
					$('errmsg').set('html', bind.Base.Language.Translate(7005005));
					$('errmsg').setStyle('color','#dd0000');
					TB_remove();
				}
				window.location.reload(false);
			}
		});
		request.send();
	},
	removeFanlist: function(id){
		var bind = this;
		var request = new Request.JSON({
			'method' : 'get',
			'url' : bind.options.ajaxURL,
			'data' : {
				'task' : '_removefans',
				'favoid' : id
			}, 
			'onComplete' : function(ajx){
				if(ajx.result == 1){
					TB_remove();
					$('errmsg').set('html', bind.Base.Language.Translate(7005008));
				}
				else{
					TB_remove();
					$('errmsg').set('html', bind.Base.Language.Translate(7005005));
				}
				window.location.reload(false);
			}
		});
		request.send();
	},
	
	confirmDel: function(str){
		var isOk = confirm(str);
		if(isOk){
			return true;
		}
		return false;
	},
	addFriends: function(id){
		$('add_fr').style.display = 'block';
	},
	
	hide: function(id, bool){
		bool = bool || false;
		$(id).set('html', '');
		if(bool){
			window.location.reload(false);
		}
	},
	
	hide1: function(id, bool){
		bool = bool || false;
		if(bool){
			window.location.reload(false);
		}
		setTimeout(function(){$(id).set('html', '');}, 3000);
	},
	
	show: function(id){
		$(id).style.display = 'block';
	},
	showPasswdBox: function(ev){
		var bind = this;
		var html1 = '<div class="chng_pass_pop_light" id="chg_frnd_new">'+
				'<div class="poptop-image">'+
					'<div class="hdg_image_chng_pass" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/change_password.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
					'</div>'+
					'<a href="javascript:void(0);" class="cross_pop_bt" onclick="show_light(\'chpasswd\', \'none\'); show_back_light(\'fade\', \'none\');" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
				'</div>'+
				'<div class="popmiddle-image">'+
					'<div class="frnds_form_chng_pass">\
							<div id="errmsg"></div><br />\
							<div class="formline_black"><label>Old Password</label><input id="pass1" type="password" name="password_old" class="chg_input" maxlength="50"></div>\
							<div class="formline_black"><label>New Password</label><input id="pass2" type="password" name="password_new" class="chg_input" maxlength="50"></div>\
							<div class="formline_black"><label>Confirm New Password</label><input id="pass3" type="password" name="password_new2" class="chg_input" maxlength="50"></div>\
							<div id="passbutton" class="chg_btn"><input type="button" onclick="SocialEngine.Favorite.changePassword();" src="'+jsBaseUrl+'images/spacer.gif" class="btn_submit1" title="Submit" /></div>\
					</div>'+
				'</div>'+
				'<div class="popbottom-image"></div>'+
			'</div>';
	
		$('chpasswd').set('html', html1);
		show_light('chpasswd', 'block'); show_back_light('fade', 'block');
	},
	
	changePassword: function(){
		var bind = this;
		$('passbutton').set('html', bind.Base.Language.Translate(7005025));
		$('passbutton').className = 'process';
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'user_account_pass.php',
			'data' : {
				'task' : 'dosave',
				'isjson' : '_jsonFormat',
				'password_old' : encodeURIComponent($('pass1').value),
				'password_new' : encodeURIComponent($('pass2').value),
				'password_new2' : encodeURIComponent($('pass3').value)
			},
			'onComplete' : function(ajx){
				if(ajx.result == 1){
					$('errmsg').set('html', 'Password successfully changed.');
					$('errmsg').className = 'success';
					$('passbutton').set('html', '<input type="button" onclick="SocialEngine.Favorite.changePassword();" src="'+jsBaseUrl+'images/spacer.gif" class="btn_submit1" title="Submit" />');
					$('passbutton').className = '';
					setTimeout("show_light('chpasswd', 'none')", 3000); 
					setTimeout("show_back_light('fade', 'none')", 3000);
				}
				else{
					$('errmsg').set('html', bind.Base.Language.Translate(ajx.result));
					$('errmsg').className = 'errors';
					$('passbutton').set('html', '<input type="button" onclick="SocialEngine.Favorite.changePassword();" src="'+jsBaseUrl+'images/spacer.gif" class="btn_submit1" title="Submit" />');
					$('passbutton').className = '';
				}
			}
		});
		request.send();
	},
	prevFavoItems: function(id, total,limit){
		var bind = this;
		var starts = parseInt($('startpoint').value)-limit;
		$('spnajh').setStyle('display', 'block');
		$('imgajh').setStyle('display', 'none');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'favoid' : id,
				'task' : 'favorite_items',
				'limit' : limit,
				'start' : starts
			},
			'onComplete' : function(ajx){
				$('startpoint').value = ajx.start;
				$('favomygallary').set('html', ajx.result);
				if(parseInt(ajx.start) < limit)
				{
					$('prevdiv').set('html', '<img src="'+jsBaseUrl+'images/spacer.gif" alt="arrow_up" />');
				}
				else
				{
					$('prevdiv').set('html', '<span class="ajax-loading2" id="spnajh" style="display:none;"></span><img id="imgajh" class="favnextprev" onClick="SocialEngine.Favorite.prevFavoItems('+id+', '+total+', '+limit+');" src="'+jsBaseUrl+'images/arrow_up.gif" alt="Previous" />');
				}
				
				if(parseInt(ajx.start)+limit >= limit)
				{
					$('nextdiv').set('html', '<span class="ajax-loading2" id="spnajh" style="display:none;"></span><img id="imgajh" onClick="SocialEngine.Favorite.nextFavoItems('+id+', '+total+', '+limit+');" src="'+jsBaseUrl+'images/arrow_down.gif" alt="Next" class="favnextprev" />');
				}
				bind.hideLoader('ajax-loading2', 'spnajh');
			}
		});
		request.send();
	},
	
		nextFavoItems: function(id, total,limit){
		var bind = this;
		var starts = parseInt($('startpoint').value)+limit;
		$('spnajh').setStyle('display', 'block');
		$('imgajh').setStyle('display', 'none');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'favoid' : id,
				'task' : 'favorite_items',
				'limit' : limit,
				'start' : starts
			},
			'onComplete' : function(ajx){
				$('startpoint').value = ajx.start;
				$('favomygallary').set('html', ajx.result);
				if(parseInt(ajx.start) >= limit)
				{
					$('prevdiv').set('html', '<span class="ajax-loading2" id="spnajh" style="display:none;"></span><img id="imgajh" class="favnextprev" onClick="SocialEngine.Favorite.prevFavoItems('+id+', '+total+', '+limit+');" src="'+jsBaseUrl+'images/arrow_up.gif" alt="Previous" />');
				}
				
				if(parseInt(ajx.start)+limit >= total)
				{
					$('nextdiv').set('html', '<img src="'+jsBaseUrl+'images/spacer.gif" alt="Next" class="float_none" />');
				}
				else
				{
					$('nextdiv').set('html', '<span class="ajax-loading2" id="spnajh" style="display:none;"></span><img id="imgajh" onClick="SocialEngine.Favorite.nextFavoItems('+id+', '+total+', '+limit+');" src="'+jsBaseUrl+'images/arrow_down.gif" alt="Next" class="favnextprev" />');
				}
				bind.hideLoader('ajax-loading2', 'spnajh');
			}
		});
		request.send();
	},

	showMyStarstoHome: function(userid,id,status,total,limit,full_name){
		var bind = this;
		var starts = parseInt($('startpoint').value);
		//callbackFunctionString = 'srmboxdiv';
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'userid' : id,
				'task'   : 'updatemystars',
				'limit'  : limit,
				'total'  : total,
				'page'   : starts,
				'type'   : status
			},
			'onComplete' : function(ajx){
				bind.getMyStars(userid,starts,total,limit);
				//$('startpoint').value = ajx.start;
				//$('mystars').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh');				 
			}
		});

		if(status ==1)
		{ var msg    = "You have sucessfully removed the "+full_name+" from Profile" }
		else{var msg = "You have sucessfully marked "+full_name+" to display on profile"}

		var html2 = '<div class="addFavHomePop_light" id="addFavBlogPop">'+
								'<div class="poptop-image">'+
									'<div class="userprofile_stars" style="margin-top:-10px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/my_stars.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
									'</div>'+
									'<a href="javascript:void(0);" class="cross_pop_bt" onclick="TB_remove()" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
								'</div>'+
								'<div class="popmiddle-image">'+
									'<div class="frnds_form_blog"><p style="clear:both;">'+msg+'</p><div class="okbtn_blog cursor">'+
											'<div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="" onclick="TB_remove()" />'+
											'</div>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="popbottom-image"></div>'+
							'</div>';

		$('srmboxdiv').set('html', html2);
		TB_show('', '#TB_inline?height=auto&width=460&inlineId=srmboxdiv', '', '{$BASE_REL_URL}images/trans.gif');

		request.send();
	},

	showMyFrndtoHome: function(id,frndid,status,total,limit,full_name){
		var bind = this;
		var starts = parseInt($('startpoint').value);
		
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'userid' : frndid,
				'task'   : 'updatemyfrnd',
				'type'   : status
			},
			'onComplete' : function(ajx){
						
				bind.getMyFriends(id,starts,total,limit);
				//$('startpoint').value = ajx.start;
				//$('mystars').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh');
			}
			
		});
		if(status ==1)
		{ var msg    = "You have sucessfully removed the "+full_name+" from Profile" }
		else{var msg = "You have sucessfully marked "+full_name+" to display on profile"}

		var html2 = '<div class="addFavHomePop_light" id="addFavBlogPop">'+
								'<div class="poptop-image">'+
									'<div class="fanfriends_txtimage_new" style="margin-top:10px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/fan_friends.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
									'</div>'+
									'<a href="javascript:void(0);" class="cross_pop_bt" onclick="TB_remove()" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
								'</div>'+
								'<div class="popmiddle-image">'+
									'<div class="frnds_form_blog"><p style="clear:both;">'+msg+'</p><div class="okbtn_blog cursor">'+
											'<div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="" onclick="TB_remove()" />'+
											'</div>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="popbottom-image"></div>'+
							'</div>';

		$('srmboxdiv').set('html', html2);
		TB_show('', '#TB_inline?height=auto&width=460&inlineId=srmboxdiv', '', '{$BASE_REL_URL}images/trans.gif');

		request.send();
		
	},

	showMyFavotoHome: function(favid,uid,type,status,total,limit,full_name){
		var bind = this;
		var starts = parseInt($('startpoint').value);
		
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'userid' : favid,
				'task'   : 'updatemyfavo',
				'type'   : status
			},
			'onComplete' : function(ajx){
						
				bind.getFavoItems(uid,type,total,limit);
				//$('startpoint').value = ajx.start;
				//$('mystars').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh');
			}
			
		});

		if(status ==1)
		{ var msg    = "You have sucessfully removed the "+full_name+" from Profile" }
		else{var msg = "You have sucessfully marked "+full_name+" to display on profile"}

		var html2 = '<div class="addFavHomePop_light" id="addFavBlogPop">'+
								'<div class="poptop-image">'+
									'<div class="fanfavo_txtimage_new" style="margin-top:10px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/favorite_box.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
									'</div>'+
									'<a href="javascript:void(0);" class="cross_pop_bt" onclick="TB_remove()" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
								'</div>'+
								'<div class="popmiddle-image">'+
									'<div class="frnds_form_blog"><p style="clear:both;">'+msg+'</p><div class="okbtn_blog cursor">'+
											'<div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="" onclick="TB_remove()" />'+
											'</div>'+
										'</div>'+
									'</div>'+
								'</div>'+
								'<div class="popbottom-image"></div>'+
							'</div>';

		$('srmboxdiv').set('html', html2);
		TB_show('', '#TB_inline?height=auto&width=460&inlineId=srmboxdiv', '', '{$BASE_REL_URL}images/trans.gif');
		request.send();
		
	},
	
	 getFavoItems: function(id,type,total,limit){
		var bind = this;
		var starts = parseInt($('startpoint').value);
		$('spnajh').setStyle('display', 'block');

		//var preId = linkId;
		//$('imgajh').setStyle('display', 'none');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'favoid' : id,
				'task'   : 'favorite_items',
				'type'   : type,
				'limit'  : limit,
				'page'   : starts
			},
			'onComplete' : function(ajx){
				
				$('startpoint').value = ajx.start;
				$('favomygallary').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh');
				/*$(preId).removeClass('navdivtext');
				$(preId).removeClass('navdivtext_blue');
				$(linkId).removeClass('navdivtext_blue');
				$(preId).addClass('navdivtext_blue');
				$(linkId).addClass('navdivtext_pink');
				preId = linkId;	*/
				$('spnajh').setStyle('display', 'none');
			}
		});
		request.send();
	},
	
	 SelectTopTenFavoItems: function(id,type,total,limit){
		var bind = this;
		var starts = parseInt($('startpoint').value);
		
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'favoid' : id,
				'task'   : 'selectfavorites',
				'type'   : type,
				'limit'  : limit,
				'page'   : starts
			},
			'onComplete' : function(ajx){
				
				$('startpoint').value = ajx.start;
				$('favomygallary').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh');
				
			}
		});
		request.send();
	},

	getActivityItems: function(id,linkId, total,limit){
		var bind = this;
		var starts = parseInt($('startpoint').value);
		$('spnajh').setStyle('display', 'block');

		//var preId = linkId;

		//$('imgajh').setStyle('display', 'none');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'userid' : id,
				'task'   : 'activity',
				'type'   : linkId,
				'limit'  : limit,
				'page'   : starts,
				'total'  : total
			},
			'onComplete' : function(ajx){
				
				$('startpoint').value = ajx.start;
				$('myactivity').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh');

				/*$(preactId).removeClass('navdivtext');
				$(preactId).removeClass('navdivtext_blue');
				$(linkId).removeClass('navdivtext_blue');
				$(preactId).addClass('navdivtext_blue');
				$(linkId).addClass('navdivtext_pink');
				

				preactId = linkId;*/	
				$('spnajh').setStyle('display', 'none');
			}
		});
		request.send();
	},

	getMyStars: function(id,page,total,limit){

		var bind = this;
		var starts = parseInt($('startpoint').value);

		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'userid' : id,
				'task'   : 'mystars',
				'limit'  : limit,
				'total'  : total,
				'page'   : starts
			},
			'onComplete' : function(ajx){
				
				$('startpoint').value = ajx.start;
				$('mystars').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh');				 
			}
		});
		request.send();
	},
	SelectTopTenStars: function(id,page,total,limit){

		var bind = this;
		var starts = parseInt($('startpoint').value);

		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'userid' : id,
				'task'   : 'selectstars',
				'limit'  : limit,
				'total'  : total,
				'page'   : starts
			},
			'onComplete' : function(ajx){
				
				$('startpoint').value = ajx.start;
				$('mystars').removeClass('mystar');
				$('mystars').addClass('selectTopTenStar');
				$('mystars').set('html', ajx.result);				
				
				bind.hideLoader('ajax-loading2', 'spnajh');				 
			}
		});
		request.send();
	},
	setBoxBg: function(id,starId,divId,countId){

		var bind = this;
		var  totCnt = $(countId).value 

		if($(id).className=="bgblack"){
				if(totCnt >= 10){
					if(countId == "StarIdsCnt"){	
						var msg      = "You cannot select more than ten stars";
						var divclass = "userprofile_stars";
						var divimg   = "my_stars.png";
						var styleVar = "margin-top:-10px;";

					}else if(countId == "FrndIdsCnt"){
						var msg      = "You cannot select more than ten friends";
						var divclass = "fanfriends_txtimage_new";
						var divimg   = "fan_friends.png";
						var styleVar = "margin-top:14px;";
					}
					else if(countId == "FavIdsCnt"){
						var msg      = "You cannot select more than ten favorites";
						var divclass = "fanfavo_txtimage_new";
						var divimg   = "my_favorites.png";
						var styleVar = "margin-top:10px;";
					}

					var html2 = '<div class="addFavHomePop_light" id="addFavBlogPop">'+
												'<div class="poptop-image">'+
													'<div class="'+divclass+'" style="'+styleVar+'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/'+divimg+'\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
													'</div>'+
													'<a href="javascript:void(0);" class="cross_pop_bt" onclick="TB_remove()" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
												'</div>'+
												'<div class="popmiddle-image">'+
													'<div class="frnds_form_blog"><p style="clear:both;">'+msg+'</p><div class="okbtn_blog cursor">'+
															'<div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="" onclick="TB_remove()" />'+
															'</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
												'<div class="popbottom-image"></div>'+
											'</div>';

					$('srmboxdiv').set('html', html2);
					TB_show('', '#TB_inline?height=auto&width=460&inlineId=srmboxdiv', '', '{$BASE_REL_URL}images/trans.gif');
					return false; 
				}
				$(id).className='';
				$(id).addClass('bgblue');	
				$(divId).value=starId;	
				totCnt++;
				$(countId).value  = totCnt;
		}
		else{
				$(id).className='';
				$(id).addClass('bgblack');
				$(divId).value = 0;
				totCnt--;
				$(countId).value  = totCnt;
		}
		return true;
	},
	getMymessage: function(id,page,total,limit){
		
		var bind = this;
		var starts = parseInt($('startpoint').value);

		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'userid' : id,
				'task'   : 'mymessage',
				'limit'  : limit,
				'total'  : total,
				'page'   : starts
			},
			'onComplete' : function(ajx){
				$('startpoint').value = ajx.start;
				$('mymessage').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh');				 
			}
		});
		request.send();
	},
	SelectTopTenFriend: function(id,page,total,limit){

		var bind = this;
		var starts = parseInt($('startpoint').value);

		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'userid' : id,
				'task'   : 'selectfriend',
				'limit'  : limit,
				'total'  : total,
				'page'   : starts
			},
			'onComplete' : function(ajx){
				
				$('startpoint').value = ajx.start;				
				$('myfriends').set('html', ajx.result);				
				
				bind.hideLoader('ajax-loading2', 'spnajh');				 
			}
		});
		request.send();
	},

	getMyFriends: function(id,page,total,limit){
		
		var bind = this;
		var starts = parseInt($('startpoint').value);

		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'userid' : id,
				'task'   : 'myfriends',
				'limit'  : limit,
				'total'  : total,
				'page'   : starts
			},
			'onComplete' : function(ajx){
				$('startpoint').value = ajx.start;
				$('myfriends').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh');				 
			}
		});
		request.send();
	},
	
	hideLoader: function(sclass, id){
		$$('.'+sclass).each(function(_div){
			if(_div.id == id){
				$(_div).setStyle('display', 'none');
			}
		});
	},
	
	prevFriendItems: function(id, total,limit){
		var bind = this;
		var starts = parseInt($('startpoint1').value)-limit;
		$('spnajh1').setStyle('display', 'block');
		$('imgajh1').setStyle('display', 'none');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'favoid' : id,
				'task' : 'friends_items',
				'limit' : limit,
				'start' : starts
			},
			'onComplete' : function(ajx){
				$('startpoint1').value = parseInt(ajx.start);
				$('frndmygallary').set('html', ajx.result);
				if(parseInt(ajx.start) < limit)
				{
					$('prevdiv1').set('html', '<img src="'+jsBaseUrl+'images/spacer.gif" alt="arrow_up" />');
				}
				else
				{
					$('prevdiv1').set('html', '<span class="ajax-loading2" id="spnajh1" style="display:none;"></span><img id="imgajh1" class="favnextprev" onClick="SocialEngine.Favorite.prevFriendItems('+id+', '+total+', '+limit+');" src="'+jsBaseUrl+'images/arrow_up.gif" alt="Previous" />');
				}

				if(parseInt(ajx.start)+limit >= limit)
				{
					$('nextdiv1').set('html', '<span class="ajax-loading2" id="spnajh1" style="display:none;"></span><img id="imgajh1" class="favnextprev" onClick="SocialEngine.Favorite.nextFriendItems('+id+', '+total+', '+limit+');" src="'+jsBaseUrl+'images/arrow_down.gif" alt="Next" />');
				}
				bind.hideLoader('ajax-loading2', 'spnajh1');
			}
		});
		request.send();
	},
	nextFriendItems: function(id, total,limit){
		var bind = this;
		var starts = parseInt($('startpoint1').value)+limit;
		$('spnajh1').setStyle('display', 'block');
		$('imgajh1').setStyle('display', 'none');
			var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {
				'favoid' : id,
				'task' : 'friends_items',
				'limit' : limit,
				'start' : starts
			},
			'onComplete' : function(ajx){
				$('startpoint1').value = ajx.start;
				$('frndmygallary').set('html', ajx.result);
				if(ajx.start >= limit)
				{
					$('prevdiv1').set('html', '<span class="ajax-loading2" id="spnajh1" style="display:none;"></span><img id="imgajh1" class="favnextprev" onClick="SocialEngine.Favorite.prevFriendItems('+id+', '+total+', '+limit+');" src="'+jsBaseUrl+'images/arrow_up.gif" alt="Previous" />');
				}
				if(parseInt(ajx.start)+limit >= total)
				{
					$('nextdiv1').set('html', '<img src="'+jsBaseUrl+'images/spacer.gif" alt="Next" class="float_none" />');
				}
				else
				{
					$('nextdiv1').set('html', '<span class="ajax-loading2" id="spnajh1" style="display:none;"></span><img id="imgajh1" class="favnextprev" onClick="SocialEngine.Favorite.nextFriendItems('+id+', '+total+', '+limit+');" src="'+jsBaseUrl+'images/arrow_down.gif" alt="Next" />');
				}
				bind.hideLoader('ajax-loading2', 'spnajh1');
			}
		});
		request.send();
	},
	
	showAddFriendBox: function(){
		$('adfrnds_Frm').reset();
		$('msgesdiv').empty();
		$('add_frdns_div').setStyle('display', 'block');
	},
	showShareStoryBox: function(){
		$('adfrnds_Frm').reset();
		$('msgesdiv').empty();
		$('add_frdns_div').setStyle('display', 'block');
	},

	showInviteBox: function(){
		$('invite_Frm').reset();
		$('msgesdiv').empty();
		$('log_res').set('html', '<input type="image" src="'+jsBaseUrl+'images/spacer.gif" class="btn_invite" title="Invite" />');
		$('invite_fr').setStyle('display', 'block');
	},
	
	showInviteBox_light: function(){
		$('invite_Frm').reset();
		$('msgesdiv').empty();
		$('log_res').set('html', '<input type="image" src="'+jsBaseUrl+'images/spacer.gif" class="btn_invite" title="Invite" />');
	},

	showInviteBox_light_lala: function(){
		$('invite_Frm').reset();
		$('msgesdiv_lala').empty();
		$('log_res_lala').set('html', '<input type="image" src="'+jsBaseUrl+'images/spacer.gif" class="btn_invite" title="Invite" />');
	},
	showForgetBox: function(ev){
		var bind = this;
		var html1 = '<div class="addFavTopPop_light" id="chg_frnd_new">'+
				'<div class="poptop-image">'+
					'<div class="hdg_image_ret_pass" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/retrieve_password.png\');"><img src="'+jsBaseUrl+'images/spacer.gif" />'+
					'</div>'+
					'<a href="javascript:void(0);" class="cross_pop_bt" onclick="show_light(\'chpasswd\', \'none\'); show_back_light(\'fade\', \'none\');" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'fixed\', src=\''+jsBaseUrl+'images/cross_icon.png\'); float:right; cursor:pointer;"><img src="'+jsBaseUrl+'images/cross_icon.png" alt="cross_icon" width="42" height="42" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a>'+
				'</div>'+
				'<div class="popmiddle-image">'+
					'<div class="frnds_form_blog">'+
						'<div id="errmsg">\
							<div class="formline_black">Can&rsquo;t remember your password?<br /> Enter your email address or username into the box below and we will send your password to you via email.</div>\
						</div><br />\
						<div style="padding-left:50px;">\
							<div id="email" class="retreive_formline_login">\
								<input type="text" class="text w250 float_left" name="user_email" id="user_email" maxlength="70" size="30">\
								<div id="passbutton" class="float_left pl5"><input type="button" onClick="SocialEngine.Favorite.forgetPassword();" src="'+jsBaseUrl+'images/spacer.gif" class="btn_submit cursor" title="Submit" /></div>\
							</div>\
						</div>'+
					'</div>'+
				'</div>'+
				'<div class="popbottom-image"></div>'+
			'</div>';
		$('chpasswd').set('html', html1);
		show_light('chpasswd', 'block'); 
		show_back_light('fade', 'block');
	},
	
	forgetPassword: function(){
		var bind = this;
		$('passbutton').set('html', '');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'lostpass.php',
			'data' : {
				'task' : 'send_email',
				'isjson' : '_jsonFormat',
				'user_email' : $('user_email').value
			},
			'onComplete' : function(ajx){
				if(ajx.result == 1){
					$('errmsg').set('html', 'E-mail successfully sent.');
					$('errmsg').className = 'success2';
					$('passbutton').set('html', '');
					$('email').set('html', '');
					setTimeout(function(){show_light('chpasswd', 'none'); show_back_light('fade', 'none');},3000);
					setTimeout("show_light('chpasswd', 'block')", 3000); 
					setTimeout("show_back_light('fade', 'block')", 3000);
				}
				else{
					$('errmsg').set('html', bind.Base.Language.Translate(ajx.result));
					$('errmsg').className = 'errors2_red';
					$('passbutton').set('html', '<input type="button" onclick="SocialEngine.Favorite.forgetPassword();" src="'+jsBaseUrl+'images/spacer.gif" class="btn_submit1" title="Submit" />');
				}
			}
		});
		request.send();
	},
	
	addFanlist_bla: function(id, nums, full_name, _bools){
		var bind = this;
		var num = nums || '';
		var _bool = _bools || false;
		if(_bool == true){
			$('fmsgdiv_'+num).setStyle('opacity','0.2','filter','alpha(opacity=10)');
		}
		else{
			$('fmsgdiv'+num).set('html', bind.Base.Language.Translate(7005025));
			$('fmsgdiv'+num).className = 'process1';
		}
		// Ajax
		var request = new Request.JSON({
			'method' : 'get',
			'url' : bind.options.ajaxURL,
			'data' : {
				'task' : '_addfans',
				'favoid' : id
			},
			'onComplete' : function(ajx){
				if(ajx.result == 1){
					SocialEngine.Favorite.commonBox('fmsgdiv'+num, full_name, true);
				}
				else if(ajx.result == 2){
					SocialEngine.Favorite.commonBox('fmsgdiv'+num, bind.Base.Language.Translate(7005004), false);
				}
				else{
					SocialEngine.Favorite.commonBox('fmsgdiv'+num, bind.Base.Language.Translate(7005005), false);
				}
			}
		});
		request.send();
	},

	commonBox_bla: function(div, str, bool){
		if(bool){
			var html1 = '<div id="chg_frnd1">\
				<div id="staradded_maincontainer">\
					<div class="popup_continer"><div class="popup_continer1">'+str+' has been added to your<br /> Star List.<div class="okbtn cursor"><div class="float_left" ><img src="'+jsBaseUrl+'images/ok_btn.gif" alt="" onclick="SocialEngine.Favorite.hide1(\''+div+'\', true);" /></div></div></div>\
					<div class="hdg_image"></div>\
					<div class="delete_icon"><div class="float_left" style="display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'.'+jsBaseUrl+'images/delete_icon.png\');"><a href="javascript:void(0);" onclick="SocialEngine.Favorite.hide1(\''+div+'\', true);"><img src="'+jsBaseUrl+'images/delete_icon.png" alt="" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" /></a></div></div>\
				</div>\
			</div>';
		}
		$(div).set('html', html1);
	},

	saveShareStory: function(){
		var chkExt = /\.jpg|\.jpeg|\.gif|\.png/i;
    	var filename = $('story_img').value;
    	if($('star_id').value == ""){
    		$('msgesdiv').set('html', 'Please select Star Name');
			$('msgesdiv').addClass('errors_share');
    		return false;
    	}
		else if($('title').value.trim() == ""){
    		$('msgesdiv').set('html', 'Please fill title field');
			$('msgesdiv').addClass('errors_share');
    		return false;
    	}
		else if($('desc').value.trim() == ""){
    		$('msgesdiv').set('html', 'Please fill description field');
			$('msgesdiv').addClass('errors_share');
    		return false;
    	}
	    /* Checking file type */
		else if (filename.search(chkExt) == -1 && filename != ""){
	    	$('msgesdiv').set('html', 'This extension is not allowed.');
			$('msgesdiv').addClass('errors_share');
	    	$('story_img').value = "";
	        return false;
	    }
		$('log_res').empty();
		$('log_res1').empty();
		$('ajaxframe').src = "user/share_story";
		$('adfrnds_Frm').target = 'ajaxframe';
		$('adfrnds_Frm').submit();
		// $('adfrnds_Frm').reset();
		$('msgesdiv').empty().removeClass('errors_share');
		$('msgesdiv').empty().addClass('success_share');
	},

	shareContent: function(){
		if($('title').value == ""){
    		$('msgtd').set('html', 'Please enter a title');
			$('msgtd').addClass('errors_share_lh25');
    		return false;
    	}
		else if($('url').value == ""){
    		$('msgtd').set('html', 'Please enter an url');
			$('msgtd').addClass('errors_share_lh25');
    		return false;
    	}
		$('log_res').empty().addClass('ajax-loading_report');
		$('ajaxframe').src = "user/share_story";
		$('frm').target = 'ajaxframe';
		$('frm').submit();
		$('frm').reset();
		$('msgtd').empty().className='';
		$('msgtd').addClass('success_share_lh25');
	},

	sendConfirm: function(friend_id){
		$('msgesdiv').empty().addClass('ajax-loading');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'user_friends_manage.php',
			'data' : {
				'friend_id' : friend_id,
				'task' : 'do_confirm'
			},
			'onComplete' : function(ajx){
				$('msgesdiv').removeClass('ajax-loading');
				$('msgesdiv').addClass('success1');
				$('msgesdiv').set('html', ajx.result);
				window.location.reload(false);
			}
		});
		request.send();
	},

	sendReject: function(friend_id){
		$('msgesdiv2').empty().addClass('ajax-loading');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'user_friends_manage.php',
			'data' : {
				'user' : friend_id,
				'task' : 'do_reject_pop'
			},
			'onComplete' : function(ajx){
				$('msgesdiv2').empty().removeClass('ajax-loading');
				$('msgesdiv2').addClass('success1');
				$('msgesdiv2').set('html', ajx.result);
				window.location.reload(false);
			}
		});
		request.send();
	},
	
	reportQuiz: function(id, quizid){
		show_light(id, 'block');
		show_back_light('fade', 'block');
		$('errmsg').empty();
		$('ok_bt_report').set('html', '<input type="image" src="'+jsBaseUrl+'images/report_btn.gif" />');
		$('reportiadiv').set('text', 'Report inappropriate Quiz');
		$('_task').value = 'dosend_quiz_report';
		$('rtype').value = 'quiz';
		$('rtypeid').value = quizid;
		var _txtarea = '<textarea id="report_details" name="report_details" rows="5" cols="30" class="w415">Please let us know what is wrong with this quiz.</textarea>';
		$('txtarea').set('html', _txtarea);
		$('report_details').addEvent('click', function(){
			if($('report_details').value == 'Please let us know what is wrong with this quiz.'){
				$('report_details').value = '';
			}
		});
		$('report_details').addEvent('blur', function(){
			if($('report_details').value == ''){
				$('report_details').value = 'Please let us know what is wrong with this quiz.';
			}
		});
		$('reportFrm').reset();
	},
	reportQuizQuestions: function(id, questionid){
		show_light(id, 'block');
		show_back_light('fade', 'block');
		$('errmsg').empty();
		$('ok_bt_report').set('html', '<input type="image" src="'+jsBaseUrl+'images/report_btn.gif" />');
		$('reportiadiv').set('text', 'Report inappropriate Question');
		$('_task').value = 'dosend_quiz_question_report';
		$('rtype').value = 'quiz_question';
		$('rtypeid').value = questionid;
		var _txtarea = '<textarea id="report_details" name="report_details" rows="5" cols="30" class="w415">Please let us know what is wrong with this question.</textarea>';
		$('txtarea').set('html', _txtarea);
		$('report_details').addEvent('click', function(){
			if($('report_details').value == 'Please let us know what is wrong with this question.'){
				$('report_details').value = '';
			}
		});
		$('report_details').addEvent('blur', function(){
			if($('report_details').value == ''){
				$('report_details').value = 'Please let us know what is wrong with this question.';
			}
		});
		$('reportFrm').reset();
	},
	

	makeScrollbar: function(content, scrollbar, handle, horizontal, ignoreMouse){
		var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y));
		var slider = new Slider(scrollbar, handle, {
			steps: steps,
			wheel:false,
			mode: (horizontal?'horizontal':'vertical'),
			onChange: function(step){
				var x = (horizontal?step:0);
				var y = (horizontal?0:step);
				content.scrollTo(x,y);
			}
		}).set(0);

		if(!(ignoreMouse)){
		$$(content, scrollbar).addEvent('mousewheel', function(e){ 
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;
			slider.set(step);
		});
		}
		$(document.body).addEvent('mouseleave', function(){slider.drag.stop()});
	},
	 getPointLeader: function(userId,username,duration,count,criteria){
		var bind = this;
		//var starts = parseInt($('startpoint').value);
		$('spnajh').setStyle('display', 'block');

		//var preId = linkId;

		//$('imgajh').setStyle('display', 'none');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {				
				'task'     : 'leaderbord',
				'userid'   : userId,
				'username' : username,
				'type'     : duration,
				'total'    : count,
				'where'    : criteria
			},
			'onComplete' : function(ajx){
				
				//$('startpoint').value = ajx.start;
				$('leaderbord').set('html', ajx.result);				
				bind.hideLoader('ajax-loading2', 'spnajh'); 	
				$('spnajh').setStyle('display', 'none');
			}
		});
		request.send();
	},
	 saveVideoWatchAction: function(videoId,userId,ownername){

		var bind = this;

		//$('spnajh').setStyle('display', 'block');
		var request = new Request.JSON({
			'method' : 'get',
			'url' : 'favorites_ajax.php',
			'data' : {				
				'task'     : 'watchvideo',
				'userid'   : userId,
				'videoid'  : videoId,
				'username' : ownername
			},
			'onComplete' : function(ajx){
				
			}
		});
		request.send();
	}

});

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
}

function showHideSelect()
{
	if($('quiz_star_id')){
		if($('quiz_star_id').getStyle('display') == 'none'){
			$('quiz_star_id').setStyle('display', 'block');
		}
		else{
			$('quiz_star_id').setStyle('display', 'none');
		}
	}
}