var result_div;
var session_check = 'heck|||||||||valid|||||||||login';
var session_check_replace = 'check|||||||||valid|||||||||login';
var captcha;
var more_li_id;
var arrow_img;
var playlistId;
var playlistTitle='';

//functions for get codes
function callAjax(path, div_id)
	{
		result_div = div_id;
		new prototype_ajax(path,'ajaxResult');
		return false;
	}

function ajaxResult(data)
	{
		data = unescape(data.responseText);
		var obj = document.getElementById(result_div);
		obj.style.display = 'block';
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				obj.innerHTML = '<span class="clsExpired" id="selExpired" style="align:right;">'+viewphoto_session_expired+'</span>';
				return;
			}
		obj.innerHTML = '<h2><span>'+viewphoto_codes_to_display+'</span></h2>'+'<p class="clsAlignRight" id="close"> <a onClick=codeWindowClose("codeBlock")>'+viewphoto_close_code+'</a></p>'+data;
	}

function RegularExpressionReplace(expression, subject, replaced)
	{
	  var re = new RegExp(expression, "g");
	  return subject.replace(re, replaced);
	}

function changeWidth(max_width_value)
	{

		var width_value = document.formGetCode.image_width.value;
		if(parseInt(max_width_value)>=width_value && (!isNaN(width_value)))
			{
				var expression = 'width="([0-9]+)"';
				var subject = document.formGetCode.image_code.value;
				var replaced = 'width="'+width_value+'"';
				document.formGetCode.image_code.value = RegularExpressionReplace(expression, subject, replaced);
			}
	}

function changeWidthOld()
	{
		var width_value = document.formGetCode.image_width.value;
		if(max_width_value>=width_value && (!isNaN(width_value)))
			{
				var code_value = document.formGetCode.image_code.value;
				var code_arr = code_value.split('width="');
				code_arr[1] = code_arr[1].substring(code_arr[1].indexOf('"'));
				var new_code = code_arr[0]+'width="'+width_value+code_arr[1];
				document.formGetCode.image_code.value = new_code;
			}
	}

function codeWindowClose(div_id)
	{
		var obj = document.getElementById(div_id);
		obj.innerHTML = '';
		obj.style.display = 'none';
	}

//functions for rating
var rate_click = true;
function callAjaxRate(path, div_id)
	{
		if(!rate_click)
			return false;
		rate_click = false;
		result_div = div_id;
		new prototype_ajax(path,'ajaxResultRate');
		setTimeout('changeRatingStatus()',2000);
		return false;
	}
function changeRatingStatus(){
		rate_click = true;
}
function ajaxResultRate(data)
	{
		data = unescape(data.responseText);
		var obj = document.getElementById(result_div);
		obj.style.display = 'block';
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}

		if(data)
			{
				obj.innerHTML = data;
				obj.style.top = getAbsoluteOffsetTopConfirmation(document.getElementById('dAltMulti')) + 'px';
			}
	}
var img_src = new Array();
function mouseOver(count)
	{
		for(var i=1; i<=count; i++)
			{
				var obj = document.getElementById('img'+i);
				img_src[i] = obj.src;
				obj.src = site_url+'design/templates/'+template_default+'/root/images/'+stylesheet_default+'/icon-ratehover.gif';
			}
		for(; i<=total_images; i++)
			{
				var obj = document.getElementById('img'+i);
				img_src[i] = obj.src;
				obj.src = site_url+'design/templates/'+template_default+'/root/images/'+stylesheet_default+'/icon-rate.gif';
			}
	}

function mouseOut(count)
	{
		for(var i=1; i<=total_images; i++)
			{
				var obj = document.getElementById('img'+i);
				obj.src = img_src[i];
			}
	}

//paging(next/previous link)
function callAjaxPaging(path, div_id)
	{
		result_div = div_id;
		new AG_ajax(path,'ajaxResultPaging');
		return false;
	}

function ajaxResultPaging(data)
	{
		data = unescape(data);
		var obj = document.getElementById(result_div);
		obj.style.display = 'block';
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				location.replace(replace_url);
				return;
			}
		data = data.split('***--***!!!');
		captcha = data[1];
		data = data[0].split('+++++--++++!+++++++');
		obj.innerHTML = data[0];
		flagged_status = data[1];
		hideFlaggedContent();
	}
function hideFlaggedContent()
	{
	if(flagged_status=="Yes")
		{
			var obj = '';
			if(obj = document.getElementById('membersAlbums'))
				{
					obj.style.display = 'none';
				}
			var obj = document.getElementById('addFavorite');
			obj.style.display = 'none';
			var obj = document.getElementById('selflaggedContent');
			obj.style.display = 'none';
			var obj = document.getElementById('confirmationDiv');
			obj.style.display = 'block';
		}
	}
function showFlaggedContent()
	{
		var obj = '';
			if(obj = document.getElementById('membersAlbums'))
				{
					obj.style.display = 'block';
				}
		var obj = document.getElementById('addFavorite');
		obj.style.display = 'block';
		var obj = document.getElementById('selflaggedContent');
		obj.style.display = 'block';
		var obj = document.getElementById('confirmationDiv');
		obj.style.display = 'none';
		return false
	}

function callAjaxAddGroups(path, div_id)
	{
		result_div = div_id;
		new prototype_ajax(path,'ajaxResultAddGroups');
		return false;
	}

function ajaxResultAddGroups(data)
	{
		data = unescape(data.responseText);
		var obj = document.getElementById(result_div);
		obj.innerHTML='';
		//obj.style.display = 'block';
		//showHideScreen(result_div);
		hideAjaxTabs(result_div);
		show_ajax_div();
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		obj.innerHTML = data;
		//$(obj).show();
		//obj.style.top = getAbsoluteOffsetTopConfirmation(document.getElementById('dAltMulti')) + 'px';
	}

function restoreFirstValue(id)
	{
		/*var obj = document.getElementById(id);
		obj.style.display = 'none';
		obj.innerHTML = '';*/
		hideAllBlocks();
		return false;
	}

var addToGroup = function()
	{
		if(arguments[1])
			addGroupsUrl = arguments[1];

		var group_ids = '';
		var frm = document.addGroups;
		for (var i=0;i<frm.elements.length;i++)
			{
				var e=frm.elements[i];
				if (e.type=='checkbox' && e.checked)
					{
						group_ids += e.value + ',';
					}
			}
		var currpath = addGroupsUrl+'&group_ids='+group_ids;
		callAjaxUpdateGroups(currpath,'selEditPhotoComments');
		return false
	}

function callAjaxUpdateGroups(path, div_id)
	{
		result_div = div_id;
		new prototype_ajax(path,'ajaxResultUpdateGroups');
	}

function ajaxResultUpdateGroups(data)
	{
		data = unescape(data.responseText);
		var obj = document.getElementById(result_div);
		//obj.style.display = 'block';
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		obj.innerHTML = data;
		//close_ajax_div(result_div);
		hideAnimateBlock(result_div);
		if(result_div == 'flag_content_tab')
			{
				$('flag').value = '';
				$('flag_comment').value = '';
			}
		else if(result_div == 'favorite_content_tab')
			{
				$('selFavoriteLink').hide();
				$('selRemoveFavoriteLink').show();
			}
		//document.getElementById('selFavoriteLink').style.display = 'none';
	}

//favorites
var favorite_count = true;
function callAjaxFavoriteGroups(path, div_id)
	{
		//if(!favorite_count)
		if(0)
			return false;
		result_div = div_id;
		//hideAjaxTabs(result_div);
		new prototype_ajax(path,'ajaxResultAddGroups');
		return false;
	}

var addToFavorite = function()
	{
		if(arguments[1])
			addFavoritesUrl = arguments[1];

		if(arguments[2])
			result_div = arguments[2];

		var favorite_id = '';

		var frm = document.addFavorites;
		for (var i=0;i<frm.elements.length;i++)
			{
				var e=frm.elements[i];
				if (e.type=='checkbox' && e.checked)
					{
						favorite_id += e.value + ',';
					}
			}
		var currpath = addFavoritesUrl+'&favorite_id='+favorite_id;

		if($('selFavoriteLink').style.display == 'none')
			$('selFavoriteLink').show();
		if($('selRemoveFavoriteLink').style.display == 'none')
			$('selRemoveFavoriteLink').hide();

		if(arguments[2])
			callAjaxUpdateGroups(currpath, result_div);
		else
			callAjaxUpdateGroups(currpath,'selEditPhotoComments');

		var obj;
		if(obj = document.getElementById('totalFavorite'))
			obj.innerHTML = parseInt(obj.innerHTML)+1;
		favorite_count = false;

		return false
	}
//flag
function callAjaxFlagGroups(path, div_id)
	{
		result_div = div_id;
		hideAjaxTabs(result_div);
		var div_value = $(result_div).innerHTML.strip();
		//arrow_img = arrow_image_id;
		if((div_value == '') || (div_value == FLAG_SUCCESS_MSG))
			{
				show_ajax_div();
				//$('flag_arrow_img').show();
				$(result_div).innerHTML = '<div class="loader" align="center">&nbsp;</div>';
				new prototype_ajax(path,'ajaxResultAddGroups');
			}
		else
			{
				show_ajax_div();
				//$('flag_arrow_img').show();
			}
		return false;
	}

function callAjaxPostVideoGroups(path, div_id)
	{
		result_div = div_id;
		new AG_ajax(path,'ajaxResultAddGroups');
		return false;
	}

var addToFlag = function()
	{
		if(arguments[1])
			addFlagUrl = arguments[1];

		var flag = '';

		var frm = document.addFlag;
		for (var i=0;i<frm.elements.length;i++)
			{
				var e = frm.elements[i];
				//alert(e.type);
				//if (e.type=='checkbox' && e.checked)
				if (e.name=='flag')
					{
						flag = e.value;
					}
				if(e.type=='textarea')
					{
						flag_comment = e.value;
					}
			}

		var currpath = addFlagUrl+'&flag='+flag+'&flag_comment='+flag_comment;
		//alert(currpath);return;
		callAjaxUpdateGroups(currpath,'flag_content_tab');
		return false
	}

//Add Comments
function callAjaxAddComments(path, div_id)
	{
		restoreFirstValue('selEditMainComments');
		//var obj = document.getElementById('selViewPostComment');
		//obj.style.display = 'none';
		result_div = div_id;
		new AG_ajax(path,'ajaxResultAddComments');
		return false;
	}
function ajaxResultAddComments(data)
	{
		data = unescape(data);
		var obj = document.getElementById(result_div);
		obj.style.display = 'block';
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		data = data.split('***--***!!!');
		obj.innerHTML = data[0];
		captcha = data[1];

	}

var addToComment = function()
	{
		if(arguments[0])
			{
				if(!dontUse)
					addCommentsUrl = arguments[0];
			}


		var f = '';

		var frm = document.addComments;
		for (var i=0;i<frm.elements.length;i++)
			{
				var e=frm.elements[i];
				if (e.type!='button' && e.name!='captcha_value')
					{
						var ovalue = Trim(e.value);
						if(ovalue)
							{
								ovalue = replace_string(ovalue, '\n', '<br />');
								f += ovalue;
							}
						else
							{
								e.value = '';
								e.focus();
								return false;
							}
					}
			}

		if(captcha!=frm.captcha_value.value)
			{
				alert_manual('invalid captcha', 'alertHyperLink', 1000, 500);
				return;
			}
		var currpath = addCommentsUrl+'&f='+encodeURIComponent(f);
		callAjaxComment(currpath,'selCommentBlock');
		return false
	}

var addComment = function()
	{

		var addCommentsUrl = arguments[0];
		var f = '';
		var frm = document.frmPostComments;
		for (var i=0;i<frm.elements.length;i++)
		{
			var e=frm.elements[i];
			if (e.type!='button' && e.name!='captcha_value')
			{
				var ovalue = Trim(e.value);
				if(ovalue)
				{
					ovalue = replace_string(ovalue, '\n', '<br />');
					f += ovalue;
				}
				else
				{
					$('selCommentError').innerHTML=no_comment_error_msg;
					e.value = '';
					e.focus();
					return false;
				}
			}
		}


		if(captcha!=frm.captcha_value.value)
			{
				$('selCaptchaError').innerHTML=invalid_captcha_error_msg;
				return;
			}
		if(!reply_comment_id)
		{
		var currpath = addCommentsUrl+'&f='+encodeURIComponent(f);
		new prototype_ajax(currpath,'ajaxCommentResult');
		}
		else
		{
			var replypath=replyUrl+'&comment_id='+reply_comment_id+'&f='+encodeURIComponent(f);
			new prototype_ajax(replypath,'ajaxCommentResult');
		}
		return false
	}

function ajaxCommentResult(request)
	{
			if(request.responseText != '')
				{
					result = request.responseText;
					result = result.split('|||');
					var commentError =false;
					for(i=0;i<result.length;i++)
						{
							if(common = result[i].split('common_'))
								{
									if(common.length > 1)
										{
											$('selMessage').innerHTML = common[1];
											commentError=true;
										}
								}
							if(comment = result[i].split('comment_'))
								{
									if(comment.length >1)
									{
										$('selCommentError').innerHTML = comment[1];
										commentError=true;
									}
								}
							if(captcha = result[i].split('captcha_'))
								{
									if(captcha.length > 1)
									{
										$('selCaptchaError').innerHTML = captcha[1];
										commentError=true;
									}
								}
						}

					//resetCaptcha('captcha_image','<?php echo $BookmarkList->CFG['site']['url'] .  "captchaSignup.php?captcha_key=" . $BookmarkList->getFormField('captcha_key');?>' );
					$('selCommentBlock').style.display = 'block';
				}

			if(!commentError)
			{
				hideAllBlocks();
			window.location.href = currentUrl;
			}
	}


var addToCommentHoneyPot = function()
	{
		if(arguments[0])
			{
				if(!dontUse)
				addCommentsUrl = arguments[0];
			}

		var f = '';
		var frm = document.addComments;
		for (var i=0;i<frm.elements.length;i++)
			{
				var e=frm.elements[i];
				if (e.type!='button' && e.name!='captcha_value' && e.name!=arguments[1])
					{
						var ovalue = Trim(e.value);
						if(ovalue)
							{
								ovalue = replace_string(ovalue, '\n', '<br />');
								f += ovalue;
							}
						else
							{
								$('selCommentError').innerHTML=no_comment_error_msg;
								e.value = '';
								e.focus();
								return false;
							}
					}
			}
		if(!$(arguments[1]) && $(arguments[1]).value!='')
			{
				alert_manual('Errors Found', 'alertHyperLink', 1000, 500);
				return;
			}
		/*if(!reply_comment_id)
		{
			var currpath = addCommentsUrl+'&f='+encodeURIComponent(f);
			new prototype_ajax(currpath,'ajaxCommentResult');
		}
		else
		{
			var replypath=replyUrl+'&comment_id='+reply_comment_id+'&f='+encodeURIComponent(f);
			new prototype_ajax(replypath,'ajaxCommentResult');
		}*/
		var currpath = addCommentsUrl+'&f='+encodeURIComponent(f);
		//alert(currpath);return;
		callAjaxComment(currpath,'selCommentBlock');
		return false;
	}

	var addToCommentNoCaptcha = function()
	{
		if(arguments[0])
			{
				if(!dontUse)
					addCommentsUrl = arguments[0];
			}

		var f = '';
		var frm = document.frmPostComments;
		for (var i=0;i<frm.elements.length;i++)
			{
				var e=frm.elements[i];
				if (e.type!='button' && e.name!='captcha_value')
					{
						var ovalue = Trim(e.value);
						if(ovalue)
							{
								ovalue = replace_string(ovalue, '\n', '<br />');
								f += ovalue;
							}
						else
							{
								$('selCommentError').innerHTML=no_comment_error_msg;
								e.value = '';
								e.focus();
								return false;
							}
					}
			}

		//var currpath = addCommentsUrl+'&f='+encodeURIComponent(f);
		//alert(currpath);return;
		//callAjaxComment(currpath,'selCommentBlock');
		if(!reply_comment_id)
		{
			var currpath = addCommentsUrl+'&f='+encodeURIComponent(f);
			new prototype_ajax(currpath,'ajaxCommentResult');
		}
		else
		{
			var replypath=replyUrl+'&comment_id='+reply_comment_id+'&f='+encodeURIComponent(f);
			new prototype_ajax(replypath,'ajaxCommentResult');
		}
		return false
	}


function clearComment()
	{
		var obj = document.getElementById('selAddComments');
		obj.style.display = 'none';
		var obj = document.getElementById('selViewPostComment');
		obj.style.display = 'block';
	}

function callAjaxComment(path, div_id)
	{
		//result_div = div_id;
		new prototype_ajax(path,'ajaxResultComment');
		return false;
	}

function ajaxResultComment(data)
	{
		data = unescape(data.responseText);
		var obj = document.getElementById('selCommentBlock');
		obj.style.display = 'block';
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		data = data.split('***--***!!!');
		obj.innerHTML = data[1];
		setEditTimerValue(data[0]);

		//if(obj = document.getElementById('selViewPostComment'))
			//obj.style.display = 'block';
		if(comment_approval){
			if(obj = document.getElementById('totalComments'))
				obj.innerHTML = parseInt(obj.innerHTML)+1;
		}
		captcha = data[2].strip();
		return;
	}


//delete comment
var tr_delete;
function deleteCommand(path, div_id)
	{
		if(confirm(deleteConfirmation))
			{
				tr_delete = div_id;
				new prototype_ajax(path,'deleteResult');
				beforeDeleteResult();
			}
		return false;
	}

function beforeDeleteResult()
	{
		var obj;

		if(obj = document.getElementById(tr_delete))
			obj.style.display = 'none';

		if(obj = document.getElementById(tr_delete+'_1'))
			obj.style.display = 'none';
		if(obj = document.getElementById(tr_delete+'_2'))
			obj.style.display = 'none';
		if(obj = document.getElementById(tr_delete+'_3'))
			obj.style.display = 'none';

		if(obj = document.getElementById('total_comments1'))
			{
				total_comments = parseInt(obj.innerHTML)-1;
				obj.innerHTML = total_comments;
			}

		if(obj = document.getElementById('total_comments2'))
			{
				total_comments = parseInt(obj.innerHTML)-1
				obj.innerHTML = total_comments;
			}

		if(total_comments && total_comments<=minimum_counts)
			{
				if(obj = document.getElementById('view_all_comments'))
					obj.style.display = 'none';
			}

		if(obj = document.getElementById('totalComments'))
			obj.innerHTML = parseInt(obj.innerHTML)-1;
	}

function deleteResult(data)
	{
		return;
	}

//group video comments
function callAjaxAddCommentsGroup(path, div_id)
	{
		result_div = div_id;
		new AG_ajax(path,'ajaxResultAddComments');
		return false;
	}

function clearCommentGroup()
	{
		var obj = document.getElementById('selAddComments');
		obj.style.display = 'none';
	}

//view Video
var downloadCount = true;
function increaseDownload(block_name)
	{
		return true;
		if(!downloadCount)
		return false;

		var obj;
		if(obj = document.getElementById(block_name))
			{
				download_count = download_count+1;
				obj.innerHTML = download_count;
			}
		downloadCount = false;
		return true;
	}

//Reply comment

var addToReply = function()
	{
		var comment_id = arguments[0];

		if(arguments[1])
			{
				if(!dontUse)
					addCommentsUrl = arguments[1];
			}

		var f = '';

		var frm = eval("document.addReply_"+comment_id);
		for (var i=0;i<frm.elements.length;i++)
			{
				var e=frm.elements[i];
				if (e.type!='button')
					{
						var ovalue = Trim(e.value);
						if(ovalue)
							{
								ovalue = replace_string(ovalue, '\n', '<br />');
								f += ovalue;
							}
						else
							{
								e.value = '';
								e.focus();
								return false;
							}
					}
			}
		var currpath = addCommentsUrl+'&comment_id='+comment_id+'&f='+encodeURIComponent(f);
		callAjaxReplyFinal(currpath,'selCommentBlock');
		return false
	}

function callAjaxReplyFinal(path, block)
	{
		path = path;
		new prototype_ajax(path,'ajaxResultReplyFinal');
		return false;
	}

function ajaxResultReplyFinal(data)
	{
		data = unescape(data.responseText);
		var obj = document.getElementById('selCommentBlock');
		obj.style.display = 'block';
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		data = data.split('***--***!!!');
		obj.innerHTML = data[1];
		setEditTimerValue(data[0]);
		return;
	}


function callAjaxReply(path, comment_id)
	{
		//result_div = div_id;
		path = path+'&comment_id='+comment_id;
		new prototype_ajax(path,'ajaxResultReply');
		return false;
	}

function ajaxResultReply(data)
	{
		data = unescape(data.responseText);
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
				data = data.strip();
				data = data.split('***--***!!!');

				var obj = document.getElementById('selAddComments_'+data[0]);
				obj.style.display = 'block';
				obj.innerHTML = data[1];

				obj = document.getElementById('selViewPostComment_'+data[0]);
				obj.style.display = 'none';
				return true;
			}
		return false;
	}

function discardReply(comment_id)
	{
		var obj = document.getElementById('selAddComments_'+comment_id);
		obj.style.display = 'none';
		var obj = document.getElementById('selViewPostComment_'+comment_id);
		obj.style.display = 'block';
	}

/*******for ediit comment functions started***********/
function callAjaxEdit(path, comment_id)
	{
		//result_div = div_id;
		path = path+'&type=edit&comment_id='+comment_id;
		new prototype_ajax(path,'ajaxResultEdit');
		return false;
	}

function ajaxResultEdit(data)
	{
		data = unescape(data.responseText);
		if(data.indexOf(session_check)>=1)
			{
				var obj;
				data=data.split(session_check_replace);
				data=data[1].strip();
				data = data.split('***--***!!!');
				var ids=data[0];
				if(obj = document.getElementById('selEditCommentTxt_'+ids))
					obj.style.display = 'none';

				obj = document.getElementById('selEditComments_'+ids);

				obj.style.display = 'block';
				var txt = replace_string(data[1], '<br>', '\n');
				txt = replace_string(txt, '<br />', '\n');
				txt = trim(txt);
				obj.innerHTML = txt;
				obj = document.getElementById('selViewEditComment_'+ids);
				obj.style.display = 'none';
				return true;
			}
		return false;
	}

function discardEdit(comment_id)
	{
		var obj;

		if(obj = document.getElementById('selEditCommentTxt_'+comment_id))
			obj.style.display = '';

		if(obj = document.getElementById('selEditComments_'+comment_id))
			obj.style.display = 'none';

		if(obj = document.getElementById('selViewEditComment_'+comment_id))
			obj.style.display = '';
	}

var addToEdit = function()
	{
		comment_id = arguments[0];

		if(arguments[1])
			addCommentsUrl = arguments[1];

		var f = '';

		var frm = eval("document.addEdit_"+comment_id);
		for (var i=0;i<frm.elements.length;i++)
			{
				var e=frm.elements[i];
				if (e.type!='button')
					{
						var ovalue = Trim(e.value);
						if(ovalue)
							{
								ovalue = replace_string(ovalue, '\n', '<br />');
								f += ovalue;
							}
						else
							{
								e.value = '';
								e.focus();
								return false;
							}
					}
			}
		f = encodeURIComponent(f);
		var currpath = addCommentsUrl+'&comment_id='+comment_id+'&type=edit&f='+encodeURIComponent(f);
		callAjaxUpdate(currpath,'selCommentBlock');
		return false;
	}

function callAjaxUpdate(path, block)
	{

		path = path;
		new prototype_ajax(path,'callAjaxUpdateResponse');
		return false;
	}

function callAjaxUpdateResponse(data)
	{
		data = unescape(data.responseText);
		if(data.indexOf(session_check)>=1)
			{
				data=data.split(session_check_replace);
				data=data[1];
			}
		else
			{
				return;
			}
		data = data.split('***--***!!!');
		data[0] = data[0].strip();
		if(obj = document.getElementById('selEditCommentTxt_'+data[0]))
			obj.innerHTML = data[1];

		discardEdit(data[0]);
		return;
	}
/************ edit comments end ********/
function changeTimer()
	{
		if(typeof enabled_edit_fields_comment == 'undefined')
			return;
		if(enabled_edit_fields_comment.length)
			{
				doTimerFunction();
				setTimeout('changeTimer()',1000);
			}
	}

function setEditTimerValue(comment_id)
	{
		enabled_edit_fields_comment[enabled_edit_fields_comment.length] = comment_id;
		enabled_edit_fields_time[comment_id] = max_timer;
	}

function doTimerFunction()
	{
		var val;
		var comment_id;
		for(var i in enabled_edit_fields_comment)
			{
				comment_id = enabled_edit_fields_comment[i];
				if(i!='undefined' && i!='has' && i!='find')
					{
						val = enabled_edit_fields_time[comment_id];
						if(val<=1)
							hideDeleteEditLinks(comment_id);
						else if(val!=null)
							decrementTime(comment_id);
					}
			}
	}

function decrementTime(comment_id)
	{
		var obj;
		var val = enabled_edit_fields_time[comment_id];
		if(obj = document.getElementById('selViewTimerComment_'+comment_id))
			{
				obj.innerHTML = val-1;
				obj.innerHTML = obj.innerHTML+' Sec';
			}
		enabled_edit_fields_time[comment_id] = val-1;
	}

function hideDeleteEditLinks(comment_id)
	{
		var obj;
		var val = enabled_edit_fields_time[comment_id];
		if(obj = document.getElementById('selViewDeleteComment_'+comment_id))
			obj.style.display = 'none';
		if(obj = document.getElementById('selViewEditComment_'+comment_id))
			obj.style.display = 'none';
		if(obj = document.getElementById('selViewTimerComment_'+comment_id))
			obj.style.display = 'none';
		if(obj = document.getElementById('cmd'+comment_id))
			obj.className = 'clsNotEditable';
		enabled_edit_fields_time[comment_id] = null;
	}

function hideMoreTabsDivs(current_div)
	{
		for(var i=0; i<more_tabs_div.length; i++)
			{
				if(more_tabs_div[i] != current_div)
					{
						//hideDiv(more_tabs_div[i]);
						$(more_tabs_div[i]).hide();
						setClass(more_tabs_class[i],'');
					}
			}
	}

function showMoreTabsDivs(current_div)
	{
		for(var i=0; i<more_tabs_div.length; i++)
			{
				if(more_tabs_div[i] == current_div)
					{
						//showDiv(current_div);
						$(current_div).show();
						setClass(more_tabs_class[i], current_active_tab_class);
						break;
					}
			}
	}

function getMoreContent(path, div_id, current_li_id)
	{
		var div_value = document.getElementById(div_id).innerHTML;
		result_div = div_id;
		more_li_id = current_li_id;
		div_value = div_value.strip();
		if(div_value == '')
			{
				hideMoreTabsDivs(div_id);
				showMoreTabsDivs(div_id);
				document.getElementById(div_id).innerHTML = '<div class="loader" align="center">&nbsp;</div>';
				new prototype_ajax(path, 'insertMoreTabsContent');
			}
		else
			{
				hideMoreTabsDivs(div_id);
				showMoreTabsDivs(div_id);
			}
	}

function insertMoreTabsContent(data)
	{
		data = unescape(data.responseText);

		var obj = document.getElementById(result_div);
		obj.style.display = 'block';
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		obj.innerHTML = data;
		//$(obj).show();
		//setClass(more_li_id,'clsActiveMoreVideosNavLink');
	}

function close_ajax_div(ajax_content_div)
	{
		//$(result_div).hide();
		//Zapatec.Effects.hide(result_div, 5, 'fade')
		Zapatec.Effects.hide(ajax_content_div, 5, 'fade');
	}

function show_ajax_div()
	{
		//$(result_div).show();
		//fade, slide, glide, wipe, unfurl, grow, shrink, highlight
		Zapatec.Effects.show(result_div, 5, 'fade');
		//slideDiv($(result_div));
	}

function hideAjaxTabs(current_div)
	{
		for(var i=0; i<hide_ajax_tabs.length; i++)
			{
				if(hide_ajax_tabs[i] != current_div)
					{
						$(hide_ajax_tabs[i]).hide();
					}
			}
	}

function callAjaxEmail(path, div_id)
	{
		result_div = div_id;
		new prototype_ajax(path,'ajaxResultEmail');
		return false;
	}

function ajaxResultEmail(data)
	{
		data = unescape(data.responseText);
		var obj = $(result_div);
		hideAjaxTabs(result_div);
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		obj.innerHTML = data;
		show_ajax_div();
	}

function checkFavorite()
	{
		if($('favorite').checked == false)
			$('add_to_favorite').disabled = true;
		else
			$('add_to_favorite').disabled = false;
	}

var removeFromFavorite = function()
	{
		if(arguments[1])
			removeFavoritesUrl = arguments[1];

		if(arguments[2])
			result_div = arguments[2];

		var currpath = removeFavoritesUrl;

		new prototype_ajax(currpath, 'removeFavorite');
		return false
	}

function removeFavorite(data)
	{
		data = unescape(data.responseText);
		var obj = document.getElementById(result_div);
		hideAjaxTabs(result_div);
		//obj.style.display = 'block';

		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		$('selFavoriteLink').show();
		$('selRemoveFavoriteLink').hide();

		obj.innerHTML = data;
		show_ajax_div();
		setTimeout('hideAnimateBlock(result_div)', 5000);
	}

function addToFeatured(path, div_id)
	{
		result_div = div_id;
		new prototype_ajax(path,'ajaxResultFeatured');
		return false;
	}

function ajaxResultFeatured(data)
	{
		data = unescape(data.responseText);
		var obj = document.getElementById(result_div);
		hideAjaxTabs(result_div);
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		$('selFeaturedLink').hide();
		$('selRemoveFeaturedLink').show();
		obj.innerHTML = data;
		show_ajax_div();
		setTimeout('hideAnimateBlock(result_div)', 5000);
	}

var removeFromFeatured = function()
	{
		if(arguments[1])
			removeFeaturedUrl = arguments[1];

		if(arguments[2])
			result_div = arguments[2];

		var currpath = removeFeaturedUrl;

		new prototype_ajax(currpath, 'removeFeatured');
		return false
	}

function removeFeatured(data)
	{
		data = unescape(data.responseText);
		var obj = document.getElementById(result_div);
		hideAjaxTabs(result_div);
		//obj.style.display = 'block';

		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		$('selFeaturedLink').show();
		$('selRemoveFeaturedLink').hide();

		obj.innerHTML = data;
		show_ajax_div(result_div);
		setTimeout('hideAnimateBlock(result_div)', 5000);
	}

function getPlaylist(path, div_id)
	{
		result_div = div_id;
		new prototype_ajax(path,'showPlaylist');
		return false;
	}

function showPlaylist(data)
	{
		data = unescape(data.responseText);
		data = data.strip();
		var obj = document.getElementById(result_div);
		hideAjaxTabs(result_div);
		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		obj.innerHTML = data;
		show_ajax_div();
	}


function chkPlaylist(obj)
	{
		if($(obj).value=="new#")
			{
				$('CreatePlaylist').toggleClassName('clsDisplayNone');
			}
	}

function createPlayList(url)
	{
		$('clsMsgDisplay_playlist').addClassName('clsDisplayNone');
		playlist = $('playlist').value;
		var pars = '';
		if(playlist=="new#")
			{
				title = $('playlistTitle').value;
				var desc = $('playlistDesc').value;
				var tags = $('playlistTags').value;
				var access =$$('.playlistAccess');
				var accessValue='';

				access.each(function(accessRadio)
				{
					if(accessRadio.checked ==true)
						{
							accessValue=accessRadio.value;
						}
				});
				if(title=='' || desc=='' || accessValue=='' || tags=='' )
					{
						$('clsMsgDisplay_playlist').removeClassName('clsDisplayNone');
						$('clsMsgDisplay_playlist').innerHTML = invalidPlaylist;
						return false;
					}
				playlistTitle = title;
				pars = 'playlist_name='+title+'&playlist_description='+desc+'&playlist_tags='+tags+'&playlist_access_type='+accessValue;
			}
		if(playlist != "new#" && playlist)
			{
				pars = 'playlist='+playlist;
				playlistId = playlist;
			}

		if(pars)
			{
				pars = url+'&'+pars
				new prototype_ajax(pars,'ajaxResultPlaylist');
			}
		else
			{
				$('clsMsgDisplay_playlist').removeClassName('clsDisplayNone');
				$('clsMsgDisplay_playlist').innerHTML = selectionError;
			}
	}

function ajaxResultPlaylist(data)
	{
		data = unescape(data.responseText);

		if(data.indexOf(session_check)>=1)
			{
				data = data.replace(session_check_replace,'');
			}
		else
			{
				return;
			}
		if(data.indexOf('#$#')>=1)
			{
				var dataTemp = data.split('#$#');
				data = dataTemp[0];
				playlistId = dataTemp[1];
			}
		$('clsMsgDisplay_playlist').removeClassName('clsDisplayNone');
		if(playlistTitle)
			{
				if(Prototype.Browser.IE)
					{
					    var optn = document.createElement("OPTION");
				    	optn.text = playlistTitle;
					    optn.value = playlistId;
				    	el.options.add(optn);
					}
				else
					{
						document.playlistfrm.reset();
						$('playlist').insert('<option value="'+playlistId+'">'+playlistTitle+'</option>');
						$('playlist').value = playlistId;
						$('CreatePlaylist').addClassName('clsDisplayNone');
					}
			}
		$('clsMsgDisplay_playlist').innerHTML = data;
		$('clsMsgDisplay_playlist').show();
	}


 function test_func(){

 }
