var blnOriginalMsgCopied = false;
var strPosTweets = "";
var strNegTweets = "";
var strAllPosRating = "";
var strAllNegRating = "";
var radValue = "";
var curParam = "";
var curPosRat = "";
var curNegRat = "";
var pager;
var obje = new Object();
obje.method = 'get';
obje.asynchronous = true;
var twitter_url='';
var vicon_url='';
var tweetId='';
var tweetUser='';
var returnShortenedUrl=false;
var shortUrl='';
var lurl;
var bitlyWorked = false;
var curTab = "divTabBlock_1";
//var searchText = "";
var sTime;
sitepathPHP = sitepath+"/expconurl.php"; 
window.onerror=function(msg, url, linenumber){
//alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber)
 return true
}
//Added by Sowmya on June 23,2009 for Expanding/Contracting URLS
//Modified by sowmya on June 30,2009 using prototype for hide and show
//Modified by sowmya on July 16,2009 for path issue
function ajaxfunction(p1,id){
	var ajaxRequest;  // The variable that makes Ajax possible!
//	alert(p1+'p1'+id+'id');
	obje.parameters="url="+p1+"&id="+id;
	obje.onSuccess=display;
	ajaxRequest =  new Ajax.Request(sitepathPHP,obje);
	return;	
}

function display(str){
	str = str.responseText;
//	alert(str);
	str = str.split(' ');
	surl = str[1];    
	lurl = str[0];
	len	=	lurl.length;
//	alert(surl +'                            surl');
//	alert(lurl + '                           lurl');
	durl = lurl.substring(0,25);
	if(len>25)
	durl=durl+'...';
//wahab: 10-Nov-09 added url redirection
	checkUrl = surl.toLowerCase();
	if (checkUrl.indexOf('feeltiptop.com') >= 0 || checkUrl.indexOf('twitter.com') >= 0) {
	 	checkUrl = surl;
	} else {
	 	checkUrl = "http://beta.tiptopbest.com/redir.php?url="+surl;
	}
	$('spa'+id).innerHTML = "<a href='"+checkUrl+"' target='_blank'>"+durl+"</a>";	
		$('sp'+id).hide();
		$('spa'+id).show();
		$('spa'+id).title =lurl;
		$('sp'+id).title = surl;
		$('span'+id).innerHTML = "<img src='"+sitepath+"/images/contract.png' title =Shrink id=img"+id+" align=absmiddle style = 'padding-left:4px;cursor:pointer;' onclick=javascript:ExpShr(this,'"+id+"')>";
}

function ExpShr(obje,id)
{
	if(obje.title == "Expand"){
			$('sp'+id).hide();
			$('spa'+id).show();
			$('spa'+id).title =lurl;
			$('sp'+id).title = surl;
			//alert(surl);
			$('span'+id).innerHTML = "<img src='"+sitepath+"/images/contract.png' title=Shrink id=img"+id+" align=absmiddle class='imgExp' onclick=ExpShr(this,'"+id+"')>";
			
		}
		else if(obje.title == "Shrink"){
			$('sp'+id).show();
			$('spa'+id).hide();
			$('span'+id).innerHTML = "<img src='"+sitepath+"/images/expand.png' title=Expand id=img"+id+" align=absmiddle class=imgExp onclick=ExpShr(this,'"+id+"')>";	
		}	
}

function ExpCon(surl,obje,id){
 this.id=id;
 source = obje.src;
 	if($('spa'+id).innerHTML == ''){
		if(source.indexOf(sitepath+"/images/expand.png") >= 0 ) {
				ajaxfunction(surl,id);			
		} 
	}
}


var objs = new Object();
objs.method = 'get';
objs.asynchronous = false;
function getShortUrl(longUrl){
	var ajaxRequest1;  // The variable that makes Ajax possible!
	objs.parameters="url="+longUrl;
	objs.onSuccess=shortenedUrl;
	ajaxRequest1 =  new Ajax.Request(sitepath+"/includes/tinyurl_api.php",objs);
	return;	
}

function shortenedUrl(str){
	shortUrl=str.responseText;	
	if(shortUrl=="No content"){
		alert('Error occured while shortening URL');
		return;
	}
	returnShortenedUrl=true;
	return;
}

function getBitlyAndRecirsiveUrls(user,id,long_urls,queryTerm,tweetMessage){
/*
* Ajax Function to call php script bitly_api.php to get short urls , also add recursive url.
* Added by: Ashutosh Anand
* Date: 11-08-2009
* Used for re-tweet
*/
//alert('worked');
var ajaxRequest;  // The variable that makes Ajax possible!
var obj = new Object();
obj.method = 'get';
obj.asynchronous = false;
queryTerm = encodeString.encode(queryTerm);
tweetMessage = encodeString.encode(tweetMessage);
var url = sitepath+'/bitly_recursive_api.php?user='+user+'&id='+id+'&long_urls='+long_urls+'&queryTerm='+queryTerm+'&tweetMessage='+tweetMessage;
obj.onSuccess = function(str){
		bitlyWorked = true;
		retip_status = str.responseText;
		if(0 == retip_status.length){
			bitlyWorked = false;
			}
		//alert(retip_status);
		return;
		}
ajaxRequest = new Ajax.Request(url,obj);
return;
}

function RecursiveRetweetURL(user,id,longurls,retweet_text)
{
 	/* Added by sowmya on August 25,2009 for recursive retweet
	 	Ajax Fuction to call php script bitly_retweet_api.php
	 */
	var ajax_Request;  // The variable that makes Ajax possible!
	var objc = new Object();
	objc.method = 'get';
	objc.asynchronous = false;
	var retweeturl = sitepath+'/bitly_recursive_api.php?user='+user+'&id='+id+'&longurls='+longurls+'&retweet_text='+retweet_text;
	objc.onSuccess = function(str_retweet)
	{
		bitlyWorked = true;
		retweet_status = str_retweet.responseText;
		//alert(retweet_status);
		if(0 == retweet_status.length)
		{
			bitlyWorked = false;
		}
		return;
	}
	ajax_Request = new Ajax.Request(retweeturl,objc);
	return;
	
}
function RecursiveTipsPitsURL(tipsPitsShare,long_urls,t_concept)
{
 	/* Added by sowmya on August 25,2009 for recursive tshares(tips pits,concept cloud)
	 	Ajax Fuction to call php script bitly_recursive_api.php
	 */
	var ajax_tips_Request;  // The variable that makes Ajax possible!
	var objt = new Object();
	objt.method = 'get';
	objt.asynchronous = false;
	var tipspitsurl = sitepath+'/bitly_recursive_api.php?tipsPitsShare='+tipsPitsShare+'&long_urls='+long_urls+'&t_concept='+t_concept;
	objt.onSuccess = function(str_tipspits)
	{
		bitlyWorked = true;
		tipspits_status = str_tipspits.responseText;
		if(0 == tipspits_status.length)
		{
			bitlyWorked = false;
		}
		return;
	}
	ajax_tips_Request = new Ajax.Request(tipspitsurl,objt);
	return;
	
}


function ajax_log(objName,objType){
/*
* Ajax Function to add number of hits of concepts / categories / twitter share / facebook share
* Added by: Ashutosh Anand
* Date: 13-07-2009
*/
//alert(objType+':'+objName);
var ajaxRequest;  // The variable that makes Ajax possible!
var logObj = new Object();
var url = sitepath+'/logClicks.php?objType='+objType+'&objName='+objName;
logObj.method = 'get';
logObj.asynchronous = true;
logObj.onSuccess = function(res){}
ajaxRequest = new Ajax.Request(url,logObj);
return;	
}



//wahab: 25-May; higlight "ALL" tab when concept clicked
function highlightAllTab() {
 	if ($('divA')) {
// 	 	$('divA').className = "button";
 	}
// 	alert ("1");
var tabs = $$('a.buttonHighlight');
	for (i=0;i<tabs.length;i++) {
	 	tabs[i].id = "";
	 	tabs[i].className = "button";
	}
	
// 	alert ("2"); 	
var tabs = $$('a.button');
	for (i=0;i<tabs.length;i++) {
	 	html = tabs[i].innerHTML;
	 	html = html.toUpperCase();
 	 	tabs[i].id = "";
	 	if (html == "<SPAN>NO FILTER</SPAN>") {
	 	 	tabs[i].className = "buttonNoFilter";
//	 	 	tabs[i].id = "divA";
	 	 	break;
	 	}
	}
	deselectConcept();
}

function deselectConcept() {
 if ($$('a.conceptHighlight') != "") {
  		concept=$$('a.conceptHighlight');
		for (i=0;i<concept.length;i++) {
			concept[i].className = "conceptA";
		}
	}
}

function submitForm(objForm) {
//wahab: 22-Oct; search not working, since id of the text box changed
var val = "";
//textbox of header id = q2; footer id = q
	if (objForm == "tiptopitform1") {
	 	val = $F('q2');
	} else {
	 	val = $F('q');
	}

if (val != "") {
 	val = val.trim();
	//val = val.replace(/#/g,"%2523");
	val=encodeURIComponent(val);
 	val = val.replace(/%23/g,"%2523");
	val = val.replace(/%2F/g,"/");
 	if ("" != val) {
 	 	window.location.href = "/"+val+"/";
 	 	return false;
 	}
} 
	return false;
}


function imgFixIE() {
// return;
browser = navigator.appName;
//alert (browser);
tImages = $$('img.tImg');
x = "";
var IE = false;
if (browser.indexOf("Microsoft Internet Explorer") >= 0) {
 	IE = true;
}
imgLength = tImages.length;
for (i=0;i<imgLength;i++) {
 	if  (IE && (!tImages[i].complete)) {
 	 	tImages[i].src = "/twitter/twitter/images/no_image_found.gif";
 	} 
}
//alert (x);
}
 
//wahab: 4-Jun-09; show/hide profile div
function showProfile(close) {
// alert (close);
 
	if (close != undefined) {
			$('divProfile').style.visibility = "hidden";
			$('divProfile').style.display = "none";
	} else {
	 		$('divProfile').style.visibility = "visible";
			$('divProfile').style.display = "block";
			$('divProfile').style.top = "50px";
			$('divProfile').style.left = "50px";
			$('divProfile').style.position = "absolute";
	}
}  

/*wahab: 5-Jun-09; TipTop says this about ram from  3 hours ago till now & returns the query
ie ram
*/
function getQuery() {
 	return "";
	searchText =  $$('h2.main_headings a');
	searchText = searchText[0].innerHTML;
	pos = searchText.indexOf("+until:");
	if (pos >= 0 ) {
	 	searchText = searchText.substring(0,pos);
	}
		return searchText;
//	return searchText[0].innerHTML;
}
function getQueryWithTime() {
	searchText =  $$('div.preTime');
	searchText = searchText[0].innerHTML;
	p1 = searchText.indexOf('"/');
	p2 = searchText.indexOf('">From');
	return searchText.substring(p1+2,p2);
	
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

 
 //sudeep: Added for invite a friend column 
var obj=new Object();obj.onSuccess=dispMsg;
obj.method="get";obj.asynchronous=true; 
function sendInvitation() {
var toMail=$F('to_email_address');
	if (toMail =="" || toMail=="Enter e-mail address") {
		$('divInviteStatus').innerHTML="Please enter e-mail address";
		return false;
	}
var filter=/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(toMail)) {
	alert('Please provide a valid email address');	
	return false;
}
	
//	ser = $('frmMain').serialize();
	obj.parameters = "to_email="+$F('to_email_address');
	var aj = new Ajax.Request(sitepath+"/invite_friend.php",obj);	
	$('divInviteStatus').innerHTML="<b>Status: </b>Sending mail";
 }
function dispMsg(str) {
//wahab: 20-Oct; change the display message based on input
	str = str.responseText;
	if (str.indexOf('Message successfully sent') >= 0 ) {
		$('divInviteStatus').innerHTML ='<b>Status: </b> Message successfully sent';
		$('to_email_address').value = 'Enter e-mail address';
	} else {
	 	$('divInviteStatus').innerHTML = '<b>Status: </b>email was not sent, please try again.';
		$('to_email_address').value = 'Enter e-mail address';
	}
}
function remind(msg1) {
	$('status').innerHTML="";
}
function dispWizard(widget_type,query) {
 //alert(query);	
 param = "";	
 
 if (query == "undefined") {
  	query = "";
}
 
 if (widget_type != "") {
  	param = "type="+widget_type;
 }
var isLive = sitepath.toLowerCase().indexOf('feeltiptop');
//alert(isLive);
var gadget_path = "";
if(isLive>-1){ //if live 
//wahab: 14-Sep-09; prevent url from Google indexing
	 gadget_path = 'http://';
	 gadget_path +='widgets.feeltiptop.com';
	 gadget_path += '/twitter/twitter/gadget_wizard.php';
	}
else{ 
	gadget_path = '/gadget_wizard.php';
	}
 	if(query == ""){
var win=window.open (gadget_path +"?"+param,'mywin',"status=0,toolbar=0,location=0,menubar=0,scrollbars=1,height=520,width=980");
	}else{
	query = query.replace(/#/g,"%23");
var win=window.open (gadget_path+"?q="+query+"&"+param,'mywin',"status=0,toolbar=0,location=0,menubar=0,scrollbars=1,height=520,width=980");
	}
	
	win.focus();
}

function addNewResults(){
	//alert('addResults()');
	var seconds = $('search_again_time_stamp').innerHTML;
	//alert('For Test: Data will refresh in '+seconds+' seconds');
	if(seconds<120){
		seconds = 120; 
	}
	var miliSec = seconds * 1000; 
	//alert('For Test: Refresh message will com after '+seconds+' seconds');
	var t = setTimeout('addRefreshLine()',miliSec);	
}	
function addRefreshLine(){
    //alert('addRefreshLine()');
	//alert('For Test: Refresh message will com now');
	var valQuery = getQuery();
	valQuery = encodeURIComponent(valQuery);
	valQuery = valQuery.replace(/%23/g,"%2523");
	valQuery = valQuery.replace(/%2F/g,"/");
	$('refresh_link').innerHTML = '<center>There are more results since you started searching. <a href="/'+valQuery+'/">Refresh</a> to see them.</center>'; 
}


/* added by teena on 14/08/09 for utf-8 encoding and decoding
The JavaScript Source!! http://javascript.internet.com
Created by: Justas | http://www.webtoolkit.info/ */
var encodeString = {

 	// public method for URL encoding
 	encode : function (string) {
 		 return escape(this._utf8_encode(string));
 	},

 	// public method for URL decoding
	 decode : function (string) {
 	 	return this._utf8_decode(unescape(string));
 	},

 	// private method for UTF-8 encoding
 	_utf8_encode : function (string) {
  		string = string.replace(/\r\n/g,"\n");
 	 	var utftext = "";

  		for (var n = 0; n < string.length; n++) {
   			var c = string.charCodeAt(n);
   			if (c < 128) {
    				utftext += String.fromCharCode(c);
 			} else if((c > 127) && (c < 2048)) {
  				utftext += String.fromCharCode((c >> 6) | 192);
  				utftext += String.fromCharCode((c & 63) | 128);
 			} else {
  				utftext += String.fromCharCode((c >> 12) | 224);
  				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
 	 			utftext += String.fromCharCode((c & 63) | 128);
 			}
 	}

		return utftext;
	},

 	// private method for UTF-8 decoding
 	_utf8_decode : function (utftext) {
 		 var string = "";
 		 var i = 0;
 		 var c = c1 = c2 = 0;

  		while ( i < utftext.length ) {
  			 c = utftext.charCodeAt(i);
   			if (c < 128) {
    				string += String.fromCharCode(c);
    				i++;
  			 } else if((c > 191) && (c < 224)) {
 				   c2 = utftext.charCodeAt(i+1);
    				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
    				i += 2;
  			 } else {
 				   c2 = utftext.charCodeAt(i+1);
    				c3 = utftext.charCodeAt(i+2);
    				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
   				 i += 3;
 			  }
		  }
		return string;
	 }
}
  
//wahab: 1-Sep-09 bookmark code
// All browser bookmark script
function bookmarksite(param){

	bookMarkTitle = 'TipTop Search Engine';
	bookMarkUrl = 'http://feeltiptop.com';

	if (param != undefined) {
 		bookMarkUrl += '/'+param;
		bookMarkTitle = param + ' in TipTop'; 		
 	}

userAgent = navigator.userAgent;
//alert (userAgent);
userAgent = userAgent.toUpperCase();

if (userAgent.indexOf("CHROME")>=0) {
	alert ("Google Chrome users please press Ctrl+D to bookmark this page");
	return false;
}

if (userAgent.indexOf("SAFARI")>=0) {
 	alert ("Safari users please press Ctrl+D to bookmark this page");
	return false;
}
    
if (userAgent.indexOf("OPERA")>=0) {
 //	alert ("Opera users please press Ctrl+D to bookmark this page");


	var elem = document.createElement('a');
	elem.setAttribute('href',bookMarkUrl);
    elem.setAttribute('title',bookMarkTitle);
	elem.setAttribute('rel','sidebar');
	elem.click();

	return false;
//	return false;
}
//alert ("a");

if (userAgent.indexOf("FIREFOX")>=0) {
    window.sidebar.addPanel(bookMarkTitle, bookMarkUrl, "");
   	return false;
}
//alert ("b");
if (userAgent.indexOf("MSIE")>=0) {
 // ie
     window.external.AddFavorite(bookMarkUrl, bookMarkTitle);
   	return false;
}
}

function instSearchProvider() {
// alert ("abc");
  url = 'http://www.feeltiptop.com/twitter/twitter/tiptopsearch.xml';
  
  if (window.external) {
    window.external.AddSearchProvider(url);
  } else {
    alert ("No search engine support");
  }
}


function showdeadcenterdiv(divid) {
// First, determine how much the visitor has scrolled
//Xwidth = $(divid).style.offsetWidth;
//Yheight = $(divid).style.offsetHeight;
Xwidth = 305;
Yheight = 138;
var scrolledX, scrolledY;
if( self.pageYOffset ) {
scrolledX = self.pageXOffset;
scrolledY = self.pageYOffset;
} else if( document.documentElement && document.documentElement.scrollTop ) {
scrolledX = document.documentElement.scrollLeft;
scrolledY = document.documentElement.scrollTop;
} else if( document.body ) {
scrolledX = document.body.scrollLeft;
scrolledY = document.body.scrollTop;
}

// Next, determine the coordinates of the center of browser's window
 
var centerX, centerY;
if( self.innerHeight ) {
centerX = self.innerWidth;
centerY = self.innerHeight;
} else if( document.documentElement && document.documentElement.clientHeight ) {
centerX = document.documentElement.clientWidth;
centerY = document.documentElement.clientHeight;
} else if( document.body ) {
centerX = document.body.clientWidth;
centerY = document.body.clientHeight;
}

// Xwidth is the width of the div, Yheight is the height of the
// div passed as arguments to the function:
var leftOffset = scrolledX + (centerX - Xwidth) / 2;
var topOffset = scrolledY + (centerY - Yheight) / 2;
// The initial width and height of the div can be set in the
// style sheet with display:none; divid is passed as an argument to // the function
var o=$(divid);
var r=o.style;
r.position='absolute';
r.top = topOffset + 'px';
r.left = leftOffset + 'px';
r.display = "block";
}   

function getRandomQuery(boxNumber){
	if(randomQueries == ""){
	return;
	}
	randomValue = Math.floor ( Math.random() * randomQueries.length ); 
	randomQuery = randomQueries[randomValue];
	//alert(randomValue);
	//alert(randomQuery);
	if(boxNumber == 2){
		$('tiptopitform').elements[0].value = randomQuery;
		$('pickButton').innerHTML = "Pick Another";
		$('pickButton').className = "pick_link1";
	}
	if(boxNumber == 1){
		$('tiptopitform1').elements[0].value = randomQuery;
		$('pickButton').innerHTML = "Pick Another";
		$('pickButton').className = "pick_link1";
	}
/*	
	else if(boxNumber == 2){
		$('tiptopitform2').elements[0].value = randomQuery;
		//$('tiptopitform2').elements[1].value = "Pick another";
		$('pickButton2').value = "Pick another";
	}
*/
	else{
		$('q').value = randomQuery;
		$('pickButton').innerHTML = "Pick Another";
		$('pickButton').className = "pick_link1";
	}
	
	
	
	return;
}

//Ashutosh : To add search operators and option lines on concept click
function addLines(isConcept,obj,param){
if(isConcept == false){
$('newSearch').innerHTML = '';
	return;
}
var qry = $('q2').value;
var clickedTerm = obj.innerHTML;
if(qry.toUpperCase()===clickedTerm.toUpperCase()){
	$('newSearch').innerHTML = '';
	return;
	}
var hrefLink = escape(qry + " " + clickedTerm);
hrefLink = hrefLink.replace('%23','%2523');
var str = "<br/><b>Want more such results? Search for </b><a href='/"+hrefLink+"/'>"+qry+" " +clickedTerm+"</a>";
str += " <b>or only</b> <a href='/"+escape(clickedTerm)+"/'>"+clickedTerm+"</a>.";
var	tmpClickedTerm = escape(qry + " -" + clickedTerm);
tmpClickedTerm = tmpClickedTerm.replace('%23','%2523');
str += "<br /><br /><b>Want to exclude <i>"+clickedTerm+"<\/i> from the results? Search for </b> <a href='/"+tmpClickedTerm+"/'>"+qry + " -" + clickedTerm+"</a>.";
$('newSearch').innerHTML = str;
return;
}



function displayTweet(param,obj,isConcept) {
//wahab: 22-Oct-09; modified to suit new layout
//Ashutosh :22-Oct-09; for apache log
//alert (param);
addLines(isConcept,obj,param);
ajax_log(param,'Results_Filtered_By');
deselectConcept();
$(obj).className = "conceptHighlight";

//for oriMsg display all rows
if (param == "oriMsg") {
  	showContainers();
	showHideTableRows('tblPositive',null,true);
	showHideTableRows('tblNegative',null,true);
	showHideTableRows('tblNeutral',null,true);
} else {
//pass table name, JSON key eg ( 	
if ((jsonData[param+"_positive"] == undefined) && (jsonData[param+"_negative"] == undefined)) {
// 	alert ("both");
	$('Tips').hide();
	$('tipsBottom').hide();
	
	$('piTs').hide();
	$('pitsBottom').hide();

} else {
	$('Tips').show();
	$('tipsBottom').show();
	
	$('piTs').show();
	$('pitsBottom').show();
 	
	showHideTableRows('tblPositive',param+"_positive",false);
	showHideTableRows('tblNegative',param+"_negative",false);
}


if (jsonData[param+"_neutral"] == undefined) {
//no neutral data
 	$('remaining').hide();
 	$('remainingBottom').hide();	  	
} else {
 	$('remaining').show();
 	$('remainingBottom').show();
	showHideTableRows('tblNeutral',param+"_neutral",false);
	}
}  
fitScrollBars();
}

//wahab: 23-Oct-09; used to show / hide rows
function showHideTableRows(table,keyStrIDs,showAllRows){
//alert ("table " + table + " key str " + keyStrIDs + " all " + showAllRows);
//show only required rows
if (!showAllRows) {
//get ids for the corresponding key
	strIDs = jsonData[keyStrIDs]; 	
//	alert ("table +" + table + "ids " + strIDs + " key str " + keyStrIDs + " all " + showAllRows);
//key is not there. Hide entire table
	if (strIDs == undefined) {
	 	$(table).hide();
	 	return;
	 	
}else {
//show the table
	 	$(table).show();
	}
} else {
 	 	$(table).show();
}

//count number of rows & get rows
	tableLength = $(table).rows.length;
 	rows = $(table).rows;
	for (i=0;i<tableLength;i++) {
		row = rows[i].cells
//need to show all rows. 
		if (showAllRows) {
		 	row[0].style.display = "";		
		 	continue;
		} 
//selectivly show required rows & hide remaining
			j = i+1;
		 	rowId = ","+j+",";
			if (strIDs.search(rowId) != -1) {
//show the row
			 	row[0].style.display = "";
			} else {
//hide it			 
			   row[0].style.display = "none";	
			}
	}	 	
}

//wahab: 23-Oct-09 recreate scroll bars 
function fitScrollBars() {
 	var scrollbarPos = new Control.ScrollBar('scrollbar_contentPos','scrollbar_trackPos'); 
 	scrollbarPos.recalculateLayout();

 	var scrollbarNeg = new Control.ScrollBar('scrollbar_contentNeg','scrollbar_trackNeg'); 
	scrollbarNeg.recalculateLayout();

	var scrollbarNeut = new Control.ScrollBar('scrollbar_contentNeut','scrollbar_trackNeut'); 
	scrollbarNeut.recalculateLayout();

} 

function hide(obj){
	$(obj).style.display="none";
}
function show(obj){
	$(obj).style.display="block";
}

function showHideWindow(obj,what) {
	if (what == "show") {
		$(obj).style.visibility = "visible";
	 	$(obj).style.display = "block";
	} else {
	 	$(obj).style.visibility = "hidden";
	 	$(obj).style.display = "none";
	}
}

/*
* Below code perform time slider operations
* Added by: Ashutosh Anand
* Date: 27-OCT-2009
*/
//Ashutosh : 27-OCT-2009 : For Indication of New Results (Blinking)
//alert('New Results will come at '+new_results_appear_time+' seconds');
function checkLatest(){
//if (typeof new_results_appear_time != "undefined"){
if(new_results_appear_time < 120){
	new_results_appear_time = 120;
	}
//alert('Blink for Latest Results will come at '+new_results_appear_time+' seconds');	
	new_results_appear_time = new_results_appear_time * 1000;
	setTimeout('blinkLatest()',new_results_appear_time);
}
function blinkLatest(){
	//alert('blinking starts');
	if($('slider_latest')){
			$('slider_latest').innerHTML = '<blink>Latest</blink>';
		}
	}
	

//Ashutosh : 27-OCT-2009 : For Handeling slider movements
function sliderHandler(pos, slider) {
	//alert('sliderHandler('+pos+',slider)');
	setTimeout('makeNewSearch('+pos+')',1000);
	}	

	function makeNewSearch(position){
	//alert(position);
	var latest_query = decodeURIComponent(actual_query);
	var earlier_query = decodeURIComponent(nextQuery)
	var still_earlier_query = decodeURIComponent(actual_query+' until:'+prevUntilDate);
	latest_query = latest_query.replace('#','%2523');
	earlier_query = earlier_query.replace('#','%2523');
	still_earlier_query = still_earlier_query.replace('#','%2523');
	latest_query = latest_query.replace('%23','%2523');
	earlier_query = earlier_query.replace('%23','%2523');
	still_earlier_query = still_earlier_query.replace('%23','%2523');
	
	if(0==position) {//previous day (Still earlier)
		if(''==prevUntilDate){
			return;
			}
		//alert('/'+still_earlier_query+'/');
		window.location.href = '/'+still_earlier_query+'/';
		return false;
		}
	if(33==position) {//previous 100 results (earlier)
		if(''==nextQuery){
			return;
			}
		//alert('/'+earlier_query+'/');
		window.location.href = '/'+earlier_query+'/';
		return false;
		}
	if(99==position) {//latest results
		//alert('/'+latest_query+'/');
		window.location.href = '/'+latest_query+'/';
		return false;
		}
	return;
	}//function makeNewSearch() ends

function checkErarlier(){
	//Ashutosh : 28-Oct-09 : For Indicating No Earlier or Still Earlier Results are available
	//alert('function checkErarlier()');
	if(!prevUntilDate){$("slider_still_earlier").innerHTML = '<del>Day(s) earlier</del>';}
	if(!nextQuery){$("slider_earlier").innerHTML = '<del>Just prior</del>';}
	return;
	}
//Ashutosh : Code for Time Slider Ends Here

//wahab: 2-Nov-09; hide tips / pits container when no tweet in both
// also hide neutral 
function hideEmptyContainers() {
 return;
 rowsPos = $('tblPositive').rows.length;
 rowsNeg = $('tblNegative').rows.length;
 rowsNeut = $('tblNeutral').rows.length;

if (rowsPos==0 && rowsNeg==0) {
//no positive & negative tweet. So hide both
	$('Tips').hide();
	$('piTs').hide();
}

if (rowsNeut==0) {
//no neutral tweet.
	$('remaining').hide();
}
}

//wahab: 4-Nov-09 fix 
//Remaining Messages module does not return after clicking Filter Results by: entrepreneur (where the RM module disappears-good!) then clicking "All Results" doesn't bring back "Remaining Messages"
function showContainers() {
	rowsPos = $('tblPositive').rows.length;
	rowsNeg = $('tblNegative').rows.length;
	rowsNeut = $('tblNeutral').rows.length; 	

if (rowsPos!=0 || rowsNeg!=0) {
//no positive & negative tweet. So hide both
	$('Tips').show();
	$('piTs').show();
}

if (rowsNeut!=0) {
//no neutral tweet.
	$('remaining').show();
}
}
//Ashutosh : Nov-16-2009
//On The Web : Retip
function web_retip(str){
var twurl = "http://twitter.com/home?status="+encodeURIComponent(str);var tweetShare=window.open(twurl,"Retweet","toolbar=0,status=0,width=626,height=436");tweetShare.focus();return false;
}

//Added by Mahesh: 25th-Jan-2010
//Product Module: ReTip
function prod_retip(str){
var tweetTxt=str;
tweetTxt = unescape(tweetTxt);
var lenTweet=tweetTxt.length;
 if(lenTweet>137){
var lenRem=lenTweet-137;
tweetTxt = tweetTxt.substring(0,(Math.abs(lenTweet-lenRem)));
tweetTxt = tweetTxt.substring(0,(tweetTxt.lastIndexOf(',')+1))+' ...';
}
else{
tweetTxt = tweetTxt+'...';
}
var twurl = "http://twitter.com/home?status="+encodeString.encode(tweetTxt);
var tweetShare=window.open(twurl,"Retweet","toolbar=0,status=0,width=626,height=436");tweetShare.focus();
return false;
}

//Added by Mahesh: 25th-Jan-2010
//People Module: ReTip
function people_retip(str){
var tweetTxt=str;
var lenTweet=tweetTxt.length;
 if(lenTweet>137){
var lenRem=lenTweet-137;
tweetTxt = tweetTxt.substring(0,(Math.abs(lenTweet-lenRem)));
tweetTxt = tweetTxt.substring(0,(tweetTxt.lastIndexOf(',')+1))+' ...';
}
else{
tweetTxt = tweetTxt+'...';
}
var twurl = "http://twitter.com/home?status="+encodeString.encode(tweetTxt);
var tweetShare=window.open(twurl,"Retweet","toolbar=0,status=0,width=626,height=436");tweetShare.focus();
return false;
}

var ajaxObj = new Object();
ajaxObj.method = 'post';
ajaxObj.asynchronous = true;
ajaxObj.onSuccess = dispUrlTitle;

function getPageTitles() {
	//alert('getPageTitles');
	//alert(actual_query);
	strJsonUrls = $('divJsonUrls').innerHTML;
	//alert('AJAX REQUEST : '+sitepath+'/get_json_data.php?json='+strJsonUrls);
	ajaxObj.parameters = 'json='+strJsonUrls+'&query='+actual_query;
	new Ajax.Request(sitepath+'/get_json_data.php',ajaxObj);
}

function dispUrlTitle(str) {
  	//alert('AJAX RESPONSE : '+str.responseText);
	$('on_the_web').innerHTML = str.responseText;
}
//sowmya:20-jan-2010 for tweet entry box in the search results page
//Sending entered data to twitter in suggestions box
function getsearchtextboxdata()
{	
	var searchdata = $('twittersearch').value;
	textboxlen = searchdata.length;
	if(textboxlen<=140)
	{      
		textboxval = encodeURIComponent(searchdata);
		var tweetShare=window.open('http://twitter.com/home?status='+textboxval, 'sharetip', 'toolbar=0,status=0,width=626,height=436');
		tweetShare.focus();
	}
	
}

//For Character Count in suggestions Box
function counterSearchHub()
{	
 	var searchdata = $('twittersearch').value;
	remainingLen = 140-searchdata.length;
	$('characters').innerHTML = remainingLen;
	disablebutton(remainingLen);
	//alert(document.getElementById('characters').innerHTML);
}
function disablebutton(maxlength)
{
 	// document.getElementById
	var searchdata =$('twittersearch').value;
	if(searchdata!=''&&maxlength>=0&&maxlength!=140)
	{
		$('spanbutid').style.cursor="pointer";
		$('spanbutid').style.color="#CC0000";
	}
	else
	{
		$('spanbutid').style.cursor="text";
		$('spanbutid').style.color="#aaa";
	}
}

function dispProfile() {
	$('divProfile').style.visibility = "visible";
	$('divProfile').style.display = "block";
}

function getShoppingProductList() {
	if (json_shopping=="no data") {
	 	return;
	}
	json_shopping=json_shopping.evalJSON();
	
	for(i=0;i<json_shopping.length;i++) {
	divAsinId=new String(json_shopping[i]);
	divAsinId=divAsinId.split(",");
	shopObj.parameters='divId='+divAsinId[0]+'&asin='+divAsinId[1]+'&nojson';
	displayBusyImg(divAsinId[0]);
	result=new Ajax.Request(sitepath+'/amazon/includes/get_ratings.php',shopObj);
	} 
}
function displayBusyImg(imgId) {
 	obj=$('overall_valmoney'+imgId);
	obj.style.visibility="visible";
	obj.style.display="block";
}
//wahab: 17-Dec-09; shopping ajax
function displayShoppingProductList(str) {
json=str.responseText;
json=json.trim();

if (json.indexOf('invalid param') >= 0 || json.indexOf('timeout') >= 0 ) {
//display N/A for rating
	divId=json.split(',');
	strRating='<span><b>Overall Quality: N/A</b></span><br />';
	strRating += '<span><b>Value for Money: N/A</b></span><br />';
	$('overall_valmoney'+divId[1]).innerHTML=strRating;
} else {
arrResult=json.split(',');
tagId='overall_valmoney'+arrResult[0];
strRating='<span><b>Overall Quality: '+arrResult[1]+'</b></span><br />';
strRating += '<span><b>Value for Money: '+arrResult[2].replace("]","")+'</b></span><br />';
$(tagId).innerHTML=strRating;
}
	return;
}

function addChannelData() {
// 	alert (addChannelQuery);
	var channelToAdd=$F('cboChannelName');
	channelObj.parameters='q='+addChannelQuery+'&nodisplay';
	filePath=sitepath+'/'+channelToAdd;
//	alert (channelObj.parameters);
//	alert (filePath);
	$('divAddChData').innerHTML="Addition was successful.";
	$('spanAddChData').style.visibility = "visible";
	$('spanAddChData').style.display = "inline";
	new Ajax.Request(filePath,channelObj);
//	alert (filePath);
}

function dispChConfirmation(str) {
}
function showTrendsData(bln) {
 	if (bln) {
 	 	$('trendsLog').style.visibility = "visible";
 	 	$('trendsLog').style.display = "block";
 	} else {
 	 	$('trendsLog').style.visibility = "hidden";
 	 	$('trendsLog').style.display = "none";
 	}
 		
	  		
}

function windowCollapse(){
	Effect.SlideUp('more_best_peeps'); 
	$('collapseButton').onclick = "";
	$('expandButton').onclick = windowExpand;
	$('collapseButton').src = sitepath+"/images/collapse.gif";
	$('expandButton').src = sitepath+"/images/exp_act.gif";
	$('collapseButton').className = "inactiveArrow";
	$('expandButton').className = "activeArrow";
	return false;
}
function windowExpand(){
	Effect.SlideDown('more_best_peeps'); 
	$('expandButton').onclick = "";
	$('collapseButton').onclick = windowCollapse;
	$('expandButton').src = sitepath+"/images/exp.gif";
	$('collapseButton').src = sitepath+"/images/collapse_act.gif";
	$('expandButton').className = "inactiveArrow";
	$('collapseButton').className = "activeArrow";
	return false;
}