function getLogin(anchor_link)
{
	window.location.href = '/z/login/login.php?go=' + encodeURIComponent(window.location) + anchor_link;
}

function delete_photo_comment(strURL,strParameter,handler,handler_flg)
{
	if(document.getElementById("post_comment"))
		document.getElementById("post_comment").value = 'N';
	if(document.getElementById("comment_div1"))
		document.getElementById("comment_div1").innerHTML = "";
	if(confirm("Are you sure you want to delete this comment?"))
	{
		xmlhttpPost_makerequest(strURL,strParameter,handler,handler_flg);
	}
}

/**
* Created by Dharmistha on 29/05/2008
**/
function delete_photo_comment_my_comments(strURL,strParameter,handler,handler_flg)
{
	if(confirm("Are you sure you want to delete this comment?"))
	{
		xmlhttpPost_makerequest(strURL,strParameter,handler,handler_flg);
	}
}
function report_abuse_photo_comment(strURL,strParameter,handler,handler_flg)
{
	xmlhttpPost_makerequest(strURL,strParameter,handler,handler_flg);
}

function photo_comment_pagination(strURL,strParameter,handler,handler_flg)
{
	
	if(document.getElementById("post_comment")!=null)
		document.getElementById("post_comment").value = 'N';
	if(document.getElementById("comment_div1"))
		document.getElementById("comment_div1").innerHTML = "";
	xmlhttpPost_makerequest(strURL,strParameter,handler,handler_flg);
}

function textPhotoCommentCounter(field,cntfield,maxlimit) 
{
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
		cntfield.value = 0;
		alert ('You cannot enter more than '+maxlimit+' characters.');
	}
	else
	{
		cntfield.value = maxlimit - field.value.length;
	}
}

function post_photo_comments(strURL,strParameter,handler,handler_flg)
{
	if(document.getElementById("post_comment"))
		document.getElementById("post_comment").value = 'Y';
	var comments = document.getElementById("photo_comment").value;
	if(TrimValue(comments) == "")
	{
		alert("Please post your comment");
		return false;
	}
//	strParameter += "&comments="+encodeURIComponent(comments);
	strParameter += "&comments="+escape(comments);
	handler = "handlerdivInsertPhotoComment('"+ handler + "')";
	xmlhttpPost_makerequest(strURL,strParameter,handler,handler_flg);
}

function handlerdivInsertPhotoComment(handler) 
{
	if(xmlHttpReq.readyState == 4) 
	{
		if(xmlHttpReq.status == 200)
		{
				if(xmlHttpReq.responseText.indexOf("<!--error_login-->") == 0)
				{
					
					document.getElementById(handler+1).innerHTML = xmlHttpReq.responseText;
					window.setTimeout("getLogin('#post_comment')",2000);
				}
				else if(xmlHttpReq.responseText.indexOf("<!--error-->") == 0)
				{
					
					document.getElementById(handler+1).innerHTML = xmlHttpReq.responseText;
				}
				else
				{
					var str_response = xmlHttpReq.responseText;
					var pos = 0;
					pos = str_response.lastIndexOf("<!---->");
					if(pos != -1)
					{
						document.getElementById (handler).innerHTML = str_response.substring(0,pos-1);
						
						
						document.getElementById(handler+1).innerHTML = str_response.substring(pos+7,str_response.length-3);;
					
						
					}
					else
					{
						
						document.getElementById (handler).innerHTML = str_response;
						
						
					}
					document.getElementById("photo_comment").value = "";
					
					document.getElementById("remLen").value = 500;
					
					
					
				}

				
		}
		else
		{
			alert("Error: While trying to fetch records, please try again later");
		}
	}
	else
	{
		document.getElementById(handler+1).innerHTML = "<span id=\"\" valign=\"middle\" align=\"center\"><img src=\"/zones-ssi/js-css-images/adding-comment.gif\" border=\"0\" alt=\"Adding Comment...\"></span>";
		
	}
}


function handlerdivIdSubscribe(handler,type,imageid, memberid, sitename)
{	

	if(timeOutView1)
	{
		window.clearTimeout(timeOutView1);
	}

	if(xmlHttpReq.readyState == 4)
	{
		if(xmlHttpReq.status == 200)
		{
			findPos(document.getElementById('last_div'));
			if(xmlHttpReq.responseText.indexOf("<!--error_login-->") != null && xmlHttpReq.responseText.indexOf("<!--error_login-->") != -1)
			{
				/* show the please wait image untill the setTimeout is called */
				document.getElementById(handler).innerHTML = "<div style=\"padding: 10px;\"><img src=\"/zones-ssi/js-css-images/please-wait.gif\" border=\"0\" alt=\"please wait...\" align=\"absmiddle\"></div>";

				window.setTimeout("getLogin('')",5000);
			}
			else
			{
				document.getElementById(handler).innerHTML = xmlHttpReq.responseText;
				show_layer(handler); 
				findPos(document.getElementById('fade_id'));
				putFocus("comment1");
				if(xmlHttpReq.responseText.indexOf("<!--success-->") != -1)
				{

				if(type == 'Subscribe')
				{
					change_display_string ="<a href=\"#\" class=\"green noborder\" onclick=\"xmlhttpPost_makerequest('"+sitename+"/z/photos/subscribe-action.php','&action=UnSubscribe&image_id="+imageid+"&member_id="+memberid+"','handlerdivIdSubscribe(\\'scrap_details\\',\\'UnSubscribe\\', \\'"+imageid+"\\', \\'"+memberid+"\\', \\'"+sitename+"\\')',3);findPos(document.getElementById('fade_id')); return false;\">Unsubscribe</a> (<a href=\"#\" class=\"green noborder\" onclick=\"showToolTip('photoUnSubscribe'); return false;\" title=\"Click to view what Unsubscribing is\">?</a>)&nbsp;&nbsp;]";

					document.getElementById('idsubscribe').innerHTML = change_display_string;
				}
				else if(type == 'UnSubscribe')
				{
					change_display_string ="<a href=\"#\" class=\"green noborder\" onclick=\"xmlhttpPost_makerequest('"+sitename+"/z/photos/subscribe-layer.php','&action=Subscribe&image_id="+imageid+"&member_id="+memberid+"', 'handlerdivIdSubscribe(\\'scrap_details\\',\\'Subscribe\\', \\'"+imageid+"\\', \\'"+memberid+"\\', \\'"+sitename+"\\')',3); findPos(document.getElementById('fade_id')); return false;\">Subscribe</a> (<a href=\"#\" class=\"green noborder\" onclick=\"showToolTip('photoSubscribe'); return false;\" title=\"Click to view what Subscribing is\">?</a>)&nbsp;&nbsp;]";
					document.getElementById('idsubscribe').innerHTML = change_display_string;
				}
				
					var handlerFun = "clear_n_hide_layer('"+handler+"')";
					if(timeOutView1)
					{
						window.clearTimeout(timeOutView1);
					}
					timeOutView1 = window.setTimeout(handlerFun,10000);
				}
			}
			findPos(document.getElementById('last_div'));
		}
		else
		{
			alert("Error: While trying to fetch records, please try again later");
		}
	}
	else
	{
		display_layer_center(handler);
		document.getElementById(handler).innerHTML = "<div style=\"padding: 10px;\"><img src=\"/zones-ssi/js-css-images/please-wait.gif\" border=\"0\" alt=\"please wait...\" align=\"absmiddle\"></div>";
	}
}//EO
