var call_fun="";
var call_param="";
var call_param1="";
var open_div="";
var act_div="";
var chk_soc_opt=0;

var msg_param='';
var head_param='';
var exturl_param='';
var tpid_param='';
var tp_param='';
var cat_param='';
var replyid_param='';

/* General function*/
function toHex(str) {
	var hex = '';
	for(var i=0;i<str.length;i++) {
		hex += ''+str.charCodeAt(i).toString(16);
	}
	return hex;
}
function strrev(str) {
   if (!str) return '';
   var revstr='';
   for (i = str.length-1; i>=0; i--)
	   revstr+=str.charAt(i)
   return revstr;
}
function trim(str) { 
	var	str1 = str.replace(/^\s\s*/,''),
		ws = /\s/,
		i = str1.length;
	while (ws.test(str1.charAt(--i)));
	return str1.slice(0, i + 1);

}
function checkEmail(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
		return (true);
	}
	return (false);
}

function chk(ele)
{
	if(isNaN(ele.value))
	{
		ele.value="";
		alert("Numeric value required")
		ele.focus();
	}
}

function IsNumeric(strString)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

/**/


function verify_signin(choe)
{
  if(choe==2)
	{
	  $('#loginchk2').load($.post('/msgboard/guest_login_ajaxverify.php', '', function(data) 
		{		if(data=='alldone')
				{
		            if(act_div=='1')
				    update_reply_msg(call_param,open_div,'2');
					else if(act_div=='2')
						update_rate(call_param,call_param1,'2');
					else if(act_div=='3')
						update_offence(call_param,'2');
					else if(act_div=='4')
						update_track_thrad(call_param,'2');
					else if(act_div=='5')
						chkfeed('2');
					else if(act_div=='6')
						track_add(call_param,'2');
					else if(act_div=='7')
						update_track_topic(call_param,call_param1,'2');
					else if(act_div=='8')
						del_track_topic(call_param,call_param1,'2');
					else if(act_div=='9')
						pop_chkfeed('2');
					else if(act_div=='10')
                        m3callot_chkfeed('2');
					else if(act_div=='11')
                        update_chat_msg('2');
					else if(act_div=='12')
                        update_repost(call_param,'2');
					else if(act_div=='13')
                        update_repost_article(call_param,'3');
					else if(act_div=='14')
                        send_pmsg_bdr(call_param,'2');
					else if(act_div=='15')
						  track_delete(call_param,'2');
				}
				
		}));
	}
	else
	{
		var f_idval="";
		var f_fwdval="";
		var remembermeval="";
		var keepsigninval="";
		if($('#f_id').val()=='')
		{
			alert("please enter username");
			$("#f_id").focus();  
			return;
		}
		if($('#f_pwd').val()=='')
		{
			alert("please enter password");
			$("#f_pwd").focus();  
			return;
		}
		if(document.getElementById('f_id')!=null&&document.getElementById('f_id').value!=''&&document.getElementById('f_id').value!='Username'){
			f_idval=$('#f_id').val();
			if(document.getElementById('rememberme')!=null){
				if(document.getElementById('rememberme').checked==true){
					remembermeval=$('#rememberme:checked').val()
				}
			}
			if(document.getElementById('keepsignin')!=null){
				if(document.getElementById('keepsignin').checked==true){
					keepsigninval=$('#keepsignin:checked').val()
				}
			}
			if(document.getElementById('f_pwd')!=null){
						f_fwdval=$('#f_pwd').val()
			}
		}	

		$('#loginchk2').load($.post('/watchlist1/login_check.php?sectionid=M3&username='+f_idval+'&password='+f_fwdval+'&saveid='+remembermeval+'&keep_signed='+keepsigninval, '', function(data) 
			{		if(data=='alldone')
					{
						if(act_div=='1')
						update_reply_msg(call_param,open_div,'2');
						else if(act_div=='2')
							update_rate(call_param,call_param1,'2');
						else if(act_div=='3')
							update_offence(call_param,'2');
						else if(act_div=='4')
						update_track_thrad(call_param,'2');
						else if(act_div=='5')
						chkfeed('2');
						else if(act_div=='6')
						  track_add(call_param,'2');
					    else if(act_div=='7')
						   update_track_topic(call_param,call_param1,'2');
						else if(act_div=='8')
						   del_track_topic(call_param,call_param1,'2');
						else if(act_div=='9')
						   pop_chkfeed('2');
						else if(act_div=='10')
                           m3callot_chkfeed('2');
						else if(act_div=='11')
                          update_chat_msg('2');
						else if(act_div=='12')
                          update_repost(call_param,'2');
						else if(act_div=='13')
                          update_repost_article(call_param,'3');
						else if(act_div=='14')
                          send_pmsg_bdr(call_param,'2');
						else if(act_div=='15')
						  track_delete(call_param,'2');
					}else{
						alert("Incorrect Username or Password.");
						$("#f_id").focus();
						return false;
					}
					
			}));

	}
	
}



function update_reply_msg(msgid,dvid,data)
	{		
			
		var reply_msg=$('#f_message_'+dvid).val();
		if(reply_msg=="" || reply_msg=='Type your message here' || reply_msg=='Reply to this message')
		{
			alert("please enter the message");
			$("#f_message_"+dvid).focus();  
			return;
		}
		else if(reply_msg.length < 2)
		{
			alert ("Message needs to be more than 1 characters");
			$("#f_message_"+dvid).focus();  
			return false;
		}
		else if(reply_msg.length > 5000)
		{
			alert("max 5000 characters allowed");
			$("#f_message_"+dvid).focus();  
			return false;
		}
		else
		{
			
			var char1h=new Array('<','>','co.uk','madarchod','bhenchod','gandu','chutiya','chutyie','bahenchod','randi','rascal','bastard','basturd','bastered','assole','asshole','fuck','sucker','fucker','chodu','lavde','makichut','makachut','mchod',' m chod','m.chod','raandi','raand','raandii',' randii',' laude','b.a.s.t.a.r.d.',' b a s t a r d',' chuteyas',' chuteya',' chut',' c h u t',' harame',' harami',' madar chod','bhen chod','benched','bhosdivaale','fodrichya',' bosrichya','ayzavadya','badwa',' bedwa','bedve','gaandu',' gandki','gaand',' chudu','chodu','Raand','Rand','chutiye','madar','chod','bhosda','choot','lode','haramzade','arsehole','chtye','gand','randi','madarjat','chut','MADARCHOD','BHADVE','chudane','chu-??-t','maderchod','fuc*ur','chudwa','Bhenchod','Haramkhoro','Madarchodo','teri ma ki chot','gand marvao','chhutttiya','bhossssaaadaa...','bhossssaaadaa','lunddd','matherfuker','bhen daaa pioo','madarchod','bhenchod','gandu','chutiya','chutyie','bahenchod','randi','rascal','bastard','basturd','bastered','assole','chodu','lavde','makichut','makachut','basterd','choot','moth er chod','mother`s cunt','madarchodo','madar chod','bastards','Chootwa','Burwa','Bur');

			var str=reply_msg;
            str=str.toLowerCase();
			
			for(i=0;i<=char1h.length;++i)
			{
				if(str.indexOf(char1h[i],0)!=-1)
				{
				alert("Word "+char1h[i]+" not allowed");
				return false;
				}					
			}
		}  
		
		var extr_lnk=$('#exturl_'+dvid).val();
		if(extr_lnk!="")
		{
			var extrchr=new Array('<','>','&lt;','&gt;');
			
				for(i=0;i<=extrchr.length;++i)
				{
					if(extr_lnk.indexOf(extrchr[i],0)!=-1)
					{
					alert("Word "+extrchr[i]+" not allowed");
					return false;
					}					
				}
		}

		if(data=="1")
		{
			call_fun="2";
			call_param=msgid;
			open_div=dvid;
			act_div='1';
            
			 $('#loginchk').load($.post('http://marketlive.commodityonline.com/', '', function(data) 
					{					
						//alert(data);
						document.getElementById("repybx_"+dvid).innerHTML="<img src='http://img1.moneycontrol.com/images/markets_new_loader.gif' valing=center align=center>";

						if(data==0)
						{						$('#loginchk2').load($.post('/india/messageboard/msgpost_before.php?msg='+escape(reply_msg)+'&r_rply_id='+msgid+'&extr_url='+extr_lnk, '', 					  function(data) 
						{
						 //alert(data);
						 document.replyfrm.rmsgid.value=data;
                         check_login('2');
			             return false;
						}));

						}
						else
						{
                          check_login('2');
						  return false;
						}
					}));

			
		}else{
			var mtype = '';
			document.replyfrm.r_rply_id.value=msgid;
			document.replyfrm.r_message.value=reply_msg;
			document.replyfrm.m_type.value=mtype;
			document.replyfrm.url_link.value=extr_lnk;
			document.replyfrm.submit();
			return true;
		}
		return false;
	}


function rateoff_open_ajax(dvid,msgid,qstr) {	
	//totdiv
	chkuser_photo(dvid,'rep');
	 var chk_soc_opt=1;


   var tot=document.getElementById("totdiv").value;
  
   
	for(i=0;i<tot;i++) {
		document.getElementById("rep_msg_"+i).style.display = "none";
		document.getElementById("rate_msg_"+i).style.display = "none";
		document.getElementById("offens_msg_"+i).style.display = "none";
		document.getElementById("share_msg_"+i).style.display = "none";
		document.getElementById("repost_msg_"+i).style.display = "none";
	}	

	document.getElementById("rep_msg_"+dvid).innerHTML='<div class="repCont">						<div class="MT5 FL"><img src="http://im.in.com/messagecentral/images/replyTab.gif" width="53" height="25" alt="Reply" /></div>						<a href="javascript:void(0);" onClick="closeme('+dvid+');" class="bl_10 FR MR25 MT15" style="cursor: hand;">x Close</a>						<textarea class="PA5 gL_12 FL" style="width: 550px; border-top: 3px #aec0cc solid; border-bottom: 1px #aec0cc solid; border-left: 1px #aec0cc solid; border-right: 1px #aec0cc solid;" name="f_message_'+dvid+'" id="f_message_'+dvid+'" onclick=\'javascript:if(this.value=="Comment"){this.value=""}\' rows="4" cols="" name="">Comment</textarea>					</div>					<div class="CL"></div>					<div class="MT5"><a href="javascript:void(0);" onclick="update_reply_msg('+msgid+','+dvid+',1);"/><img src="http://im.in.com/connect/images/submitBtn2.gif" width="54" height="17" border="0"></a></div>';

	

	document.getElementById("rep_msg_"+dvid).innerHTML='<form name="reply_'+dvid+'"><div style="width:482px;" class="arrow"><div class="ymsgbar MT5" id="msg_alert" style="display:none;">Messages posted within 200 characters are best viewed on mobile screens.  <a href="javascript:void(0);" onclick=document.getElementById("msg_alert").style.display="none" class="bl_12 uline">close</a></div><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/callArrow.gif" alt="" /></div><div align="right"><a href="javascript:void(0);" class="bl_11" onClick="closeme('+dvid+');"><img src="http://marketlive.commodityonline.com/images/btn_close.gif" width="13" height="13" alt="" border="0"/></a></div><div class="b_15"><div class="clearfix FL"><div class="FL PR10"><div id="user_photo_rep_'+dvid+'"></div></div><div class="FL PT10" style="width:220px"><div id="user_name_rep_'+dvid+'"></div><strong>'+qstr+'</strong></div></div><div class="FR PT10"></div><div class="CL"></div></div><div class="gL_13 PT25">Want to comment on it.. post your message</div><div class="PT10"><textarea class="replyInt" name="f_message_'+dvid+'" id="f_message_'+dvid+'" onclick=\'javascript:if(this.value=="Type your message here"){this.value=""}\' onKeyDown="textCounter(this.form.f_message_'+dvid+',this.form.remLen,5000);" onKeyUp="textCounter(this.form.f_message_'+dvid+',this.form.remLen,5000);"></textarea></div><div class="PT10 PB7"><div class="FL b_12"></div><div class="FR"><div id="repybx_'+dvid+'"><a href="javascript:void(0);" onclick="update_reply_msg('+msgid+','+dvid+',1);"/><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/btn_reply.gif" /></a></div></div><div class="CL"></div></div><input type="hidden" name="exturl_'+dvid+'" id="exturl_'+dvid+'"></form>';
	
	open_div=dvid;	
	document.getElementById("rep_msg_"+dvid).style.display = "block";
	//document.getElementById("thank_msg_"+dvid).style.display = "none";
}


function update_rate(msgid,rate,data)
{
	if(data=="1")
		{
			call_fun="4";
			call_param=msgid;
			call_param1=rate;
			act_div='2';
			check_login('2');
		}
		else
		{

			$('#loginchk2').load($.post('/india/messageboard/home/ajax_update_rating.php?msg_id='+msgid+'&rating='+rate, '', function(data) 
			{					
					closesignin();	
					rateoff_open_ajax(open_div,msgid,data);
			        //alert(data);							
			       // closeme(open_div);

			}));
         
		}
}

function update_offence(msgid,data)
{		
	var reason = $('input[name=ofc_reason]:checked').val();	
	 if(data=="1")
		{
			call_fun="3";
			call_param=msgid;
			act_div='3';
			check_login('2');
		}
		else
		{

			$('#loginchk2').load($.post('/india/messageboard/home/ajax_update_offensive.php?msg_id='+msgid+'&f_reason='+reason, '', function(data) 
			{					
					closesignin();			
			        //alert(data);							
			        //closeme(open_div);
					rateoff_open_ajax(open_div,msgid,data);

			}));
         
		}
	
		
}

function update_track_thrad(thrdid,data)
{		

	 if(data=="1")
		{
			call_fun="4";
			call_param=thrdid;
			act_div='4';
			check_login('2');
		}
		else
		{

			$('#loginchk2').load($.post('/india/messageboard/home/ajax_update_trackthread.php?f_thread_id='+thrdid, '', function(data) 
			{					
					closesignin();			
			        alert(data);							
			       //closeme(open_div);

			}));
         
		}
		
}

function chkfeed(data)
{
	var msgobj=document.enter_newmsg.f_message;
	var headobj=document.enter_newmsg.f_heading;
	var extlkobj=document.enter_newmsg.url_link;
 
	var tmp=msgobj.value;
	var heading=headobj.value;
	var extrlk=extlkobj.value;
	
	tmp.replace(" ","");
	heading.replace(" ","");
 
	if(heading=="" || heading=="Heading")
	{
		alert("Please input heading");
		headobj.focus();
		return false;
	}
	
 
	if(tmp=="" || tmp=="Type your message here")
	{
		alert("Please input your Message");
		msgobj.focus();
		return false;
	}
 
	else if(tmp.length < 2)
	{
		alert ("Message needs to be more than 1 characters");
		return false;
	}
 
	if(tmp.length > 5000)
	{
		alert("max 5000 characters allowed");
		return false;
	}
 
	var char1=new Array('<','>','&lt;','&gt;');
	for(i=0;i<=char1.length;++i)
	{
		if(tmp.indexOf(char1[i],0)!=-1)
		{
		alert("No "+char1[i]+" allowed");
		return false;
		}
			
	}
 
	var str=tmp;
	str=str.toLowerCase();
	var char1=new Array('<','>','fuck','aswhole','co.uk','madarchod','bhenchod','gandu','chutiya','chutyie','bahenchod','randi','rascal','bastard','basturd','bastered','assole','asshole','fuck','sucker','fucker','chodu','lavde','makichut','makachut','mchod',' m chod','m.chod','raandi','raand','raandii',' randii',' laude','b.a.s.t.a.r.d.',' b a s t a r d',' chuteyas',' chuteya',' chut',' c h u t',' harame',' harami',' madar chod','bhen chod','benched','bhosdivaale','fodrichya',' bosrichya','ayzavadya','badwa',' bedwa','bedve','gaandu',' gandki','gaand',' chudu','chodu','Raand','Rand','chutiye','madar','chod','bhosda','choot','lode','haramzade','arsehole','chtye','gand','randi','madarjat','chut','MADARCHOD','BHADVE','chudane','chu-??-t','maderchod','fuc*ur','chudwa','Bhenchod','Haramkhoro','Madarchodo','teri ma ki chot','gand marvao','chhutttiya','bhossssaaadaa...','bhossssaaadaa','lunddd','matherfuker','bhen daaa pioo','madarchod','bhenchod','gandu','chutiya','chutyie','bahenchod','randi','rascal','bastard','basturd','bastered','assole','asshole','fuck','sucker','fucker','chodu','lavde','makichut','makachut','basterd','choot','moth er chod','mother`s cunt','madarchodo','madar chod','bastards','Chootwa','Burwa','Bur');
		
	for(i=0;i<=char1.length;++i)
	{
		if(str.indexOf(char1[i],0)!=-1)
		{
			alert("Word "+char1[i]+" not allowed");
			return false;
		}
	}

	if(extrlk!="")
	{
		var chkurl=new Array('http://');
		if(extrlk.indexOf(chkurl[0],0)==-1)
		{
		 alert('Please enter valid URL including http://');
		 return false;
		}

		var extrchr=new Array('<','>','&lt;','&gt;');
			
		for(i=0;i<=extrchr.length;++i)
		{
			if(extrlk.indexOf(extrchr[i],0)!=-1)
			{
			alert("Word "+extrchr[i]+" not allowed");
			return false;
			}					
		}
	}
 //alert(data);
 
	if(data=='1')
	{	  
		act_div='5';

        var msg_param=tmp;
		var head_param=heading;
		var exturl_param=extrlk;
		var tpid_param=document.enter_newmsg.f_topicid.value;
		var tp_param=document.enter_newmsg.f_topicname.value;
		var cat_param=document.enter_newmsg.f_category.value;
		var thrdid_param='';

		  $('#loginchk').load($.post('/india/messageboard/home/update_reply_action.php', '', function(data) 
			{					
				//alert(data);

				 try{
					 document.getElementById("post_ldr").style.display="block";
					 document.getElementById("post_but").style.display="none";
				 }catch(err){

				 }

				if(data==0)
				{						$('#loginchk2').load($.post('/india/messageboard/msgpost_before.php?msg='+escape(msg_param)+'&head='+escape(head_param)+'&extr_url='+exturl_param+'&topicid='+tpid_param+'&topic='+tp_param+'&category='+cat_param, '', function(data) 
				{
				 //alert(data);
				 document.enter_newmsg.gmsgid.value=data;
				 check_login('2');
				}));

				}
				else
				  check_login('2');
			}));
  

		//check_login('2');
		//return false;
	}else{
     document.enter_newmsg.submit();
     return true;
	}
}

function track_add(usr,data){
	if(data=="1"){
		act_div='6';
		call_param=usr;		
		check_login('2');
	}else{															
		$('#loginchk2').load($.post('/india/messageboard/ajax_mmb_tracking.php?userid='+usr , '', function(data) 
		{	
			alert(data);			
			$('#loginchk2').html(data);
			closesignin();	
		}));		
	}
}

function track_delete(usr,data){
	if(data=="1"){
		act_div='15';
		call_param=usr;		
		check_login('2');
	}else{															
		$('#loginchk2').load($.post('/india/messageboard/ajax_delete_trackuser.php?userid='+usr , '', function(data) 
		{	
			alert(data);			
			$('#loginchk2').html(data);
			closesignin();	
		}));		
	}
}

function update_track_topic(topicid,catid,data)
{			
	 if(data=="1")
		{
			call_fun="3";
			call_param=topicid;
			call_param1=catid;
			act_div='7';
			check_login('2');
		}
		else
		{

			$('#track_tp').load($.post('/india/messageboard/home/update_track_topics.php?f_topicid='+topicid+'&f_categoryid='+catid, '', function(data) 
			{		alert(data);			
							
					$('#track_tp').html(data);
					closesignin();	

			}));
         
		}
}

function del_track_topic(topicid,catid,data)
{			
	 if(data=="1")
		{
			call_fun="3";
			call_param=topicid;
			call_param1=catid;
			act_div='8';
			check_login('2');
		}
		else
		{

			$('#track_tp').load($.post('/india/messageboard/home/delete_track_topics.php?f_topicid='+topicid+'&f_categoryid='+catid, '', function(data) 
			{		alert(data);			
							
					$('#track_tp').html(data);
					closesignin();	

			}));
         
		}
}

function pop_chkfeed(data)
{
	var msgobj=document.enter_newmsg_pop.f_message;
	var headobj=document.enter_newmsg_pop.f_heading;
 
	var tmp=msgobj.value;
	var heading=headobj.value;
	
	tmp.replace(" ","");
	heading.replace(" ","");
 
	if(heading=="" || heading=="Heading")
	{
		alert("Please input heading");
		headobj.focus();
		return false;
	}
	
 
	if(tmp.length < 1)
	{
		alert("Please input your Message");
		msgobj.focus();
		return false;
	}
 
	else if(tmp.length < 2)
	{
		alert ("Message needs to be more than 1 characters");
		return false;
	}
 
	if(tmp.length > 5000)
	{
		alert("max 5000 characters allowed");
		return false;
	}
 
	var char1=new Array('<','>','&lt;','&gt;');
	for(i=0;i<=char1.length;++i)
	{
		if(tmp.indexOf(char1[i],0)!=-1)
		{
		alert("No "+char1[i]+" allowed");
		return false;
		}
			
	}
 
	var str=tmp;
	str=str.toLowerCase();
	var char1=new Array('<','>','fuck','aswhole','co.uk','Raand','Rand','chutiye','madar','chod','bhosda','choot','lode','haramzade','arsehole','chtye','gand','randi','madarjat','chut','MADARCHOD','BHADVE','chudane','chu-??-t','maderchod','fuc*ur','chudwa','Bhenchod','Haramkhoro','Madarchodo','teri ma ki chot','gand marvao','chhutttiya','bhossssaaadaa...','bhossssaaadaa','lunddd','matherfuker','bhen daaa pioo','madarchod','bhenchod','gandu','chutiya','chutyie','bahenchod','randi','rascal','bastard','basturd','bastered','assole','asshole','fuck','sucker','fucker','chodu','lavde','makichut','makachut','basterd','choot','moth er chod','mother`s cunt','madarchodo','madar chod','bastards','Chootwa','Burwa','Bur');
		
	for(i=0;i<=char1.length;++i)
	{
		if(str.indexOf(char1[i],0)!=-1)
		{
			alert("Word "+char1[i]+" not allowed");
			return false;
		}
	}

	
 //alert(data);
 
	if(data=='1')
	{	  
		act_div='9';
		check_login('2');
		//return false;
	}
     document.enter_newmsg_pop.submit();

   return true;
}

function m3post_callot()
	{
	   document.getElementById("m3post_1").style.display = "block";
	   document.getElementById("m3post_3").style.display = "block";
	   document.getElementById("m3post_2").innerHTML = '<p class="PT5"><textarea class="texbox2" name="f_message" id="f_message"></textarea></p>';
		document.getElementById("m3post_4").style.display = "block";
	   document.m3callot_newmsg.f_message.focus();
	}

 function m3callot_chkfeed(data)
	{
		var msgobj=document.m3callot_newmsg.f_message;
		var headobj=document.m3callot_newmsg.f_heading;
		var extlkobj=document.m3callot_newmsg.url_link;
		var boxstr=document.m3callot_newmsg.box_str.value;
    
		var tmp=msgobj.value;
		var heading=headobj.value;
		var extrlk=extlkobj.value;


		tmp.replace(" ","");
		heading.replace(" ","");
	 
		if(heading=="" || heading=="Heading")
		{
			alert("Please input heading");
			headobj.focus();
			return false;
		}
		
	 
		if(tmp=="" || tmp==boxstr)
		{
			alert("Please input your Message");
			msgobj.focus();
			return false;
		}
	 
		else if(tmp.length < 2)
		{
			alert ("Message needs to be more than 1 characters");
			return false;
		}
	 
		if(tmp.length > 5000)
		{
			alert("max 5000 characters allowed");
			return false;
		}
	 
		var char1=new Array('<','>','&lt;','&gt;');
		for(i=0;i<=char1.length;++i)
		{
			if(tmp.indexOf(char1[i],0)!=-1)
			{
			alert("No "+char1[i]+" allowed");
			return false;
			}
				
		}
	 
		var str=tmp;
		str=str.toLowerCase();
		var char1=new Array('<','>','fuck','aswhole','co.uk','madarchod','bhenchod','gandu','chutiya','chutyie','bahenchod','randi','rascal','bastard','basturd','bastered','assole','asshole','fuck','sucker','fucker','chodu','lavde','makichut','makachut','mchod',' m chod','m.chod','raandi','raand','raandii',' randii',' laude','b.a.s.t.a.r.d.',' b a s t a r d',' chuteyas',' chuteya',' chut',' c h u t',' harame',' harami',' madar chod','bhen chod','benched','bhosdivaale','fodrichya',' bosrichya','ayzavadya','badwa',' bedwa','bedve','gaandu',' gandki','gaand',' chudu','chodu','Raand','Rand','chutiye','madar','chod','bhosda','choot','lode','haramzade','arsehole','chtye','gand','randi','madarjat','chut','MADARCHOD','BHADVE','chudane','chu-??-t','maderchod','fuc*ur','chudwa','Bhenchod','Haramkhoro','Madarchodo','teri ma ki chot','gand marvao','chhutttiya','bhossssaaadaa...','bhossssaaadaa','lunddd','matherfuker','bhen daaa pioo','madarchod','bhenchod','gandu','chutiya','chutyie','bahenchod','randi','rascal','bastard','basturd','bastered','assole','asshole','fuck','sucker','fucker','chodu','lavde','makichut','makachut','basterd','choot','moth er chod','mother`s cunt','madarchodo','madar chod','bastards','Chootwa','Burwa','Bur');
			
		for(i=0;i<=char1.length;++i)
		{
			if(str.indexOf(char1[i],0)!=-1)
			{
				alert("Word "+char1[i]+" not allowed");
				return false;
			}
		}
		 
		 if(extrlk!="" && extrlk!="External URL")
			{
				var chkurl=new Array('http://');
				if(extrlk.indexOf(chkurl[0],0)==-1)
				{
				 alert('Please enter valid URL including http://');
				 return false;
				}

				var extrchr=new Array('<','>','&lt;','&gt;');
					
				for(i=0;i<=extrchr.length;++i)
				{
					if(extrlk.indexOf(extrchr[i],0)!=-1)
					{
					alert("Word "+extrchr[i]+" not allowed");
					return false;
					}					
				}
			}
			

			if(data=='1')
				{	  
					act_div='10';

					var msg_param=tmp;
					var head_param=heading;
					var exturl_param=extrlk;
					var tpid_param=document.m3callot_newmsg.f_topicid.value;
					var tp_param=document.m3callot_newmsg.f_topicname.value;
					var cat_param=document.m3callot_newmsg.f_category.value;
					var thrdid_param='';

					 $('#loginchk').load($.post('/india/messageboard/home/update_reply_action.php', '', function(data) 
						{					
							//alert(data);
                             document.getElementById("m3post_4").style.display="none";
							 document.getElementById("postldr_l").style.display="block";
							
							if(data==0)
							{						$('#loginchk2').load($.post('/india/messageboard/msgpost_before.php?msg='+escape(msg_param)+'&head='+escape(head_param)+'&extr_url='+exturl_param+'&topicid='+tpid_param+'&topic='+tp_param+'&category='+cat_param, '', function(data) 
							{
							 //alert(data);
							 document.m3callot_newmsg.gmsgid.value=data;
							 check_login('2');
							}));

							}
							else
							  check_login('2');
						}));
					   
				}
		
		
		 document.m3callot_newmsg.submit();

	   return true;
	}

function check_login(btn)
{	
	
	$('#loginchk').load($.post('/india/messageboard/home/update_reply_action.php', '', function(data) 
			{					
				if(data==0)
				{
					loginbx(btn);
				}
				else
				{
					if(act_div=='1')
						update_reply_msg(call_param,open_div,'2');
					else if(act_div=='2')
						update_rate(call_param,call_param1,'2');
					else if(act_div=='3')
						update_offence(call_param,'2');
					else if(act_div=='4')
						update_track_thrad(call_param,'2');
					else if(act_div=='5')
						chkfeed('2');
					else if(act_div=='6')
						track_add(call_param,'2');
					else if(act_div=='7')
						update_track_topic(call_param,call_param1,'2');
					else if(act_div=='8')
						del_track_topic(call_param,call_param1,'2');
					else if(act_div=='9')
						pop_chkfeed('2');
					else if(act_div=='10')
                        m3callot_chkfeed('2');
					else if(act_div=='11')
                        update_chat_msg('2');
					else if(act_div=='12')
                        update_repost(call_param,'2');
					else if(act_div=='13')
                        update_repost_article(call_param,'3');
					else if(act_div=='14')
                        send_pmsg_bdr(call_param,'2');
					else if(act_div=='15')
						  track_delete(call_param,'2');
				}
					
			}));
}

function chkuser_photo(dvid,dna)
{

	if(readCookie('nnmc'))
	  {
	      $('#tp_user_ph').load($.post('/india/messageboard/tp_ajax_user_photo.php?section=JS', '', function(data) 
						{												
							// alert(data);
							  if(data=="No Data")
								{
								}
							  else
								{
								     var myResult = data;
								    var mySplitResult = myResult.split("~");
									 
								document.getElementById("user_photo_"+dna+"_"+dvid).innerHTML=mySplitResult[0];
								document.getElementById("user_name_"+dna+"_"+dvid).innerHTML=mySplitResult[1];
								}
								 
						}));
	  }
}
function test111(uid,sess)
{

	var mess=document.forms["form"]["f_message"].value;
if (mess==null || mess=="")
  {
  alert("Please enetr a replay message");
  return false;
  }
	
	
}

function repy_open_ajax(dvid,msgid,uid,sess) {	
	//totdiv
// no useee

	chkuser_photo(dvid,'rep');
	 var chk_soc_opt=1;

   var tot=document.getElementById("totdiv").value;
 // alert(tot);
    for(i=0;i<tot;i++) {
		document.getElementById("rate_msg_"+i).style.display = "none";
	}
	for(i=0;i<tot;i++) {
		document.getElementById("offens_msg_"+i).style.display = "none";
		document.getElementById("share_msg_"+i).style.display = "none";
		document.getElementById("repost_msg_"+i).style.display = "none";
	}	
//no

	

	document.getElementById("rep_msg_"+dvid).innerHTML='<form method="post" action="" name="form" onsubmit="return test111('+uid+','+sess+')"><div style="width:482px;" class="arrow"><div class="ymsgbar MT5" id="msg_alert" style="display:none;">Messages posted within 200 characters are best viewed on mobile screens.  <a href="javascript:void(0);" onclick=document.getElementById("msg_alert").style.display="none" class="bl_12 uline">close</a></div><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/callArrow.gif" alt="" /></div><div align="right"><a href="javascript:void(0);" class="bl_11" onClick="closeme('+dvid+');"><img src="http://marketlive.commodityonline.com/images/btn_close.gif" width="13" height="13" alt="" border="0"/></a></div><div class="b_15"><div class="clearfix FL"><div class="FL PR10"><div id="user_photo_rep_'+dvid+'"></div></div><div class="FL PT10"><div id="user_name_rep_'+dvid+'"></div><strong>Reply to the Message</strong></div></div><div class="FR PT10"></div><div class="CL"></div></div><div class="PT10"><textarea class="replyInt" name="f_message" id="f_message_'+dvid+'" onclick=\'javascript:if(this.value=="Type your message here"){this.value=""}\' onKeyDown="textCounter(this.form.f_message_'+dvid+',this.form.remLen,5000);" onKeyUp="textCounter(this.form.f_message_'+dvid+',this.form.remLen,5000);"></textarea></div><div class="PT10 PB7"><div class="FL b_12"></div><div class="FR"><div id="repybx_'+dvid+'"><input type="image" src="http://marketlive.commodityonline.com/images/post.jpg" name="replay" /></div></div><div class="CL"></div></div><input type="hidden" name="exturl" id="exturl" value="'+msgid+'" /></form>';
	
	open_div=dvid;	
	//alert(open_div);
	document.getElementById("rep_msg_"+dvid).style.display = "block";
	//document.getElementById("thank_msg_"+dvid).style.display = "none";
}



function repclose(dvid)
{
	 document.getElementById("rep_msg_"+dvid).style.display = "none";
}


function test(uid,sess)
{
	var mess=document.forms["form11"]["c_message"].value;
if (mess==null || mess=="")
  {
  alert("Please enetr a replay message");
  return false;
  }
	
	if(uid==sess)
	{
		alert('sorry, you cannot replay this message');
		return false;
		}else{
			return true;
		}
}


function repy_com_ajax(dvid,msgid,uid,user,sess) {	
	//totdiv


	

	

	document.getElementById("rep_msg_"+dvid).innerHTML='<form method="post" action="" name="form11" onsubmit="return test('+user+','+sess+')"><div style="width:482px;" class="arrow"><div class="ymsgbar MT5" id="msg_alert" style="display:none;">Messages posted within 200 characters are best viewed on mobile screens.  <a href="javascript:void(0);" onclick=document.getElementById("msg_alert").style.display="none" class="bl_12 uline">close</a></div><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/callArrow.gif" alt="" /></div><div align="right"><a href="javascript:void(0);" class="bl_11" onClick="repclose('+dvid+');"><img src="http://marketlive.commodityonline.com/images/btn_close.gif" width="13" height="13" alt="" border="0"/></a></div><div class="b_15"><div class="clearfix FL"><div class="FL PR10"><div id="user_photo_rep_'+dvid+'"></div></div><div class="FL PT10"><div id="user_name_rep_'+dvid+'"></div><strong>Reply to the Message</strong></div></div><div class="FR PT10"></div><div class="CL"></div></div><div class="PT10"><textarea class="replyInt" name="c_message" id="c_message_'+dvid+'" onclick=\'javascript:if(this.value=="Type your message here"){this.value=""}\' onKeyDown="textCounter(this.form.f_message_'+dvid+',this.form.remLen,5000);" onKeyUp="textCounter(this.form.f_message_'+dvid+',this.form.remLen,5000);"></textarea></div><div class="PT10 PB7"><div class="FL b_12"></div><div class="FR"><div id="repybx_'+dvid+'"><input type="image" src="http://marketlive.commodityonline.com//images/post.jpg" name="replaycom" /></div></div><div class="CL"></div></div><input type="hidden" name="msgid" id="msgid" value="'+msgid+'" /> <input type="hidden" name="url" id="url" value="'+uid+'" /></form>';
	
	open_div=dvid;	
	//alert(open_div);
	document.getElementById("rep_msg_"+dvid).style.display = "block";
	//document.getElementById("thank_msg_"+dvid).style.display = "none";
}

function rate_open_ajax(dvid,msgid) {
	

	 document.getElementById("rate_msg_"+dvid).innerHTML='<div id="rate" style="width:270px;" class="arrow"><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/callArrow.gif" alt="" /></div><div align="right"><a href="javascript:void(0);" class="bl_11" onClick="closeme('+dvid+');"><img src="http://marketlive.commodityonline.com/images/btn_close.gif" width="13" height="13" alt="" border="0"/></a></div><div class="clearfix"><div class="FL PR10"><div id="user_photo_rate_'+dvid+'"></div></div><div class="FL PT10 b_15"><div id="user_name_rate_'+dvid+'"></div><strong>Rate this Message</strong></div></div><div class="b_15 PT20 PB20"></div>';

	 open_div=dvid;
	 document.getElementById("rate_msg_"+dvid).style.display = "block";
}



function offens_open_ajax(dvid,msgid) {
	var chk_soc_opt=3;
var tot=document.getElementById("totdiv").value;
	for(i=0;i<tot;i++) {
		document.getElementById("rep_msg_"+i).style.display = "none";
	}
	for(i=0;i<tot;i++) {
		document.getElementById("rate_msg_"+i).style.display = "none";
	}
	for(i=0;i<tot;i++) {
		document.getElementById("offens_msg_"+i).style.display = "none";
		document.getElementById("share_msg_"+i).style.display = "none";
		document.getElementById("repost_msg_"+i).style.display = "none";
		document.getElementById("rep_msg_"+i).style.display = "none";
	}



	document.getElementById("offens_msg_"+dvid).innerHTML='<div style="width:475px;" class="arrow"><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/callArrow.gif" alt="" /></div><div class="clearfix PB10"><div class="FL PR10"><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/userPhoto.jpg" alt="" /></div><div class="FL PT10 b_15"><a href="#" class="bl_12">Rajesh Seth</a><br /><strong>Click if Offensive</strong></div></div><div class="gl_12 PT10"><b>Thankyou for moderating the messageboard. We appreciate your concern to keep the forum clean. We will notify <span class="bl_12"><b>expertbola</b></span> that the message has been marked offensive by you.</b></div><div><ul class="offCont"><li><input type="radio" class="vam MR5" name="ofc_reason" value="1">Personal attacks - name calling, insulting, etc - on other boarders</li><li><input type="radio" class="vam MR5" value="2" name="ofc_reason">Insensitive references to any race, sex, religion, caste or linguistic community</li><li><input type="radio" class="vam MR5" value="3" name="ofc_reason">Statements that are deliberately made to evoke outrage</li><li><input type="radio" class="vam MR5" value="4" name="ofc_reason">Verbal violence or threats</li><li><input type="radio" class="vam MR5" value="5" name="ofc_reason">Offensive or abusive language</li><li><input type="radio" class="vam MR5" value="6" name="ofc_reason">Blatant and mischievous misrepresentation of facts</li><li><input type="radio" class="vam MR5" value="7" name="ofc_reason">Spamming - obsessive repetitiveness</li><li><input type="radio" class="vam MR5" value="8" name="ofc_reason">Message with commercial or promotional content</li><li><input type="radio" class="vam MR5" value="9" name="ofc_reason">Malafide insinuations related to the integrity, probity and judgment of the Moneycontrol Team</li></ul><div class="MT10 CL PL10 PB20"><a style="" class="bl_11" onclick="update_offence(7188049,1);" href="javascript:void(0);"><img border="0" align="absmiddle" class="MR10" src="http://img1.moneycontrol.com/images/messageboard/ver_july11/btn_submit02.jpg"></a><a style="" class="bl_11" onclick="closeme(0);" href="javascript:void(0);">Cancel</a></div></div>';



	open_div=dvid;
	document.getElementById("offens_msg_"+dvid).style.display = "block";
	//document.getElementById("thank_msg_"+dvid).style.display = "none";
	  
}


function testone(uid,sess)
{
	
	
	if(uid==sess)
	{
		alert('sorry, you cannot repost this message');
		return false;
		}else{
			return true;
		}
}

function offens_options(dvid,msgid,mess,uid,sess) {

// alert(sess);

	document.getElementById("offens_msg_"+dvid).innerHTML='<form method="post" action="" onsubmit="return testone('+uid+','+sess+')"><div style="width:482px;" class="arrow"><div class="ymsgbar MT5" id="msg_alert" style="display:none;">Messages posted within 200 characters are best viewed on mobile screens.  <a href="javascript:void(0);" onclick=document.getElementById("msg_alert").style.display="none" class="bl_12 uline">close</a></div><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/callArrow.gif" alt="" /></div><div align="right"><a href="javascript:void(0);" class="bl_11" onClick="closeme('+dvid+');"><img src="http://marketlive.commodityonline.com/images/btn_close.gif" width="13" height="13" alt="" border="0"/></a></div><div class="b_15"><div class="clearfix FL"><div class="FL PR10"><div id="user_photo_rep_'+dvid+'"></div></div><div class="FL PT10"><div id="user_name_rep_'+dvid+'"></div><strong>Repost this message</strong></div></div><div class="FR PT10"></div><div class="CL"></div></div><div class="PT10">'+mess+'</div><div class="PT10 PB7"><div class="FL b_12"></div><div class="FR"><div id="repybx_'+msgid+'"><input type="image" src="http://marketlive.commodityonline.com//images/btn_repost.gif" name="repost"/></div></div><div class="CL"></div></div><input type="hidden" name="id" id="id" value="'+msgid+'" /><input type="hidden" name="mess" id="mess" value="'+mess+'" /></form>';

	open_div=dvid;
	document.getElementById("offens_msg_"+dvid).style.display = "block";
	//document.getElementById("thank_msg_"+dvid).style.display = "none";
}

function close11(dvid)
{
	
 document.getElementById("offens_msg_"+dvid).style.display = "none";
}

function testone1(uid,sess)
{
	
	
	if(uid==sess)
	{
		alert('sorry, you cannot repost this message');
		return false;
		}else{
			return true;
		}
}

function repost(dvid,msgid,uid,mess,user,sess) {



	document.getElementById("offens_msg_"+dvid).innerHTML='<form method="post" action="" onsubmit="return testone1('+user+','+sess+')"><div style="width:482px;" class="arrow"><div class="ymsgbar MT5" id="msg_alert" style="display:none;">Messages posted within 200 characters are best viewed on mobile screens.  <a href="javascript:void(0);" onclick=document.getElementById("msg_alert").style.display="none" class="bl_12 uline">close</a></div><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/callArrow.gif" alt="" /></div><div align="right"><a href="javascript:void(0);" class="bl_11" onClick="close11('+dvid+');"><img src="http://marketlive.commodityonline.com/images/btn_close.gif" width="13" height="13" alt="" border="0"/></a></div><div class="b_15"><div class="clearfix FL"><div class="FL PR10"><div id="user_photo_rep_'+dvid+'"></div></div><div class="FL PT10"><div id="user_name_rep_'+dvid+'"></div><strong>Repost this message</strong></div></div><div class="FR PT10"></div><div class="CL"></div></div><div class="PT10">'+mess+'</div><div class="PT10 PB7"><div class="FL b_12"></div><div class="FR"><div id="repybx_'+msgid+'"><input type="image" src="http://marketlive.commodityonline.com//images/btn_repost.gif" name="repostcom"/></div></div><div class="CL"></div></div><input type="hidden" name="uid" id="uid" value="'+uid+'" /><input type="hidden" name="messcom" id="messcom" value="'+mess+'" /></form>';

	open_div=dvid;
	document.getElementById("offens_msg_"+dvid).style.display = "block";
	//document.getElementById("thank_msg_"+dvid).style.display = "none";
}



function ss(dvid)
{
	var w= document.getElementById("repost_msg_"+dvid).style.display = "none";
	//alert(w);
}


function share(dvid,msgid) {	
	//totdiv
   
	document.getElementById("repost_msg_"+dvid).innerHTML='<div style="width:475px;" class="arrow"><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/callArrow.gif" alt="" /></div><div align="right"><a href="javascript:void(0);" class="bl_11" onClick="ss('+dvid+');"><img src="http://marketlive.commodityonline.com/images/btn_close.gif" width="13" height="13" alt="" border="0"/></a></div></div>';
	
	open_div=dvid;	

document.getElementById("repost_msg_"+dvid).style.display = "block";

}

function update_repost(msgid,data)
{
	
	if(data=="1")
	{
			call_fun="4";
			call_param=msgid;
			act_div='12';
			check_login('2');
	}else if(data=="3"){
		try{
			if(type=='video')type='video';
			else type='news';
		}catch(err){
		    type = 'news';
		}
		$('#loginchk2').load($.post('/india/messageboard/ajax_update_repost.php?autono='+msgid+'&type='+type, '', function(data) 
		{					
					var data_arr=data.split("~");  
					var resdata=data_arr[0].substring(0,9);
					var showmsg=0;
					try{
						var m3msg = trim(document.m3sharefrm.f_message_article.value);
						if(m3msg!=''){
							if(m3msg.length>20){
								var mid=document.replyfrm.r_rply_id.value;
								document.replyfrm.moverefname.value=data_arr[1];
								closesignin();			
								closeme(open_div);
								update_reply_msg(mid,'article','2');
							}else{
                                 showmsg=1;          
							}
						}else{
							 showmsg=1;
						}
					}catch(err){
						//alert(err)
						showmsg=1;          
					}
					if(showmsg==1){
						alert(data_arr[0]);
						if(resdata=='Thank you'){
							document.repostredirect.action=data_arr[1];
							document.repostredirect.submit();
						}
						closesignin();
						closeme(open_div);
					}
		}));
	}else
	{
		$('#loginchk2').load($.post('/india/messageboard/ajax_update_repost.php?msg_id='+msgid, '', function(data) 
		{					
					var data_arr=data.split("~");
					closesignin();			
			        alert(data_arr[0]);							
			        closeme(open_div);
					var resdata=data_arr[0].substring(0,9);
					if(resdata=='Thank you'){
						//window.location.reload();
						document.repostredirect.repostmsgid.value=msgid;
						document.repostredirect.submit();
					}
		}));
	}
}



  function closeme(dvid)
	{
		//alert(divid);
		 document.getElementById("rate_msg_"+dvid).style.display = "none";
		 document.getElementById("rep_msg_"+dvid).style.display = "none";
		 document.getElementById("offens_msg_"+dvid).style.display = "none";
		 document.getElementById("share_msg_"+dvid).style.display = "none";
         document.getElementById("repost_msg_"+dvid).style.display = "none";
		
	}



function closesignin(){tb_remove();}


function get_ratedby(msid)
	{
		
		$('#msgrate_'+msid).load($.post('/india/messageboard/get_msg_ratedby.php?msgid='+msid, '', function(data) 
					{					
						$('#msgrate_'+msid).html(data);
					}));
	}

function textCounter(field, countfield, maxlimit) 
{
	if(field.value.length>200)
		document.getElementById("msg_alert").style.display='block';
    else
       document.getElementById("msg_alert").style.display='none';
	
}

function get_trackedby(thrdid,msgid)
{
	
	$('#msgtrack_'+msgid).load($.post('/india/messageboard/get_msg_trackby.php?thread_id='+thrdid, '', function(data) 
				{					
					$('#msgtrack_'+msgid).html(data);
				}));
}

//Facebook Login Popup
function openFacebookPopup(url){	
	var url = "http://login.moneycontrol.com/social_user/Login.php?fblogin"+url;

	var match = navigator.userAgent.match("MSIE (.)");
	var version = match && match.length > 1 ? match[1] : "";
	if(version != "" && version > 6){ 
		fbLoginWindow = window.open(url,'FacebookLogin','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=850,height=500,left=180,top=15');
	}else{
		fbLoginWindow = window.open(url,'FacebookLogin','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=850,height=500,left=180,top=15');
	}
	

	if (window.focus){
		fbLoginWindow.focus()
	}
	return false;
}

//Twitter Login Popup
function twitterLoginPopup(url) {
	var url = 'http://login.moneycontrol.com/social_user/getTwitterData.php?twlogin'+url;

	var match = navigator.userAgent.match("MSIE (.)");
	var version = match && match.length > 1 ? match[1] : "";
	if(version != "" && version > 6){
		twLoginWindow = window.open(url,'TwitterLogin','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=400,left=230,top=15');
	}else{
		twLoginWindow = window.open(url,'TwitterLogin','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=400,left=230,top=15');
	}

	if (window.focus){
		twLoginWindow.focus()
	}
	return false;
}

//Google Login Popup
function googleLoginPopup(url) {
	var url = 'http://login.moneycontrol.com/social_user/Login.php?glogin'+url;

	var match = navigator.userAgent.match("MSIE (.)");
	var version = match && match.length > 1 ? match[1] : "";
	if(version != "" && version > 6){
		ggLoginWindow = window.open(url,'GoogleLogin','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=400,left=230,top=15');
	}else{
		ggLoginWindow = window.open(url,'GoogleLogin','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=400,left=230,top=15');
	}

	if (window.focus){
		ggLoginWindow.focus()
	}
	return false;
}

//Yahoo Login Popup
function yahooLoginPopup(url) {
	var url = 'http://login.moneycontrol.com/social_user/Login.php?ylogin'+url;

	var match = navigator.userAgent.match("MSIE (.)");
	var version = match && match.length > 1 ? match[1] : "";
	if(version != "" && version > 6){
		yhLoginWindow = window.open(url,'YahooLogin','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=400,left=230,top=15');
	}else{
		yhLoginWindow = window.open(url,'YahooLogin','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no, width=800,height=400,left=230,top=15');
	}

	if (window.focus){
		yhLoginWindow.focus()
	}
	return false;
}


function fade_inshow(obj,bcolor,fcolor,olcolor)
{
	var objid=eval("document.getElementById('"+obj+"')");
	objid.style.background='#'+bcolor;
	objid.style.color='#'+fcolor;
	setTimeout("fade_outshow('"+obj+"','','#"+olcolor+"')",3000);
}

function fade_outshow(obj,bcolor,fcolor)
{
	var objid=eval("document.getElementById('"+obj+"')");
	objid.style.background = bcolor;
	objid.style.color = fcolor;
}

////////////////  SENSEX Values:
function sensex_auto()
{
	var rn_cach = new Date().getTime() + Math.floor(Math.random() * (324-102)) + 340;	
	$.getJSON("http://www.moneycontrol.com/india/messageboard/get_sensex_nifty_val.php?f_domain=cross&format=json&_="+rn_cach+"&jsoncallback=?",function(data){	
		
		if(data[0].BValue.length > 2 && data[1].NValue.length > 2)
		{			
			var currentcloseprice_nse = parseFloat(data[1].NValue);
			currentcloseprice_nse = currentcloseprice_nse.toFixed(2);
			var change_nse = parseFloat(data[1].Nchg);
			change_nse = change_nse.toFixed(2);

			var currentcloseprice_bse = parseFloat(data[0].BValue);
			currentcloseprice_bse = currentcloseprice_bse.toFixed(2);
			var change_bse = parseFloat(data[0].Bchg);
			change_bse = change_bse.toFixed(2);

			if(change_bse > 0)
			{
				var img_arr_bse = "http://img1.moneycontrol.com/images/messageboard/home/uparw.gif";
				var bse_cls = 'grn_14';
			}
			else
			{
				var img_arr_bse = "http://img1.moneycontrol.com/images/messageboard/home/downarw.gif";
				var bse_cls = 'r_14';
			}
			if(change_nse > 0)
			{
				var img_arr_nse = "http://img1.moneycontrol.com/images/messageboard/home/uparw.gif";
				var nse_cls = 'grn_14';
			}
			else
			{
				var img_arr_nse = "http://img1.moneycontrol.com/images/messageboard/home/downarw.gif";
				var nse_cls = 'r_14';
			}

			
			var bsecurr_old = parseFloat(document.getElementById("sensex_val_top").innerHTML);
			var nsecurr_old = parseFloat(document.getElementById("nifty_val_top").innerHTML);

			document.getElementById("sensex_val_top").innerHTML=currentcloseprice_bse;
			if(bsecurr_old>currentcloseprice_bse)
				fade_inshow('sensex_val_top','cc0000','FFF','000');
			else if(bsecurr_old<currentcloseprice_bse)
				fade_inshow('sensex_val_top','006600','FFF','000');

			document.getElementById("sensex_change").innerHTML=change_bse;
			document.getElementById("nifty_val_top").innerHTML=currentcloseprice_nse;
			if(nsecurr_old>currentcloseprice_nse)
				fade_inshow('nifty_val_top','cc0000','FFF','000');
			else if(nsecurr_old<currentcloseprice_nse)
				fade_inshow('nifty_val_top','006600','FFF','000');

			document.getElementById("nifty_change").innerHTML=change_nse;
			document.getElementById("bse_img_top").src=img_arr_bse;
			document.getElementById("nse_img_top").src=img_arr_nse;

			document.getElementById("sensex_change").className = bse_cls;
			document.getElementById("nifty_change").className = nse_cls;
		}  
	});	
}

/* Article Page JS */

function chkuser_photo_article(dvid,dna)
{
	if(readCookie('nnmc'))
	{
		$('#tp_user_ph').load($.post('/india/messageboard/tp_ajax_user_photo.php?section=JS', '', function(data) 
			{												
				// alert(data);
				  if(data=="No Data")
					{
					}
				  else
					{
						 var myResult = data;
						var mySplitResult = myResult.split("~");
						 
					document.getElementById("user_photo_"+dna+"_"+dvid).innerHTML=mySplitResult[0];
					document.getElementById("user_name_"+dna+"_"+dvid).innerHTML=mySplitResult[1];
					}
					 
			}));
	  }
}

function repost_open_ajax_article(dvid,autono) {	
	//totdiv
	chkuser_photo_article(dvid,'repost');
	var chk_soc_opt=4;
	try{
		if(type=='video')type='video';
		else type='news';
	}catch(err){
		type = 'news';
	}
	if(type=='video')var disptxt='Repost this Video';
	else var disptxt='Repost this News';
	$('#tp_user_ph').load($.post('/india/messageboard/get_repost_txt.php?autono='+autono+'&type='+type, '', function(data) 
	{
		var data_arr=data.split("~#~");
		data=data_arr[0];
		var tid=data_arr[1];
		var mid=data_arr[2];
		if(data=="No Data")
		{
		}
		else
		{
			$("#repost_txt_"+dvid).html(data);
			open_div=dvid;	
			$("#repost_msg_"+dvid).show("slow");
			var mtype = '';
			document.replyfrm.f_thread_id.value=tid;
			document.replyfrm.r_rply_id.value=mid;
			document.repostredirect.repostmsgid.value=mid;
		}
	}));
}

function closeme_article(dvid)
{	 
	 $("#repost_msg_"+dvid).hide("slow");
}

function update_repost_article(autono,data)
{	
	if(data=="1")
	{
		call_fun="4";
		call_param=autono;
		act_div='13';
		check_login('2');
	}
	else
	{
		try{
			if(type=='video')type='video';
			else type='news';
		}catch(err){
              type = 'news';
		}
		$('#loginchk2').load($.post('/india/messageboard/ajax_update_repost.php?autono='+autono+'&type='+type, '', function(data) 
		{
			var data_arr=data.split("~");
			var resdata=data_arr[0].substring(0,9);
			var showmsg=0;
			try{
				var m3msg = trim(document.m3sharefrm.f_message_article.value);
				if(m3msg!=''){
					if(m3msg.length>20){
						var mid=document.replyfrm.r_rply_id.value;
						document.replyfrm.moverefname.value=data_arr[1];
						closesignin();			
						closeme(open_div);
						update_reply_msg(mid,'article','2');
					}else{
						showmsg=1;
					}
				}else{
					 showmsg=1;
				}
			}catch(err){
                //alert(err)
				var showmsg=1;
			}
			if(showmsg==1){
				alert(data_arr[0]);		
				if(resdata=='Thank you'){
					document.repostredirect.action=data_arr[1];
					document.repostredirect.submit();
				}
				closesignin();			
				closeme(open_div);
			}
		}));
     }
}


function submit_m3share(frm){
	var m3sharemsg = trim(frm.f_message_article.value);
	var m3autono = trim(frm.m3autono.value);
	var act_div='13';
	if(m3sharemsg!=''){
          if(m3sharemsg.length<2){
			  alert("Message needs to be more than 1 characters.");
			  return false;
		  }else{
             update_repost_article(m3autono,'1');    
		  }
	}else{
		update_repost_article(m3autono,'1');
	}
    return false;
}

/*----------*/// JavaScript Document



function repyfollow_open_ajax(dvid,msgid) {	
	//totdiv




	document.getElementById("rep_msg_"+dvid).innerHTML='<form method="post" action="" name="form" onsubmit="return test('+uid+','+sess+')"><div style="width:482px;" class="arrow"><div class="ymsgbar MT5" id="msg_alert" style="display:none;">Messages posted within 200 characters are best viewed on mobile screens.  <a href="javascript:void(0);" onclick=document.getElementById("msg_alert").style.display="none" class="bl_12 uline">close</a></div><img src="http://img1.moneycontrol.com/images/messageboard/ver_july11/callArrow.gif" alt="" /></div><div align="right"><a href="javascript:void(0);" class="bl_11" onClick="closeme('+dvid+');"><img src="http://marketlive.commodityonline.com/images/btn_close.gif" width="13" height="13" alt="" border="0"/></a></div><div class="b_15"><div class="clearfix FL"><div class="FL PR10"><div id="user_photo_rep_'+dvid+'"></div></div><div class="FL PT10"><div id="user_name_rep_'+dvid+'"></div><strong>Reply to the Message</strong></div></div><div class="FR PT10"></div><div class="CL"></div></div><div class="PT10"><textarea class="replyInt" name="f_message" id="f_message_'+dvid+'" onclick=\'javascript:if(this.value=="Type your message here"){this.value=""}\' onKeyDown="textCounter(this.form.f_message_'+dvid+',this.form.remLen,5000);" onKeyUp="textCounter(this.form.f_message_'+dvid+',this.form.remLen,5000);"></textarea></div><div class="PT10 PB7"><div class="FL b_12"></div><div class="FR"><div id="repybx_'+dvid+'"><input type="image" src="http://marketlive.commodityonline.com//images/post.jpg" name="replay" /></div></div><div class="CL"></div></div><input type="hidden" name="exturl" id="exturl" value="'+msgid+'" /></form>';
	
	open_div=dvid;	
	//alert(open_div);
	document.getElementById("rep_msg_"+dvid).style.display = "block";
	//document.getElementById("thank_msg_"+dvid).style.display = "none";
}

