SNI.Community.Toolbox.ie=document.all;
SNI.Community.Toolbox.ns6=document.getElementById&&!document.all;

SNI.Community.Toolbox.dName;
SNI.Community.Toolbox.dCaption;
SNI.Community.Toolbox.dText;
SNI.Community.Toolbox.posted;
SNI.Community.Toolbox.commentsId;
SNI.Community.Toolbox.commentsUserid ;
SNI.Community.Toolbox.userCity;
SNI.Community.Toolbox.userState;
SNI.Community.Toolbox.userCountry;
SNI.Community.Toolbox.userLocation;
SNI.Community.Toolbox.pageLen = 10;	
SNI.Community.Toolbox.totCommentsPages = 0;
SNI.Community.Toolbox.globalPostCommentStatus = true;


SNI.Community.Toolbox.flagTmpDiv = 0;
SNI.Community.Widgets.temp1 = 0;

SNI.Community.Widgets.trim = function(str){
	try{ 
		return str.replace(/^\s*|\s*$/g,'')
	}catch(e){}
}

SNI.Community.Widgets.DA = function(url,callBack)
{
 var locationUrl = document.location+"";
 if(locationUrl.indexOf(":80")==-1 && url.indexOf(":80")!=-1)
 {
 	var temp = url.substring(0,url.indexOf(":80"));
 	var temp1 = url.substring(url.indexOf(":80")+3,url.length);
 	url = temp + temp1;
 } 
 var request=document.all?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
 request.onreadystatechange=function()
 {
  if(request.readyState==4)
  {
   if(request.status==200)
   { 	
         try{eval(callBack);}catch(e){}
   }    
  }
 }
 request.open("POST",url,true);
 request.setRequestHeader("content-type","text/plain;charset=UTF-8");
 request.send(''); 
}

SNI.Community.Widgets.DAPost = function(url,callBack,reqParameters){
	var locationUrl = document.location+"";
	if(locationUrl.indexOf(":80")==-1 && url.indexOf(":80")!=-1){
 		var temp = url.substring(0,url.indexOf(":80"));
 		var temp1 = url.substring(url.indexOf(":80")+3,url.length);
 		url = temp + temp1;
	} 
	var request=document.all?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
 	request.onreadystatechange=function(){
  		if(request.readyState==4){
   			if(request.status==200){ 	
         		try{eval(callBack);}catch(e){}
   			}    
  		}
 	}
	request.open("POST",url,true);
	request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	request.setRequestHeader("Content-length", reqParameters.length);
	request.setRequestHeader("Connection", "close");	
	request.send(reqParameters); 
}

SNI.Community.Widgets.includeCss = function(hrefLink){
	var links = document.getElementsByTagName("link");
	var found = false;
	for(i=0;i<links.length;i++)
	 {
	    var lnk = links[i].href;
	 if(lnk.indexOf(hrefLink)!=-1)
	 {
	   found = true;
	 }
	 }
	 if(!found)
	 {
	  document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\""+hrefLink+"\" />");
	 }
}

SNI.Community.Widgets.numberFormat = function(nStr,prefix)
{
  			var prefix = prefix || '';
  			nStr += '';
  			x = nStr.split('.');
  			x1 = x[0];
  			x2 = x.length > 1 ? '.' + x[1] : '';

  			var rgx = /(\d+)(\d{3})/;
  			while (rgx.test(x1))
      			x1 = x1.replace(rgx, '$1' + ',' + '$2');

  			return prefix + x1 + x2;
}

SNI.Community.Widgets.isEmail = function(obj)
{
	var string = obj.value
	var emailerror=false;
	if (SNI.Community.Widgets.trim(string).search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	{
		emailerror=false;
	}
	else
	{
		emailerror=true;
		//alert('Enter Valid User Name !!!');
		obj.focus();
		obj.select();
	}
	return emailerror;
}

SNI.Community.Widgets.replaceAll = function(OldString,FindString,ReplaceString)
{
	var SearchIndex = 0;
	var NewString = ""; 
	while (OldString.indexOf(FindString,SearchIndex) != -1)  
	  {
 		NewString += OldString.substring(SearchIndex,OldString.indexOf(FindString,SearchIndex));
 		NewString += ReplaceString;
 		SearchIndex = (OldString.indexOf(FindString,SearchIndex) + FindString.length);         
	}
	NewString += OldString.substring(SearchIndex,OldString.length);
	return NewString;
}





SNI.Community.Widgets.Set_Cookie = function( name, value, expires, path, domain, secure ) 
{
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24 * 1000;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );	

}

SNI.Community.Widgets.Get_Cookie = function( name ) {
	var start = document.cookie.indexOf( name + "=" );
	
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

SNI.Community.Widgets.Delete_Cookie =  function( name, path, domain ) {
	if ( SNI.Community.Widgets.Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

SNI.Community.Widgets.setPickleCookie = function(type,itemid)
{
	var currval = SNI.Community.Widgets.Get_Cookie(type);	
	if(currval){
	 SNI.Community.Widgets.Delete_Cookie(type, '/', '');
	 currval = currval + ',' + itemid ;
	}
	else{
	 currval = itemid;
	}
	SNI.Community.Widgets.Set_Cookie( type,currval, '365', '/', '', '' );
}

SNI.Community.Widgets.displayOn = function(objId){
	if( document.getElementById(objId) ){
		document.getElementById(objId).style.display = "block";
	}
}

SNI.Community.Widgets.displayOff = function(objId){
	if( document.getElementById(objId) ){
		document.getElementById(objId).style.display = "none";
	}
}

SNI.Community.Widgets.layerOn = function(objId){
	if( document.getElementById(objId) ){
		document.getElementById(objId).style.visibility = "visible";
	}
}

SNI.Community.Widgets.layerOff = function(objId){
	if( document.getElementById(objId) ){
		document.getElementById(objId).style.visibility = "hidden";
	}
}

SNI.Community.Widgets.ismaxlength = function(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";
	if (obj.getAttribute && obj.value.length>mlength){
	obj.value=obj.value.substring(0,mlength)
		obj.scrollLeft = obj.scrollWidth;
		obj.scrollTop = obj.scrollHeight;
	}
}


SNI.Community.Widgets.changeText = function(odjId)
{
	document.getElementById(odjId).className = 'error-field';	
}
SNI.Community.Widgets.changeBack = function(odjId)
{
	document.getElementById(odjId).className = '';
}	
	
SNI.Community.Widgets.showCommentsPopUp_cp = function(){
	SNI.Community.Widgets.displayOn('pcw-ttop');
	SNI.Community.Widgets.displayOff('pcw-ttopa');
}

/*
SNI.Community.Toolbox.checkandshow = function()
{
	secureComponent("SNI.Community.Widgets.displayOn('com-add-comment'); SNI.Community.Widgets.layerOff('cgp-id-comment-ad');","You Need To Be Signed In To Do That.");
}
*/

SNI.Community.Widgets.showCommentsPopUp = function(){
	SNI.Community.Widgets.displayOn('com-add-comment'); 
	SNI.Community.Widgets.layerOff('cgp-id-comment-ad');
}
SNI.Community.Widgets.drawVotingWidgets = function()
{
	if(document.getElementById('toolbox-v-05_'+SNI.Community.Toolbox.cAssetId))
	{
		//utilizing the decorator widget js methods
		
		SNI.Community.Toolbox.executeCode = "renderVote('toolbox-v-05_"+SNI.Community.Toolbox.cAssetId+"','votingType3','"+SNI.Community.Toolbox.cAssetId+"','"+SNI.Community.Toolbox.csoFarVoteval+"','"+SNI.Community.Toolbox.cGlobalUserId+"','"+SNI.Community.Toolbox.cObjectType+"','"+escape(SNI.Community.Toolbox.cAssetUrl)+"','"+SNI.Community.Toolbox.cWidgetNameUsedInApp+"','"+SNI.Community.Toolbox.cGlobalOrigWidgetProjectId+"');";
		//renderVote('toolbox-v-05_'+SNI.Community.Toolbox.cAssetId,"votingType3",SNI.Community.Toolbox.cAssetId,SNI.Community.Toolbox.csoFarVoteval,SNI.Community.Toolbox.cGlobalUserId,SNI.Community.Toolbox.cObjectType,SNI.Community.Toolbox.cAssetUrl);
	}
	if(document.getElementById('toolbox-v-03_'+SNI.Community.Toolbox.cAssetId))
	{
		//utilizing the decorator widget js methods
		
		SNI.Community.Toolbox.executeCode += "renderVote('toolbox-v-03_"+SNI.Community.Toolbox.cAssetId+"','votingType6','"+SNI.Community.Toolbox.cAssetId+"','"+SNI.Community.Toolbox.csoFarVoteval+"','"+SNI.Community.Toolbox.cGlobalUserId+"','"+SNI.Community.Toolbox.cObjectType+"','"+escape(SNI.Community.Toolbox.cAssetUrl)+"','"+SNI.Community.Toolbox.cWidgetNameUsedInApp+"','"+SNI.Community.Toolbox.cGlobalOrigWidgetProjectId+"');";
		//renderVote('toolbox-v-03_'+SNI.Community.Toolbox.cAssetId,"votingType6",SNI.Community.Toolbox.cAssetId,SNI.Community.Toolbox.csoFarVoteval,SNI.Community.Toolbox.cGlobalUserId,SNI.Community.Toolbox.cObjectType,SNI.Community.Toolbox.cAssetUrl);
	}
	try{
		renderMethods();
	}catch(e){}	
}
SNI.Community.Widgets.afterPost = function(request)
{
	try{
		document.getElementById('commentsshell').innerHTML=request.responseText;
	}catch(e){}
	
	try{
		SNI.Community.Widgets.drawVotingWidgets();
	}catch(e){}
	
	if(document.getElementById('totcom'))
	{
		var count = SNI.Community.Widgets.numberWithCommas(document.getElementById('totcom').value);
		//var counth2Text =  document.getElementById('counth2').innerHTML;
		var counth2Text =  SNI.Community.Toolbox.cGlobalCounterText;			
		if(counth2Text.indexOf("(")!=-1)
			counth2Text = counth2Text.substring(0,counth2Text.indexOf("("));
		if(document.getElementById('counth2')){
			if(parseInt(count)==1)
				document.getElementById('counth2').innerHTML = counth2Text+" ("+count+" Comment)";
			else
				document.getElementById('counth2').innerHTML = counth2Text+" ("+count+" Comments)";
		}		
		if(document.getElementById('comment_count_header')){
			if(parseInt(count)==1)
				document.getElementById('comment_count_header').innerHTML = counth2Text+" ("+count+" Comment)";
			else
				document.getElementById('comment_count_header').innerHTML = counth2Text+" ("+count+" Comments)";
		}
	}	
}
//Added New function to keep commas to numbers in the thousands for Pickle issue 2425
SNI.Community.Widgets.numberWithCommas = function(value) {
	//alert("valuecommetnsjs"+value);
    return value.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
}
//Changes Ends here

SNI.Community.Widgets.reloadcomments = function(url)
{
	SNI.Community.Widgets.DA(url,"SNI.Community.Widgets.afterPost(request)");
}

SNI.Community.Widgets.reloadcommentsInternal = function(url,reqParams)
{
	var d2cURL = "";
    if(document.getElementById("gDetailPageURL")){
    	d2cURL = document.getElementById("gDetailPageURL").value+"&";
    }
	reqParams += "&dp="+escape(d2cURL);
	SNI.Community.Widgets.DAPost(url,"SNI.Community.Widgets.afterPost(request)",reqParams);
}

SNI.Community.Widgets.moveToPageInternal = function(val)
{
	var url2 = "";
	var reqParams = "";
	var pageSize = 5;
	var commentsLayoutName = '';
	if(SNI.Community.Toolbox.ur){
		commentsLayoutName = 'internal';
	}else{
		commentsLayoutName = 'internalnonur';
	}
	if( SNI.Community.Toolbox.cCommentsLayoutName != '' && SNI.Community.Toolbox.cCommentsLayoutName != undefined && SNI.Community.Toolbox.cCommentsLayoutName != 'undefined' ){
		commentsLayoutName = SNI.Community.Toolbox.cCommentsLayoutName;
	}
	
	if(SNI.Community.Toolbox.ur){
		url2 = SNI.Community.Toolbox.rootUrl+"/getcommentscommon.do";
		reqParams = "pageSize="+pageSize+"&page="+val+"&layout="+commentsLayoutName+"&nonur=false&id="+SNI.Community.Toolbox.cSelectedId+"&wid="+SNI.Community.Toolbox.cWidInsId;
	}else{
		url2 = SNI.Community.Toolbox.rootUrl+"/getcommentscommon.do";
    reqParams = "pageSize="+pageSize+"&page="+val+"&layout="+commentsLayoutName+"&nonur=true&id="+SNI.Community.Toolbox.cSelectedId+"&wid="+SNI.Community.Toolbox.cWidInsId;
	}
	SNI.Community.Widgets.reloadcommentsInternal(url2,reqParams);
	return false;
}
//Added newly for RMR bottom button for pickle-2476
SNI.Community.Widgets.postInternalComment_bottom = function(Config)
{
	var comment_id_name 	= "commenttext";
	var text_div_id_name 	= "com-add-comment";
	var addbtn_id_name 		= "com-add-button-container";
	var postbtn_id_name 	= "com-post-comment-content";
	var addbtn_id_name_cnt		= "com-add-button-container02";
	
	if(typeof(config) != "undefined") {
		comment_id_name		= config.comment_id_name;
		text_div_id_name 	= config.text_div_id_name;
		addbtn_id_name 		= config.addbtn_id_name;
		postbtn_id_name 	= config.postbtn_id_name; 
		addbtn_id_name_cnt		= config.addbtn_id_name_cnt;
	}
	if(SNI.Community.Toolbox.globalPostCommentStatus==false){
		return;
	}
	
	if(document.getElementById("ispv")){
		//isPVProject = true;
		SNI.Community.Toolbox.cSelectedId = document.getElementById("gObjId").value;
	} 
		
	var userInfo = "";
	var userId = SNI.Community.Toolbox.cGlobalUserId;
	var yournameVal = SNI.Community.Toolbox.cGlobalUserDisplayName;		
	var yourEmailVal = SNI.Community.Toolbox.cGlobalUserEmail;
	var commenttext = document.getElementById('commenttext_btm').value;
	var modFlag = document.getElementById('moderationFlag').value;
	
	var nonurSiteId = SNI.Community.Toolbox.cSiteId;
	var nonurWid = SNI.Community.Toolbox.cWidInsId;
	var nonurCId = SNI.Community.Toolbox.cCollId;
	
	var oc = "";
	try{
		oc = document.getElementById("objCaption_h1").innerHTML;
	}catch(e){oc = $('.title').html();}
	oc = oc.replace(/&nbsp;/gi, "&");
	var wpid = document.getElementById("wpid").value;
	var projectname = document.getElementById("wp_pro_name").value;
	var projectId = document.getElementById("wpid_hid").value;
	var channelName = SNI.Community.channelName;
  var totalComments = document.getElementById("totcom").value;
  var pageSize = document.getElementById("pageSize").value;
  
	if(SNI.Community.Widgets.Get_Cookie('AJAX_LOGIN_RESPONSE'))
	{
	   userInfo = SNI.Community.Widgets.Get_Cookie('AJAX_LOGIN_RESPONSE').split("||");
	   if(userInfo.length>0){
		userId = userInfo[0];
		yourEmailVal = userInfo[1];
		yournameVal = userInfo[2];
	   }
	}else if(SNI.Community.Widgets.Get_Cookie('picklecookie')){
		userInfo = SNI.Community.Widgets.Get_Cookie('picklecookie').split(",");
		  if(userInfo.length>0)
		  {
		  	yournameVal = userInfo[6];
		  	yourEmailVal = userInfo[1];
		  	userId = userInfo[0];
		  }
	}
	userId = userId.replace('"','');	
	
	if(SNI.Community.Widgets.trim(commenttext)!=''){
		commenttext =encodeURIComponent(commenttext);
	}else if(commenttext == ''){
		alert("Please enter a comment.");
		return;
	}else if(document.getElementById(comment_id_name).value.length > 1000){
		alert("Please limit comments to 1000 characters.");
		return;
	}

	SNI.Community.Widgets.displayOff('com-add-button-container_btm02'); 
	SNI.Community.Widgets.displayOn('com-add-button-container_btm03');
	SNI.Community.Widgets.displayOff('com-post-comment-content_btm02');	
	SNI.Community.Widgets.displayOff('com-post-comment-content_btm'); 
	SNI.Community.Widgets.displayOn('com-post-comment-content_btm02');
	
	/*SNI.Community.Widgets.displayOff('com-post-comment-content_btm02');
	SNI.Community.Widgets.displayOn('com-add-button-container_btm03'); 
	SNI.Community.Widgets.displayOff('com-post-comment-content');
	SNI.Community.Widgets.displayOn('com-add-button-container_btm02');*/
	
	
	var request=SNI.Community.Toolbox.ie?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
	
	var url=  SNI.Community.Toolbox.rootUrl+"/postcomment.do";
	var url2 = SNI.Community.Toolbox.rootUrl+"/getcommentscommon.do";
	
	var commentsLayoutName = '';
	if(SNI.Community.Toolbox.ur){
		commentsLayoutName = 'internal';
	}else{
		commentsLayoutName = 'internalnonur';
	}
	if( SNI.Community.Toolbox.cCommentsLayoutName != '' && SNI.Community.Toolbox.cCommentsLayoutName != undefined && SNI.Community.Toolbox.cCommentsLayoutName != 'undefined' ){
		commentsLayoutName = SNI.Community.Toolbox.cCommentsLayoutName;
	}	
	
	var url2ReqParams = "page=1&layout="+commentsLayoutName+"&nonur=false&id="+escape(SNI.Community.Toolbox.cSelectedId)+"&wid="+nonurWid+"&modflg="+modFlag+"&proname="+projectname + "&proid=" + projectId+"&oc="+oc;
	//var reqParameters = "nonur=false&user_name="+escape(yournameVal)+"&user_email="+yourEmailVal+"&comment="+commenttext+"&object_id="+escape(SNI.Community.Toolbox.cSelectedId)+"&user_id="+userId+"&site_id="+nonurSiteId+"&wid="+nonurWid+"&collectionsId="+nonurCId+"&sourceurl="+escape(document.location)+"&oc="+oc+"&wpid="+wpid+"&channelName="+channelName;
	var reqParameters = "nonur=false&user_name="+escape(yournameVal)+"&user_email="+escape(yourEmailVal)+"&comment="+commenttext+"&object_id="+escape(SNI.Community.Toolbox.cSelectedId)+"&site_id="+escape(nonurSiteId)+"&wid="+escape(nonurWid)+"&collectionsId="+escape(nonurCId)+"&sourceurl="+escape(document.location)+"&oc="+oc+"&wpid="+escape(wpid)+"&channelName="+escape(channelName)+"&modflg="+modFlag+"&proname="+projectname + "&proid=" + projectId;
    reqParameters += "&totalComments="+totalComments+"&pageSize="+pageSize;
  
	SNI.Community.Toolbox.globalPostCommentStatus = false;
	
	request.onreadystatechange=function()
	{	
		
		if(request.readyState==4)
		{	
			if(request.status==200)
			{	
				if(modFlag == 1) {
					var cmtId = request.responseText;	
					SNI.Community.Toolbox.globalPostCommentStatus = true;
					document.getElementById(comment_id_name).value = '';	
					if(document.getElementById('commentcaption') != null) {
						document.getElementById('commentcaption').value = '';
					}			
			   	 	SNI.Community.Widgets.displayOff('com-add-comment_btm');

					SNI.Community.Widgets.displayOn('com-add-button-container_btm02'); 
					SNI.Community.Widgets.displayOff('com-add-button-container_btm03');
					SNI.Community.Widgets.displayOn('com-post-comment-content_btm02');	
					SNI.Community.Widgets.displayOn('com-post-comment-content_btm'); 
					SNI.Community.Widgets.displayOff('com-post-comment-content_btm02');

					SNI.Community.Toolbox.getComment(userId,nonurSiteId,cmtId);		



				} else {
					SNI.Community.Toolbox.globalPostCommentStatus=true;
					SNI.Community.Widgets.reloadcommentsInternal(url2,url2ReqParams);
				} 
				
			}else if(request.status==12152){
				SNI.Community.Toolbox.globalPostCommentStatus=true;
				SNI.Community.Widgets.reloadcommentsInternal(url2,url2ReqParams); 
			}
			else if(request.status==500)
			{
				SNI.Community.Toolbox.globalPostCommentStatus=true;	
				alert("You found an opportunity for improvement! Please try again later");
			}
			else{
				SNI.Community.Toolbox.globalPostCommentStatus=true;
				SNI.Community.Widgets.reloadcommentsInternal(url2,url2ReqParams);
			}	
		}
	}
	request.open("POST",url,true);
	request.setRequestHeader("content-type","application/x-www-form-urlencoded");
	request.send(reqParameters);
			
}

SNI.Community.Widgets.postInternalComment = function()
{
	if(SNI.Community.Toolbox.globalPostCommentStatus==false){
		return;
	}
	
	if(document.getElementById("ispv")){
		//isPVProject = true;
		SNI.Community.Toolbox.cSelectedId = document.getElementById("gObjId").value;
	} 
		
	var userInfo = "";
	var userId = SNI.Community.Toolbox.cGlobalUserId;
	var yournameVal = SNI.Community.Toolbox.cGlobalUserDisplayName;		
	var yourEmailVal = SNI.Community.Toolbox.cGlobalUserEmail;
	var commenttext = document.getElementById("commenttext").value;
	var modFlag = document.getElementById('moderationFlag').value;
	
	var nonurSiteId = SNI.Community.Toolbox.cSiteId;
	var nonurWid = SNI.Community.Toolbox.cWidInsId;
	var nonurCId = SNI.Community.Toolbox.cCollId;
	
	var oc = "";
	try{
		oc = document.getElementById("objCaption_h1").innerHTML;
	}catch(e){oc = $('.title').html();}
	oc = oc.replace(/&nbsp;/gi, "&");
	var wpid = document.getElementById("wpid").value;
	var projectname = document.getElementById("wp_pro_name").value;
	var projectId = document.getElementById("wpid_hid").value;
	var channelName = SNI.Community.channelName;
  var totalComments = document.getElementById("totcom").value;
  var pageSize = document.getElementById("pageSize").value;
  
	if(SNI.Community.Widgets.Get_Cookie('AJAX_LOGIN_RESPONSE'))
	{
	   userInfo = SNI.Community.Widgets.Get_Cookie('AJAX_LOGIN_RESPONSE').split("||");
	   if(userInfo.length>0){
		userId = userInfo[0];
		yourEmailVal = userInfo[1];
		yournameVal = userInfo[2];
	   }
	}else if(SNI.Community.Widgets.Get_Cookie('picklecookie')){
		userInfo = SNI.Community.Widgets.Get_Cookie('picklecookie').split(",");
		  if(userInfo.length>0)
		  {
		  	yournameVal = userInfo[6];
		  	yourEmailVal = userInfo[1];
		  	userId = userInfo[0];
		  }
	}
	userId = userId.replace('"','');	
	
	if(SNI.Community.Widgets.trim(commenttext)!=''){
		commenttext =encodeURIComponent(commenttext);
	}else if(commenttext == ''){
		alert("Please enter a comment.");
		return;
	}else if(document.getElementById('commenttext').value.length > 1000){
		alert("Please limit comments to 1000 characters.");
		return;
	}

	SNI.Community.Widgets.displayOn('com-post-comment-content02');
	SNI.Community.Widgets.displayOff('com-post-comment-content'); 
	SNI.Community.Widgets.displayOn('com-add-button-container02');
	SNI.Community.Widgets.displayOff('com-add-button-container');
	
	var request=SNI.Community.Toolbox.ie?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
	
	var url=  SNI.Community.Toolbox.rootUrl+"/postcomment.do";
	var url2 = SNI.Community.Toolbox.rootUrl+"/getcommentscommon.do";
	
	var commentsLayoutName = '';
	if(SNI.Community.Toolbox.ur){
		commentsLayoutName = 'internal';
	}else{
		commentsLayoutName = 'internalnonur';
	}
	if( SNI.Community.Toolbox.cCommentsLayoutName != '' && SNI.Community.Toolbox.cCommentsLayoutName != undefined && SNI.Community.Toolbox.cCommentsLayoutName != 'undefined'){
		commentsLayoutName = SNI.Community.Toolbox.cCommentsLayoutName;
	}	
	
	var url2ReqParams = "page=1&layout="+commentsLayoutName+"&nonur=false&id="+escape(SNI.Community.Toolbox.cSelectedId)+"&wid="+nonurWid+"&modflg="+modFlag+"&proname="+projectname + "&proid=" + projectId+"&oc="+oc;
	//var reqParameters = "nonur=false&user_name="+escape(yournameVal)+"&user_email="+yourEmailVal+"&comment="+commenttext+"&object_id="+escape(SNI.Community.Toolbox.cSelectedId)+"&user_id="+userId+"&site_id="+nonurSiteId+"&wid="+nonurWid+"&collectionsId="+nonurCId+"&sourceurl="+escape(document.location)+"&oc="+oc+"&wpid="+wpid+"&channelName="+channelName;
	var reqParameters = "nonur=false&user_name="+escape(yournameVal)+"&user_email="+escape(yourEmailVal)+"&comment="+commenttext+"&object_id="+escape(SNI.Community.Toolbox.cSelectedId)+"&site_id="+escape(nonurSiteId)+"&wid="+escape(nonurWid)+"&collectionsId="+escape(nonurCId)+"&sourceurl="+escape(document.location)+"&oc="+oc+"&wpid="+escape(wpid)+"&channelName="+escape(channelName)+"&modflg="+modFlag+"&proname="+projectname + "&proid=" + projectId;
    reqParameters += "&totalComments="+totalComments+"&pageSize="+pageSize;
  
	SNI.Community.Toolbox.globalPostCommentStatus = false;
	
	request.onreadystatechange=function()
	{	
		
		if(request.readyState==4)
		{	
			if(request.status==200)
			{
				
				if(modFlag == 1) {
					var cmtId = request.responseText;	
					SNI.Community.Toolbox.globalPostCommentStatus = true;
					document.getElementById('commenttext').value = '';	
					if(document.getElementById('commentcaption') != null) {
						document.getElementById('commentcaption').value = '';
					}			
					SNI.Community.Toolbox.getComment(userId,nonurSiteId,cmtId);		
					SNI.Community.Widgets.displayOff('com-post-comment-content02');
					SNI.Community.Widgets.displayOn('com-post-comment-content');	
					SNI.Community.Widgets.displayOff('com-add-button-container02');
					SNI.Community.Widgets.displayOn('com-add-button-container');
				} else {
					SNI.Community.Toolbox.globalPostCommentStatus=true;
					SNI.Community.Widgets.reloadcommentsInternal(url2,url2ReqParams);
				} 
				
			}else if(request.status==12152){
				SNI.Community.Toolbox.globalPostCommentStatus=true;
				SNI.Community.Widgets.reloadcommentsInternal(url2,url2ReqParams); 
			}
			else if(request.status==500)
			{
				SNI.Community.Toolbox.globalPostCommentStatus=true;	
				alert("You found an opportunity for improvement! Please try again later");
			}
			else{
				SNI.Community.Toolbox.globalPostCommentStatus=true;
				SNI.Community.Widgets.reloadcommentsInternal(url2,url2ReqParams);
			}	
		}
	}
	request.open("POST",url,true);
	request.setRequestHeader("content-type","application/x-www-form-urlencoded");
	request.send(reqParameters);
			
}


SNI.Community.Widgets.postInternalNonUrComment = function()
{
	if(SNI.Community.Toolbox.globalPostCommentStatus==false){
		return;
	}

	if(document.getElementById("ispv")){
		//isPVProject = true;
		SNI.Community.Toolbox.cSelectedId = document.getElementById("gObjId").value;
	} 
	
	//1,nishant@one-i.net,0,null,null,Sys_Admin
	var userInfo = "";
	var userId = SNI.Community.Toolbox.cGlobalUserId;
	var yournameVal = document.getElementById("commentYourName").value;		
	var yourEmailVal = document.getElementById("commentEmail").value;
	var commenttext = document.getElementById("commenttext").value;
	var emailCheck = SNI.Community.Widgets.isEmail(document.getElementById("commentEmail"));
	var modFlag = document.getElementById('moderationFlag').value;
	var projectname = document.getElementById("wp_pro_name").value;
	var projectId = document.getElementById("wpid_hid").value;
	var oc = document.getElementById("objCaption_h1").innerHTML;
  var totalComments = document.getElementById("totcom").value;
  var pageSize = document.getElementById("pageSize").value;
	oc = oc.replace(/&nbsp;/gi, "&");
	var cmttext = '';
	if(commenttext!=''){
		cmttext = commenttext;
		commenttext =encodeURIComponent(commenttext);		
	}

	if(SNI.Community.Widgets.trim(commenttext) == ''){
	   alert("Please enter a comment.");
	   return;
	}else if(document.getElementById('commenttext').value.length > 1000){
	   alert("Please limit comments to 1000 characters.");
	   return;
	}else if(SNI.Community.Widgets.trim(yournameVal) == ''){
	   alert("Please enter your name.");
	   return;
	}else if(SNI.Community.Widgets.trim(yourEmailVal) == ''){
	   alert("Please enter your e-mail address.");
	   return;
	}else if(emailCheck==true){
	     alert("Please enter a valid e-mail address.");
	     return;
	}		
	userId = userId.replace('"','');	
	var nonurSiteId = SNI.Community.Toolbox.cSiteId;
	var nonurWid = SNI.Community.Toolbox.cWidInsId;
	var nonurCId = SNI.Community.Toolbox.cCollId;
	
	var wpid = document.getElementById("wpid").value;
	
	var request=SNI.Community.Toolbox.ie?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
	
	var url= baseUrl + "postcommentnonur.do";
	var url2 = SNI.Community.Toolbox.rootUrl+"/getcommentscommon.do";
	var url2ReqParams = "page=1&layout=internalnonur&nonur=true&id="+SNI.Community.Toolbox.cSelectedId+"&wid="+nonurWid+"&modflg="+modFlag+"&proname="+projectname + "&proid=" + projectId +"&oc="+oc;
	var reqParameters = "nonur=true&user_name="+escape(yournameVal)+"&user_email="+yourEmailVal+"&comment="+commenttext+"&object_id="+SNI.Community.Toolbox.cSelectedId+"&user_id="+userId+"&site_id="+nonurSiteId+"&wid="+nonurWid+"&collectionsId="+nonurCId+"&sourceurl="+escape(document.location)+"&modflg="+modFlag +"&proname="+projectname + "&proid=" + projectId+"&oc="+oc;
	reqParameters += "&wpid="+wpid+"&totalComments="+totalComments+"&pageSize="+pageSize;
	
	SNI.Community.Widgets.displayOn('com-noURpost-comment-content02');
	SNI.Community.Widgets.displayOff('com-noURpost-comment-content'); 
	SNI.Community.Widgets.displayOn('com-noUR-button-container02');
	SNI.Community.Widgets.displayOff('com-noUR-button-container');
	
	SNI.Community.Toolbox.globalPostCommentStatus = false;
	
	request.onreadystatechange=function()
	{	
		
		if(request.readyState==4)
		{	
			SNI.Community.Toolbox.globalPostCommentStatus=true;
			if(request.status==200)
			{
				if(modFlag == 1) {
					var cmtId = request.responseText;				
					SNI.Community.Toolbox.getCommentNonUR(yournameVal,cmttext);
					SNI.Community.Toolbox.globalPostCommentStatus==true;
					SNI.Community.Widgets.displayOff('com-noURpost-comment-content02');
					SNI.Community.Widgets.displayOn('com-noURpost-comment-content'); 
					SNI.Community.Widgets.displayOff('com-noUR-button-container02');
					SNI.Community.Widgets.displayOn('com-noUR-button-container');
					
				} else {
					SNI.Community.Widgets.reloadcommentsInternal(url2,url2ReqParams);
				} 
				
			}else if(request.status==12152){
				SNI.Community.Widgets.reloadcommentsInternal(url2,url2ReqParams); 
			}
			else if(request.status==500)
			{
				alert("You found an opportunity for improvement! Please try again later");
			}
			else{
				SNI.Community.Widgets.reloadcommentsInternal(url2,url2ReqParams);
			}	
		}
	}
	request.open("POST",url,true);
	request.setRequestHeader("content-type","application/x-www-form-urlencoded");
	request.send(reqParameters);
			
}

SNI.Community.Widgets.cancelComment = function(){
	SNI.Community.Toolbox.globalPostCommentStatus = true;
	SNI.Community.Widgets.displayOn('pcw-pre-tab');
	SNI.Community.Widgets.displayOff('pcw-pre-tab2');
	SNI.Community.Widgets.displayOff('pcw-pre-loading');
}

SNI.Community.Toolbox.postExternalComment = function()
{

	if(SNI.Community.Toolbox.globalPostCommentStatus==false){
		return;
	}
	
	//1,nishant@one-i.net,0,null,null,Sys_Admin
	var userInfo = "";
	var userId = SNI.Community.Toolbox.cGlobalUserId;	
	var yournameVal = SNI.Community.Toolbox.cGlobalUserDisplayName;		
	var yourEmailVal = SNI.Community.Toolbox.cGlobalUserEmail;
	var commenttext = document.getElementById("commenttext").value;
	var commentcaption = document.getElementById("commentcaption").value;
	var modFlag = document.getElementById('moderationFlag').value;
	var projectname = document.getElementById("wp_pro_name").value;
	var projectId = document.getElementById("wpid_hid").value;
	var nonurSiteId = SNI.Community.Toolbox.cSiteId;
	var nonurWid = SNI.Community.Toolbox.cWidInsId;
	var nonurCId = SNI.Community.Toolbox.cCollId;
	var wpid = SNI.Community.Toolbox.cGlobalOrigWidgetProjectId;
	var totalComments = document.getElementById("totcom").value;
	var pageSize = document.getElementById("pageSize").value;
	
	SNI.Community.Widgets.changeBack('headline');
	SNI.Community.Widgets.changeBack('comment');	
	SNI.Community.Widgets.displayOff('deletediv');
	document.getElementById('E_message').innerHTML = "";
	
	if(SNI.Community.Widgets.Get_Cookie('AJAX_LOGIN_RESPONSE'))
	{
	   userInfo = SNI.Community.Widgets.Get_Cookie('AJAX_LOGIN_RESPONSE').split("||");
	   if(userInfo.length>0){
		userId = userInfo[0];		
		yourEmailVal = userInfo[1];
		yournameVal = userInfo[2];
	   }
	}else if(SNI.Community.Widgets.Get_Cookie('picklecookie')){
		userInfo = SNI.Community.Widgets.Get_Cookie('picklecookie').split(",");
		  if(userInfo.length>0)
		  {
		  	yournameVal = userInfo[6];
		  	yourEmailVal = userInfo[1];		  	
		  	userId = userInfo[0];		  	
		  }
	}
	userId = userId.replace('"','');	
	if(SNI.Community.Widgets.trim(commenttext)!=''){
		commenttext =encodeURIComponent(commenttext);
	}

	if(SNI.Community.Widgets.trim(commentcaption)!=''){
		commentcaption =encodeURIComponent(commentcaption);
	}

	document.getElementById('E_message').innerHTML = "";
	SNI.Community.Widgets.displayOff('deletediv');
	//alert(document.getElementById('showheadline').value);
	if(SNI.Community.Widgets.trim(commentcaption) == '' && document.getElementById('showheadline').value == 'true'){
	   SNI.Community.Widgets.displayOn('deletediv');
	   SNI.Community.Widgets.changeText('headline');
	   document.getElementById('E_message').innerHTML = "Please enter a headline."; 	
	   return;
	}else if(commentcaption.length > 255 && document.getElementById('showheadline').value == true){
	   document.getElementById('E_message').innerHTML = "Please limit headline to 255 characters.";
	   SNI.Community.Widgets.displayOn('deletediv');
	   SNI.Community.Widgets.changeText('headline');	
	   return;
	}		

	if(SNI.Community.Widgets.trim(commenttext) == ''){
	   document.getElementById('E_message').innerHTML = "Please enter a comment.";
	   SNI.Community.Widgets.displayOn('deletediv');
	   SNI.Community.Widgets.changeText('comment');	
	   return;
	}else if(document.getElementById('commenttext').value.length > 1000){
	   document.getElementById('E_message').innerHTML = "Please limit comments to 1000 characters.";
	   SNI.Community.Widgets.displayOn('deletediv');
	   SNI.Community.Widgets.changeText('comment');	
	   return;
	}		
	
	SNI.Community.Widgets.displayOff('pcw-pre-tab');
	SNI.Community.Widgets.displayOn('pcw-pre-tab2');
	SNI.Community.Widgets.displayOn('pcw-pre-loading');
	
	var request=SNI.Community.Toolbox.ie?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
	
	var url=  SNI.Community.Toolbox.subPath + "/postcomment.do";
	var url2 = SNI.Community.Toolbox.subPath + "/getcommentscommon.do?page=1&layout=external&nonur=false&id="+SNI.Community.Toolbox.cSelectedId+"&wid="+nonurWid+"&clientUrl="+escape(SNI.Community.Toolbox.cClientUrl)+"&assetId="+SNI.Community.Toolbox.cAssetId+"&modflg="+modFlag+"&proname="+projectname+ "&proid=" + projectId+ "&ext=true" + "&totalComments="+totalComments+"&pageSize="+pageSize;
	var reqParameters = "nonur=false&user_name="+escape(yournameVal)+"&user_email="+yourEmailVal+"&comment="+commenttext+"&object_id="+SNI.Community.Toolbox.cSelectedId+"&user_id="+userId+"&site_id="+nonurSiteId+"&wid="+nonurWid+"&collectionsId="+nonurCId+"&sourceurl="+escape(document.location)+"&wpid="+wpid+"&modflg="+modFlag+"&proname="+projectname+ "&proid=" + projectId;
	reqParameters += "&commentcaption="+commentcaption+ "&ext=true";
	reqParameters += "&totalComments="+totalComments+"&pageSize="+pageSize;
	SNI.Community.Toolbox.globalPostCommentStatus = false;
	
	request.onreadystatechange=function()
	{	
		
		if(request.readyState==4)
		{
			SNI.Community.Widgets.displayOn('pcw-pre-tab');
			SNI.Community.Widgets.displayOff('pcw-pre-tab2');
			SNI.Community.Widgets.displayOff('pcw-pre-loading');
			
			if(request.status==200)
			{				
				if(modFlag == 1) {
					var cmtId = request.responseText;				
					SNI.Community.Toolbox.getExternalModerateComment(userId,nonurSiteId,cmtId);
					document.getElementById('commenttext').value = '';
					document.getElementById('commentcaption').value = '';
					SNI.Community.Toolbox.offCommenting();
					SNI.Community.Toolbox.globalPostCommentStatus=true;
				} else {
					SNI.Community.Toolbox.globalPostCommentStatus=true;
					SNI.Community.Widgets.reloadcomments(url2);
				}
				
			}else if(request.status==12152){
				SNI.Community.Widgets.reloadcomments(url2);
			}
			else if(request.status==500)
			{
				SNI.Community.Toolbox.globalPostCommentStatus=true;	
				alert("You found an opportunity for improvement! Please try again later");
			}
			else{
				SNI.Community.Toolbox.globalPostCommentStatus=true;
				SNI.Community.Widgets.reloadcomments(url2);
			}	
		}
	}
	request.open("POST",url,true);
	request.setRequestHeader("content-type","application/x-www-form-urlencoded");
	request.send(reqParameters);
			
}

SNI.Community.Toolbox.getComment = function(userId,siteId,commentId) {	
				var innerRequest=SNI.Community.Toolbox.ie?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();	
				var innerUrl =  SNI.Community.Toolbox.subPath + "/getmodeatecomment.do";
				commentId = commentId.replace('"','');					
				var innerParam = "site_id="+siteId + "&cmt_id=" + commentId + "&user_id=" +userId;
				var flag = 1;
				innerUrl = innerUrl + "?" + innerParam;				
				innerRequest.onreadystatechange=function()
				{
				  if(innerRequest.status==200)
				   {			
				     SNI.Community.Widgets.displayOff('com-add-comment');
				     SNI.Community.Widgets.layerOn('cgp-id-comment-ad');	    
				    var data = innerRequest.responseXML;	     
				    if(data == null) {
				    } 
				    else if(flag == 1) {				    	
				    	flag = 2;	
				    	var username = "";
				    	var timestamp = "";
				    	var text = "";
				    	var location = "";
				    	var imgurl = "";
				    	var profileurl = "";
				    	try {			
				    		 			    	
				    	 username =  data.getElementsByTagName('displayname').item(0).firstChild.nodeValue;
				    	} catch(err){}
				    	try {
				    	 timestamp =  data.getElementsByTagName('timestamp').item(0).firstChild.nodeValue;
				    	 } catch(err1){}
				    	 try {				    	 	
				    	 	text =  data.getElementsByTagName('object-text').item(0).firstChild.nodeValue;
				    	 } catch(err2){}
				    	 try {
				    	 location =  data.getElementsByTagName('location').item(0).firstChild.nodeValue;
				    	 } catch(err3){}	
				    	 try {			    	
				    	 imgurl =  data.getElementsByTagName('imgurl').item(0).firstChild.nodeValue;
				    	 } catch(err4){}		
				    	 try {		    	
				    		profileurl =  data.getElementsByTagName('profileUrl').item(0).firstChild.nodeValue;		
				    		profileurl = SNI.Community.Widgets.replaceAll(profileurl,"(\r\n|\r|\n|\n\r)","");		    		
				    	} catch(err5){}				    	
				    	document.getElementById('mod-cmt').innerHTML += 
				    	'<div id="pedingApproval">'+
							'<div class="hd"></div>'+
							'<div class="bd"><p>'+document.getElementById('errmsg').value + '</p></div>'+
							'<div class="ft"></div>'+
						'</div>'+
						'<div id="cgp-id-comment-item">' + 
							'<div id="cgp-id-comment-titles"><div id="cgp-id-comment-titles-pic">' + 
							'<a href="' + profileurl + '"><img width="48px" height="48px" src="' +
							imgurl + '" /></a></div></div><div style="z-index: 14500;" id="cgp-id-comment-info">' + 
								'<div id="cgp-id-comment-titles-user">' +
									'<p id="comments_name0"><a href="' + profileurl+ '">' +
										username 	+		
									'</a></p>' +
								'</div>' +
								'<div id="cgp-id-comment-top"></div><div id="cgp-id-comment-middle"><div id="cgp-id-comment-content">' + 
								'<p id="comments_text0">' + text + '</p><span>Posted: ' + timestamp + '</span></div></div>' +
								'<div id="cgp-id-comment-bottom"></div><div id="cgp-id-comment-arrow"></div></div> <div id="up-clear"></div></div>';								
						
							if( typeof(SNI.Community.Widgets.isFirstItemLoad) != 'undefined' 
									&& !SNI.Community.Widgets.isFirstItemLoad ){
							    var new_position = $('#mod-cmt').offset();
							    window.scrollTo(new_position.left,new_position.top);
							}		
						
							SNI.Community.Widgets.displayOff('com-add-comment_btm');												
			
				    }
				    
				   }
				 }
				innerRequest.open("POST",innerUrl,true);
				innerRequest.setRequestHeader("content-type","application/x-www-form-urlencoded");
				innerRequest.send(innerParam);
}



SNI.Community.Toolbox.getCommentNonUR = function(username,text) {		
						SNI.Community.Widgets.displayOff('com-add-comment');
				     	SNI.Community.Widgets.layerOn('cgp-id-comment-ad');		
				    	var timestamp =  "Posted: 0 seconds ago";				    				    				    	
				    	document.getElementById('mod-cmt').innerHTML += 
				    	'<div id="pedingApproval">'+
							'<div class="hd"></div>'+
							'<div class="bd"><p>'+document.getElementById('errmsg').value + '</p></div>'+
							'<div class="ft"></div>'+
						'</div>'+
						'<div id="cgp-id-comment-item">' + 
							'<div style="z-index: 14500;" id="cgp-noUR-comment-info">' + 
							'<div id="cgp-noUR-comment-titles-user">' +								
									'<p id="comments_name0">' +
										username 	+		
									'</p>' +
								'</div>' +
								'<div id="cgp-noUR-comment-titles-action"><p>' + timestamp + '</p></div>' +
								'<div id="up-clear"></div><div id="cgp-noUR-comment-top"></div><div id="cgp-noUR-comment-middle"><div id="cgp-noUR-comment-content"><p id="comments_text0">' + text + '</p>' +
								'</div></div><div id="cgp-noUR-comment-bottom"></div><div id="cgp-noUR-comment-arrow"></div></div><div id="up-clear"></div></div>';								

}

SNI.Community.Toolbox.getExternalModerateComment = function(userId,siteId,commentId) {	
				
				
				var innerRequest=SNI.Community.Toolbox.ie?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();	
				var innerUrl =  SNI.Community.Toolbox.subPath + "/getmodeatecomment.do";
				commentId = commentId.replace('"','');					
				var innerParam = "site_id="+siteId + "&cmt_id=" + commentId + "&user_id=" +userId;
				var flag = 1;
				innerUrl = innerUrl + "?" + innerParam;				
				innerRequest.onreadystatechange=function()
				{
				  if(innerRequest.status==200)
				   {				    
				    var data = innerRequest.responseXML;				      
				    if(data != null && flag == 1) {				    	
				    	flag = 2;				    		    
				    	var username = "";
				    	var timestamp = "";
				    	var text = "";
				    	var location = "";
				    	var imgurl = "";
				    	var profileurl = "";
				    	try {			    	
				    		username =  data.getElementsByTagName('displayname').item(0).firstChild.nodeValue;
				    	} catch(err){}
				    	try {
				    	 timestamp =  data.getElementsByTagName('timestamp').item(0).firstChild.nodeValue;
				    	} catch(err1) {}
				    	try {
				    		text =  data.getElementsByTagName('object-text').item(0).firstChild.nodeValue;
				    	} catch(err2){}
				    	try {
				    		location =  data.getElementsByTagName('location').item(0).firstChild.nodeValue;
				    	} catch(err3){}
				    	try {				    	
				    	 	imgurl=  data.getElementsByTagName('imgurl').item(0).firstChild.nodeValue;
				    	 } catch(err4){}	
				    	 try {			    	
				    	  profileurl =  data.getElementsByTagName('profileUrl').item(0).firstChild.nodeValue;
				    	  } catch(err5){}	
				    	var caption = "";				    	
				    	if(data.getElementsByTagName('caption') != null && data.getElementsByTagName('caption') != undefined) {
				    	    if(data.getElementsByTagName('caption').item(0).firstChild != null) {		    	
				    			caption =  data.getElementsByTagName('caption').item(0).firstChild.nodeValue;
				    		}
				    	}
				    	var headerStyle = '<div style="display: none;" id="cl-r-top">';
				    	if(document.getElementById('showheadline').value == 'true') {
				    	    headerStyle = '<div id="cl-r-top">';
				    	}
				    	document.getElementById('mod-cmt').innerHTML += 
				    	'<div id="pedingApproval">'+
							'<div class="hd"></div>'+
							'<div class="bd"><p>'+document.getElementById('errmsg').value+'</p></div>'+
							'<div class="ft"></div>'+
						'</div>'+
						'<div id="pcw-cl-c" class="clrfix"><div id="pcw-cltop"><div id="cl-l">' + 
							'<div style="display: block;" id="cl-l-image"><p>' + 
							'<a href="' + profileurl + '"><img border="0" src="' +
							imgurl + '"/></a></p></div>' + 
								'<div style="display: block;" id="cl-l-name"><p><a href="' +
									 profileurl+ '">' + username 	+'</a></p></div>' +
								'<div style="display: block;" id="cl-l-address"><p>' + location + '</p></div>' +
								'<div style="display: block;" id="cl-l-timestamp"><p>' + timestamp + '</p></div></div>' +
								'<div id="cl-rtop"><div id="cl-r"><div id="cl-r-c">' + 
								headerStyle + '<h2>' + caption + '</h2>' +								
								'<div id="pcw-arrow"></div></div><div id="cl-r-cont"><div id="q-t"></div><p id="comments_text0">' + text +
								'</p><div id="q-b"></div></div></div></div><div id="cl-rfoot"></div></div><div id="pcw-clfoot"></div></div></div>';
				    }
				    
				   }
				 }
				innerRequest.open("POST",innerUrl,true);
				innerRequest.setRequestHeader("content-type","application/x-www-form-urlencoded");
				innerRequest.send(innerParam);
}

SNI.Community.Toolbox.postExternalReview = function()
{
	
	if(SNI.Community.Toolbox.globalPostCommentStatus==false){
		return;
	}
	
	//1,nishant@one-i.net,0,null,null,Sys_Admin
	var userInfo = "";
	var userId = SNI.Community.Toolbox.cGlobalUserId;
	var yournameVal = SNI.Community.Toolbox.cGlobalUserDisplayName;		
	var yourEmailVal = SNI.Community.Toolbox.cGlobalUserEmail;
	var commenttext = document.getElementById("cmt_txt").value;
	var cmttext = commenttext;
	var rating = document.getElementById("objectRating").value;
	var commentId = document.getElementById("object_edit").value;
	var key = document.getElementById("cachekey").value;
	var objectType = document.getElementById("wp_obj_type").value;
	var modFlag = document.getElementById("moderationFlag").value;
	var projectname = document.getElementById("wp_pro_name").value;
	var projectId = document.getElementById("wpid_hid").value;
	
	
	var nonurSiteId = SNI.Community.Toolbox.cSiteId;
	var nonurWid = SNI.Community.Toolbox.cWidInsId;
	var nonurCId = SNI.Community.Toolbox.cCollId;
	var wpid = SNI.Community.Toolbox.cGlobalOrigWidgetProjectId;
	//alert('a');
	//commenting out next three lines
	//SNI.Community.Widgets.changeBack('headline');
	//SNI.Community.Widgets.changeBack('comment');	
	//SNI.Community.Widgets.displayOff('deletediv');
	
	document.getElementById('E_message').innerHTML = "";
	
	if(SNI.Community.Widgets.Get_Cookie('picklecookie')){
		userInfo = SNI.Community.Widgets.Get_Cookie('picklecookie').split(",");
		
		
		  if(userInfo.length>0)
		  {
		  	yournameVal = userInfo[6];
		  	yourEmailVal = userInfo[1];
		  	userId = userInfo[0];
		  	
		  }
	}
	
	//alert("1");
	if(SNI.Community.Widgets.trim(commenttext)!=''){
		commenttext =encodeURIComponent(commenttext);
	}

	//if(SNI.Community.Widgets.trim(commentcaption)!=''){
	//	commentcaption =encodeURIComponent(commentcaption);
	//}
	
	document.getElementById('E_message').innerHTML = "";
	SNI.Community.Widgets.displayOff('deletediv');
	//alert("2");
	   
	if(rating == "0") {
		 document.getElementById('E_message').innerHTML = "<div class='error-msg'><h2>Whoops, we noticed something...</h2><p>Please enter a rating.</p></div>";		   
		   SNI.Community.Widgets.displayOn('deletediv');
		   document.getElementById("ur-rating-lab").className = "error-field";
		  // SNI.Community.Widgets.changeText('comment');	
		   return;
	}	
	else if(SNI.Community.Widgets.trim(commenttext) == '' || commenttext == null || commenttext == 'null' || trim(cmttext) == 'Tasty? What did you think?'){
	   document.getElementById('E_message').innerHTML = "<div class='error-msg'><h2>Whoops, we noticed something...</h2><p>Please enter your review.</p></div>";
	  // alert("please enter a comment");
	   SNI.Community.Widgets.displayOn('deletediv');
	   //SNI.Community.Widgets.changeText('comment');	   
	   if(document.getElementById('cmdid') != null && trim(document.getElementById('cmdid').value) != '' && trim(document.getElementById('cmdid').value) != '0'){		   
		   document.getElementById('edit-rev-lab').className = "error-field";
	   } else {		   
		   document.getElementById('write-rev-lab').className = "error-field";
	   }
	   return;
	}else if(cmttext.length > 1000){
	   document.getElementById('E_message').innerHTML = "<div class='error-msg'><h2>Whoops, we noticed something...</h2><p>Please limit comments to 1000 characters.</p></div>";
	   //alert("please limit comment to 1000 chars");
	   SNI.Community.Widgets.displayOn('deletediv');
	   SNI.Community.Widgets.changeText('comment');	
	   return;
	} 
	
	//here i need to hide the input review area ....
	SNI.Community.Widgets.displayOff('pcw-pre-tab');
	//SNI.Community.Widgets.displayOn('pcw-pre-tab2');
	SNI.Community.Widgets.displayOff('pcw-pre-tab2');
	SNI.Community.Widgets.displayOn('pcw-pre-loading');
	SNI.Community.Widgets.displayOff('pcw-pre-can');	
	var request=SNI.Community.Toolbox.ie?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
	
	var url=  SNI.Community.Toolbox.subPath + "/postreview.do";
	var url2 = SNI.Community.Toolbox.subPath + "/getcommentscommon.do?page=1&layout=external&nonur=false&id="+SNI.Community.Toolbox.cSelectedId+"&wid="+nonurWid+"&clientUrl="+escape(SNI.Community.Toolbox.cClientUrl)+"&assetId="+SNI.Community.Toolbox.cAssetId;
	var reqParameters = "nonur=false&user_name="+escape(yournameVal)+"&user_email="+yourEmailVal+"&comment="+commenttext+"&object_id="+SNI.Community.Toolbox.cSelectedId+"&user_id="+userId+"&site_id="+nonurSiteId+"&wid="+nonurWid+"&collectionsId="+nonurCId+"&sourceurl="+escape(document.location.href)+"&wpid="+wpid + "&rating=" + rating + "&comment_id=" + commentId + "&key="+key + "&obj_type="+objectType + "&modflag=" + modFlag + "&proname=" + projectname + "&proid=" + projectId;
	
	SNI.Community.Toolbox.globalPostCommentStatus = false;
	
	
	request.onreadystatechange=function()
	{	
		
		
		if(request.readyState==4)
		{
			//SNI.Community.Widgets.displayOn('pcw-pre-tab');
			//SNI.Community.Widgets.displayOff('pcw-pre-tab2');
			var res = request.responseText;			
			if(trim(res) == 'failed') {
				document.getElementById('E_message').innerHTML = "<div class='error-msg'><h2>Whoops, we noticed something...</h2><p>We apologize, but your submission contains a link, which we do not currently support. Please remove the link and resubmit your review.</p></div>";
	  			// alert("please enter a comment");
	   			SNI.Community.Widgets.displayOn('deletediv');
	   			//SNI.Community.Widgets.changeText('comment');	   
	   			if(document.getElementById('cmdid') != null && trim(document.getElementById('cmdid').value) != '' && trim(document.getElementById('cmdid').value) != '0'){		   
		   			document.getElementById('edit-rev-lab').className = "error-field";
	  			 } else {		   
		   			document.getElementById('write-rev-lab').className = "error-field";
	   			}
					SNI.Community.Widgets.displayOn('pcw-pre-tab');
					SNI.Community.Widgets.displayOn('pcw-pre-can');
					SNI.Community.Widgets.displayOff('pcw-pre-tab2');
					SNI.Community.Widgets.displayOff('pcw-pre-loading');
					SNI.Community.Toolbox.globalPostCommentStatus = true;
					
					
			} else {
			     SNI.Community.Widgets.displayOn('pcw-pre-loading');
				if(request.status==200)
				{
					
						window.location.href=window.location.href;
				
					//SNI.Community.Toolbox.globalPostCommentStatus=true;
					//SNI.Community.Widgets.reloadcomments(url2);
				}else if(request.status==12152){
					//SNI.Community.Widgets.reloadcomments(url2);
				}
				else if(request.status==500)
				{
					SNI.Community.Toolbox.globalPostCommentStatus=true;				
					alert("You found an opportunity for improvement! Please try again later");
					SNI.Community.Widgets.displayOn('pcw-pre-tab');
					SNI.Community.Widgets.displayOn('pcw-pre-can');
					SNI.Community.Widgets.displayOff('pcw-pre-tab2');
					SNI.Community.Widgets.displayOff('pcw-pre-loading');
				}
				else{
					SNI.Community.Toolbox.globalPostCommentStatus=true;
					SNI.Community.Widgets.reloadcomments(url2);
				}	
			}
		}
	}
	request.open("POST",url,true);
	request.setRequestHeader("content-type","application/x-www-form-urlencoded");
	request.send(reqParameters);
	
			
}
//END JEE NEW



SNI.Community.Toolbox.checkandshow = function()
{
	secureComponent("SNI.Community.Widgets.displayOn('com-add-comment'); SNI.Community.Widgets.layerOff('cgp-id-comment-ad');","You Need To Be Signed In To Do That.","cgp-id-comment-ad",5);
}

SNI.Community.Toolbox.TopNavCheckandShow = function()
{
	var btmCommentId  = document.getElementById('com-add-comment_btm');
   if(btmCommentId)
   {
   	 if(btmCommentId.style.display == 'block'){
   	 	SNI.Community.Widgets.displayOff('com-add-comment_btm');
   	 	SNI.Community.Widgets.layerOn('cgp-id-comment-ad_btm');
   	 }
   }
	secureComponent("SNI.Community.Widgets.displayOn('com-add-comment');","You Need To Be Signed In To Do That.","cmt_place",5);
}

//Pickle 2476 issue,Newly added for rmr bootom button
SNI.Community.Toolbox.TopNavCheckandShow_bottom = function()
{
  var topCommentId  = document.getElementById('com-add-comment');
   if(topCommentId)
   {
   	 if(topCommentId.style.display == 'block'){
   	 	//topCommentId.style.display == 'none';
   	 	SNI.Community.Widgets.displayOff('com-add-comment');
   	 	SNI.Community.Widgets.layerOn('cgp-id-comment-ad');
   	 }
   }
	secureComponent("SNI.Community.Widgets.displayOn('com-add-comment_btm');","You Need To Be Signed In To Do That.","cmt_place",5);
}

SNI.Community.Toolbox.doComment = function(curObj){
	var result = secureComponent("","You Need To Be Signed In To Do That.",curObj,5);
	if(result == "found"){
		SNI.Community.Widgets.showCommentsPopUp_cp();
	}
}

SNI.Community.Toolbox.doCommentsFlag = function(objId,curObj){
	SNI.Community.Toolbox.flagTmpDiv = objId;
	SNI.Community.Widgets.temp1 = objId;
	var result = secureComponent("","You Need To Be Signed In To Do That.",curObj,7);
	if(result == "found"){
		SNI.Community.Widgets.flagComment();
	}		
}

SNI.Community.Widgets.flagCommentNoUr = function(cmtId)
{
	SNI.Community.Toolbox.flagTmpDiv = cmtId;
	SNI.Community.Widgets.temp1 = cmtId;
	SNI.Community.Widgets.displayOn('cgp-flyout-'+cmtId);
	document.getElementById("comment_flag_reason_error_"+cmtId).innerHTML = "";
	SNI.Community.Widgets.displayOff("comment_flag_reason_error_"+cmtId);
	
}

SNI.Community.Widgets.addReviewCookie = function(type,userid,cmtid){
	var value = type+"-"+cmtid;
	if(readCookie(userid) !=null && trim(readCookie(userid)).length>0 && trim(readCookie(userid))!= "null")
	{
		var existingvalue = readCookie(userid)
		if(existingvalue.indexOf(value)==-1){
			value = existingvalue+","+value;
			createCookie(userid,value)
		}		
	}else{
		createCookie(userid,value);
	}
	
}
SNI.Community.Widgets.isAlreadyReviewed = function(type,userid,cmtid){
	var value = type+"-"+cmtid;
	var cookieVal =readCookie(userid); 
	if(cookieVal !=null && trim(cookieVal).length>0 && trim(cookieVal)!= "null")
	{	
		if(cookieVal.indexOf(value)!=-1){
			return true;
		}else {
			return false;
		}
	}else{
		return false;
	}
}
SNI.Community.Widgets.foundHelpFulorNo = function(found,cmtid,parentId,userid) {

	if(! SNI.Community.Widgets.isAlreadyReviewed(found,userid,cmtid)){
		
	 	var request=SNI.Community.Toolbox.ie?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
		var url=  SNI.Community.Toolbox.subPath + "/wasthishelpful.do";	
		var reqParameters = "vote=" + found + "&cmtid=" +cmtid + "&key=" + parentId ;
		request.onreadystatechange=function()
		{		
			if(request.readyState==4)
			{			
				if(request.status==200)
				{
					if(found != "No" && request.responseText !="Failed") {
						var yesVotes = request.responseText;
						document.getElementById('vote_use_'+cmtid).innerHTML = yesVotes;
						
					}
				}
	        }
		}
		request.open("POST",url,true);
		request.setRequestHeader("content-type","application/x-www-form-urlencoded");
		request.send(reqParameters);
		SNI.Community.Widgets.addReviewCookie(found,userid,cmtid);
		
	}
}



SNI.Community.Widgets.flagComment = function()
{
	SNI.Community.Widgets.displayOn('cgp-flyout-'+SNI.Community.Toolbox.flagTmpDiv);
	document.getElementById("comment_flag_reason_error_"+SNI.Community.Toolbox.flagTmpDiv).innerHTML = "";
	SNI.Community.Widgets.displayOff("comment_flag_reason_error_"+SNI.Community.Toolbox.flagTmpDiv);
	
}

SNI.Community.Widgets.flagAsInappropriate = function(id,flagType,obj,commentsId,userId)
{
	var flagReason = "";
	var request=SNI.Community.Toolbox.ie?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
	var comments = "";
	var caption = "";
	var uploadBy = "";
	var description = "";
	var uploadbyurl = "";
	var modId = id;
	var d2cLink = window.location.href;
	d2cLink = d2cLink.replace(/#/g, "");
	var commentsHeading = ""; 
	
	var sendalertemailValue=document.getElementById("sendalertemailValue").value;
	var deactivateItemValue=document.getElementById("deactivateItemValue").value;
	var sendalertemailthreshold=document.getElementById("sendalertemailthreshold").value;
	var deactivateItemthreshold=document.getElementById("deactivateItemthreshold").value;
	//var reviewprokey = userId + ".ReviewsVO";
	var reviewprokey = userId + ".1.1.CompositeReviewsVO";
	if(document.getElementById("comment_flag_reason_"+SNI.Community.Toolbox.flagTmpDiv)){
		flagReason = document.getElementById("comment_flag_reason_"+SNI.Community.Toolbox.flagTmpDiv).value;
	}

	if(trim(flagReason) == ""){
		SNI.Community.Widgets.displayOn("comment_flag_reason_error_"+SNI.Community.Toolbox.flagTmpDiv);
		//condition added for PICKLE-2227 to replace the text "Comment/Review" if configured in Pickle Admin
			var isErrorMsgAvailable = "";
			if(document.getElementById("errorTextAltered_"+SNI.Community.Toolbox.flagTmpDiv)){
				isErrorMsgAvailable = document.getElementById("errorTextAltered_"+SNI.Community.Toolbox.flagTmpDiv).innerHTML;
			}
		//end
		if(trim(isErrorMsgAvailable) == ""){
			document.getElementById("comment_flag_reason_error_"+SNI.Community.Toolbox.flagTmpDiv).innerHTML = "You must provide a reason for flagging this comment.";
		}else{
			document.getElementById("comment_flag_reason_error_"+SNI.Community.Toolbox.flagTmpDiv).innerHTML = isErrorMsgAvailable;
		}
		return;
	}else{
		SNI.Community.Widgets.displayOff('cgp-flyout-'+SNI.Community.Toolbox.flagTmpDiv);
	}
	
	//d2cLink += "&cObjId="+SNI.Community.Toolbox.cSelectedId;

	if(commentsId!='null'){
		comments = document.getElementById(commentsId).innerHTML;
		comments = comments.replace('<div>','');
		comments = comments.replace('</div>','');
	}
	
	if(document.getElementById("comments_heading_"+SNI.Community.Toolbox.flagTmpDiv)){
		commentsHeading = document.getElementById("comments_heading_"+SNI.Community.Toolbox.flagTmpDiv).innerHTML;
		commentsHeading = commentsHeading.replace('<div>','');
		commentsHeading = commentsHeading.replace('</div>','');		
	}
	
	var url= SNI.Community.Toolbox.subPath + "/flagasinappropriate.do";
	var params = "id="+id+"&obj_type="+flagType;
	params += "&d2c_link="+escape(d2cLink);
	params += "&moderationurl="+escape(""+SNI.Community.Toolbox.cAdminRootUrl+"/moderation.do?oid="+id+"&statusId=1&objectType=pva&flag="+flagType+"&pid="+SNI.Community.Toolbox.cAssetId+"&ht="+SNI.Community.Toolbox.cSelectedId);
	params += "&inappropriateurl="+escape(SNI.Community.Toolbox.cAdminRootUrl+"/loadCMS.do?cmsId="+SNI.Community.Toolbox.cSelectedId+"&assetid="+SNI.Community.Toolbox.cAssetId);
	params += "&comments="+escape(comments)+"&caption="+escape(SNI.Community.Toolbox.cAssetTitle);
	params += "&sendalertemailValue="+escape(sendalertemailValue);
	params += "&deactivateItemValue="+escape(deactivateItemValue);
	params += "&sendalertemailthreshold="+escape(sendalertemailthreshold);
	params += "&deactivateItemthreshold="+escape(deactivateItemthreshold);	
	params += "&reason="+escape(flagReason);
	params += "&reviewkey="+reviewprokey;
	params += "&wpid="+document.getElementById("wpid_hid").value;
	params += "&ch="+escape(commentsHeading);
		
				
	request.onreadystatechange=function()
	{
		if(request.readyState==4)
		{
			if(request.status==200 ||request.status==12152)
			{
				obj = document.getElementById(obj);
				SNI.Community.Widgets.setPickleCookie("pickle_comments_inapp",id);
				obj.parentNode.innerHTML = " Flagged";
			}
			else if(request.status==500){
				alert("You found an opportunity for improvement! Please try again later");
				//obj.parentNode.innerHTML = " Flagged";
			}	
			else{
				alert("There appears to be a connectivity problem. Please check your internet connection and try again.");
			}	
		}
	}
	request.open("POST",url,true);
	request.setRequestHeader("content-type","application/x-www-form-urlencoded");
	request.setRequestHeader("Content-length", params.length);
	request.send(params);
}

SNI.Community.Toolbox.onCommenting = function()
{
	document.getElementById('pcw-ttop').style.display = 'block';
	document.getElementById('c-comment-up').id = "c-comment-down";
	document.getElementById('c-comment-down').onclick = new Function("SNI.Community.Toolbox.offCommenting()");
}

SNI.Community.Toolbox.offCommenting = function()
{
	document.getElementById('pcw-ttop').style.display = 'none';
	document.getElementById('c-comment-down').id = "c-comment-up";
	document.getElementById('c-comment-up').onclick = new Function("SNI.Community.Toolbox.onCommenting()");
}
SNI.Community.Toolbox.changeRating = function(val){
	
	for(i=1;i<=val;i++)
	{
		document.getElementById('star'+i).className = "staron";
	}
	
	for(i=(parseInt(val)+1);i<=5;i++)
	{				
		
		document.getElementById('star'+i).className = "staroff";
	}
}
SNI.Community.Toolbox.clearText = function (obj) {
	
	if(trim(obj.value) == 'Tasty? What did you think?') {
		document.getElementById('cmt_txt').value = '';			
		document.getElementById('cmt_txt').style.color = '#000000';
		document.getElementById('is_def').value == "1";		
			
	}
	
}

SNI.Community.Toolbox.setRating = function (val){		
	SNI.Community.Toolbox.changeRating(val);		
	document.getElementById("objectRating").value=val;		
}	
SNI.Community.Toolbox.clearRating = function() {
	for(i=1;i<=5;i++)
		document.getElementById('star'+i).className = "staroff";		
		SNI.Community.Toolbox.changeRating(document.getElementById("objectRating").value);
	
}
SNI.Community.Toolbox.changeSortOrder = function (sortOrder){
	var a = document.location+"";	
	if(sortOrder != 1) {
		var sortByConstant = "ob";	
		if(a.indexOf("?") != -1) {
		 	a = a.substring(0,a.indexOf("?") + 1);
		} else {
			a += "?";
		}
		a += sortByConstant+"="+sortOrder;				
		a = a.replace("?&amp;","?");
		a = a.replace("#","");
	} else {
		if(a.indexOf("?") != -1) {
		 	a = a.substring(0,a.indexOf("?"));
		} 
	}
	document.getElementById("reviews-sortorder").value=sortOrder;
	document.location = a; 
	return false;
}

SNI.Community.Toolbox.showSort = function () {		
	document.getElementById("fluout-opt").style.display = "block";			
	return false;
}
SNI.Community.Toolbox.showParentRec = function()  {
	var url = document.location.href;
	if(url.indexOf("/reviews/") != -1) {
		var revUrl1 = url.substring(0,url.indexOf("/reviews/"));     
		var revUrl2 = url.substring(url.indexOf("/reviews/") + 8, url.length);
		var revurl = revUrl1 + revUrl2 ;
		document.location = revurl ;
	} else {
		document.location = url;
	}
		
}		

SNI.Community.Toolbox.populateLoginLink = function(){	
	var postObj = document.getElementById("post");
	var curURL = escape(document.location.href);		
	var loginURL=document.getElementById('loginproURL').value + "?DEST_URL="+escape(curURL);		
	if(postObj)
		postObj.href = loginURL;
}

SNI.Community.Toolbox.populateRegLink = function(){	
	var regObj = document.getElementById("register");
	var curURL = escape(document.location.href);
	var loginURL = document.getElementById('loginproURL').value;
	var registerURL=loginURL.replace("login.esi","register_lite.esi") + "?DEST_URL="+escape(curURL);		
	if(regObj)
		regObj.href = registerURL;
}
SNI.Community.Toolbox.showEditReview = function(val) {
	if(val == '0') {
		document.getElementById('edit-review').style.display = "none";
		document.getElementById('editReviewArea').style.display = "block";
	} else {
		document.getElementById('edit-review').style.display = "block";
		document.getElementById('editReviewArea').style.display = "none";
	}
}
SNI.Community.Toolbox.showWrtOpt=function(opt)  {
	if(opt == '1') {
		document.getElementById('no-rev-msg').style.display = "none";
		document.getElementById('pod-write-review').style.display = "block";
		
	} else {
		document.getElementById('no-rev-msg').style.display = "block";
		document.getElementById('pod-write-review').style.display = "none";
		
	}
}
SNI.Community.Toolbox.secureReview = function(op,val,userid,parentobj)
{
	
	if(op!=null){
		var yesId = "yes_"+val;
		var noId = "no_"+val;
		if(op=="add")	
			secureComponent("SNI.Community.Widgets.foundHelpFulorNo('Yes',"+val+","+ parentobj +","+userid+")","You Need To Be Signed In To Do That.",yesId,"13");
		if(op=="remove")
			secureComponent("SNI.Community.Widgets.foundHelpFulorNo('No',"+val+","+parentobj+","+userid+")","You Need To Be Signed In To Do That.",noId,"13");
		if((userid!=null && userid!=-1)  && (document.getElementById("comment_"+val) != null))
		document.getElementById("comment_"+val).style.display = "none";
	}
}



