//1st line loader.js:
if('undefined' == typeof Ild){Ild={d:'http://ishare.ibibo.com',j:(new Date()).valueOf(),l:'',x:0,t:'',Fls:function(u){e=document.createElement('SCRIPT');e.src=u;e.id='Is'+Ild.j;document.getElementsByTagName('HEAD')[0].appendChild(e)},Flc:function(u){e=document.createElement('LINK');e.rel='stylesheet';e.type='text/css';e.href=u;e.id='Ic'+Ild.j;document.getElementsByTagName('HEAD')[0].appendChild(e)},Fi:function(){u=Ild.d+'/z.php?l=';if(!Ild.Fj())u+='js/jquery.js,';u+='js/thickbox.js';Ild.Fls(u);Ild.Flc(Ild.d+'/css/thickbox.css')},Fr:function(){if(Ild.Fj()&&'undefined' != typeof Itb)Itb.Foc(Ild.l);else{if(5>Ild.x++)Ild.t=setTimeout('Ild.Fr()',1500)}},Fj:function(){return 'function'==typeof jQuery},Fl:function(l){Ild.x=0;Ild.l=l;if(Ild.t)clearTimeout(Ild.t);Ild.t=setTimeout('Ild.Fr()',500)}};Ild.Fi();function ishare_tb_onclick(l){if(l.href.indexOf('iinvite.ibibo.com')!=-1)return true;Ild.Fl(l);return false}}
(function(c){c.fn.progression=function(e){var f=c.extend({Current:50,Maximum:100,Background:"#FFFFFF",TextColor:"#0A35A6",aBackground:"#FE5B00",aTextColor:"#ffffff",BorderColor:"#9AC8E0",Animate:true,AnimateTimeOut:5000,Easing:"linear"},c.fn.progression.defaults,e);if(e){var d=e.Current}return this.each(function(){$this=c(this);$innerdiv=$this.find(".progress");var m=c.metadata?c.extend({},f,$this.metadata()):f;if($innerdiv.length!=1){b($this,m)}else{if(d){m.Current=d}m.Maximum=parseInt($this.attr("pmax"))}if(m.Current>m.Maximum){a("La valeur demandee doit etre inférieur ou egale a la valeur maximale.");return false}var h=Math.round(parseInt($this.attr("pcur"))/m.Maximum*100);var g=Math.round(parseInt(m.Current)/m.Maximum*100);if(m.Animate){var j=parseInt($this.attr("pcur"));var l=Math.abs(j-m.Current);var k=Math.floor(m.AnimateTimeOut/m.Maximum);$innerdiv.queue("fx",[]);$innerdiv.stop();$innerdiv.animate({width:g+"%"},{duration:Math.round(k*(l+1)),queue:false,easing:m.Easing});for(i=0;i<=l;i++){$innerdiv.animate({opacity:1},{duration:Math.round(k*i),queue:false,complete:function(){if(j<=m.Current){c(this).progressionSetTextTo(j++)}else{c(this).progressionSetTextTo(j--)}}})}}else{$innerdiv.css({width:g+"%"});$innerdiv.progressionSetTextTo(m.Current)}})};function b(d,e){d.html("");d.css({textAlign:"left",overflow:"hidden",backgroundColor:e.Background,borderColor:e.BorderColor,color:e.TextColor});if(e.Width){d.css("width",e.Width)}if(e.Height){d.css({height:e.Height,lineHeight:e.Height})}if(e.BackgroundImg){d.css({backgroundImage:"url("+e.BackgroundImg+")"})}$innerdiv=c("<div class='progress'></div>");c("<div class='text'>&nbsp;</div>").css({position:"absolute",width:"100%",height:"100%",textAlign:"center"}).appendTo(d);c("<span class='text'>&nbsp;</span>").css({position:"absolute",width:d.width(),textAlign:"center"}).appendTo($innerdiv);d.append($innerdiv);$innerdiv.css({position:"absolute",width:0,height:"100%",overflow:"hidden",backgroundColor:e.aBackground,color:e.aTextColor});if(e.aBackgroundImg){$innerdiv.css({backgroundImage:"url("+e.aBackgroundImg+")"})}d.attr("pmax",e.Maximum);d.attr("pcur",0)}c.fn.progressionSetTextTo=function(d){return this.each(function(){$this=c(this).parent();if($this.attr("pmax")!=100){$this.find(".text").html(loadingtext)}else{$this.find(".text").html(loadingtext)}$this.attr("pcur",d)})};function a(d){if(window.console&&window.console.log){window.console.log("jQuery Progression: "+d)}}c.fn.progression.defaults={}})(jQuery);


//jquery scrollTo:
;(function($){var $scrollTo=$.scrollTo=function(target,duration,settings){$scrollTo.window().scrollTo(target,duration,settings);};$scrollTo.defaults={axis:'y',duration:1};$scrollTo.window=function(){return $($.browser.safari?'body':'html');};$.fn.scrollTo=function(target,duration,settings){if(typeof duration=='object'){settings=duration;duration=0;}
settings=$.extend({},$scrollTo.defaults,settings);duration=duration||settings.speed||settings.duration;settings.queue=settings.queue&&settings.axis.length>1;if(settings.queue)
duration/=2;settings.offset=both(settings.offset);settings.over=both(settings.over);return this.each(function(){var elem=this,$elem=$(elem),t=target,toff,attr={},win=$elem.is('html,body');switch(typeof t){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(t)){t=both(t);break;}
t=$(t,this);case'object':if(t.is||t.style)
toff=(t=$(t)).offset();}
$.each(settings.axis.split(''),function(i,axis){var Pos=axis=='x'?'Left':'Top',pos=Pos.toLowerCase(),key='scroll'+Pos,act=elem[key],Dim=axis=='x'?'Width':'Height',dim=Dim.toLowerCase();if(toff){attr[key]=toff[pos]+(win?0:act-$elem.offset()[pos]);if(settings.margin){attr[key]-=parseInt(t.css('margin'+Pos))||0;attr[key]-=parseInt(t.css('border'+Pos+'Width'))||0;}
attr[key]+=settings.offset[pos]||0;if(settings.over[pos])
attr[key]+=t[dim]()*settings.over[pos];}else
attr[key]=t[pos];if(/^\d+$/.test(attr[key]))
attr[key]=attr[key]<=0?0:Math.min(attr[key],max(Dim));if(!i&&settings.queue){if(act!=attr[key])
animate(settings.onAfterFirst);delete attr[key];}});animate(settings.onAfter);function animate(callback){$elem.animate(attr,duration,settings.easing,callback&&function(){callback.call(this,target);});};function max(Dim){var el=win?$.browser.opera?document.body:document.documentElement:elem;return el['scroll'+Dim]-el['client'+Dim];};});};function both(val){return typeof val=='object'?val:{top:val,left:val};};})(jQuery);
//end scrollTo

var currentajaxindicator=false;
var currentajaxindicatorcount=0;

var loadingtext="";
function ajaxstart(){
	//ignore if url is presensearray/a 
	if(this.url.match(/^presensearray/)){return;}
	if(this.url.match(/searchnew\//)){return;}
	loadingtext="Loading...";
	loadingstart();

    if(location.href=="http://isms.ibibo.com/contact" && appnameglobaljs=="tata")
    {
    	jstracktata();
    }
    else
    {
	var disurl=this.url;
	 
	disurl=disurl.replace(/\//g,'');
	disurl=disurl.replace(/\?/g,'&');
	disurl="/i/i.php?p="+disurl.replace(/\//g,'');
	jQuery("#iframecorrector").attr("src",disurl);
    }
}

function jstracktata()
{
if(location.href=="http://isms.ibibo.com/contact" && appnameglobaljs=="tata")
{
	 
		var disurl;			 
		disurl="/i/c.php";
		jQuery("#iframecorrector").attr("src",disurl);
}
}
function loadingstart(){
	jQuery('#progressbar').progression({Current:currentajaxindicatorcount,AnimateTimeOut:0,Animate:false});
	clearTimeout(currentajaxindicator);
	jQuery("#progressbar").fadeIn(100);
	currentajaxindicatorcount=0;
	currentajaxindicator=setInterval(ajaxupdate,10);	
	ajaxupdate();
}

function ajaxupdate(){
	//achillies heel ... 
	var diff= parseInt((100-currentajaxindicatorcount)/100*15);
	//if(diff<2){diff= -(10*Math.random())};
	if(diff==1) diff=-1;
	currentajaxindicatorcount+=diff;
	if(currentajaxindicatorcount>90){
		clearTimeout(currentajaxindicator);
	}else{
	jQuery('#progressbar').progression({Current:currentajaxindicatorcount,AnimateTimeOut:100});
	}
}

function ajaxend(){
	jQuery('#progressbar').progression({Current:100,AnimateTimeOut:300});
	currentajaxindicatorcount=0;
	clearTimeout(currentajaxindicator);
	jQuery("#progressbar").fadeOut(700);
}

jQuery.ajaxSetup({"beforeSend": ajaxstart,"complete": ajaxend});

function workstart(){
	document.body.style.cursor="wait"
	loadingtext="Working...";
	currentajaxindicatorcount=50
	jQuery('#progressbar').progression({Current:currentajaxindicatorcount,AnimateTimeOut:0,Animate:false});
	clearTimeout(currentajaxindicator);
	jQuery("#progressbar").show(0);
	//currentajaxindicatorcount=0;
	currentajaxindicator=setInterval(ajaxupdate,10);	
	ajaxupdate();	
}
function workend(){
	jQuery('#progressbar').progression({Current:100,AnimateTimeOut:300});
	currentajaxindicatorcount=0;
	clearTimeout(currentajaxindicator);
	jQuery("#progressbar").fadeOut(10);
	document.body.style.cursor="";
}
 
  
  function make_friend (fid, guid) {
    jQuery.get('/addfriend/a?fid='+fid,
	           function (d){
                  eval('var da='+d);
                  if (da.success == 1){
					 jQuery("span.makefriend_"+da.receiver).hide();
                     balert('Friend request sent');
		          } else {
                     balert('Friend request failed! Please try again later');
		          }
	           }
	);
  }

function followask(guid,action,name){
if(action=='add'){
	Boxy.ask("<h2>Do you want to receive "+name+"'s updates by SMS?</h2>",["Yes","No, only follow on web"],
	function(a){
	if(a=='Yes'){
		follow(guid,action,1,name);
	}else{
		follow(guid,action,0,name);
	}}
	)
	}
}

function follow(guid, action,devupdate,nam){
    jQuery.get('/addfollower/a?uid='+guid+'&action='+action+'&dev='+devupdate,
	           function(d){
                  eval('var da='+d);
                  if (da.success == 1){
					  if (action == 'add') {
					      jQuery("span.follow_"+da.followee).hide();
					      
						  jQuery("span.follow_delete_"+da.followee).show('slow');
						  jQuery(".fbutton"+da.followee).hide();
						  var appe = "";
						  if(devupdate==1 && da.linked==''){
							appe=" Please link your number to get SMS updates!"
						  }
						  balert('You are now following '+ jQuery(".fbutton"+da.followee).attr('fname')+appe);
					  } else {
					      jQuery("span.follow_"+da.followee).show('slow');
						  jQuery("span.follow_delete_"+da.followee).hide();
						  jQuery("#mcont"+da.followee).hide();
						  balert('You are not following '+nam +' anymore');
					  }
		          } else {
                     balert('failed! :-( please try again later');
		          }
	           }
	);
}

function changedeviceupdatestate(guid,newstatus,nam){
	jQuery(".devupd"+guid).html('Updating...');
	jQuery.get('/followdeviceupdate/a',{dev:newstatus,guid:guid},
	function(d){
		if(0+d==0){
			balert("Please link your mobile number first!");
			location.href="http://imobile.ibibo.com/Call/Start.aspx?turl=http://isms.ibibo.com/follow/1/ifollow.html#LISMSPostContainer";
			return;
		}


		var ht="<span class='devgui#GUID#' title='#TITLE#'><a href=\"javascript:void(changedeviceupdatestate('#GUID#',1,'#NAM#'))\" class=\"devgui#GUID#\"><span style='color:#COLOR#'>#STARTSTOP#</span> SMS updates</a></span>";
			var color='green';
			var startstop='Start';
			var title = "Click to start receving updates from "+nam+" by SMS!";
		if(newstatus==1){
			color='red';
			startstop='Stop';
			balert("You will now receive "+nam+"'s updates by SMS");
			title="You are receiving updates from "+nam+" by SMS. Click to stop";
		}else{
			balert("You will no longer receive "+nam+"'s updates by SMS");
		}
		ht=ht.replace(/#GUID#/g,guid);
		ht=ht.replace(/#COLOR#/g,color);
		ht=ht.replace(/#STARTSTOP#/g,startstop);
		ht=ht.replace(/#NAM#/g,nam);
		ht=ht.replace(/#TITLE#/g,title);
		jQuery(".devupd"+guid).html(ht).tooltip();
		setTimeout(function(){
		jQuery(".devgui"+guid).tooltip();
		},500);
	}
	);
}

function commentiframeshow(id){
	//open up the comments iframe here:
	jQuery("#comment_img_"+id).show();
	var h="<img id='comment_img_"+id+"' style='position:absolute;padding-left:50px;padding-top:20px' src='/images/loading-small.gif'/><iframe id='comment_iframe_"+id+"' src='/discuss/topic-iframe.php?id="+id+"'  onload='ciframeloaded("+id+")' style='width:100%;height:200px;border:0;borders:1px solid #000000' border='0'></iframe>";
//	var h="<iframe id='comment_iframe_"+id+"' src='/discuss/topic-iframe.php?id="+id+"'  style='width:100%;height:200px;border:0;border:0'></iframe>";
	jQuery("#comment_"+id).html(h);
	return false;
}
function ciframeloaded(id){
	jQuery("#comment_img_"+id).hide();
}

deferload = function(j,t){
		if(typeof(t)=='undefined'){t=3000;}
		setTimeout(function(){
		var sob=document.createElement('SCRIPT');
		sob.src=j;
		document.getElementsByTagName('HEAD')[0].appendChild(sob);
		},t);
}

deferloadcss = function(c,t){
		if(typeof(t)=='undefined'){t=3000;}
		setTimeout(function(){

	  var sob=document.createElement("link")
	  sob.setAttribute("rel", "stylesheet")
	  sob.setAttribute("type", "text/css")
	  sob.setAttribute("href", c)
	document.getElementsByTagName('HEAD')[0].appendChild(sob);
		},t);
}


function notifinbox(){
	//take me to the inbox
	if(location.href.match(/ibibo\.com\/contact/)){
		contentswitch('inbox');
	}else{
		location.href="/contact?po=inbox";
	}
}

function notifinreply(num){
	//take me to the inbox
	if(location.href.match(/ibibo\.com\/contact/)){
		contentswitch('sms');
		jQuery("#toid").val(num);
	}else{
		location.href="/contact?po=sms";
	}
}

function pnotify(msg){
	jQuery.jGrowl(msg,{sticky:true});
	profileoverlay(".imgpnotify");
}

function websms(guid){
	if(jQuery("#websmsinput"+guid+":visible").length==0){
		jQuery("#websmsinput"+guid).show('fast');
		jQuery("#websmsinput"+guid+" textarea").val('').focus();
	}else{
		jQuery("#websmsinput"+guid).hide('fast');
		jQuery("#websmsinput"+guid+" textarea").val('');
	}
}
function websmssend(guid){
	var parr=Array();
	parr['guid']=guid;
	parr['websms']=jQuery("#websmsinput"+guid+" textarea").val();
	if(jQuery.trim(parr['websms'])==''){
		balert('Cant send a blank!');
		jQuery("#websmsinput"+guid+" textarea").focus();
		return false;
	}
	jQuery("#websmsinput"+guid).hide('fast');
	jQuery("#websmsinput"+guid+" textarea").val('')
	
	jQuery.get('/websms/a?recipient='+encodeURIComponent(parr['guid'])+"&websms="+encodeURIComponent(parr['websms']),function(d){
		eval("var ret="+d);
		balert(ret['msg']);	
		
		return;
	})
}

function profileoverlay(jselector){
	jQuery(jselector).tooltip({
		delay: 0, 
		showURL: false,
		fade: 250,
		id:'tooltipajax',
		linger: true,
		bodyHandler: function(){
			var guid=jQuery(this).attr('guid');
			var ht='';
			if(mycache[guid]){
				ht=mycache[guid];
			}else{
				ht="<div id='imgoverlay"+guid+"'><img src='http://isms.ibibo.com/images/loading-big.gif'/><div>Loading profile ...</div></div>";
				jQuery.get('/profileoverlay/a?gu='+guid,function(d){
					jQuery('#imgoverlay'+guid).html(d);
					mycache[guid]=d;
				});
			}
			return jQuery(ht);
		}
	});
}

var MAX_WEBSMS_LENGTH=90;
function websmslenupdate() {
	var len = MAX_WEBSMS_LENGTH - jQuery('#websmstext').val().length;
	if (len < 0) {
		jQuery('#websmstext').val(
				jQuery('#websmstext').val().substr(0, MAX_WEBSMS_LENGTH));
		len = 0;
	}
	var story = 'Characters left: ' + len;
	var col = len < 10 ? 'red' : '';
	jQuery('#websmscharcount').html(story).css('color', col);
}

function blockwebsmser(guid){
	jQuery.get('blockwebsmser/a?guid='+guid,function(d){
		balert(d);
	}
	);
	jQuery(".jGrowl-notification .close").click();
}

function spamreport(id){
	jQuery.get('spamreport/a?wid='+id,function(d){
		balert(d);
	});
}





/* Code from the top part of the wallunitjs.php */

function repostasstatus(e){
	var p=jQuery(e).parents('.channelunit');
	var wallid=p.children('#wallid').html();
	var status=p.children('#msg').html();
	//alert(p.children('#msg').length);
	jQuery('form#channelf').html('<input type="hidden" name="status" value="'+status+'" />');
	jQuery('form#channelf').attr('action','/follow');
	jQuery('form#channelf').submit();
}

function forwardsms(e){
	var pd=jQuery(e).parents('.channelunit');
//	var p=pd.children('#rgtDiv');
	//var p1=jQuery(e).parents('#channelunit').children('#rgtDiv');
	var wallid=pd.attr('wallid');
	var msg=pd.children('.amsg').html();
	 

	jQuery('form#channelf').html('<input type="hidden" name="msg"/> <input type="hidden" name="msgid" value="'+wallid+'" />');
	jQuery('form#msg').val(msg);
	jQuery('form#channelf').attr('action','/contact');
	jQuery('form#channelf').submit();
}

if(typeof(thumsupdw)!='function'){



	
	function thumsupdw(id,r){

	 

		
		var par={r:r,id:id};
		jQuery.get('http://isms.ibibo.com/wrate/a',par,function(d){
			if(d==''){
				alert('Please login to rate this SMS!');
				return;
			}
			eval("var r="+d);
	
			if(r.s==0){
				//alreadyrated();
				alert("You have already rated this wall post");
			}else{
				var d= r.r==0?-1:1;
				var v=parseInt(d)+parseInt(jQuery("#rating_for_"+r.id).html());
				jQuery("#rating_for_"+r.id).html(v);

				 
				alert('Your rating has been saved!','success');
				//alert('This SMS now has a rating of '+ v+'. Thank you for rating!','success');
			}
			jQuery("#rater_span_"+r.id).css("opacity","0.5");
			jQuery("#rater_span_"+r.id+" a").attr("href","javascript:void(alreadyrated())");
		});
	}
}
/* end of code from top part*/

/* begin of second part from wallunitjs*/

var templatefoption='<div class="askOptn"><span id="followee" style="display:none;">#followee#</span><span id="follower" style="display:none;">#follower#</span><span id="followeename" style="display:none;">#followeename#</span><a href="javascript:void(0);" onclick="jQuery(this).parents(\'.askOptn\').slideUp(100);" class="clsBt">x close</a>Do you want to receive #followeename#\'s updates by SMS?<br /><input type="button" value="Yes" onclick="addfollower(\'\',\'\',\'\',1,this)"/> <input type="button" value="No, only follow on web" onclick="addfollower(\'\',\'\',\'\',0,this)" /></div>';

var templatefollow='<a href="javascript:void(0)" onclick="showoption(\'#followee#\',\'#follower#\',\'#followeename#\',this)">Follow</a>';
var templatestopfollow='<a href="javascript:void(0)" onclick="deletefollower(\'#followee#\',\'#follower#\',this)">Stop Following</a>';

function showoption(followee,follower,followeename,e){
	var t=templatefoption;
	t=t.replace(/#followee#/g,followee);
	t=t.replace(/#follower#/g,follower);
	t=t.replace(/#followeename#/g,followeename);
	
	jQuery(e).parents('.channelunit').children('#optiondiv').html(t).css('display','none').slideDown(300);
}

function addfollower(followee,follower,followeename,smsflag,e){
	
	if( smsflag &&(!userphone || userphone=="")){
		document.location=phonelinkurl;
		return;
	}
	
	if(!followee||followee==''||!follower||follower==''){
		followee=jQuery(e).parents('.askOptn').children('#followee').html();	
		follower=jQuery(e).parents('.askOptn').children('#follower').html();	
		followeename=jQuery(e).parents('.askOptn').children('#followeename').html();	
	}
	var wid=jQuery(e).parents('.channelunit').attr('wallid');
	jQuery(e).disabled=true;
	jQuery('#channelerror').html();
	jQuery
	.get('/handlefollowers/a?action=add&followee='+followee+'&follower='+follower+'&addsms='+smsflag,
	function(d) {
		
						eval('var ja=' + d);
						
						if(ja['s']=='-4')
						{
							alert("You are already following this user !");
						}
						 
						if(ja['s']=='1'){
							 
							var t=templatestopfollow;
							t=t.replace(/#followee#/g,followee);
							t=t.replace(/#follower#/g,follower);
							t=t.replace(/#followeename#/g,followeename);
							//jQuery(e).parents('#channelunit').children('#followspan').html(t);
							//jQuery(e).parents('#followspan').html(t);
			//				jQuery(e).parents('#channelunit').children('.rgtDiv').children('#font1').children('#followspan').html(t);
							 
							jQuery('span[@pid='+wid).html(t);
//							//jQuery(e).parents('#channelunit').children('.rgtDiv').children('#followspan').html(t);
							jQuery(e).parents('.askOptn').slideUp(100);
						}
						else{
							
							jQuery('#channelerror').html('Sorry!! Error while changing your default city. Try again later.');
						}
				}	
	)
}

function deletefollower(followee,follower,e){
	jQuery(e).disabled=true;
	jQuery('#channelerror').html();
	jQuery
	.get('/handlefollowers/a?action=delete&followee='+followee+'&follower='+follower,
	function(d) {
						eval('var ja=' + d);
						 
						if(ja['s']=='1'){
							//alert('changed');
							var t=templatefollow;
							t=t.replace(/#followee#/g,followee);
							t=t.replace(/#follower#/g,follower);
							jQuery(e).parents('#followspan').html(t);
							//jQuery(e).parents('#channelunit').children('#followspan').html(t);

						}
						else{
							jQuery('#channelerror').html('Sorry!! Error while changing your default city. Try again later.');
						}
				}	
	)
}

function opencomments(e,permalink,wid,savestatus)
{

	
	jQuery
	.get('/comments/a?act=gc&wid=' + wid + '&sstatus=' + savestatus,
	function(d) {
		 
		eval('var ja=' + d);
		 
						jQuery(e).parents('.channelunit').children('.rgtDiv').children('#divComments').show();
						jQuery(e).parents('.channelunit').children('.rgtDiv').children('#divComments').html(ja['s']);
		//				jQuery(e).parents('#divComments').children('#rgtDiv').html(ja['s']).css('display','block').slideDown(300);
	});


	

}

function postcomment(wid,btn)
{
	savestatus=0;
	 var ctext=jQuery("textarea#tacomment").val();
	  
     if(ctext=='' || ctext=='Add comment here...')
     {
    	// alert("ctext");
        // document.getElementById("spanerror").innerHtml="Enter comment text";
        jQuery("#spanerror").html("Enter comment text &nbsp;&nbsp;&nbsp;");
    	 //jQuery("#divwallpostcomment").children("#submitCont").children("spanerror").html("Enter comment text");
     }

     else
     {
		//alert(wid);
		 
		jQuery
		.get('/comments/a?act=sc&wid=' + wid + "&ct=" + ctext,
		function(d) {
			 
			eval('var ja=' + d);
		//	alert(ja['s']);
			savestatus=ja['s'];
							//jQuery(e).parents('#channelunit').children('.rgtDiv').children('#divComments').html(ja['s']);
		});
     }
     opencomments(btn,'',wid,savestatus);
      
         
}

function commentfocus(obj)
{
	if(obj.value == "Add comment here...")
		{ obj.value="";
		obj.style.color="#333";
		}

}
function resizecommentbox(obj)
{
	obj.style.height='100px';
}

 
function qwallcharcheck1(){
	var cleft=qwallcharleft1();
	var col='';
	if(cleft<5)
	{
		col='#800';
	}
	if(cleft<=0){
		col='red';
		jQuery("#txtcomment").val(jQuery("#txtcomment").val().substring(0,140));
	}
	jQuery("#saysharecount").html(cleft).css('color',col);


}

function qwallcharleft1(){
	return 141-jQuery("#txtcomment").val().length;
}


function qwallcharcheck2(){
	
	var cleft=qwallcharleft2();
	var col='';
	if(cleft<5)
	{
		col='#800';
	}
	if(cleft<=0){
		col='red';
		jQuery("#tacomment").val(jQuery("#tacomment").val().substring(0,140));
	}
	jQuery("#spancommtextcount").html(cleft).css('color',col);


}

function qwallcharleft2(){
	return 141-jQuery("#tacomment").val().length;
}

/* end of second part from wallunitjs*/

/*begin of third part from wallunitjs*/


function promptlogin(msg)

{
	 
	    jQuery.scrollTo("#topBanner",{duration:200,easing:'swing',offset:-5, onAfter:function(){
	    	jQuery("#divloginmsg").html(msg).show();;
		setTimeout(function(){jQuery("#divloginmsg").css('border','1px solid yellow')},100);
		setTimeout(function(){jQuery("#divloginmsg").css('border','1px solid red')},200);
		setTimeout(function(){jQuery("#divloginmsg").css('border','1px solid green')},400);
		setTimeout(function(){jQuery("#divloginmsg").css('border','')},250);
		}});
}

function promptlogincomments()
{
	promptlogin("Login to comment");
}






function quickwallpostCountCh()
{    			    
	var maxlimit=140;
	var field=document.getElementById("txtquickwallpost");
	var cntfield=document.getElementById("spanquickwallpostcount");
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);   
	else    // otherwise, update 'characters left' counter
		cntfield.innerHTML = maxlimit - field.value.length;
	 
	 //document.getElementById("divQuickErrorMessage").innerHTML="";
}

function qwallcharcheck(){
	var cleft=qwallcharleft();
	var col='';
	if(cleft<5)
	{
		col='#800';
	}
	if(cleft<=0){
		col='red';
		jQuery("textarea#txtquickwallpost").val(jQuery("textarea#txtquickwallpost").val().substring(0,140));
	}
	jQuery("#saysharecount").html(cleft).css('color',col);


}
function qwallcharleft(){
	return 140-jQuery("#txtquickwallpost").val().length;
}
function savequickwallpost()
{  
	var resp=jQuery("textarea#txtquickwallpost").val();	 
	if(resp=='' || resp==saysharedefmsg)
	{
		alert("Please type something!");
		return false;
	}
	   if(resp.length>140)
        {
		   alert("You need to keep your update to less than 140 characters!");
			return false;
        }     

	   document.getElementById("btnsubmitquickwallpost").disabled=true;
	   //jQuery("#btnsubmitquickwallpost").disable();
	   addquicksmswallpost();	 
}

/*end of third part from wallunitjs*/

/*begin of fourth part from wallunitjs*/




function viewquickwallpostbox()
{
	jQuery("#txtquickwallpost").val("");
	jQuery("#spanquickwallpostcount").html("140");
	jQuery('#divquickwallpostdone').hide();
	jQuery('#divquickwallpost').show();
	jQuery("#spanquickwallposterror").html("");
	
	document.getElementById("btnsubmitquickwallpost").disabled=false;	
}

function quickwallpostonblur()
{
	jQuery("#txtquickwallpost").height('30px');
}
function quickwallpostblur()
{
jQuery("#txtquickwallpost").css('color','#999');
if(jQuery("#txtquickwallpost").val()==''){
	jQuery("#txtquickwallpost").val(saysharedefmsg);
}
if(jQuery("#txtquickwallpost").val()==saysharedefmsg){
	jQuery("#txtquickwallpost").height('50px');
	setTimeout(function(){jQuery("#txtquickwallpost").height('40px')},20);
	setTimeout(function(){jQuery("#txtquickwallpost").height('30px')},25);
}
}
function quickwallpostfocus()
{
	if(jQuery("#txtquickwallpost").val()==''||jQuery("#txtquickwallpost").val()==saysharedefmsg){
		jQuery("#txtquickwallpost").val('');
	}
	jQuery("#txtquickwallpost").css('color','#000');
	if(jQuery("#txtquickwallpost").height()!=60){
	jQuery("#txtquickwallpost").height('32px');
	setTimeout(function(){jQuery("#txtquickwallpost").height('38px')},20);
	setTimeout(function(){jQuery("#txtquickwallpost").height('48px')},40);
	setTimeout(function(){jQuery("#txtquickwallpost").height('60px').css('overflow-y','auto')},70);
	}
}
function quickwallpostflash(){
	jQuery.scrollTo("#myStatusMsgContt",{duration:200,easing:'swing',offset:-5, onAfter:function(){
	setTimeout(function(){jQuery("#txtquickwallpost").css('background-color','#ccf')},100);
	setTimeout(function(){jQuery("#txtquickwallpost").css('background-color','#ddf')},150);
	setTimeout(function(){jQuery("#txtquickwallpost").css('background-color','#eef')},200);
	setTimeout(function(){jQuery("#txtquickwallpost").css('background-color','')},250);
	}});
	
}
function quickwallrepost(mid){
	//jQuery("#txtquickwallpost").val(jQuery("#msg").text()).focus();
	
	jQuery("#txtquickwallpost").val(jQuery(mid).parents('.channelunit').children('#rgtDiv').children('#msg').text()).focus();
	quickwallpostflash();
	qwallcharcheck();
	return false;
}
 
function addquicksmswallpost(){
	var m=jQuery("#txtquickwallpost").val();	
	var params={ msg: m, via: 2};	
	jQuery.get('/smswall/a?action=qpost&walltext='+encodeURIComponent(m),function(d){
		eval("var da="+d);
		var p=da['p'];
		var plink=da['plink'];
		if(p && p!='')
		{
			if(p>=1)
			{
			/*var t= '<h3 style="color:#fff">Posted to wall and <?=$xfoll?> follower<?=$grammarnazi?></h3> <br/>';
			t+='<a href="' + plink + '" style="color: rgb(131, 201, 237);">view post</a>, <a href="/similar?id='+p+'" style="color: rgb(131, 201, 237);">view similar posts</a> or<br><br>';
			t+=' <a style="cursor:pointer" onclick="viewquickwallpostbox()"><h3 style="color: rgb(131, 201, 237);">Publish Another!</h3></a>';
			*/
				
				document.getElementById("quickwallposted").innerText='';
				jQuery("#quickwallposted").html('');
			jQuery("#quickwallposted").html(m).css('color','red');
			jQuery("#statusMsgTime").html(' just now ');
			setTimeout(
				function(){
				jQuery("#quickwallposted").css('color','');
				document.getElementById("btnsubmitquickwallpost").disabled=false;
				//location.href=location.href;//refresh page
			},1200);
			jQuery("#txtquickwallpost").val('');
			}
			else if(p=="-2")
			{
				alert("Error! Could not save.");
			}
		}
	});
}

 
/*end of fourth part from wallunitjs*/



/* for sign in form form right column*/

function signin(formaction)
{
  

   var username=document.getElementById("login").value;
   var password=document.getElementById("password").value;

    remember='0';
	if(document.getElementById("chkremember").checked==true)
	{
		 
		remember='remember=1';
	}
   /* if(username=='username')
    {
    	jQuery("#divloginmsg").html("Enter Username");
    	return;
    }
    else  if(password=='password')
    {
    	jQuery("#divloginmsg").html("Enter Password");
    	return;
    }*/

	;
	//%26letype%3Derror%26uname%3D
	document.forms['frmlogin'].action=formaction+ '%26uname%3D'+username;
	document.forms['frmlogin'].submit();
}
 
function checkEnter(e,url){ //e is event object passed from function invocation
	var characterCode;
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e;
	characterCode = e.which; //character code is contained in NN4's which property
	}
	else{
	e = event;
	characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		signin(url); //submit the form
	return false;
	}
	else{
	return true;
	}

}

function morechannels(){
	if(jQuery(".channelmore:visible").length>0){
		jQuery(".channelmore").slideUp();
		jQuery("#viewmorechannels").html('View All');
	}else{
		jQuery(".channelmore").slideDown();
		jQuery("#viewmorechannels").html('Less Cities');
	}

	return false;
}
function balert(xxx)
{
	
}
/*end of from signin from from rightcolumn*/
