function loginbox()
{
	        Delete_Cookie('redirect_path_ibn', '/', '');
			var_url=document.location.href;
			set_cookie("redirect_path_ibn", var_url,0,0,0,'/',"",'');
			if( get_cookie("POST_DATA_IBN") != "")
			{
				var_url=document.location.href;
				if((get_cookie_variable(get_cookie("POST_DATA_IBN"),2)=="") && (get_cookie_variable(get_cookie("POST_DATA_IBN"),3)==""))
				{
				var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),1);
				}
				else
				{
				var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),2)+' '+get_cookie_variable(get_cookie("POST_DATA_IBN"),3);
				}
			   //user no (integer)**user name**First Name**Last Name**Email**Country**Blaze id**Blaze image**FB image**FB URL**Source Log-in (0-IBN/1-Facebook/2-Twitter/3-Google) 
    			var us_id=get_cookie_variable(get_cookie("POST_DATA_IBN"),0);
    			var cookieBlazeId      = get_cookie_variable(get_cookie("POST_DATA_IBN"),6);
    			var cookieBlazeImage   = get_cookie_variable(get_cookie("POST_DATA_IBN"),7);
				if (cookieBlazeImage == 'undefined') cookieBlazeImage = '';
    			var cookieUserImage    = get_cookie_variable(get_cookie("POST_DATA_IBN"),8);
				if (cookieUserImage == 'undefined') cookieUserImage = '';
				var cookieSiteViaLogin = get_cookie_variable(get_cookie("POST_DATA_IBN"),10);
				if (cookieUserImage != '' && cookieUserImage != null) 
					document.write ('<a href="/conversations/user/'+us_id+'.html" target="_top" ><img src="'+cookieUserImage+'" width="22" height="22" style="padding:0px 5px 0px 0px;" /></a> <a href="/conversations/user/'+us_id+'.html" target="_top" >'+us_name+'</a> | <a class="none" href="/ibnregistration/logout.php" target="_top">Sign out</a>');
				else if (cookieBlazeImage != '')
					document.write ('<a href="/conversations/user/'+us_id+'.html" target="_top" ><img src="'+cookieBlazeImage+'" width="22" height="22" style="padding:0px 5px 0px 0px;" /></a> <a href="/conversations/user/'+us_id+'.html" target="_top" >'+us_name+'</a> | <a class="none" href="/ibnregistration/logout.php" target="_top">Sign out</a>');
				else
					document.write ('<a href="/conversations/user/'+us_id+'.html" target="_top" >'+us_name+'</a> | <a class="none" href="/ibnregistration/logout.php" target="_top">Sign out</a>');
				return true;

			}
			else
	        {
			
			document.write('<a href="/ibnregistration/login.php?url_path='+var_url+'">Sign In</a><a href="/ibnregistration/login.php?url_path='+var_url+'"><img src="http://static.ibnlive.com/pix/social/facebook_sicon01.gif" align="absmiddle" style="padding:0px 5px 0px 5px;"></a><a href="/ibnregistration/login.php?url_path='+var_url+'"><img src="http://static.ibnlive.com/pix/social/twitter_sicon01.gif" align="absmiddle" style="padding:0px 5px 0px 5px;"></a><a href="/ibnregistration/login.php?url_path='+var_url+'"><img src="http://static.ibnlive.com/pix/social/in_sicon01.gif" alt="Login" title="Login" align="absmiddle" style="padding:0px 5px 0px 0px;"></a>&nbsp;|&nbsp;<a class="none" href="/ibnregistration/ibn_common_registration.php" target="_top" > Register</a>');

			}
}

function tUser()
{
	        Delete_Cookie('redirect_path_ibn', '/', '');
			var_url=document.location.href;
			set_cookie("redirect_path_ibn", var_url,0,0,0,'/',"",'');
			if( get_cookie("POST_DATA_IBN") != "")
			{
				var_url=document.location.href;
				if((get_cookie_variable(get_cookie("POST_DATA_IBN"),2)=="") && (get_cookie_variable(get_cookie("POST_DATA_IBN"),3)==""))
				{
				var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),1);
				}
				else
				{
				var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),2)+' '+get_cookie_variable(get_cookie("POST_DATA_IBN"),3);
				}

				var us_id=get_cookie_variable(get_cookie("POST_DATA_IBN"),0);
				//document.write ('<a href="/conversations/user/'+us_id+'.html" target="_top" >'+us_name+'</a></li><li><a class="none" href="/ibnregistration/logout.php" target="_top">Sign out</a>');
				return true;

			}
			else
	        {
				top.location.href = "/ibnregistration/login.php?url_path="+var_url;
			}

}
function follow_button()
{
	var c= tUser();
	if(c==true)
	{top.location.href = "/blaze/follow.html";}
}
function recent_button()
{
	var c= tUser();
	if(c==true)
	{top.location.href = "/blaze/recent.html";}
}
function popular_button()
{
	var c= tUser();
	if(c==true)
	{top.location.href = "/blaze/popular.html";}
}


function follow(aid)
{
	var c= tUser();
	if(c==true)
	{
	
		 var us_id=get_cookie_variable(get_cookie("POST_DATA_IBN"),0);
		 var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),2)+' '+get_cookie_variable(get_cookie("POST_DATA_IBN"),3);

		 $.post("/touch/api/follow.php", {'aid': aid,'follow':'1'}, function(data)
		 { 
			 //alert(data);
			$('#follow_text_'+aid).html(data);
			$("#"+aid+"_follow").hide();
			$("#"+aid+"_unfollow").show();

			 
		 });

	}

}
function unfollow(aid)
{
	var c= tUser();
	if(c==true)
	{
	
		 var us_id=get_cookie_variable(get_cookie("POST_DATA_IBN"),0);
		 var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),2)+' '+get_cookie_variable(get_cookie("POST_DATA_IBN"),3);

		 $.post("/touch/api/unfollow.php", {'aid': aid,'unfollow':'0'}, function(data)
		 { 
			 //alert(data);
			$('#follow_text_'+aid).html(data);
			$("#"+aid+"_follow").show();
			$("#"+aid+"_unfollow").hide();

			 
		 });
	}


}

function follow_h(aid,str)
{
	var c= tUser();
	if(c==true)
	{
	
		 var us_id=get_cookie_variable(get_cookie("POST_DATA_IBN"),0);
		 var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),2)+' '+get_cookie_variable(get_cookie("POST_DATA_IBN"),3);

		 $.post("/touch/api/follow.php", {'aid': aid,'follow':'1'}, function(data)
		 { 
			 //alert(data);
			$('#follow_text_'+aid).html(data);
			$("#"+aid+"_follow").hide();
			$("#"+aid+"_unfollow").show();

			 
		 });

	}

}
function unfollow_h(aid,str)
{
	var c= tUser();
	if(c==true)
	{
	
		 var us_id=get_cookie_variable(get_cookie("POST_DATA_IBN"),0);
		 var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),2)+' '+get_cookie_variable(get_cookie("POST_DATA_IBN"),3);

		 $.post("/touch/api/unfollow.php", {'aid': aid,'unfollow':'0'}, function(data)
		 { 
			 //alert(data);
			 $("#f_"+str).hide();
			/*$('#follow_text_'+aid).html(data);
			$("#"+aid+"_follow").show();
			$("#"+aid+"_unfollow").hide();*/

			 
		 });
	}


}

function follow_y(aid)
{
	var c= tUser();
	if(c==true)
	{
	
		 var us_id=get_cookie_variable(get_cookie("POST_DATA_IBN"),0);
		 var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),2)+' '+get_cookie_variable(get_cookie("POST_DATA_IBN"),3);

		 $.post("/touch/api/follow.php", {'aid': aid,'follow':'1'}, function(data)
		 { 
			 //alert(data);
			//$('#follow_text_'+aid).html(data);
			$("#"+aid+"_follow_y").hide();
			$("#"+aid+"_unfollow_y").show();

			 
		 });

	}

}
function unfollow_y(aid)
{
	var c= tUser();
	if(c==true)
	{
	
		 var us_id=get_cookie_variable(get_cookie("POST_DATA_IBN"),0);
		 var us_name=get_cookie_variable(get_cookie("POST_DATA_IBN"),2)+' '+get_cookie_variable(get_cookie("POST_DATA_IBN"),3);

		 $.post("/touch/api/unfollow.php", {'aid': aid,'unfollow':'0'}, function(data)
		 { 
			 //alert(data);
			//$('#follow_text_'+aid).html(data);
			$("#"+aid+"_follow_y").show();
			$("#"+aid+"_unfollow_y").hide();

			 
		 });
	}


}

	<!--
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
//-->

function chkNumeric(strString)
   //  check for valid numeric strings	
   {
   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 frm_validate(str)
{  
	   MM_validateForm('question','','R','name','','R');
	   if(document.MM_returnValue == true)
	   {
		var	emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
		var	phoneRe = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,3})|(\(?\d{2,3}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/


				var question =document.getElementById('question').value;
				var name =document.getElementById('name').value;
				var email_id =document.getElementById('email_id').value;
				var mobile =document.getElementById('mobile').value;
				var strLen = mobile.length;
				//alert(strLen)

		if (!emailRe.test(email_id) && email_id != "")
			{
				alert("Enter the proper Email-ID");
				return false;
			}
		if(mobile != "")
		   {
				if ((chkNumeric(mobile) == false) || strLen < 10)
				{
					alert("Enter the 10 digit Mobile number");
					return false;
				}
		   }


			 $.post("/api/submitquestion_bypeople.php", {'question': question,'topic_id':str,'name': name,'email_id':email_id,'mobile': mobile}, function(data)
			   {
			   //alert(data);
			   $("#cd2").hide(); 
			   $("#cd1").show(); 
			   $("#cd1").html("<h2 align='center'>Thank you for your question. It will be published after moderation.</h2>"); 

			   });
			   //return true;
		
	   }
	   return false;
	    

}

function frm_validate_right(str)
{  
//alert('asddsa')
	   MM_validateForm('question','','R','name','','R');
	   if(document.MM_returnValue == true)
	   {
		var	emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
		var	phoneRe = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,3})|(\(?\d{2,3}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/


				var question =document.getElementById('question').value;
				var name =document.getElementById('name').value;
				var email_id =document.getElementById('email_id1').value;
				var mobile =document.getElementById('mobile1').value;
				var strLen = mobile.length;
				//alert(strLen)

		if (!emailRe.test(email_id) && email_id != "")
			{
				alert("Enter the proper Email-ID");
				return false;
			}
		if(mobile != "")
		   {
				if ((chkNumeric(mobile) == false) || strLen < 10)
				{
					alert("Enter the 10 digit Mobile number");
					return false;
				}
		   }


			 $.post("/api/submitquestion_bypeople.php", {'question': question,'topic_id':str,'name': name,'email_id':email_id,'mobile': mobile}, function(data)
			   {
			   //alert(data);
			   $("#cd2").hide(); 
			   $("#cd1").show(); 
			   $("#cd1").html("<h2 align='center'>Thank you for your question. It will be published after moderation.</h2>"); 

			   });
			   //return true;
		
	   }
	   return false;
	    

}

function frm_validate_answerraghav(str)
{  
	var	emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
		var	phoneRe = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,3})|(\(?\d{2,3}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/


	   MM_validateForm('title','','R','answer','','R','username','','R');
	   if(document.MM_returnValue == true)
	   {
		   		var title =document.getElementById('title').value;
				var answer =document.getElementById('answer').value;
				var name =document.getElementById('username').value;
				var email_id =document.getElementById('email_id').value;
				var mobile =document.getElementById('mobile').value;


			if (!emailRe.test(email_id) && email_id != "")
			{
				alert("Enter the proper Email-ID");
				return false;
			}
		if(mobile != "")
		   {
				if ((chkNumeric(mobile) == false) || strLen < 10)
				{
					alert("Enter the 10 digit Mobile number");
					return false;
				}
		   }


			 $.post("/api/submitanswer_bypeople.php", {'title': title,'answer': answer,'topic_id':str,'name': name,'email_id':email_id,'mobile': mobile}, function(data)
			   {
			   //alert(data);
			   $("#cd2answer").hide(); 
			   $("#cd1answer").show(); 
			   $("#cd1answer").html("<h2 align='center'>Thank you for your answers. It will be published after moderation.</h2>"); 

			   });
			   //return true;
		
	   }
	   return false;
	    

}
function frm_chat_validate(str,str1)
{  
	   MM_validateForm('question','','R');
	   if(document.MM_returnValue == true)
	   {

           var question =document.getElementById('question').value;
		    var user_name =document.getElementById('user_name').value;
		     //  $("#cd1").show(); 
			 //  $("#cd1").html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 

		   $.post("/touch/api/chatAuestionSubmit.php", {'question': question,'topic_id':str,'author_id':str1,'user_name':user_name}, function(data)
			   {
			   //alert(data);
			   $("#cd2").hide(); 
			   $("#cd1").show(); 
			   $("#cd1").html("<h2 align='center'>"+data+"</h2>"); 

			   });
		
	   }

}

function frm_validate_pending(tid,pid,web18id,web18username,offset)
{  
	   MM_validateForm('answer','','R');
	   if(document.MM_returnValue == true)
	   {

            var answer =document.getElementById('answer_'+pid).value;
            //  $("#"+pid+"_P1").show(); 
			   //$("#"+pid+"_P1").html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 
		   $.post("/touch/api/submitanswer_byadmin.php", {'answer': answer,'topic_id':tid,'post_id':pid,'web18_id':web18id,'web18username':web18username,'offset':offset}, function(data)
			   {
			  // alert(data);
			    $("#"+pid+"_P0").hide(); 
			   $("#"+pid+"_P2").hide(); 
			   $("#"+pid+"_P1").show(); 
			   $("#"+pid+"_P1").html("<h2 align='center'>Thank you for your answer</h2>"); 

			   });
		
	   }

}

function frm_validate_admin_chat(tid,pid)
{  
	   MM_validateForm('answer','','R');
	   if(document.MM_returnValue == true)
	   {

            var answer =document.getElementById('answer').value;

			//$("#"+pid+"_P1").show(); 
			 //  $("#"+pid+"_P1").html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 



		   $.post("/touch/api/answerAdmin.php", {'answer': answer,'topic_id':tid,'chat_id':pid}, function(data)
			   {
			  // alert(data);
			    $("#"+pid+"_P0").hide(); 
			   $("#"+pid+"_P2").hide(); 
			   $("#"+pid+"_P1").show(); 
			   $("#"+pid+"_P1").html("<h2 align='center'>Thank you for your answer</h2>"); 

			   });
		
	   }

}

function frm_validate_answer(author_id)
{  
	   MM_validateForm('question','','R');
	   if(document.MM_returnValue == true)
	   {

                var question =document.getElementById('question').value;
			//	$("#cd1").show(); 
			  // $("#cd1").html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 


		   $.post("/touch/api/submitquestion_byadmin.php", {'author_id': author_id,'question': question}, function(data)
			   {
			 // alert(data);
			   $("#cd2").hide(); 
			   $("#cd1").show(); 
			   $("#cd1").html("<h2 align='center'>Your Question has been submitted</h2>"); 
			   window.location.reload();

			   });
		
	   }

}

function frm_validate_answeruser(tid)
{  
	   MM_validateForm('answer','','R');
	   if(document.MM_returnValue == true)
	   {

            var answer =document.getElementById('answer').value;

				$("#"+tid+"_P1").show(); 
			   $("#"+tid+"_P1").html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 



		   $.post("/touch/api/submitanswer_bypeople.php", {'answer': answer,'topic_id':tid}, function(data)
			   {
			//alert(data);
			    //$("#"+pid+"_P0").hide(); 
			    $("#"+tid+"_P2").hide(); 
			   $("#"+tid+"_P1").show(); 
			   $("#"+tid+"_P1").html("<h2 align='center'>Your Answer has been submitted</h2>");

			   });
		
	   }

}


function anchor_header(str)
{
	if(str != '')
	{
		$("#anchor_header").html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 
 $.post("/touch/api/anchor_header.php", {'author_id':str}, function(data)
			   {
			   $("#anchor_header").html(data); 

			   });
	}
}

function cBox(tid,offset)
{
	
	$("#cBox_"+offset).html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 
        $.post("/api/cBox.php", {'topic_id': tid,'offset':offset}, function(data)
			   {
			   //alert(data);
			   	   $("#cBox_"+offset).html(data); 

			   });
	

}

function cBox_answer(tid,offset)
{
	
	$("#cBox_"+offset).html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 
        $.post("/api/cBox_answer.php", {'topic_id': tid,'offset':offset}, function(data)
			   {
			   //alert(data);
			   	   $("#cBox_answer_"+offset).html(data); 

			   });
	

}


function cBox_answer_all(author_id,offset,mode)
{
	$("#cBox_answer_all_"+offset).html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 
        $.post("/touch/api/cBox_answer_all.php", {'author':author_id,'offset':offset,'mode':mode}, function(data)
			   {
			   //alert(data);
			   	   $("#cBox_answer_all_"+offset).html(data); 

			   });
	

}


function adminBox_ask(tid,aid,offset,mode)
{
	$("#adminBox_ask_"+offset).html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 
        $.post("/touch/api/adminBox_ask.php", {'topic_id':tid,'author_id': aid,'offset':offset,'mode':mode}, function(data)
			   {
			   //alert(data);
			   	   $("#adminBox_ask_"+offset).html(data); 

			   });
	

}


function loadVoting(cid,sid,story_type)
{

 $.post("/touch/voting/getBox.php", {'content_id': cid,'site_id': sid,'story_type': story_type}, function(data)
{
   $("#vote_"+cid+"_"+story_type).html(data);
});

}

function loadVoting_chat(cid,sid,story_type)
{
 $.post("/touch/voting_chat/getBox.php", {'content_id': cid,'site_id': sid,'story_type': story_type}, function(data)
{
   $("#vote_"+cid+"_"+story_type).html(data);
});

}

function total()
{
$.post("/touch/api/totalcount.php", {'aid': '1'}, function(data)
  {
   $('#total').html(data);
  });
}
function abox(pid)
{
$("#ansbox_"+pid).show(); 
}

function shuffle()
{
	$("#shuffle").html("<div><b><img src = 'http://static.ibnlive.com/pix/touch/images/ajax-loader.gif' border = '0'></b></div>"); 
$.post("/touch/api/shuffle.php", {'aid': '1'}, function(data)
  {
   $('#shuffle').html(data);
  });
}
function opentxt(str)
{
//alert(str)
$("[id^=txt_]").hide();
$("#txt_"+str).show();

}

function rject_answered(pid,tid)
{
 $.post("/touch/api/rject_answered.php", {'post_id': pid,'topic_id': tid}, function(data)
{
   $("#main-"+pid).hide();
});

}
function approved_answered(pid,tid)
{
 $.post("/touch/api/approved_answered.php", {'post_id': pid,'topic_id': tid}, function(data)
{
   $("#main-"+pid).hide();
});

}

function del_questions(tid)
{
 $.post("/touch/api/del_questions.php", {'topic_id': tid}, function(data)
{
	window.location.reload();
   //$("#main-"+pid).hide();
});

}

function del_questions_user(pid)
{
 $.post("/touch/api/del_questions_user.php", {'post_id': pid}, function(data)
{
	window.location.reload();
   //$("#main-"+pid).hide();
});

}

function del_questions_userbyanchor(pid)
{
 $.post("/touch/api/del_questions_user.php", {'post_id': pid}, function(data)
{
	//window.location.reload();
   $("#"+pid+"_P0").hide();
});

}

function uncomments_questions_answer(pid,rpid)
{
 $.post("/touch/api/uncomments_questions_answer.php", {'post_id': pid,'reply_post_id': rpid}, function(data)
{
	//window.location.reload();
   $("#"+rpid+"_P0").hide();
});

}


