var shrno,rt,finalvalue;function hidedivshown(a,b){dropdowncontent.hidediv("subcontent_"+a)}function record_rating(a,b){var c="shrno="+a;c=c+"&rt="+b;url="save_sharesms_ratings.aspx";b=new Ajax.Request(url,{method:"post",postBody:c,onSuccess:function(d){document.getElementById("txt_er_"+a).innerHTML=d.responseText;document.body.style.cursor="";return false},onFailure:function(d){alert(d.responseText);document.body.style.cursor="";return false}});document.body.style.cursor="wait";return false}
function clearall(a){document.getElementById("txt_share_no_"+a).value="";return false}
function save_msg(){var a;a=document.getElementById("txt_share_sms").value;a=trimAll(a);if(a==""){alert("Please enter your message for sharing");document.getElementById("txt_share_sms").focus();return false}if(a.length<5){alert("Please enter valid message");document.getElementById("txt_share_sms").focus();return false}if(a.length>140){alert("Please enter your message with in 140 characters");document.getElementById("txt_share_sms").focus();return false}a="shr_msg="+a;url="save_share_sms.aspx";a=new Ajax.Request(url,
{method:"post",postBody:a,onSuccess:function(b){alert("Your message shared successfully");document.getElementById("btn_share_submit").disabled=false;document.body.style.cursor="";window.location.href="sharesms.aspx";return false},onFailure:function(b){alert(b.responseText);document.getElementById("btn_share_submit").disabled=false;document.body.style.cursor="";return false}});document.getElementById("btn_share_submit").disabled=true;document.body.style.cursor="wait";return false}
function clear_share_sms(){document.getElementById("txt_share_sms").value="";document.getElementById("txt_sharesms_count").innerHTML=140;return false}
function alertMsgLength(){var a;if(document.getElementById("txt_share_sms").value.length>140){a=document.getElementById("txt_share_sms").value;document.getElementById("txt_share_sms").value=a.substring(0,140);document.getElementById("txt_share_sms").focus();return false}a=document.getElementById("txt_share_sms").value.length;document.getElementById("txt_sharesms_count").innerHTML=140-a}
function ShowPopUp(a,b){for(var c=document.getElementById("popup"),d=0,f=0,g=b;g.tagName!="BODY"&&g.offsetParent!=null;){d+=g.offsetLeft;f+=g.offsetTop;g=g.offsetParent}f+=b.offsetHeight;c.style.left=d+"px";c.style.top=f+"px";document.getElementById("sharesubmit").onclick=function k(i){share_sms(a,this)};ClearPopUp();c.style.visibility="visible"}function ClearPopUp(){document.getElementById("txtHint").innerHTML="";document.getElementById("popupform").reset()}
function hidepopup(){document.getElementById("popup").style.visibility="hidden"}
function share_sms(a,b){var c;c=document.getElementById("txt_shared_sms_"+a).innerHTML;if(document.getElementById("shareMnos").value==""){alert("Please enetr mobile number to share this sms");document.getElementById("shareMnos").focus();return false}if(!formatnumber(a)){document.getElementById("shareMnos").focus();finalvalue="";return false}var d="shrno="+a;d+="&shr_msg="+c;d+="&shr_mobile="+finalvalue;url="save_send_share_sms.aspx";c=new Ajax.Request(url,{method:"post",postBody:d,onSuccess:function(f){document.getElementById("txtHint").innerHTML=
"sms sent successfully";b.disabled=false;document.body.style.cursor="";document.getElementById("txt_no_of_shares_"+a).innerHTML=parseInt(document.getElementById("txt_no_of_shares_"+a).innerHTML)+1;setTimeout("hidepopup()",2E3);return false},onFailure:function(f){document.getElementById("txtHint").innerHTML="Unable to Process,Please Try Again";b.disabled=false;document.body.style.cursor="";return false}});b.disabled=true;document.body.style.cursor="wait";return false}var groups,contacts;
function loadcontacts(){postdata="t="+(new Date).getTime()+"&nogroups=yes";var a=new Ajax.Request("getcontactlist.aspx",{method:"get",postBody:postdata,onSuccess:function(b){var c=b.responseText;b=c.split(":");c=c.replace(":",",");c=new AutoSuggestControl(document.getElementById("shareMnos"),new StateSuggestions(c));contacts=b[0]},onFailure:function(b){return false}})}
function formatnumber(a){finalvalue="";a=[];var b,c,d,f;a=trimAll(document.getElementById("shareMnos").value).split(",");c=f=false;if(a.length>10){alert("Cannot send More than 10 SMS at a time");return false}for(x=0;x<a.length;x++){b=trimAll(a[x].toString());b=b.toLowerCase();if(groups==null||(","+groups+",").toLowerCase().search(","+b+",")==-1){if(f){alert("Send SMS to either contacts or group.");return false}if(contacts.indexOf(b)!=-1){c=b.indexOf("<");d=b.indexOf(">");if(c>0)b=b.substring(c+1,
d)}if(!validatemobilenumber(b))return false;c=true;if(b.length==10&&(b.indexOf("9")==0||b.indexOf("8")==0))b="91"+b}else{if(f){alert("Send SMS to one group Only");return false}if(c){alert("Send SMS to either contacts or group.");return false}f=true}finalvalue+=b+","}return true}
function Init(){if(document.getElementById("hidShareUserId").value>0){loadcontacts();LoadUserShareSms(1)}else{document.getElementById("smsholder").innerHTML="No User Founded";document.getElementById("PleaseWait").style.display="none";document.getElementById("smsholder").style.display="block"}}
function LoadUserShareSms(a){var b=document.getElementById("hidShareUserId").value,c=document.getElementById("hidShareUserName").value;a=new Ajax.Request("load_usersharesms.aspx",{method:"post",postBody:"spage="+a+"&shareuserid="+b,onSuccess:function(d){d=d.responseXML.getElementsByTagName("sharesms");var f=document.getElementById("smsholder");document.getElementById("PleaseWait").style.display="none";document.getElementById("smsholder").style.display="block";if(d.length==0){var g=document.createElement("div");
g.innerHTML="User Has Not Posted Any Sms's";f.appendChild(g)}else{f.innerHTML="";var k=false;if(d[0].getElementsByTagName("sms_message")[0].firstChild.nodeValue==1)k=true;for(var i=1;i<d.length;i++){var l=d[i].getElementsByTagName("sms_message")[0].firstChild.nodeValue;g=document.createElement("div");var e="";if(i!=d.length-1){var m=d[i].getElementsByTagName("User_name")[0].firstChild.nodeValue,j=document.getElementById("UserImg").src;if(j.indexOf("avatar")>0)j+="?s=30";var h=d[i].getElementsByTagName("shrno")[0].firstChild.nodeValue,
n=d[i].getElementsByTagName("TimeString")[0].firstChild.nodeValue,p=d[i].getElementsByTagName("effective_rating")[0].firstChild.nodeValue,o=d[i].getElementsByTagName("no_of_shares")[0].firstChild.nodeValue;if(k){e+="<div style='margin-left:15px;'>";e+="<img src='"+j+"' style='margin-top:10px;'  alt='"+m+"' class='udi'/>";e+="<p class='commenttop' style='float:left;' id='txt_shared_sms_"+h;e+="' name='txt_shared_sms_"+h+"'>"+l+"</p>  ";e+=" </div> <div style='clear:both;'></div> ";e+="<div class='comments'>  <div style='float:left;'><span style='background:#ffff99;'>";
e+="<span id='txt_no_of_shares_"+h+"'>"+o+"</span> Shares </span> - ";e+=" <a href='javascript:void(null);' id='contentlink_share_"+h+"' onclick='javascript:ShowPopUp(\""+h+"\",this);' ><b>Share It </b></a>";e+="</div> <div style='float:right;'><b>"+n+"</b></div> <div>";e+="<img src='images/up.gif' style='cursor:pointer;' onclick='return record_rating("+h+",0)' class='udi'/> ";e+="<img src='images/down.gif' style='cursor:pointer;' onclick='return record_rating("+h+",1)' class='udi'/> "}else{e+="<div style='margin-left:15px;'>";
e+="<img src='"+j+"' style='margin-top:10px;'  alt='"+m+"' class='udi'/>";e+="<p class='commenttop' style='float:left;' id='txt_shared_sms_"+h;e+="' name='txt_shared_sms_"+h+"'>"+l+"</p> </div>";e+="<div style='clear:both;'></div> ";e+="<div class='comments'> <div style='float:left;'><span style='background:#ffff99;'>";e+="<span id='txt_no_of_shares_"+h+"'>"+o+"</span> Shares </span> - ";e+=" <a href='index.aspx?hmsg=0011&shareuser="+c+"' id='contentlink_share_"+h+"' ><b>Share It </b></a>";e+="</div> <div style='float:right;'><b>"+
n+"</b></div> <div>";e+=" <a href='index.aspx?hmsg=0011&shareuser="+c+"'> <img src='images/up.gif' style='cursor:pointer;'  class='udi'/> </a>";e+="<a href='index.aspx?hmsg=0011&shareuser="+c+"'><img src='images/down.gif' style='cursor:pointer;' class='udi'/> </a>"}e+="<span id='txt_er_"+h+"'>"+p+"</span> </div> </div>"}else{e+=l;g.style.cssText="text-align:center;font-weight:bold;"}g.innerHTML=e;f.appendChild(g)}}},onFailure:function(d){return false}});document.getElementById("smsholder").style.display=
"none";document.getElementById("PleaseWait").style.display="block";return false}
function FollowUser(){postdata="shareuserid="+document.getElementById("hidShareUserId").value;var a=new Ajax.Request("FollowUser.aspx",{method:"post",postBody:postdata,onSuccess:function(b){if(b.responseText=="OK"){document.getElementById("Follow").innerHTML="<b> Following </b>";document.getElementById("Followers").innerHTML=parseInt(document.getElementById("Followers").innerHTML)+1}},onFailure:function(b){return false}});return false};