// JavaScript Document
function createObject()
{
	var objXmlHttp=null 
	if (navigator.userAgent.indexOf("Opera")>=0)    { 
       objXmlHttp=new XMLHttpRequest() 
	   return objXmlHttp 
   } 
	if (navigator.userAgent.indexOf("MSIE")>=0) 
   { 
	   var strName="Msxml2.XMLHTTP" 
	   if (navigator.appVersion.indexOf("MSIE 5.5")>=0) 
      { 
    	  strName="Microsoft.XMLHTTP" 
      } 
	   try       { 
	      objXmlHttp=new ActiveXObject(strName) 
    	  return objXmlHttp 
      } 
	  catch(e)       { 
	      alert("Error. Scripting for ActiveX might be disabled") 
    	  return 
      } 
    } 
	if (navigator.userAgent.indexOf("Mozilla")>=0) 
   { 
	   objXmlHttp=new XMLHttpRequest() 
	   return objXmlHttp 
   } 
}

var http_request=createObject();

function funcLoading(parameter,url)
{
	var url=url;
	var parameters="parameter="+parameter;
	if(http_request.overrideMimeType){http_request.overrideMimeType('text/xml');}
	if(!http_request){return false;}
	http_request.open('GET',url+"?"+parameters,true);http_request.send(null);
}

function funcLoadingBlogs(parameter,url)
{
	var url=url;
	var parameters="parameter="+parameter;
	if(http_request.overrideMimeType){http_request.overrideMimeType('text/xml');}
	if(!http_request){return false;}
	http_request.open('GET',url+"?"+parameters,true);http_request.send(null);
}


function funcLoadingWiki(content_id, headline, intro, entityname)
{
	var url= "/api/web18_wiki.php";
	var parameters="autono="+content_id+"&headline="+headline+"&entityname="+entityname+"&intro="+intro;
	if(http_request.overrideMimeType){http_request.overrideMimeType('text/xml');}
	if(!http_request){return false;}
	http_request.open('GET',url+"?"+parameters,true);http_request.send(null);
	http_request.onreadystatechange=handleWiki;
}

function changeNewTab(val)
{
	if(document.getElementById('toptab_'+val).innerHTML=='')
	{
		url="/tab/homepage/newTab.php?id="+val;
		http_request.open("get",url);
		http_request.onreadystatechange=handleResponseNewTopTab;
		http_request.send(null);
	}
	else
	{
		show_selected_topNewdiv(val);
	}              
}
function changeNewTab_webx(val)
{
	if(document.getElementById('toptab_'+val).innerHTML=='')
	{
		url="/tab/homepage/newTab_webx.php?id="+val;
		http_request.open("get",url);
		http_request.onreadystatechange=handleResponseNewTopTab;
		http_request.send(null);
	}
	else
	{
		show_selected_topNewdiv(val);
	}              
}
function handleResponseNewTopTab(){
	var text;
	var temp;
	if(http_request.readyState==4)
	{
		text=http_request.responseText;
		temp= text.split('*****');
		var id= temp[0];
		var value=temp[1];
		document.getElementById('toptab_'+id).innerHTML = value;
		show_selected_topNewdiv(id);
	}                              
}
function show_selected_topNewdiv(val)
{
	 for (var i=1;i<=3;i++)
	  {
		   if(i==val){
				document.getElementById('toptab_'+i).style.display="block";
				document.getElementById('TopClass'+i).className="active";
				document.getElementById('TopSelectedClass'+i).className="btxt11";
			 }
		   else{
				document.getElementById('toptab_'+i).style.display="none";
				document.getElementById('TopClass'+i).className="";
				document.getElementById('TopSelectedClass'+i).className="gtxt11";
			}
	 }
}


function htab_netwotk(a, b, c, d){
		for(var i=1; i<=b; i++){
			if(i == a){
				document.getElementById(c+i).className = "hother_tact";
				document.getElementById(d+i).style.display = "block"
			}else{
				document.getElementById(c+i).className = "hother_tnact";
				document.getElementById(d+i).style.display = "none"
			}
		}
}

function get_cookie(Name) 
	{
		
		var search = Name+"="	
		var returnvalue = "";
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search)
			if (offset != -1) {
				offset += search.length
				end = document.cookie.indexOf(";", offset);
				if (end == -1) end = document.cookie.length;
				returnvalue=unescape(document.cookie.substring(offset, end));
				
					var a 	=returnvalue.length;
					for(i=0;i<a;i++)
					{
						returnvalue=replace_plus(returnvalue);
					}
			}
		}
		
		return returnvalue;
}
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie1( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
			
function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}

function Delete_Cookie( name, path, domain ) {
	if ( get_cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function get_cookie_variable(str,pos)
{
	var arr_cookie=str.split("**");
	var name=arr_cookie[pos];
	return name;
}

function replace_plus(text)
{
       return text.replace('+',' ');
}	

////  tooltip.js

////


/////

  
function collapse(stg)
{

document.getElementById("flash_big").style.display="none";
document.getElementById("flash_big").style.visibility="hidden";
document.getElementById("flash_big").style.zIndex = "999999";

}
function expand()
{
	
	document.getElementById("flash_big").style.display="block";
	document.getElementById("flash_big").style.visibility="visible";
	
}

function flashResizer_big_DoFSCommand(command, args) { 
	if (command == "collapse") { 
		collapse();
	}
}

////////////////////////////////////////////////////////////////////



/*****************************SEARCH.JS****************************************/
function tab_search(search)
{
if(search==1)
{
document.getElementById("search_in").value="News";
	path="/searcher/index.php";
document.getElementById("searchp").innerHTML="<a href='#' class='selected'  style='text-decoration:none'><input name='tempp' type='radio' value='' checked />News</a> <a href='#' onclick='javascript:tab_search(2);' style='text-decoration:none'><input name='tempp' type='radio' value='' />Videos</a>  <a href='#'  onclick='javascript:tab_search(3);' style='text-decoration:none'><input name='tempp' type='radio' value='' />Blogs</a> ";
document.getElementById("fornews").innerHTML="<input type='hidden' name='domains' value='http://www.ibnlive.in.com'></input><input type='hidden' name='client' value='pub-2140165247056050'></input><input type='hidden' name='forid' value='1'></input><input type='hidden' name='channel' value='4422786151'></input><input type='hidden' name='ie' value='ISO-8859-1'></input><input type='hidden' name='oe' value='ISO-8859-1'></input>	<input type='hidden' name='safe' value='active'></input><input type='hidden' name='cof' value='GALT:#006699;GL:1;DIV:#FFFFFF;VLC:7E3939;AH:center;BGC:FFFFFF;LBGC:FF3333;ALC:003366;LC:003366;T:000000;GFNT:6C82B5;GIMP:6C82B5;LH:49;LW:432;L:/pix/common/ibnlogo_google.jpg;S:http://www.ibnlive.in.com/;FORID:11'></input><input type='hidden' name='hl' value='en'></input><input type='hidden' name='domains' value='http://www.ibnlive.in.com'></input><input type='hidden' name='sitesearch' value='http://www.ibnlive.in.com' checked='checked' class='radiobut' align='middle' />";

}
else if (search==2)
{
document.getElementById("search_in").value="Videos";
	path="/searcher/index.php";
document.getElementById("searchp").innerHTML="<a href='#' onclick='javascript:tab_search(1);' style='text-decoration:none'><input name='tempp' type='radio' value='' />News</a> <a href='#' onclick='javascript:tab_search(2);'  class='selected'  style='text-decoration:none'><input name='tempp' type='radio' value=''  checked />Videos</a>  <a href='#'  onclick='javascript:tab_search(3);' style='text-decoration:none'><input name='tempp' type='radio' value='' />Blogs</a> ";
document.getElementById("fornews").innerHTML=" ";
}
else if(search==3)
{
document.getElementById("search_in").value="Blogs";
	path="/searcher/index.php";
document.getElementById("searchp").innerHTML="<a href='#' onclick='javascript:tab_search(1);' style='text-decoration:none'><input name='tempp' type='radio' value='' />News</a> <a href='#' onclick='javascript:tab_search(2);' style='text-decoration:none'><input name='tempp' type='radio' value='' />Videos</a> <a href='#'  onclick='javascript:tab_search(3);' class='selected'  style='text-decoration:none'><input name='tempp' type='radio' value='' checked />Blogs</a> ";
document.getElementById("fornews").innerHTML=" ";
}
document.getElementById("searcher1").action=path;
}

/*****************************END SEARCH.JS******************************************/


/*****************************DYNAMIC WRITE.JS************************************************/
<!--
var xmlhttp =createObject();
var xmlhttp2 =createObject();
function includefile(pURL) {
  
      xmlhttp.onreadystatechange=postFileReady;
      xmlhttp.open("GET", pURL, true);
      xmlhttp.send();
  
}
// function to handle asynchronous call
function postFileReady() {
   if (xmlhttp.readyState==4) {
      if (xmlhttp.status==200) {
         document.getElementById('theDivToLoad').innerHTML=xmlhttp.responseText;
      }
   }
}
function includefile2(pURL2) {
 
      xmlhttp2.onreadystatechange=postFileReady2;
      xmlhttp2.open("GET", pURL2, true);
      xmlhttp2.send();
}

// function to handle asynchronous call
function postFileReady2() {
   if (xmlhttp2.readyState==4) {
      if (xmlhttp2.status==200) {
         document.getElementById('theDivToLoad2').innerHTML=xmlhttp2.responseText;
      }
   }
}
//-->
/*****************************END DYNAMIC WRITE.JS************************************************/


/*****************************TOOL TIPS.JS************************************************/
function enableTooltips(id)
{

	var links,i,h;
	if(!document.getElementById || !document.getElementsByTagName) return;
	AddCss();
	h=document.createElement("span");
	h.id="btc";
	h.setAttribute("id","btc");
	h.style.position="absolute";
	document.getElementsByTagName("body")[0].appendChild(h);
	if(id==null) links=document.getElementsByTagName("a");
	else links=document.getElementById(id).getElementsByTagName("a");
	for(i=0;i<links.length;i++)
	{
		Prepare(links[i]);
	}
}

function Prepare(el)
{
	var tooltip,t,b,s,l, img;

	t=el.getAttribute("title");
	link=el.getAttribute("link");
	width = el.getAttribute("rel");
	height =el.getAttribute("rev");


	if(t==null || t.length==0) t="link:";

	el.removeAttribute("title");

	img=el.getAttribute("name");
	var newimg = document.createElement('img');
	newimg.src = img;
	newimg.alt = t;
	newimg.width = width;
	newimg.height = height;

	if(img==null || img.length==0)
	{
		img = "";
		el.removeAttribute("name");
	}
	else
	{
		tooltip=CreateEl("span","tooltip");

		imgdisplay=CreateEl("span", "top");
		imgdisplay.appendChild(newimg);
		tooltip.appendChild(imgdisplay);

		b=CreateEl("b","bottom");
		tooltip.appendChild(b);
		setOpacity(tooltip);
		el.tooltip=tooltip;
		el.onmouseover=showTooltip;
		el.onmouseout=hideTooltip;
		el.onmousemove=Locate;
	}
}

function showTooltip(e){
document.getElementById("btc").appendChild(this.tooltip);
Locate(e);
}

function hideTooltip(e){
var d=document.getElementById("btc");
if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacity(el){
el.style.filter="alpha(opacity:95)";
el.style.KHTMLOpacity="0.95";
el.style.MozOpacity="0.95";
el.style.opacity="0.95";
}

function CreateEl(t,c){
var x=document.createElement(t);
x.className=c;
x.style.display="block";
return(x);
}

function AddCss(){
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","/css/web2/tooltips1.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Locate(e){
var posx=0,posy=0;
if(e==null) e=window.event;
if(e.pageX || e.pageY){
    posx=e.pageX; posy=e.pageY;
    }
else if(e.clientX || e.clientY){
    if(document.documentElement.scrollTop){
        posx=e.clientX+document.documentElement.scrollLeft;
        posy=e.clientY+document.documentElement.scrollTop;
        }
    else{
        posx=e.clientX+document.body.scrollLeft;
        posy=e.clientY+document.body.scrollTop;
        }
    }
document.getElementById("btc").style.top=(posy+5)+"px";
document.getElementById("btc").style.left=(posx-50)+"px";
}
/*****************************END TOOL TIPS.JS************************************************/


/****************************MAIN.JS**********************************************/
var xmlHttp

function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}


function getVote(cod_value,poll_value)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
//var url="/poll/"+int+"/"+poll_value+"/"+Math.random()+".html";
var url="/poll/poll_vote.php?cod="+cod_value+"&id="+poll_value;
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function getVotePoll(cod_value,poll_value,topic_id)
{
xmlHttp2=GetXmlHttpObject()
if (xmlHttp2==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
//var url="/poll/"+int+"/"+poll_value+"/"+Math.random()+".html";
var url="/conversations/poll_submit_budget.php?arg1="+poll_value+"&arg2="+cod_value+"&topic_id="+topic_id;
xmlHttp2.onreadystatechange=stateChanged_budget
xmlHttp2.open("GET",url,true)
xmlHttp2.send(null)
} 


function stateChanged_budget() 
{ 
	var text;
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
 	{ 
		text=xmlHttp2.responseText;
		//alert(text);
		arr= text.split('***---***');
		var id=LTrim(RTrim(arr[0]));
		var content= unescape(arr[1]);
		//alert(text);
		document.getElementById('poll' + id).innerHTML=content;
    } 
} 


function getVote_politics(cod_value,poll_value)
{
xmlHttp1=GetXmlHttpObject()
if (xmlHttp1==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
//var url="/poll/"+int+"/"+poll_value+"/"+Math.random()+".html";
var url="/poll/poll_vote_politics.php?cod="+cod_value+"&id="+poll_value;
xmlHttp1.onreadystatechange=stateChanged_politics 
xmlHttp1.open("GET",url,true)
xmlHttp1.send(null)
} 

function stateChanged_politics() 
{ 
	var text;
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
 	{ 
		text=xmlHttp1.responseText;
		//alert(text);
		arr= text.split('***---***');
		var id=LTrim(RTrim(arr[0]));
		var content= unescape(arr[1]);
		//alert(id);
		document.getElementById('poll' + id).innerHTML=content;
    } 
} 


function stateChanged() 
{ 
	var text;
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 	{ 
		text=xmlHttp.responseText;
		//alert(text);
		arr= text.split('***---***');
		var id=LTrim(RTrim(arr[0]));
		var content= unescape(arr[1]);
		//alert(id);
		document.getElementById('poll' + id).innerHTML=content;
    } 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
 {
 objXMLHttp=new XMLHttpRequest()
 }
else if (window.ActiveXObject)
 {
 objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
 }
return objXMLHttp
}


if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}
function myXMLHttpRequest() {
  var xmlhttplocal;
  try {
    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
    xmlhttplocal=false;
  }
 }

if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
 try {
  var xmlhttplocal = new XMLHttpRequest();
 } catch (e) {
  var xmlhttplocal=false;
  alert('couldn\'t create xmlhttp object');
 }
}
return(xmlhttplocal);
}


function sndReq(vote,id_num,ip_num) {
	
	var element = document.getElementById('unit_long'+id_num);
	//new Effect.Fade(element);
    element.innerHTML = '<div style="height: 30px;"><em>Loading ...</em></div>';
	
    xmlhttp.open('get', '/rate_this_web2.php?j='+vote+'&q='+id_num+'&t='+ip_num);
    xmlhttp.onreadystatechange = handleResponse;
    xmlhttp.send(null);
	
}

function handleResponse() {
    if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
            changeText(update[0], update[1]);
        }
		}
    }
}

function changeText( div2show, text ) {
    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"

    if (DOM) {
        var viewer = document.getElementById(div2show)
        viewer.innerHTML=text
    }
    else if(IE) {
        document.all[div2show].innerHTML=text
    }
}

// JavaScript Document

function textsize(inc)
{
	var tbdy=document.getElementById("font_text").style.fontSize;
	// alert(tbdy);
	var newSize = parseInt(tbdy.substring(0, tbdy.indexOf("px")));
	 //alert(newSize);
	 newSize+=inc;
	document.getElementById("font_text").style.fontSize = newSize+"px";
	//alert(newSize);
	//alert(tbdy);

}

function setFont()
{
  document.getElementById("font_text").style.fontSize="14px";
}


function gallery(sid,id){
//alert("oops")
var fs=window.open("/swf/slideshow/slideshow.html?sid="+sid+"&id="+id,"SlideShow","toolbar=no,width=990,height=600,status=no,resizable=no,fullscreen=yes,scrollbars=no");
	  fs.focus();
}






/****************************END MAIN.JS*********************************************/
/******************************COMMON.JS**************************************************/
// JavaScript Document
//open new window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//for link on layer
function reload(form){
var val=document.sel.cat.options[form.cat.options.selectedIndex].value;
self.location='section_select.php?sec_id=' + val ;
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

//auto jump to new location on select
function surfto(s)
{
	var url=s.options[s.selectedIndex].value;
	window.location.href=url;
}

function textCounter(textfield,countfield) {
countfield.value = textfield.value.length;
}

function doClear(field)
{
	if (field.value == field.defaultValue) 
	{
		field.value = ""
	}
}

function removevalue(theSel)
{
	var selIndex = theSel.selectedIndex;
	if (selIndex != -1) {
		for(i=theSel.length-1; i>=0; i--)
		{
			if(theSel.options[i].selected)
			{
				theSel.options[i] = null;
			}
		}
		if (theSel.length > 0) {
			theSel.selectedIndex = selIndex == 0 ? 0 : selIndex - 1;
		}
	}
}

//function blockError(){return true;} 
//window.onerror = blockError; 
/////////////////////////Login Status End ////
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
        newWindow=window.open(URLtoOpen, windowName, windowFeatures);
    }



function tracking()
{
   var a=document.URL;
   var b=a.split(".",3);
   var c="(.)+/news/([\\w\\d-]+)/(.)+";
   var f="com/?(index)?";
    myregexp = new RegExp(c)
	myregexp1 = new RegExp(f)
   var d=myregexp.test(b[2]);
    var e=myregexp1.test(b[2]);
   if(d)
   {
     var x="smart_search_article";
   }
   else if(e)
   {
     var x="smart_search_home";
   }
   else
   {
     var x="smart_search_rest";
   }
  urchinTracker("/outgoing/"+x);
}
/*****************************END COMMON.JS************************************************/


// MC Flash Container //
    var plus_img = "http://im.in.com/active18/homenewin/images/feed_min.gif";
    var minus_img = "http://im.in.com/active18/homenewin/images/feed_max.gif";
    function bsensedata_mc(passid){
        if(passid==1){
            if(document.getElementById("bsegraph").style.display=='block'){
                $("#bsegraph").slideUp(1,'');
                $("#nsegraph").slideDown(500,'');
                $("#pmnse").attr("src",plus_img,'gif');
                $("#pmbse").attr("src",minus_img,'gif');                
            }else{
                $("#nsegraph").slideUp(1,'');
                $("#bsegraph").slideDown(500,'');
                $("#pmbse").attr("src",plus_img,'gif');
                $("#pmnse").attr("src",minus_img,'gif');
            }
        }else{
            if(document.getElementById("nsegraph").style.display=='block'){
                $("#nsegraph").slideUp(1,'');
                $("#bsegraph").slideDown(500,'');
                $("#pmbse").attr("src",plus_img,'gif');
                $("#pmnse").attr("src",minus_img,'gif');                
            }else{
                $("#bsegraph").slideUp(1,'');
                $("#nsegraph").slideDown(500,'');
                $("#pmnse").attr("src",plus_img,'gif');
                $("#pmbse").attr("src",minus_img,'gif');
            }    
        }
    }

function latestnews()
	{
var img_id=document.getElementById('arr_img_latest').value;
	if(img_id=='down')
	{
		document.getElementById('arrow_img_latest').innerHTML='<img src="http://static.ibnlive.com/pix/ibnhome/ln_arrow02.gif"  onClick="latestnews(); return false;" />';
		document.getElementById('arr_img_latest').value='up';
	}
	else
	{
		document.getElementById('arrow_img_latest').innerHTML='<img src="http://static.ibnlive.com/pix/ibnhome/ln_arrow01.gif"  onClick="latestnews(); return false;"/>';
		document.getElementById('arr_img_latest').value='down';
	}
	$('#slidingDivLatest').animate({'height': 'toggle'}, { duration: 1000 });
}
